Minor. Refactor DeserializedMemberScope.addNonDeclaredDescriptors
This commit is contained in:
+9
-11
@@ -226,17 +226,15 @@ class DeserializedClassDescriptor(
|
||||
})
|
||||
}
|
||||
|
||||
override fun addNonDeclaredDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
|
||||
for (descriptor in supertype.memberScope.getContributedDescriptors()) {
|
||||
if (descriptor is FunctionDescriptor) {
|
||||
result.addAll(getContributedFunctions(descriptor.name, location))
|
||||
}
|
||||
else if (descriptor is PropertyDescriptor) {
|
||||
result.addAll(getContributedVariables(descriptor.name, location))
|
||||
}
|
||||
// Nothing else is inherited
|
||||
}
|
||||
override fun getNonDeclaredFunctionNames(location: LookupLocation): Set<Name> {
|
||||
return classDescriptor.typeConstructor.supertypes.flatMapTo(LinkedHashSet()) {
|
||||
it.memberScope.getContributedDescriptors().filterIsInstance<SimpleFunctionDescriptor>().map { it.name }
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNonDeclaredVariableNames(location: LookupLocation): Set<Name> {
|
||||
return classDescriptor.typeConstructor.supertypes.flatMapTo(LinkedHashSet()) {
|
||||
it.memberScope.getContributedDescriptors().filterIsInstance<PropertyDescriptor>().map { it.name }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -165,7 +165,13 @@ abstract class DeserializedMemberScope protected constructor(
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun addNonDeclaredDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation)
|
||||
protected fun addNonDeclaredDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
result.addAll(getNonDeclaredFunctionNames(location).flatMap { getContributedFunctions(it, location) })
|
||||
result.addAll(getNonDeclaredVariableNames(location).flatMap { getContributedVariables(it, location) })
|
||||
}
|
||||
|
||||
protected abstract fun getNonDeclaredFunctionNames(location: LookupLocation): Set<Name>
|
||||
protected abstract fun getNonDeclaredVariableNames(location: LookupLocation): Set<Name>
|
||||
|
||||
protected abstract fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
||||
|
||||
|
||||
+2
-3
@@ -63,9 +63,8 @@ open class DeserializedPackageMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun addNonDeclaredDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
// Do nothing
|
||||
}
|
||||
override fun getNonDeclaredFunctionNames(location: LookupLocation): Set<Name> = emptySet()
|
||||
override fun getNonDeclaredVariableNames(location: LookupLocation): Set<Name> = emptySet()
|
||||
|
||||
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
|
||||
// Do nothing
|
||||
|
||||
Reference in New Issue
Block a user