This commit is contained in:
Valentin Kipyatkov
2015-03-30 14:51:17 +03:00
parent f92bc39323
commit 546af84435
3 changed files with 13 additions and 13 deletions
@@ -77,18 +77,18 @@ public class KotlinIndicesHelper(
.flatMap { findTopLevelCallables(it).filter(visibilityFilter) }
}
public fun getCallableExtensions(nameFilter: (String) -> Boolean, expression: JetSimpleNameExpression): Collection<CallableDescriptor> {
public fun getCallableTopLevelExtensions(nameFilter: (String) -> Boolean, expression: JetSimpleNameExpression): Collection<CallableDescriptor> {
val dataFlowInfo = bindingContext.getDataFlowInfo(expression)
val functionsIndex = JetTopLevelFunctionFqnNameIndex.getInstance()
val propertiesIndex = JetTopLevelPropertyFqnNameIndex.getInstance()
val sourceFunctionNames = functionsIndex.getAllKeys(project).sequence().map { FqName(it) }
val sourcePropertyNames = propertiesIndex.getAllKeys(project).sequence().map { FqName(it) }
val functionFqNames = functionsIndex.getAllKeys(project).sequence().map { FqName(it) }
val propertyFqNames = propertiesIndex.getAllKeys(project).sequence().map { FqName(it) }
val result = HashSet<CallableDescriptor>()
result.fqNamesToSuitableExtensions(sourceFunctionNames, nameFilter, functionsIndex, expression, bindingContext, dataFlowInfo)
result.fqNamesToSuitableExtensions(sourcePropertyNames, nameFilter, propertiesIndex, expression, bindingContext, dataFlowInfo)
result.fqNamesToSuitableExtensions(functionFqNames, nameFilter, functionsIndex, expression, bindingContext, dataFlowInfo)
result.fqNamesToSuitableExtensions(propertyFqNames, nameFilter, propertiesIndex, expression, bindingContext, dataFlowInfo)
return result
}
@@ -219,11 +219,11 @@ abstract class CompletionSessionBase(protected val configuration: CompletionSess
protected fun shouldRunExtensionsCompletion(): Boolean
= configuration.completeNonImportedDeclarations || prefix.length() >= 3
protected fun getKotlinTopLevelCallables(): Collection<DeclarationDescriptor>
protected fun getTopLevelCallables(): Collection<DeclarationDescriptor>
= indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) })
protected fun getKotlinExtensions(): Collection<CallableDescriptor>
= indicesHelper.getCallableExtensions({ prefixMatcher.prefixMatches(it) }, reference!!.expression)
protected fun getTopLevelExtensions(): Collection<CallableDescriptor>
= indicesHelper.getCallableTopLevelExtensions({ prefixMatcher.prefixMatches(it) }, reference!!.expression)
protected fun addAllClasses(kindFilter: (ClassKind) -> Boolean) {
AllClassesCompletion(
@@ -371,12 +371,12 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration,
}
if (completionKind == CompletionKind.ALL) {
collector.addDescriptorElements(getKotlinTopLevelCallables(), suppressAutoInsertion = true)
collector.addDescriptorElements(getTopLevelCallables(), suppressAutoInsertion = true)
}
}
if (completionKind == CompletionKind.ALL && shouldRunExtensionsCompletion()) {
collector.addDescriptorElements(getKotlinExtensions(), suppressAutoInsertion = true)
collector.addDescriptorElements(getTopLevelExtensions(), suppressAutoInsertion = true)
}
}
@@ -431,11 +431,11 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para
private fun processNonImported(processor: (DeclarationDescriptor) -> Unit) {
if (shouldRunTopLevelCompletion()) {
getKotlinTopLevelCallables().forEach(processor)
getTopLevelCallables().forEach(processor)
}
if (shouldRunExtensionsCompletion()) {
getKotlinExtensions().forEach(processor)
getTopLevelExtensions().forEach(processor)
}
}
}
@@ -145,7 +145,7 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction<Jet
result.addAll(indicesHelper.getTopLevelCallablesByName(referenceName))
}
result.addAll(indicesHelper.getCallableExtensions({ it == referenceName }, element))
result.addAll(indicesHelper.getCallableTopLevelExtensions({ it == referenceName }, element))
return result
}