Moved filtering of excluded symbols to KotlinIndicesHelper
This commit is contained in:
+2
-4
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper
|
||||
import org.jetbrains.kotlin.idea.core.isInExcludedPackage
|
||||
import org.jetbrains.kotlin.idea.project.ProjectStructureUtil
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
@@ -42,12 +41,11 @@ class AllClassesCompletion(private val parameters: CompletionParameters,
|
||||
//TODO: this is a temporary hack until we have built-ins in indices
|
||||
val builtIns = JavaToKotlinClassMap.INSTANCE.allKotlinClasses()
|
||||
val filteredBuiltIns = builtIns
|
||||
.filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) && !isInExcludedPackage(it) }
|
||||
.filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) }
|
||||
filteredBuiltIns.forEach { classDescriptorCollector(it) }
|
||||
|
||||
kotlinIndicesHelper
|
||||
.getClassDescriptors({ prefixMatcher.prefixMatches(it) }, kindFilter)
|
||||
.filter { !isInExcludedPackage(it) }
|
||||
.getKotlinClasses({ prefixMatcher.prefixMatches(it) }, kindFilter)
|
||||
.forEach { classDescriptorCollector(it) }
|
||||
|
||||
if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) {
|
||||
|
||||
@@ -165,7 +165,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
}
|
||||
|
||||
protected val indicesHelper: KotlinIndicesHelper
|
||||
get() = KotlinIndicesHelper(project, resolutionFacade, searchScope, moduleDescriptor, isVisibleFilter)
|
||||
get() = KotlinIndicesHelper(project, resolutionFacade, searchScope, moduleDescriptor, isVisibleFilter, true)
|
||||
|
||||
protected fun isVisibleDescriptor(descriptor: DeclarationDescriptor): Boolean {
|
||||
if (descriptor is TypeParameterDescriptor && !isTypeParameterVisible(descriptor)) return false
|
||||
@@ -247,17 +247,16 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC
|
||||
|
||||
protected fun getTopLevelCallables(): Collection<DeclarationDescriptor> {
|
||||
val descriptors = indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) })
|
||||
return filterShadowedNonImportedAndExcluded(descriptors, reference!!)
|
||||
return filterShadowedNonImported(descriptors, reference!!)
|
||||
}
|
||||
|
||||
protected fun getTopLevelExtensions(): Collection<CallableDescriptor> {
|
||||
val descriptors = indicesHelper.getCallableTopLevelExtensions({ prefixMatcher.prefixMatches(it) }, reference!!.expression, bindingContext)
|
||||
return filterShadowedNonImportedAndExcluded(descriptors, reference)
|
||||
return filterShadowedNonImported(descriptors, reference)
|
||||
}
|
||||
|
||||
private fun filterShadowedNonImportedAndExcluded(descriptors: Collection<CallableDescriptor>, reference: JetSimpleNameReference): Collection<CallableDescriptor> {
|
||||
val notExcluded = descriptors.filter { !isInExcludedPackage(it) }
|
||||
return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(notExcluded, referenceVariants, reference.expression)
|
||||
private fun filterShadowedNonImported(descriptors: Collection<CallableDescriptor>, reference: JetSimpleNameReference): Collection<CallableDescriptor> {
|
||||
return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(descriptors, referenceVariants, reference.expression)
|
||||
}
|
||||
|
||||
protected fun addAllClasses(kindFilter: (ClassKind) -> Boolean) {
|
||||
|
||||
Reference in New Issue
Block a user