Renamed methods in MemberScope from getSmth to getContributedSmth
This commit is contained in:
+1
-1
@@ -65,7 +65,7 @@ public class LazyJavaPackageFragmentProvider(
|
||||
|
||||
javaClass.outerClass?.let { outerClass ->
|
||||
val outerClassScope = resolveClass(outerClass)?.unsubstitutedInnerClassesScope
|
||||
return outerClassScope?.getClassifier(javaClass.name, NoLookupLocation.FROM_JAVA_LOADER) as? ClassDescriptor
|
||||
return outerClassScope?.getContributedClassifier(javaClass.name, NoLookupLocation.FROM_JAVA_LOADER) as? ClassDescriptor
|
||||
}
|
||||
|
||||
val kotlinResult = c.resolveKotlinBinaryClass(c.components.kotlinClassFinder.findKotlinClass(javaClass))
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
//TODO: (module refactoring) moduleClassResolver should be used here
|
||||
val enumClass = c.javaClassResolver.resolveClass(containingJavaClass) ?: return null
|
||||
|
||||
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER)
|
||||
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(element.getName(), NoLookupLocation.FROM_JAVA_LOADER)
|
||||
if (classifier !is ClassDescriptor) return null
|
||||
|
||||
return factory.createEnumValue(classifier)
|
||||
|
||||
+4
-4
@@ -302,7 +302,7 @@ public class LazyJavaClassMemberScope(
|
||||
|
||||
private fun getFunctionsFromSupertypes(name: Name): Set<SimpleFunctionDescriptor> {
|
||||
return getContainingDeclaration().typeConstructor.supertypes.flatMap {
|
||||
it.memberScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { f -> f as SimpleFunctionDescriptor }
|
||||
it.memberScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { f -> f as SimpleFunctionDescriptor }
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ public class LazyJavaClassMemberScope(
|
||||
|
||||
private fun getPropertiesFromSupertypes(name: Name): Set<PropertyDescriptor> {
|
||||
return getContainingDeclaration().typeConstructor.supertypes.flatMap {
|
||||
it.memberScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { p -> p }
|
||||
it.memberScope.getContributedVariables(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { p -> p }
|
||||
}.toSet()
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ public class LazyJavaClassMemberScope(
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? =
|
||||
DescriptorUtils.getDispatchReceiverParameterIfNeeded(getContainingDeclaration())
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
recordLookup(name, location)
|
||||
return nestedClasses(name)
|
||||
}
|
||||
@@ -628,7 +628,7 @@ public class LazyJavaClassMemberScope(
|
||||
|
||||
return memberIndex().getAllFieldNames() +
|
||||
getContainingDeclaration().getTypeConstructor().getSupertypes().flatMapTo(LinkedHashSet<Name>()) { supertype ->
|
||||
supertype.getMemberScope().getDescriptors(kindFilter, nameFilter).map { variable ->
|
||||
supertype.getMemberScope().getContributedDescriptors(kindFilter, nameFilter).map { variable ->
|
||||
variable.getName()
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -99,29 +99,29 @@ public class LazyJavaPackageScope(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
if (!SpecialNames.isSafeIdentifier(name)) return null
|
||||
|
||||
recordLookup(name, location)
|
||||
return classes(name)
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
// We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions).
|
||||
recordLookup(name, location)
|
||||
return deserializedPackageScope().getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
return deserializedPackageScope().getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): List<FunctionDescriptor> {
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): List<FunctionDescriptor> {
|
||||
// We should track lookups here because this scope can be used for kotlin packages too (if it doesn't contain toplevel properties nor functions).
|
||||
recordLookup(name, location)
|
||||
return deserializedPackageScope().getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
return deserializedPackageScope().getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED) + super.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED)
|
||||
}
|
||||
|
||||
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
|
||||
kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) {
|
||||
result.addAll(deserializedPackageScope().getDescriptors(kindFilter, nameFilter))
|
||||
result.addAll(deserializedPackageScope().getContributedDescriptors(kindFilter, nameFilter))
|
||||
}
|
||||
|
||||
override fun computeMemberIndex(): MemberIndex = object : MemberIndex by EMPTY_MEMBER_INDEX {
|
||||
@@ -162,7 +162,7 @@ public class LazyJavaPackageScope(
|
||||
override fun getPropertyNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = listOf<Name>()
|
||||
|
||||
// we don't use implementation from super which caches all descriptors and does not use filters
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
return computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -214,7 +214,7 @@ public abstract class LazyJavaScope(
|
||||
return ResolvedValueParameters(descriptors, synthesizedNames)
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return functions(name)
|
||||
}
|
||||
@@ -298,13 +298,13 @@ public abstract class LazyJavaScope(
|
||||
return propertyType
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return properties(name)
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = allDescriptors()
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = allDescriptors()
|
||||
|
||||
protected fun computeDescriptors(
|
||||
kindFilter: DescriptorKindFilter,
|
||||
@@ -317,7 +317,7 @@ public abstract class LazyJavaScope(
|
||||
for (name in getClassNames(kindFilter, nameFilter)) {
|
||||
if (nameFilter(name)) {
|
||||
// Null signifies that a class found in Java is not present in Kotlin (e.g. package class)
|
||||
result.addIfNotNull(getClassifier(name, location))
|
||||
result.addIfNotNull(getContributedClassifier(name, location))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ public abstract class LazyJavaScope(
|
||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK) && !kindFilter.excludes.contains(NonExtensions)) {
|
||||
for (name in getFunctionNames(kindFilter, nameFilter)) {
|
||||
if (nameFilter(name)) {
|
||||
result.addAll(getFunctions(name, location))
|
||||
result.addAll(getContributedFunctions(name, location))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,7 +333,7 @@ public abstract class LazyJavaScope(
|
||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK) && !kindFilter.excludes.contains(NonExtensions)) {
|
||||
for (name in getPropertyNames(kindFilter, nameFilter)) {
|
||||
if (nameFilter(name)) {
|
||||
result.addAll(getProperties(name, location))
|
||||
result.addAll(getContributedVariables(name, location))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -63,7 +63,8 @@ public class LazyJavaStaticClassScope(
|
||||
memberIndex().getAllFieldNames() + (if (jClass.isEnum) listOf(DescriptorUtils.ENUM_VALUES) else emptyList())
|
||||
|
||||
override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name> = listOf()
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
// We don't need to track lookups here because we find nested/inner classes in LazyJavaClassMemberScope
|
||||
return null
|
||||
}
|
||||
@@ -113,7 +114,7 @@ public class LazyJavaStaticClassScope(
|
||||
|
||||
private fun getStaticFunctionsFromJavaSuperClasses(name: Name, descriptor: ClassDescriptor): Set<SimpleFunctionDescriptor> {
|
||||
val staticScope = descriptor.getParentJavaStaticClassScope() ?: return emptySet()
|
||||
return staticScope.getFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet()
|
||||
return staticScope.getContributedFunctions(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it as SimpleFunctionDescriptor }.toSet()
|
||||
}
|
||||
|
||||
private fun getStaticPropertiesFromJavaSupertypes(name: Name, descriptor: ClassDescriptor): Set<PropertyDescriptor> {
|
||||
@@ -125,7 +126,7 @@ public class LazyJavaStaticClassScope(
|
||||
|
||||
if (staticScope !is LazyJavaStaticClassScope) return getStaticPropertiesFromJavaSupertypes(name, superTypeDescriptor)
|
||||
|
||||
return staticScope.getProperties(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it }
|
||||
return staticScope.getContributedVariables(name, NoLookupLocation.WHEN_GET_SUPER_MEMBERS).map { it }
|
||||
}
|
||||
|
||||
return descriptor.typeConstructor.supertypes.flatMap(::getStaticProperties).toSet()
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl(
|
||||
private fun enumEntryValue(enumClassId: ClassId, name: Name): ConstantValue<*> {
|
||||
val enumClass = resolveClass(enumClassId)
|
||||
if (enumClass.getKind() == ClassKind.ENUM_CLASS) {
|
||||
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(name, NoLookupLocation.FROM_JAVA_LOADER)
|
||||
val classifier = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(name, NoLookupLocation.FROM_JAVA_LOADER)
|
||||
if (classifier is ClassDescriptor) {
|
||||
return factory.createEnumValue(classifier)
|
||||
}
|
||||
|
||||
@@ -219,8 +219,8 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) {
|
||||
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName,
|
||||
NoLookupLocation.FROM_BUILTINS);
|
||||
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getContributedClassifier(simpleName,
|
||||
NoLookupLocation.FROM_BUILTINS);
|
||||
assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " +
|
||||
(classifier == null ? "null" : classifier.toString());
|
||||
return (ClassDescriptor) classifier;
|
||||
@@ -235,8 +235,8 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) {
|
||||
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName,
|
||||
NoLookupLocation.FROM_BUILTINS);
|
||||
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getContributedClassifier(simpleName,
|
||||
NoLookupLocation.FROM_BUILTINS);
|
||||
assert classifier == null ||
|
||||
classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier;
|
||||
return (ClassDescriptor) classifier;
|
||||
@@ -405,7 +405,7 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getAnnotationTargetEnumEntry(@NotNull KotlinTarget target) {
|
||||
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getClassifier(
|
||||
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier(
|
||||
Name.identifier(target.name()), NoLookupLocation.FROM_BUILTINS
|
||||
);
|
||||
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
|
||||
@@ -418,7 +418,7 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getAnnotationRetentionEnumEntry(@NotNull KotlinRetention retention) {
|
||||
ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getClassifier(
|
||||
ClassifierDescriptor result = getAnnotationRetentionEnum().getUnsubstitutedInnerClassesScope().getContributedClassifier(
|
||||
Name.identifier(retention.name()), NoLookupLocation.FROM_BUILTINS
|
||||
);
|
||||
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
|
||||
@@ -1072,7 +1072,7 @@ public abstract class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
public FunctionDescriptor getIdentityEquals() {
|
||||
return first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"),
|
||||
NoLookupLocation.FROM_BUILTINS));
|
||||
return first(getBuiltInsPackageFragment().getMemberScope().getContributedFunctions(Name.identifier("identityEquals"),
|
||||
NoLookupLocation.FROM_BUILTINS));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) {
|
||||
|
||||
fun find(className: String): ClassDescriptor {
|
||||
val name = Name.identifier(className)
|
||||
return kotlinReflectScope.getClassifier(name, NoLookupLocation.FROM_REFLECTION) as? ClassDescriptor
|
||||
return kotlinReflectScope.getContributedClassifier(name, NoLookupLocation.FROM_REFLECTION) as? ClassDescriptor
|
||||
?: ErrorUtils.createErrorClass(KOTLIN_REFLECT_FQ_NAME.child(name).asString())
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ public class FunctionClassDescriptor(
|
||||
val result = ArrayList<KotlinType>(2)
|
||||
|
||||
fun add(packageFragment: PackageFragmentDescriptor, name: Name) {
|
||||
val descriptor = packageFragment.getMemberScope().getClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor
|
||||
val descriptor = packageFragment.getMemberScope().getContributedClassifier(name, NoLookupLocation.FROM_BUILTINS) as? ClassDescriptor
|
||||
?: error("Class $name not found in $packageFragment")
|
||||
|
||||
val typeConstructor = descriptor.getTypeConstructor()
|
||||
|
||||
@@ -43,23 +43,23 @@ class FunctionClassScope(
|
||||
|
||||
override fun getContainingDeclaration() = functionClass
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
if (!kindFilter.acceptsKinds(DescriptorKindFilter.CALLABLES.kindMask)) return listOf()
|
||||
return allDescriptors()
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return allDescriptors().filterIsInstance<FunctionDescriptor>().filter { it.getName() == name }
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return allDescriptors().filterIsInstance<PropertyDescriptor>().filter { it.getName() == name }
|
||||
}
|
||||
|
||||
private fun createFakeOverrides(invoke: FunctionDescriptor?): List<DeclarationDescriptor> {
|
||||
val result = ArrayList<DeclarationDescriptor>(3)
|
||||
val allSuperDescriptors = functionClass.getTypeConstructor().getSupertypes()
|
||||
.flatMap { it.getMemberScope().getDescriptors() }
|
||||
.flatMap { it.getMemberScope().getContributedDescriptors() }
|
||||
.filterIsInstance<CallableMemberDescriptor>()
|
||||
for ((name, group) in allSuperDescriptors.groupBy { it.getName() }) {
|
||||
for ((isFunction, descriptors) in group.groupBy { it is FunctionDescriptor }) {
|
||||
|
||||
+7
-7
@@ -201,25 +201,25 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public Collection<PropertyDescriptor> getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
return properties.invoke(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
private Collection<PropertyDescriptor> computeProperties(@NotNull Name name) {
|
||||
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getProperties(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
return resolveFakeOverrides(name, (Collection) getSupertypeScope().getContributedVariables(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public Collection<FunctionDescriptor> getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
return functions.invoke(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Collection<FunctionDescriptor> computeFunctions(@NotNull Name name) {
|
||||
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
return resolveFakeOverrides(name, getSupertypeScope().getContributedFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -264,7 +264,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getDescriptors(
|
||||
public Collection<DeclarationDescriptor> getContributedDescriptors(
|
||||
@NotNull DescriptorKindFilter kindFilter,
|
||||
@NotNull Function1<? super Name, ? extends Boolean> nameFilter
|
||||
) {
|
||||
@@ -275,8 +275,8 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
||||
private Collection<DeclarationDescriptor> computeAllDeclarations() {
|
||||
Collection<DeclarationDescriptor> result = new HashSet<DeclarationDescriptor>();
|
||||
for (Name name : enumMemberNames.invoke()) {
|
||||
result.addAll(getFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
result.addAll(getProperties(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
result.addAll(getContributedFunctions(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
result.addAll(getContributedVariables(name, NoLookupLocation.FOR_NON_TRACKED_SCOPE));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ public class SubpackagesScope(private val moduleDescriptor: ModuleDescriptor, pr
|
||||
return packageViewDescriptor
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
if (!kindFilter.acceptsKinds(DescriptorKindFilter.PACKAGES_MASK)) return listOf()
|
||||
if (fqName.isRoot() && kindFilter.excludes.contains(DescriptorKindExclude.TopLevelPackages)) return listOf()
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ public class DescriptorUtils {
|
||||
@Nullable
|
||||
public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName, @NotNull LookupLocation location) {
|
||||
ClassifierDescriptor classifier =
|
||||
classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), location);
|
||||
classDescriptor.getDefaultType().getMemberScope().getContributedClassifier(Name.identifier(innerClassName), location);
|
||||
assert classifier instanceof ClassDescriptor :
|
||||
"Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: "
|
||||
+ (classifier == null ? "null" : classifier.getClass());
|
||||
@@ -551,6 +551,6 @@ public class DescriptorUtils {
|
||||
|
||||
@NotNull
|
||||
public static Collection<DeclarationDescriptor> getAllDescriptors(@NotNull MemberScope scope) {
|
||||
return scope.getDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER());
|
||||
return scope.getContributedDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public val DeclarationDescriptor.module: ModuleDescriptor
|
||||
|
||||
public fun ModuleDescriptor.resolveTopLevelClass(topLevelClassFqName: FqName, location: LookupLocation): ClassDescriptor? {
|
||||
assert(!topLevelClassFqName.isRoot())
|
||||
return getPackage(topLevelClassFqName.parent()).memberScope.getClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor
|
||||
return getPackage(topLevelClassFqName.parent()).memberScope.getContributedClassifier(topLevelClassFqName.shortName(), location) as? ClassDescriptor
|
||||
}
|
||||
|
||||
public val ClassDescriptor.classId: ClassId
|
||||
|
||||
@@ -33,29 +33,29 @@ public abstract class AbstractScopeAdapter : MemberScope {
|
||||
else
|
||||
workerScope
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return workerScope.getFunctions(name, location)
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
return workerScope.getContributedFunctions(name, location)
|
||||
}
|
||||
|
||||
override fun getPackage(name: Name): PackageViewDescriptor? {
|
||||
return workerScope.getPackage(name)
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
return workerScope.getClassifier(name, location)
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
return workerScope.getContributedClassifier(name, location)
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return workerScope.getProperties(name, location)
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
return workerScope.getContributedVariables(name, location)
|
||||
}
|
||||
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
||||
return workerScope.getContainingDeclaration()
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
return workerScope.getDescriptors(kindFilter, nameFilter)
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> {
|
||||
return workerScope.getContributedDescriptors(kindFilter, nameFilter)
|
||||
}
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
|
||||
@@ -30,22 +30,22 @@ public open class ChainedScope(
|
||||
) : MemberScope {
|
||||
private val scopeChain = scopes.clone()
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
= getFirstMatch(scopeChain) { it.getClassifier(name, location) }
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
= getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) }
|
||||
|
||||
override fun getPackage(name: Name): PackageViewDescriptor?
|
||||
= getFirstMatch(scopeChain) { it.getPackage(name) }
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getProperties(name, location) }
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getContributedVariables(name, location) }
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getFunctions(name, location) }
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
|
||||
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration!!
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= getFromAllScopes(scopeChain) { it.getDescriptors(kindFilter, nameFilter) }
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= getFromAllScopes(scopeChain) { it.getContributedDescriptors(kindFilter, nameFilter) }
|
||||
|
||||
override fun toString() = debugName
|
||||
|
||||
|
||||
+3
-3
@@ -27,11 +27,11 @@ public class InnerClassesScopeWrapper(val workerScope: MemberScope) : MemberScop
|
||||
return workerScope.getContainingDeclaration()
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation) = workerScope.getClassifier(name, location) as? ClassDescriptor
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = workerScope.getContributedClassifier(name, location) as? ClassDescriptor
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<ClassDescriptor> {
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List<ClassDescriptor> {
|
||||
val restrictedFilter = kindFilter.restrictedToKindsOrNull(DescriptorKindFilter.CLASSIFIERS_MASK) ?: return listOf()
|
||||
return workerScope.getDescriptors(restrictedFilter, nameFilter).filterIsInstance<ClassDescriptor>()
|
||||
return workerScope.getContributedDescriptors(restrictedFilter, nameFilter).filterIsInstance<ClassDescriptor>()
|
||||
}
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
|
||||
@@ -25,14 +25,14 @@ import java.lang.reflect.Modifier
|
||||
|
||||
public interface MemberScope {
|
||||
|
||||
public fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
public fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor?
|
||||
|
||||
@Deprecated("Should be removed soon")
|
||||
public fun getPackage(name: Name): PackageViewDescriptor?
|
||||
|
||||
public fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
public fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor>
|
||||
|
||||
public fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
public fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getContainingDeclaration(): DeclarationDescriptor
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface MemberScope {
|
||||
* 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).
|
||||
*/
|
||||
public fun getDescriptors(
|
||||
public fun getContributedDescriptors(
|
||||
kindFilter: DescriptorKindFilter = DescriptorKindFilter.ALL,
|
||||
nameFilter: (Name) -> Boolean = ALL_NAME_FILTER
|
||||
): Collection<DeclarationDescriptor>
|
||||
@@ -75,7 +75,7 @@ public fun MemberScope.getDescriptorsFiltered(
|
||||
nameFilter: (Name) -> Boolean = { true }
|
||||
): Collection<DeclarationDescriptor> {
|
||||
if (kindFilter.kindMask == 0) return listOf()
|
||||
return getDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) }
|
||||
return getContributedDescriptors(kindFilter, nameFilter).filter { kindFilter.accepts(it) && nameFilter(it.getName()) }
|
||||
}
|
||||
|
||||
public class DescriptorKindFilter(
|
||||
|
||||
@@ -22,16 +22,16 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
abstract class MemberScopeImpl : MemberScope {
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = null
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> = emptyList()
|
||||
|
||||
override fun getPackage(name: Name): PackageViewDescriptor? = null
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = emptyList()
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
// This method should not be implemented here by default: every scope class has its unique structure pattern
|
||||
abstract override fun printScopeStructure(p: Printer)
|
||||
|
||||
+5
-5
@@ -30,7 +30,7 @@ import java.util.*
|
||||
public class StaticScopeForKotlinClass(
|
||||
private val containingClass: ClassDescriptor
|
||||
) : MemberScopeImpl() {
|
||||
override fun getClassifier(name: Name, location: LookupLocation) = null // TODO
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = null // TODO
|
||||
|
||||
private val functions: List<FunctionDescriptor> by lazy {
|
||||
if (containingClass.getKind() != ClassKind.ENUM_CLASS) {
|
||||
@@ -50,12 +50,12 @@ public class StaticScopeForKotlinClass(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = functions + properties
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = functions + properties
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name }
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation) = properties.filterTo(ArrayList(1)) { it.name == name }
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
|
||||
|
||||
override fun getContainingDeclaration() = containingClass
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val
|
||||
|
||||
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor?>? = null
|
||||
|
||||
private val _allDescriptors by lazy { substitute(workerScope.getDescriptors()) }
|
||||
private val _allDescriptors by lazy { substitute(workerScope.getContributedDescriptors()) }
|
||||
|
||||
private fun <D : DeclarationDescriptor> substitute(descriptor: D?): D? {
|
||||
if (descriptor == null) return null
|
||||
@@ -59,18 +59,18 @@ public class SubstitutingScope(private val workerScope: MemberScope, private val
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation) = substitute(workerScope.getProperties(name, location))
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation) = substitute(workerScope.getContributedVariables(name, location))
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getClassifier(name, location))
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = substitute(workerScope.getContributedClassifier(name, location))
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getFunctions(name, location))
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = substitute(workerScope.getContributedFunctions(name, location))
|
||||
|
||||
override fun getPackage(name: Name) = workerScope.getPackage(name)
|
||||
|
||||
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = _allDescriptors
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean) = _allDescriptors
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.getSimpleName(), " {")
|
||||
|
||||
@@ -169,13 +169,13 @@ public class ErrorUtils {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public ClassifierDescriptor getContributedClassifier(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
return createErrorClass(name.asString());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<PropertyDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public Set<PropertyDescriptor> getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
return ERROR_PROPERTY_GROUP;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public Set<FunctionDescriptor> getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getDescriptors(
|
||||
public Collection<DeclarationDescriptor> getContributedDescriptors(
|
||||
@NotNull DescriptorKindFilter kindFilter, @NotNull Function1<? super Name, ? extends Boolean> nameFilter
|
||||
) {
|
||||
return Collections.emptyList();
|
||||
@@ -224,7 +224,7 @@ public class ErrorUtils {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public ClassifierDescriptor getContributedClassifier(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@@ -236,13 +236,13 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getProperties(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public Collection<PropertyDescriptor> getContributedVariables(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
public Collection<FunctionDescriptor> getContributedFunctions(@NotNull Name name, @NotNull LookupLocation location) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class ErrorUtils {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getDescriptors(
|
||||
public Collection<DeclarationDescriptor> getContributedDescriptors(
|
||||
@NotNull DescriptorKindFilter kindFilter, @NotNull Function1<? super Name, ? extends Boolean> nameFilter
|
||||
) {
|
||||
throw new IllegalStateException();
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) {
|
||||
private fun resolveEnumValue(enumClassId: ClassId, enumEntryName: Name): ConstantValue<*> {
|
||||
val enumClass = resolveClass(enumClassId)
|
||||
if (enumClass.getKind() == ClassKind.ENUM_CLASS) {
|
||||
val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION)
|
||||
val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getContributedClassifier(enumEntryName, NoLookupLocation.FROM_DESERIALIZATION)
|
||||
if (enumEntry is ClassDescriptor) {
|
||||
return factory.createEnumValue(enumEntry)
|
||||
}
|
||||
|
||||
+9
-9
@@ -130,7 +130,7 @@ public class DeserializedClassDescriptor(
|
||||
if (!classProto.hasCompanionObjectName()) return null
|
||||
|
||||
val companionObjectName = c.nameResolver.getName(classProto.getCompanionObjectName())
|
||||
return memberScope.getClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor
|
||||
return memberScope.getContributedClassifier(companionObjectName, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor
|
||||
}
|
||||
|
||||
override fun getCompanionObjectDescriptor(): ClassDescriptor? = companionObjectDescriptor()
|
||||
@@ -192,13 +192,13 @@ public class DeserializedClassDescriptor(
|
||||
computeDescriptors(DescriptorKindFilter.ALL, MemberScope.ALL_NAME_FILTER, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
|
||||
}
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = allDescriptors()
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = allDescriptors()
|
||||
|
||||
override fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
|
||||
val fromSupertypes = ArrayList<FunctionDescriptor>()
|
||||
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
|
||||
fromSupertypes.addAll(supertype.memberScope.getFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
fromSupertypes.addAll(supertype.memberScope.getContributedFunctions(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
}
|
||||
generateFakeOverrides(name, fromSupertypes, functions)
|
||||
}
|
||||
@@ -206,7 +206,7 @@ public class DeserializedClassDescriptor(
|
||||
override fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
||||
val fromSupertypes = ArrayList<PropertyDescriptor>()
|
||||
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
|
||||
fromSupertypes.addAll(supertype.memberScope.getProperties(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
fromSupertypes.addAll(supertype.memberScope.getContributedVariables(name, NoLookupLocation.FOR_ALREADY_TRACKED))
|
||||
}
|
||||
generateFakeOverrides(name, fromSupertypes, descriptors)
|
||||
}
|
||||
@@ -229,12 +229,12 @@ public class DeserializedClassDescriptor(
|
||||
|
||||
override fun addNonDeclaredDescriptors(result: MutableCollection<DeclarationDescriptor>, location: LookupLocation) {
|
||||
for (supertype in classDescriptor.getTypeConstructor().supertypes) {
|
||||
for (descriptor in supertype.memberScope.getDescriptors()) {
|
||||
for (descriptor in supertype.memberScope.getContributedDescriptors()) {
|
||||
if (descriptor is FunctionDescriptor) {
|
||||
result.addAll(getFunctions(descriptor.name, location))
|
||||
result.addAll(getContributedFunctions(descriptor.name, location))
|
||||
}
|
||||
else if (descriptor is PropertyDescriptor) {
|
||||
result.addAll(getProperties(descriptor.name, location))
|
||||
result.addAll(getContributedVariables(descriptor.name, location))
|
||||
}
|
||||
// Nothing else is inherited
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public class DeserializedClassDescriptor(
|
||||
val result = HashSet<Name>()
|
||||
|
||||
for (supertype in getTypeConstructor().getSupertypes()) {
|
||||
for (descriptor in supertype.getMemberScope().getDescriptors()) {
|
||||
for (descriptor in supertype.getMemberScope().getContributedDescriptors()) {
|
||||
if (descriptor is SimpleFunctionDescriptor || descriptor is PropertyDescriptor) {
|
||||
result.add(descriptor.getName())
|
||||
}
|
||||
|
||||
+5
-5
@@ -82,7 +82,7 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
|
||||
}
|
||||
|
||||
override fun getFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation): Collection<FunctionDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return functions(name)
|
||||
}
|
||||
@@ -102,12 +102,12 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
protected open fun computeNonDeclaredProperties(name: Name, descriptors: MutableCollection<PropertyDescriptor>) {
|
||||
}
|
||||
|
||||
override fun getProperties(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation): Collection<PropertyDescriptor> {
|
||||
recordLookup(name, location)
|
||||
return properties.invoke(name)
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||
recordLookup(name, location)
|
||||
return getClassDescriptor(name)
|
||||
}
|
||||
@@ -150,12 +150,12 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
) {
|
||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.VARIABLES_MASK)) {
|
||||
val keys = propertyProtos().keySet().filter { nameFilter(it.name) }
|
||||
addMembers(result, keys) { getProperties(it, location) }
|
||||
addMembers(result, keys) { getContributedVariables(it, location) }
|
||||
}
|
||||
|
||||
if (kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) {
|
||||
val keys = functionProtos().keySet().filter { nameFilter(it.name) }
|
||||
addMembers(result, keys) { getFunctions(it, location) }
|
||||
addMembers(result, keys) { getContributedFunctions(it, location) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public open class DeserializedPackageMemberScope(
|
||||
|
||||
internal val classNames by c.storageManager.createLazyValue { classNames().toSet() }
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= computeDescriptors(kindFilter, nameFilter, NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS)
|
||||
|
||||
override fun getClassDescriptor(name: Name): ClassDescriptor? =
|
||||
|
||||
+2
-2
@@ -24,10 +24,10 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
public fun ModuleDescriptor.findClassAcrossModuleDependencies(classId: ClassId): ClassDescriptor? {
|
||||
val packageViewDescriptor = getPackage(classId.packageFqName)
|
||||
val segments = classId.relativeClassName.pathSegments()
|
||||
val topLevelClass = packageViewDescriptor.memberScope.getClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
|
||||
val topLevelClass = packageViewDescriptor.memberScope.getContributedClassifier(segments.first(), NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
|
||||
var result = topLevelClass
|
||||
for (name in segments.subList(1, segments.size())) {
|
||||
result = result.unsubstitutedInnerClassesScope.getClassifier(name, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
|
||||
result = result.unsubstitutedInnerClassesScope.getContributedClassifier(name, NoLookupLocation.FROM_DESERIALIZATION) as? ClassDescriptor ?: return null
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ internal class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclaration
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun getProperties(name: Name): Collection<PropertyDescriptor> =
|
||||
(memberScope.getProperties(name, NoLookupLocation.FROM_REFLECTION) +
|
||||
staticScope.getProperties(name, NoLookupLocation.FROM_REFLECTION)) as Collection<PropertyDescriptor>
|
||||
(memberScope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION) +
|
||||
staticScope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION)) as Collection<PropertyDescriptor>
|
||||
|
||||
override fun getFunctions(name: Name): Collection<FunctionDescriptor> =
|
||||
memberScope.getFunctions(name, NoLookupLocation.FROM_REFLECTION) +
|
||||
staticScope.getFunctions(name, NoLookupLocation.FROM_REFLECTION)
|
||||
memberScope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION) +
|
||||
staticScope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION)
|
||||
|
||||
override val simpleName: String? get() {
|
||||
if (jClass.isAnonymousClass()) return null
|
||||
@@ -120,7 +120,7 @@ internal class KClassImpl<T : Any>(override val jClass: Class<T>) : KDeclaration
|
||||
}
|
||||
|
||||
override val nestedClasses: Collection<KClass<*>>
|
||||
get() = descriptor.unsubstitutedInnerClassesScope.getDescriptors().map { nestedClass ->
|
||||
get() = descriptor.unsubstitutedInnerClassesScope.getContributedDescriptors().map { nestedClass ->
|
||||
val source = (nestedClass as DeclarationDescriptorWithSource).source
|
||||
when (source) {
|
||||
is KotlinJvmBinarySourceElement ->
|
||||
|
||||
@@ -78,7 +78,7 @@ internal abstract class KDeclarationContainerImpl : ClassBasedDeclarationContain
|
||||
}
|
||||
}
|
||||
|
||||
return scope.getDescriptors().asSequence()
|
||||
return scope.getContributedDescriptors().asSequence()
|
||||
.filter { descriptor ->
|
||||
descriptor !is MemberDescriptor || descriptor.getVisibility() != Visibilities.INVISIBLE_FAKE
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ internal class KPackageImpl(override val jClass: Class<*>, val moduleName: Strin
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun getProperties(name: Name): Collection<PropertyDescriptor> =
|
||||
scope.getProperties(name, NoLookupLocation.FROM_REFLECTION) as Collection<PropertyDescriptor>
|
||||
scope.getContributedVariables(name, NoLookupLocation.FROM_REFLECTION) as Collection<PropertyDescriptor>
|
||||
|
||||
override fun getFunctions(name: Name): Collection<FunctionDescriptor> =
|
||||
scope.getFunctions(name, NoLookupLocation.FROM_REFLECTION)
|
||||
scope.getContributedFunctions(name, NoLookupLocation.FROM_REFLECTION)
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is KPackageImpl && jClass == other.jClass
|
||||
|
||||
Reference in New Issue
Block a user