Delete JetScope.getObjectDescriptor()

This commit is contained in:
Alexander Udalov
2013-11-15 22:09:47 +04:00
parent 550df37056
commit 4526d96186
20 changed files with 7 additions and 193 deletions
@@ -432,18 +432,6 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme
protected void addAllClassDescriptors(@NotNull Collection<DeclarationDescriptor> result) {
result.addAll(classDescriptor.nestedClasses.getAllDescriptors());
}
@Nullable
@Override
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
return null;
}
@NotNull
@Override
protected Collection<ClassDescriptor> computeAllObjectDescriptors() {
return Collections.emptySet();
}
}
private class NestedClassDescriptors {
@@ -59,7 +59,6 @@ public abstract class DeserializedMemberScope implements JetScope {
private final MemoizedFunctionToNotNull<Name, Collection<FunctionDescriptor>> functions;
private final MemoizedFunctionToNotNull<Name, Collection<VariableDescriptor>> properties;
private final NotNullLazyValue<Collection<DeclarationDescriptor>> allDescriptors;
private final NotNullLazyValue<Collection<ClassDescriptor>> objectDescriptors;
public DeserializedMemberScope(
@NotNull StorageManager storageManager,
@@ -89,12 +88,6 @@ public abstract class DeserializedMemberScope implements JetScope {
return computeAllDescriptors();
}
});
this.objectDescriptors = storageManager.createLazyValue(new Function0<Collection<ClassDescriptor>>() {
@Override
public Collection<ClassDescriptor> invoke() {
return computeAllObjectDescriptors();
}
});
}
@NotNull
@@ -172,13 +165,6 @@ public abstract class DeserializedMemberScope implements JetScope {
protected abstract void addAllClassDescriptors(@NotNull Collection<DeclarationDescriptor> result);
@Nullable
@Override
public abstract ClassDescriptor getObjectDescriptor(@NotNull Name name);
@NotNull
protected abstract Collection<ClassDescriptor> computeAllObjectDescriptors();
@Nullable
@Override
public NamespaceDescriptor getNamespace(@NotNull Name name) {
@@ -19,7 +19,10 @@ package org.jetbrains.jet.descriptors.serialization.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.descriptors.serialization.*;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
@@ -27,7 +30,6 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.storage.StorageManager;
import java.util.Collection;
import java.util.Collections;
public class DeserializedPackageMemberScope extends DeserializedMemberScope {
private final DescriptorFinder descriptorFinder;
@@ -62,25 +64,14 @@ public class DeserializedPackageMemberScope extends DeserializedMemberScope {
@Nullable
@Override
protected ClassifierDescriptor getClassDescriptor(@NotNull Name name) {
return findClassDescriptor(name);
}
@Nullable
@Override
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
return null;
}
@Nullable
private ClassDescriptor findClassDescriptor(Name name) {
protected ClassDescriptor getClassDescriptor(@NotNull Name name) {
return descriptorFinder.findClass(new ClassId(packageFqName, FqNameUnsafe.topLevel(name)));
}
@Override
protected void addAllClassDescriptors(@NotNull Collection<DeclarationDescriptor> result) {
for (Name className : descriptorFinder.getClassNames(packageFqName)) {
ClassDescriptor classDescriptor = findClassDescriptor(className);
ClassDescriptor classDescriptor = getClassDescriptor(className);
if (classDescriptor != null) {
result.add(classDescriptor);
@@ -88,12 +79,6 @@ public class DeserializedPackageMemberScope extends DeserializedMemberScope {
}
}
@NotNull
@Override
protected Collection<ClassDescriptor> computeAllObjectDescriptors() {
return Collections.emptySet();
}
@Override
protected void addNonDeclaredDescriptors(@NotNull Collection<DeclarationDescriptor> result) {
// Do nothing
@@ -268,13 +268,7 @@ public class QualifiedExpressionResolver {
descriptors.add(classifierDescriptor);
}
if (lookupMode == LookupMode.ONLY_CLASSES) {
ClassDescriptor objectDescriptor = outerScope.getObjectDescriptor(referencedName);
if (objectDescriptor != null) {
descriptors.add(objectDescriptor);
}
}
else {
if (lookupMode == LookupMode.EVERYTHING) {
descriptors.addAll(outerScope.getFunctions(referencedName));
descriptors.addAll(outerScope.getProperties(referencedName));
@@ -244,12 +244,6 @@ public class LazyImportScope implements JetScope {
return selectFirstFromImports(name, LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.CLASSIFIER_DESCRIPTOR_SCOPE_SELECTOR);
}
@Nullable
@Override
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
return selectFirstFromImports(name, LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.NAMED_OBJECT_SCOPE_SELECTOR);
}
@Nullable
@Override
public NamespaceDescriptor getNamespace(@NotNull Name name) {
@@ -180,11 +180,6 @@ public class ResolveSession implements KotlinCodeAnalyzer {
resolutionScope.getClassifier(name);
DeclarationDescriptor declaration = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
if (declaration == null) {
// Why not use the result here. See the comment
resolutionScope.getObjectDescriptor(name);
declaration = getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, classOrObject);
}
if (declaration == null) {
throw new IllegalArgumentException("Could not find a classifier for " + classOrObject + " " + classOrObject.getText());
}
@@ -108,11 +108,6 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
return first(classDescriptors.invoke(name));
}
@Override
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
return null;
}
private static <T> T first(@NotNull List<T> list) {
if (list.isEmpty()) return null;
return list.get(0);
@@ -75,15 +75,6 @@ public class JetScopeSelectorUtil {
}
};
public static final ScopeByNameSelector<ClassDescriptor> NAMED_OBJECT_SCOPE_SELECTOR =
new ScopeByNameSelector<ClassDescriptor>() {
@Nullable
@Override
public ClassDescriptor get(@NotNull JetScope scope, @NotNull Name name) {
return scope.getObjectDescriptor(name);
}
};
public static final ScopeByNameSelector<NamespaceDescriptor> NAMESPACE_SCOPE_SELECTOR =
new ScopeByNameSelector<NamespaceDescriptor>() {
@Nullable
@@ -126,19 +126,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
return super.getClassifier(name); // Imports
}
@Override
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
checkMayRead();
ClassDescriptor objectDescriptor = writableWorker.getObjectDescriptor(name);
if (objectDescriptor != null) return objectDescriptor;
objectDescriptor = getWorkerScope().getObjectDescriptor(name);
if (objectDescriptor != null) return objectDescriptor;
return super.getObjectDescriptor(name); // Imports
}
@Override
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
checkMayWrite();
@@ -261,13 +248,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
return allDescriptors;
}
@NotNull
public JetScope getOuterScope() {
checkMayRead();
return getWorkerScope();
}
@TestOnly
@Override
protected void printAdditionalScopeStructure(@NotNull Printer p) {