Got rid of two getContributedDescriptors calling each other
This commit is contained in:
@@ -38,7 +38,8 @@ public class LexicalChainedScope(
|
||||
override val parent = parent.takeSnapshot()
|
||||
private val scopeChain = memberScopes.clone()
|
||||
|
||||
override fun getContributedDescriptors() = getFromAllScopes(scopeChain) { it.getAllDescriptors() }
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= getFromAllScopes(scopeChain) { it.getAllDescriptors() }
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getClassifier(name, location) }
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class LexicalScopeImpl @JvmOverloads constructor(
|
||||
InitializeHandler(redeclarationHandler).initialize()
|
||||
}
|
||||
|
||||
override fun getContributedDescriptors() = addedDescriptors
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = addedDescriptors
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = getDeclaredClassifier(name)
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ class LexicalWritableScope(
|
||||
addVariableOrClassDescriptor(classifierDescriptor)
|
||||
}
|
||||
|
||||
override fun getContributedDescriptors() = checkMayRead().addedDescriptors
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= checkMayRead().addedDescriptors
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = checkMayRead().getDeclaredClassifier(name)
|
||||
|
||||
@@ -101,7 +102,8 @@ class LexicalWritableScope(
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?
|
||||
get() = this@LexicalWritableScope.implicitReceiver
|
||||
|
||||
override fun getContributedDescriptors() = this@LexicalWritableScope.addedDescriptors.subList(0, descriptorLimit)
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= this@LexicalWritableScope.addedDescriptors.subList(0, descriptorLimit)
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation)
|
||||
= this@LexicalWritableScope.getDeclaredClassifier(name, descriptorLimit)
|
||||
|
||||
@@ -226,8 +226,6 @@ private class MemberScopeToImportingScopeAdapter(override val parent: ImportingS
|
||||
override val ownerDescriptor: DeclarationDescriptor
|
||||
get() = memberScope.getContainingDeclaration()
|
||||
|
||||
override fun getContributedDescriptors() = memberScope.getOwnDeclaredDescriptors()
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = memberScope.getClassifier(name, location)
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation) = memberScope.getProperties(name, location)
|
||||
|
||||
@@ -36,12 +36,10 @@ interface LexicalScope {
|
||||
* All visible descriptors from current scope possibly filtered by the given name and kind filters
|
||||
* (that means that the implementation is not obliged to use the filters but may do so when it gives any performance advantage).
|
||||
*/
|
||||
open fun getContributedDescriptors(
|
||||
fun getContributedDescriptors(
|
||||
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
||||
nameFilter: (Name) -> Boolean = KtScope.ALL_NAME_FILTER
|
||||
): Collection<DeclarationDescriptor> = getContributedDescriptors()
|
||||
|
||||
fun getContributedDescriptors(): Collection<DeclarationDescriptor>
|
||||
): Collection<DeclarationDescriptor>
|
||||
|
||||
fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
|
||||
@@ -64,7 +62,7 @@ interface LexicalScope {
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?
|
||||
get() = null
|
||||
|
||||
override fun getContributedDescriptors(): Collection<DeclarationDescriptor> = emptyList()
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
|
||||
|
||||
@@ -96,13 +94,6 @@ interface ImportingScope : LexicalScope {
|
||||
fun getContributedSyntheticExtensionProperties(receiverTypes: Collection<KotlinType>): Collection<PropertyDescriptor>
|
||||
fun getContributedSyntheticExtensionFunctions(receiverTypes: Collection<KotlinType>): Collection<FunctionDescriptor>
|
||||
|
||||
// please, do not override this method
|
||||
override fun getContributedDescriptors(): Collection<DeclarationDescriptor> {
|
||||
return getContributedDescriptors(DescriptorKindFilter.ALL, { true })
|
||||
}
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor>
|
||||
|
||||
object Empty : ImportingScope, LexicalScope by LexicalScope.Empty {
|
||||
override fun getContributedPackage(name: Name) = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user