Classify Location.NO_LOCATION usages
This commit is contained in:
+2
-1
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cli.jvm.config.addJavaSourceRoots
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.context.ProjectContext
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
@@ -113,7 +114,7 @@ public class MultiModuleJavaAnalysisCustomTest : UsefulTestCase() {
|
||||
private fun checkClassInPackage(moduleDescriptor: ModuleDescriptor, packageName: String, className: String) {
|
||||
val kotlinPackage = moduleDescriptor.getPackage(FqName(packageName))
|
||||
val kotlinClassName = Name.identifier(className)
|
||||
val kotlinClass = kotlinPackage.memberScope.getClassifier(kotlinClassName) as ClassDescriptor
|
||||
val kotlinClass = kotlinPackage.memberScope.getClassifier(kotlinClassName, LookupLocation.NO_LOCATION_FROM_TEST) as ClassDescriptor
|
||||
checkClass(kotlinClass)
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -155,7 +155,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
|
||||
Name functionName = Name.identifier(name);
|
||||
JetScope memberScope = packageView.getMemberScope();
|
||||
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, LookupLocation.NO_LOCATION);
|
||||
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
|
||||
return functions.iterator().next();
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
|
||||
Name functionName = Name.identifier(name);
|
||||
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
|
||||
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, LookupLocation.NO_LOCATION);
|
||||
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
|
||||
return functions.iterator().next();
|
||||
}
|
||||
@@ -173,13 +173,13 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
protected static PropertyDescriptor getPropertyDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name, boolean failOnMissing) {
|
||||
Name propertyName = Name.identifier(name);
|
||||
JetScope memberScope = packageView.getMemberScope();
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, LookupLocation.NO_LOCATION);
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
if (properties.isEmpty()) {
|
||||
for (DeclarationDescriptor descriptor : memberScope.getAllDescriptors()) {
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
Collection<VariableDescriptor> classProperties =
|
||||
((ClassDescriptor) descriptor).getMemberScope(Collections.<TypeProjection>emptyList())
|
||||
.getProperties(propertyName, LookupLocation.NO_LOCATION);
|
||||
.getProperties(propertyName, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
if (!classProperties.isEmpty()) {
|
||||
properties = classProperties;
|
||||
break;
|
||||
@@ -200,7 +200,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
private static PropertyDescriptor getPropertyDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
|
||||
Name propertyName = Name.identifier(name);
|
||||
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, LookupLocation.NO_LOCATION);
|
||||
Collection<VariableDescriptor> properties = memberScope.getProperties(propertyName, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assert properties.size() == 1 : "Failed to find property " + propertyName + " in class " + classDescriptor.getName();
|
||||
return (PropertyDescriptor) properties.iterator().next();
|
||||
}
|
||||
@@ -208,7 +208,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
@NotNull
|
||||
protected static ClassDescriptor getClassDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
|
||||
Name className = Name.identifier(name);
|
||||
ClassifierDescriptor aClass = packageView.getMemberScope().getClassifier(className, LookupLocation.NO_LOCATION);
|
||||
ClassifierDescriptor aClass = packageView.getMemberScope().getClassifier(className, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assertNotNull("Failed to find class: " + packageView.getName() + "." + className, aClass);
|
||||
assert aClass instanceof ClassDescriptor : "Not a class: " + aClass;
|
||||
return (ClassDescriptor) aClass;
|
||||
@@ -218,7 +218,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
|
||||
private static ClassDescriptor getInnerClassDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
|
||||
Name propertyName = Name.identifier(name);
|
||||
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
|
||||
ClassifierDescriptor innerClass = memberScope.getClassifier(propertyName, LookupLocation.NO_LOCATION);
|
||||
ClassifierDescriptor innerClass = memberScope.getClassifier(propertyName, LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assert innerClass instanceof ClassDescriptor : "Failed to find inner class " +
|
||||
propertyName +
|
||||
" in class " +
|
||||
|
||||
@@ -411,7 +411,7 @@ public class DescriptorValidator {
|
||||
public Void visitVariableDescriptor(
|
||||
VariableDescriptor descriptor, JetScope scope
|
||||
) {
|
||||
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), LookupLocation.NO_LOCATION));
|
||||
assertFound(scope, descriptor, scope.getProperties(descriptor.getName(), LookupLocation.NO_LOCATION_FROM_TEST));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,7 @@ public class DescriptorValidator {
|
||||
public Void visitFunctionDescriptor(
|
||||
FunctionDescriptor descriptor, JetScope scope
|
||||
) {
|
||||
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), LookupLocation.NO_LOCATION));
|
||||
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), LookupLocation.NO_LOCATION_FROM_TEST));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ public class DescriptorValidator {
|
||||
public Void visitTypeParameterDescriptor(
|
||||
TypeParameterDescriptor descriptor, JetScope scope
|
||||
) {
|
||||
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), LookupLocation.NO_LOCATION), true);
|
||||
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), LookupLocation.NO_LOCATION_FROM_TEST), true);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ public class DescriptorValidator {
|
||||
public Void visitClassDescriptor(
|
||||
ClassDescriptor descriptor, JetScope scope
|
||||
) {
|
||||
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), LookupLocation.NO_LOCATION), true);
|
||||
assertFound(scope, descriptor, scope.getClassifier(descriptor.getName(), LookupLocation.NO_LOCATION_FROM_TEST), true);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class BoundsSubstitutorTest extends KotlinTestWithEnvironment {
|
||||
JetFile jetFile = JetPsiFactory(getProject()).createFile("fun.kt", text);
|
||||
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
|
||||
Collection<FunctionDescriptor> functions =
|
||||
module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"), LookupLocation.NO_LOCATION);
|
||||
module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"), LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assert functions.size() == 1 : "Many functions defined";
|
||||
FunctionDescriptor function = ContainerUtil.getFirstItem(functions);
|
||||
|
||||
|
||||
@@ -624,7 +624,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
else {
|
||||
Name shortName = fqName.shortName();
|
||||
assert shortName.equals(defaultImport.getImportedName());
|
||||
writableScope.addClassifierDescriptor(module.getPackage(fqName.parent()).getMemberScope().getClassifier(shortName, LookupLocation.NO_LOCATION));
|
||||
writableScope.addClassifierDescriptor(module.getPackage(fqName.parent()).getMemberScope().getClassifier(shortName, LookupLocation.NO_LOCATION_FROM_TEST));
|
||||
}
|
||||
}
|
||||
scopeChain.add(module.getPackage(FqName.ROOT).getMemberScope());
|
||||
|
||||
@@ -86,7 +86,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
|
||||
JetFile jetFile = JetPsiFactory(getProject()).createFile(text);
|
||||
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
|
||||
JetScope topLevelDeclarations = module.getPackage(FqName.ROOT).getMemberScope();
|
||||
ClassifierDescriptor contextClass = topLevelDeclarations.getClassifier(Name.identifier("___Context"), LookupLocation.NO_LOCATION);
|
||||
ClassifierDescriptor contextClass = topLevelDeclarations.getClassifier(Name.identifier("___Context"), LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assert contextClass instanceof ClassDescriptor;
|
||||
WritableScopeImpl typeParameters = new WritableScopeImpl(JetScope.Empty.INSTANCE$, module, RedeclarationHandler.THROW_EXCEPTION,
|
||||
"Type parameter scope");
|
||||
@@ -125,7 +125,7 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
|
||||
String typeParameterName = pair.first;
|
||||
String replacementProjectionString = pair.second;
|
||||
|
||||
ClassifierDescriptor classifier = scope.getClassifier(Name.identifier(typeParameterName), LookupLocation.NO_LOCATION);
|
||||
ClassifierDescriptor classifier = scope.getClassifier(Name.identifier(typeParameterName), LookupLocation.NO_LOCATION_FROM_TEST);
|
||||
assertNotNull("No type parameter named " + typeParameterName, classifier);
|
||||
assertTrue(typeParameterName + " is not a type parameter: " + classifier, classifier instanceof TypeParameterDescriptor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user