diff --git a/idea/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 61db040a3fe..8513752952a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -216,9 +216,6 @@ abstract class CompletionSessionBase(protected val configuration: CompletionSess return parent is JetSimpleNameExpression && !JetPsiUtil.isSelectorInQualified(parent) } - protected fun shouldRunExtensionsCompletion(): Boolean - = configuration.completeNonImportedDeclarations || prefix.length() >= 3 - protected fun getTopLevelCallables(): Collection = indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) }) @@ -362,6 +359,12 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, } private fun addNonImported(completionKind: CompletionKind) { + if (completionKind == CompletionKind.ALL) { + collector.addDescriptorElements(getTopLevelExtensions(), suppressAutoInsertion = true) + } + + flushToResultSet() + if (shouldRunTopLevelCompletion()) { addAllClasses { if (completionKind != CompletionKind.ANNOTATION_TYPES && completionKind != CompletionKind.ANNOTATION_TYPES_OR_PARAMETER_NAME) @@ -374,10 +377,6 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, collector.addDescriptorElements(getTopLevelCallables(), suppressAutoInsertion = true) } } - - if (completionKind == CompletionKind.ALL && shouldRunExtensionsCompletion()) { - collector.addDescriptorElements(getTopLevelExtensions(), suppressAutoInsertion = true) - } } private fun addReferenceVariants(kindFilter: DescriptorKindFilter, runtimeReceiverType: Boolean) { @@ -430,12 +429,12 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para } private fun processNonImported(processor: (DeclarationDescriptor) -> Unit) { + getTopLevelExtensions().forEach(processor) + + flushToResultSet() + if (shouldRunTopLevelCompletion()) { getTopLevelCallables().forEach(processor) } - - if (shouldRunExtensionsCompletion()) { - getTopLevelExtensions().forEach(processor) - } } } diff --git a/idea/testData/completion/basic/multifile/NotImportedExtensionFunction/NotImportedExtensionFunction.kt b/idea/testData/completion/basic/multifile/NotImportedExtensionFunction/NotImportedExtensionFunction.kt index 68cf2a3dc82..07cd20c8978 100644 --- a/idea/testData/completion/basic/multifile/NotImportedExtensionFunction/NotImportedExtensionFunction.kt +++ b/idea/testData/completion/basic/multifile/NotImportedExtensionFunction/NotImportedExtensionFunction.kt @@ -2,7 +2,7 @@ package first fun firstFun() { val a = "" - a.hello + a. } // EXIST: helloFun