From 633005fb5754b85d5c9bcece19281343fd952dbf Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Wed, 13 Nov 2019 15:01:12 +0300 Subject: [PATCH] KT-25732 Perform keywords completion earlier to complete them before freeze - If you complete keywords too late, the completion list may become frozen, and `null` will never make it to the top of it - Remove `flushToResultSet` between `addReferenceVariantElements` calls because flush already happens inside of them - ^KT-25732 Fixed --- .../kotlin/idea/completion/BasicCompletionSession.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index 008c0acd218..7f3cf4e75de 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -237,6 +237,8 @@ class BasicCompletionSession( ).completeDslFunctions() } + KEYWORDS_ONLY.doComplete() + val contextVariableTypesForSmartCompletion = withCollectRequiredContextVariableTypes(::completeWithSmartCompletion) val contextVariableTypesForReferenceVariants = withCollectRequiredContextVariableTypes { lookupElementFactory -> @@ -249,21 +251,17 @@ class BasicCompletionSession( prefix[0].isLowerCase() -> { addReferenceVariantElements(lookupElementFactory, USUALLY_START_LOWER_CASE.intersect(descriptorKindFilter)) - flushToResultSet() addReferenceVariantElements(lookupElementFactory, USUALLY_START_UPPER_CASE.intersect(descriptorKindFilter)) } else -> { addReferenceVariantElements(lookupElementFactory, USUALLY_START_UPPER_CASE.intersect(descriptorKindFilter)) - flushToResultSet() addReferenceVariantElements(lookupElementFactory, USUALLY_START_LOWER_CASE.intersect(descriptorKindFilter)) } } referenceVariantsCollector!!.collectingFinished() } - KEYWORDS_ONLY.doComplete() - // getting root packages from scope is very slow so we do this in alternative way if (callTypeAndReceiver.receiver == null && callTypeAndReceiver.callType.descriptorKindFilter.kindMask.and(DescriptorKindFilter.PACKAGES_MASK) != 0) { //TODO: move this code somewhere else?