Top-level callables are added one by one
This commit is contained in:
+4
-1
@@ -242,7 +242,10 @@ class BasicCompletionSession(
|
||||
|
||||
private fun completeNonImported(lookupElementFactory: LookupElementFactory) {
|
||||
if (shouldCompleteTopLevelCallablesFromIndex()) {
|
||||
collector.addDescriptorElements(getTopLevelCallables(), lookupElementFactory, notImported = true)
|
||||
processTopLevelCallables {
|
||||
collector.addDescriptorElements(it, lookupElementFactory, notImported = true)
|
||||
flushToResultSet()
|
||||
}
|
||||
}
|
||||
|
||||
val classKindFilter: ((ClassKind) -> Boolean)?
|
||||
|
||||
+14
-10
@@ -337,7 +337,9 @@ abstract class CompletionSession(
|
||||
|
||||
if (shadowedDeclarationsFilter != null) {
|
||||
variants = shadowedDeclarationsFilter.filter(variants)
|
||||
notImportedExtensions = shadowedDeclarationsFilter.filterNonImported(notImportedExtensions, variants)
|
||||
notImportedExtensions = shadowedDeclarationsFilter
|
||||
.createNonImportedDeclarationsFilter<CallableDescriptor>(importedDeclarations = variants)
|
||||
.invoke(notImportedExtensions)
|
||||
}
|
||||
|
||||
if (configuration.filterOutJavaGettersAndSetters) {
|
||||
@@ -394,10 +396,17 @@ abstract class CompletionSession(
|
||||
return callTypeAndReceiver.receiver == null
|
||||
}
|
||||
|
||||
protected fun getTopLevelCallables(): Collection<CallableDescriptor> {
|
||||
val result = LinkedHashSet<CallableDescriptor>()
|
||||
indicesHelper(true).processTopLevelCallables({ prefixMatcher.prefixMatches(it) }) { result.add(it) }
|
||||
return result.filterShadowedNonImported()
|
||||
protected fun processTopLevelCallables(processor: (CallableDescriptor) -> Unit) {
|
||||
val shadowedFilter = ShadowedDeclarationsFilter.create(bindingContext, resolutionFacade, nameExpression!!, callTypeAndReceiver)
|
||||
?.createNonImportedDeclarationsFilter<CallableDescriptor>(referenceVariants!!.imported)
|
||||
indicesHelper(true).processTopLevelCallables({ prefixMatcher.prefixMatches(it) }) {
|
||||
if (shadowedFilter != null) {
|
||||
shadowedFilter(listOf(it)).singleOrNull()?.let(processor)
|
||||
}
|
||||
else {
|
||||
processor(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun CallTypeAndReceiver<*, *>.shouldCompleteCallableExtensions(): Boolean {
|
||||
@@ -405,11 +414,6 @@ abstract class CompletionSession(
|
||||
&& this !is CallTypeAndReceiver.IMPORT_DIRECTIVE
|
||||
}
|
||||
|
||||
private fun Collection<CallableDescriptor>.filterShadowedNonImported(): Collection<CallableDescriptor> {
|
||||
val filter = ShadowedDeclarationsFilter.create(bindingContext, resolutionFacade, nameExpression!!, callTypeAndReceiver)
|
||||
return if (filter != null) filter.filterNonImported(this, referenceVariants!!.imported) else this
|
||||
}
|
||||
|
||||
protected fun addClassesFromIndex(kindFilter: (ClassKind) -> Boolean) {
|
||||
AllClassesCompletion(parameters, indicesHelper(true), prefixMatcher, resolutionFacade, kindFilter)
|
||||
.collect(
|
||||
|
||||
+4
-2
@@ -120,8 +120,10 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para
|
||||
}
|
||||
|
||||
if (shouldCompleteTopLevelCallablesFromIndex()) {
|
||||
getTopLevelCallables().forEach { collector.addElements(filter(it, lookupElementFactory), notImported = true) }
|
||||
flushToResultSet()
|
||||
processTopLevelCallables {
|
||||
collector.addElements(filter(it, lookupElementFactory), notImported = true)
|
||||
flushToResultSet()
|
||||
}
|
||||
}
|
||||
|
||||
if (position.getContainingFile() is KtCodeFragment) {
|
||||
|
||||
Reference in New Issue
Block a user