Minor. Drop unused getNonDeclaredTypeAliasNames
Also cleanup type aliases related code in DeserializedMemberScope
This commit is contained in:
-6
@@ -263,12 +263,6 @@ class DeserializedClassDescriptor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNonDeclaredTypeAliasNames(): Set<Name> {
|
|
||||||
return classDescriptor.typeConstructor.supertypes.flatMapTo(LinkedHashSet()) {
|
|
||||||
it.memberScope.getContributedDescriptors().filterIsInstance<TypeAliasDescriptor>().map { it.name }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||||
recordLookup(name, location)
|
recordLookup(name, location)
|
||||||
return classDescriptor.enumEntries?.findEnumEntry(name) ?:
|
return classDescriptor.enumEntries?.findEnumEntry(name) ?:
|
||||||
|
|||||||
+11
-16
@@ -52,17 +52,13 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
c.storageManager.createLazyValue {
|
c.storageManager.createLazyValue {
|
||||||
typeAliasList.groupByName { it.name }
|
typeAliasList.groupByName { it.name }
|
||||||
}
|
}
|
||||||
protected val typeAliasNames by
|
|
||||||
c.storageManager.createLazyValue {
|
|
||||||
typeAliasList.map { c.nameResolver.getName(it.name) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private val functions =
|
private val functions =
|
||||||
c.storageManager.createMemoizedFunction<Name, Collection<SimpleFunctionDescriptor>> { computeFunctions(it) }
|
c.storageManager.createMemoizedFunction<Name, Collection<SimpleFunctionDescriptor>> { computeFunctions(it) }
|
||||||
private val properties =
|
private val properties =
|
||||||
c.storageManager.createMemoizedFunction<Name, Collection<PropertyDescriptor>> { computeProperties(it) }
|
c.storageManager.createMemoizedFunction<Name, Collection<PropertyDescriptor>> { computeProperties(it) }
|
||||||
private val typeAliases =
|
private val typeAliasByName =
|
||||||
c.storageManager.createMemoizedFunction<Name, Collection<TypeAliasDescriptor>> { computeTypeAliases(it) }
|
c.storageManager.createMemoizedFunctionWithNullableValues<Name, TypeAliasDescriptor> { createTypeAlias(it) }
|
||||||
|
|
||||||
private val functionNamesLazy by c.storageManager.createLazyValue {
|
private val functionNamesLazy by c.storageManager.createLazyValue {
|
||||||
functionProtos.keys + getNonDeclaredFunctionNames()
|
functionProtos.keys + getNonDeclaredFunctionNames()
|
||||||
@@ -72,6 +68,8 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
propertyProtos.keys + getNonDeclaredVariableNames()
|
propertyProtos.keys + getNonDeclaredVariableNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected val typeAliasNames: Set<Name> get() = typeAliasProtos.keys
|
||||||
|
|
||||||
override fun getFunctionNames() = functionNamesLazy
|
override fun getFunctionNames() = functionNamesLazy
|
||||||
override fun getVariableNames() = variableNamesLazy
|
override fun getVariableNames() = variableNamesLazy
|
||||||
|
|
||||||
@@ -120,21 +118,19 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun computeTypeAliases(name: Name) =
|
private fun createTypeAlias(name: Name) =
|
||||||
computeDescriptors(
|
typeAliasProtos[name]?.singleOrNull()?.let {
|
||||||
name,
|
c.memberDeserializer.loadTypeAlias(it)
|
||||||
typeAliasProtos,
|
}
|
||||||
{ c.memberDeserializer.loadTypeAlias(it) },
|
|
||||||
{ })
|
|
||||||
|
|
||||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||||
if (name !in getVariableNames()) return emptyList()
|
if (name !in getVariableNames()) return emptyList()
|
||||||
return properties(name)
|
return properties(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun getContributedTypeAliases(name: Name): Collection<TypeAliasDescriptor> {
|
protected fun getTypeAlias(name: Name): TypeAliasDescriptor? {
|
||||||
if (name !in typeAliasNames) return emptyList()
|
if (name !in typeAliasNames) return null
|
||||||
return typeAliases(name)
|
return typeAliasByName(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract fun addClassifierDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
protected abstract fun addClassifierDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
||||||
@@ -203,7 +199,6 @@ abstract class DeserializedMemberScope protected constructor(
|
|||||||
|
|
||||||
protected abstract fun getNonDeclaredFunctionNames(): Set<Name>
|
protected abstract fun getNonDeclaredFunctionNames(): Set<Name>
|
||||||
protected abstract fun getNonDeclaredVariableNames(): Set<Name>
|
protected abstract fun getNonDeclaredVariableNames(): Set<Name>
|
||||||
protected abstract fun getNonDeclaredTypeAliasNames(): Set<Name>
|
|
||||||
|
|
||||||
protected abstract fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
protected abstract fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean)
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -53,7 +53,7 @@ open class DeserializedPackageMemberScope(
|
|||||||
(name in classNames || c.components.fictitiousClassDescriptorFactory.shouldCreateClass(packageFqName, name))) {
|
(name in classNames || c.components.fictitiousClassDescriptorFactory.shouldCreateClass(packageFqName, name))) {
|
||||||
return getClassDescriptor(name)
|
return getClassDescriptor(name)
|
||||||
}
|
}
|
||||||
return getContributedTypeAliases(name).singleOrNull()
|
return getTypeAlias(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getClassDescriptor(name: Name): ClassDescriptor? =
|
private fun getClassDescriptor(name: Name): ClassDescriptor? =
|
||||||
@@ -67,14 +67,13 @@ open class DeserializedPackageMemberScope(
|
|||||||
}
|
}
|
||||||
for (typeAliasName in typeAliasNames) {
|
for (typeAliasName in typeAliasNames) {
|
||||||
if (nameFilter(typeAliasName)) {
|
if (nameFilter(typeAliasName)) {
|
||||||
result.addAll(getContributedTypeAliases(typeAliasName))
|
result.addIfNotNull(getTypeAlias(typeAliasName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getNonDeclaredFunctionNames(): Set<Name> = emptySet()
|
override fun getNonDeclaredFunctionNames(): Set<Name> = emptySet()
|
||||||
override fun getNonDeclaredVariableNames(): Set<Name> = emptySet()
|
override fun getNonDeclaredVariableNames(): Set<Name> = emptySet()
|
||||||
override fun getNonDeclaredTypeAliasNames(): Set<Name> = emptySet()
|
|
||||||
|
|
||||||
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
|
override fun addEnumEntryDescriptors(result: MutableCollection<DeclarationDescriptor>, nameFilter: (Name) -> Boolean) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user