Not imported extension functions are always listed in code completion

This commit is contained in:
Valentin Kipyatkov
2015-03-31 18:40:30 +03:00
parent c54541b269
commit b45b462bdf
2 changed files with 11 additions and 12 deletions
@@ -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<DeclarationDescriptor>
= 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)
}
}
}
@@ -2,7 +2,7 @@ package first
fun firstFun() {
val a = ""
a.hello<caret>
a.<caret>
}
// EXIST: helloFun