Add location parameter to JetScope::getClassifier
This commit is contained in:
+2
-2
@@ -35,12 +35,12 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaConstructor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaMethod
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.load.java.typeEnhacement.enhanceSignatures
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.utils.*
|
||||
@@ -285,7 +285,7 @@ public class LazyJavaClassMemberScope(
|
||||
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? =
|
||||
DescriptorUtils.getDispatchReceiverParameterIfNeeded(getContainingDeclaration())
|
||||
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? = nestedClasses(name)
|
||||
override fun getClassifier(name: Name, location: Location): ClassifierDescriptor? = nestedClasses(name)
|
||||
|
||||
override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
|
||||
= nestedClassIndex().keySet() + enumEntryIndex().keySet()
|
||||
|
||||
+10
-6
@@ -16,14 +16,18 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.name.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory.*
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
public class LazyJavaStaticClassScope(
|
||||
c: LazyJavaResolverContext,
|
||||
@@ -54,7 +58,7 @@ public class LazyJavaStaticClassScope(
|
||||
memberIndex().getAllFieldNames()
|
||||
|
||||
override fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name> = listOf()
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? = null
|
||||
override fun getClassifier(name: Name, location: Location): ClassifierDescriptor? = null
|
||||
|
||||
override fun getSubPackages(): Collection<FqName> = listOf()
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public class LazyPackageFragmentScopeForJavaPackage(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? = classes(name)
|
||||
override fun getClassifier(name: Name, location: Location): ClassifierDescriptor? = classes(name)
|
||||
|
||||
override fun getProperties(name: Name, location: Location) = deserializedPackageScope().getProperties(name)
|
||||
override fun getFunctions(name: Name, location: Location) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
|
||||
|
||||
@@ -237,7 +237,7 @@ public class KotlinBuiltIns {
|
||||
|
||||
@NotNull
|
||||
private ClassDescriptor getAnnotationClassByName(@NotNull Name simpleName) {
|
||||
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName);
|
||||
ClassifierDescriptor classifier = annotationPackageFragment.getMemberScope().getClassifier(simpleName, UsageLocation.NO_LOCATION);
|
||||
assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " +
|
||||
(classifier == null ? "null" : classifier.toString());
|
||||
return (ClassDescriptor) classifier;
|
||||
@@ -252,7 +252,7 @@ public class KotlinBuiltIns {
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) {
|
||||
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName);
|
||||
ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName, Location.NOWHERE);
|
||||
assert classifier == null ||
|
||||
classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier;
|
||||
return (ClassDescriptor) classifier;
|
||||
@@ -401,7 +401,7 @@ public class KotlinBuiltIns {
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor getAnnotationTargetEnumEntry(@NotNull Name name) {
|
||||
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getClassifier(name);
|
||||
ClassifierDescriptor result = getAnnotationTargetEnum().getUnsubstitutedInnerClassesScope().getClassifier(name, UsageLocation.NO_LOCATION);
|
||||
return result instanceof ClassDescriptor ? (ClassDescriptor) result : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.name.SpecialNames;
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
|
||||
import org.jetbrains.kotlin.resolve.scopes.FilteringScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.Location;
|
||||
import org.jetbrains.kotlin.types.ErrorUtils;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.kotlin.types.LazyType;
|
||||
@@ -387,7 +388,8 @@ public class DescriptorUtils {
|
||||
|
||||
@Nullable
|
||||
public static ClassDescriptor getInnerClassByName(@NotNull ClassDescriptor classDescriptor, @NotNull String innerClassName) {
|
||||
ClassifierDescriptor classifier = classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName));
|
||||
ClassifierDescriptor classifier =
|
||||
classDescriptor.getDefaultType().getMemberScope().getClassifier(Name.identifier(innerClassName), Location.NOWHERE);
|
||||
assert classifier instanceof ClassDescriptor :
|
||||
"Inner class " + innerClassName + " in " + classDescriptor + " should be instance of ClassDescriptor, but was: "
|
||||
+ (classifier == null ? "null" : classifier.getClass());
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class AbstractScopeAdapter : JetScope {
|
||||
return workerScope.getPackage(name)
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? {
|
||||
override fun getClassifier(name: Name, location: Location): ClassifierDescriptor? {
|
||||
return workerScope.getClassifier(name)
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public open class ChainedScope(
|
||||
return result ?: emptySet()
|
||||
}
|
||||
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor?
|
||||
override fun getClassifier(name: Name, location: Location): ClassifierDescriptor?
|
||||
= getFirstMatch { it.getClassifier(name) }
|
||||
|
||||
override fun getPackage(name: Name): PackageViewDescriptor?
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
|
||||
public class ExplicitImportsScope(private val descriptors: Collection<DeclarationDescriptor>) : JetScopeImpl() {
|
||||
override fun getClassifier(name: Name) = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<ClassifierDescriptor>()
|
||||
override fun getClassifier(name: Name, location: Location) = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<ClassifierDescriptor>()
|
||||
|
||||
override fun getPackage(name: Name)= descriptors.filter { it.getName() == name }.firstIsInstanceOrNull<PackageViewDescriptor>()
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
|
||||
|
||||
override fun getPackage(name: Name) = filterDescriptor(workerScope.getPackage(name))
|
||||
|
||||
override fun getClassifier(name: Name) = filterDescriptor(workerScope.getClassifier(name))
|
||||
override fun getClassifier(name: Name, location: Location) = filterDescriptor(workerScope.getClassifier(name))
|
||||
|
||||
override fun getProperties(name: Name, location: Location) = workerScope.getProperties(name).filter(predicate)
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
public class InnerClassesScopeWrapper(override val workerScope: JetScope) : AbstractScopeAdapter() {
|
||||
override fun getClassifier(name: Name) = workerScope.getClassifier(name) as? ClassDescriptor
|
||||
override fun getClassifier(name: Name, location: Location) = workerScope.getClassifier(name) as? ClassDescriptor
|
||||
|
||||
override fun getDeclarationsByLabel(labelName: Name) = workerScope.getDeclarationsByLabel(labelName).filterIsInstance<ClassDescriptor>()
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.lang.reflect.Modifier
|
||||
|
||||
public interface JetScope {
|
||||
|
||||
public fun getClassifier(name: Name): ClassifierDescriptor?
|
||||
public fun getClassifier(name: Name, location: Location = Location.NOWHERE): ClassifierDescriptor?
|
||||
|
||||
public fun getPackage(name: Name): PackageViewDescriptor?
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
public abstract class JetScopeImpl : JetScope {
|
||||
override fun getClassifier(name: Name): ClassifierDescriptor? = null
|
||||
override fun getClassifier(name: Name, location: Location): ClassifierDescriptor? = null
|
||||
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> = setOf()
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import java.util.ArrayList
|
||||
public class StaticScopeForKotlinClass(
|
||||
private val containingClass: ClassDescriptor
|
||||
) : JetScopeImpl() {
|
||||
override fun getClassifier(name: Name) = null // TODO
|
||||
override fun getClassifier(name: Name, location: Location) = null // TODO
|
||||
|
||||
private val functions: List<FunctionDescriptor> by lazy {
|
||||
if (containingClass.getKind() != ClassKind.ENUM_CLASS) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
|
||||
|
||||
override fun getLocalVariable(name: Name) = substitute(workerScope.getLocalVariable(name))
|
||||
|
||||
override fun getClassifier(name: Name) = substitute(workerScope.getClassifier(name))
|
||||
override fun getClassifier(name: Name, location: Location) = substitute(workerScope.getClassifier(name))
|
||||
|
||||
override fun getFunctions(name: Name, location: Location) = substitute(workerScope.getFunctions(name))
|
||||
|
||||
|
||||
@@ -81,8 +81,9 @@ public class ErrorUtils {
|
||||
this.debugMessage = debugMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull Location location) {
|
||||
return createErrorClass(name.asString());
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ public class ErrorUtils {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name, @NotNull Location location) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public abstract class DeserializedMemberScope protected constructor(
|
||||
|
||||
override fun getProperties(name: Name, location: Location): Collection<VariableDescriptor> = properties.invoke(name)
|
||||
|
||||
override fun getClassifier(name: Name) = getClassDescriptor(name)
|
||||
override fun getClassifier(name: Name, location: Location) = getClassDescriptor(name)
|
||||
|
||||
protected abstract fun getClassDescriptor(name: Name): ClassifierDescriptor?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user