Reuse allDescriptors() from LazyJavaScope to avoid compute contributed descriptors in LazyJavaPackageScope

This commit is contained in:
Vladimir Dolzhenko
2019-10-14 10:13:30 +02:00
parent 88bc6b992f
commit 8bba596c4e
@@ -160,18 +160,25 @@ class LazyJavaPackageScope(
}
}
override fun computeFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: ((Name) -> Boolean)?): Set<Name> {
return emptySet()
}
override fun computeFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: ((Name) -> Boolean)?): Set<Name> = emptySet()
override fun computeNonDeclaredFunctions(result: MutableCollection<SimpleFunctionDescriptor>, name: Name) {
}
override fun computePropertyNames(kindFilter: DescriptorKindFilter, nameFilter: ((Name) -> Boolean)?) = emptySet<Name>()
// we don't use implementation from super which caches all descriptors and does not use filters
override fun getContributedDescriptors(
kindFilter: DescriptorKindFilter,
nameFilter: (Name) -> Boolean
): Collection<DeclarationDescriptor> = computeDescriptors(kindFilter, nameFilter)
): Collection<DeclarationDescriptor> {
// combined computeDescriptors() and computeClassNames()
// computeFunctionNames and computePropertyNames return always emptySet
// therefore don't need to check if kindFilter anything else but CLASSIFIERS
if (!kindFilter.acceptsKinds(DescriptorKindFilter.CLASSIFIERS_MASK or DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK))
emptyList<DeclarationDescriptor>()
// we don't use implementation from super which caches all descriptors and does not use filters
val allContributedDescriptors = allDescriptors()
return allContributedDescriptors.filter { it is ClassDescriptor && nameFilter(it.name) }.toList()
}
}