From 615f9d3a1f6a5d934b5364ad6efc78e3245af290 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 17 Jan 2017 21:23:29 +0300 Subject: [PATCH] Try to avoid exception in getOffset() call --- .../src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index 09b9492a239..26a4d16acf5 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -412,6 +412,7 @@ fun ImportableFqNameClassifier.isImportableDescriptorImported(descriptor: Declar fun OffsetMap.tryGetOffset(key: OffsetKey): Int? { try { + if (!containsOffset(key)) return null return getOffset(key).takeIf { it != -1 } // prior to IDEA 2016.3 getOffset() returned -1 if not found, now it throws exception } catch(e: Exception) {