Delete JetScope.getObjectDescriptor()
This commit is contained in:
-12
@@ -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 {
|
||||
|
||||
-14
@@ -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) {
|
||||
|
||||
+6
-21
@@ -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
|
||||
|
||||
+1
-7
@@ -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());
|
||||
}
|
||||
|
||||
-5
@@ -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) {
|
||||
|
||||
-5
@@ -52,11 +52,6 @@ public abstract class JavaClassMembersScope extends JavaBaseScope {
|
||||
return memberResolver.resolveFunctionGroupForClass(members, descriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassifierDescriptor getClassifier(@NotNull Name name) {
|
||||
if (innerClassesMap == null) {
|
||||
|
||||
-9
@@ -58,15 +58,6 @@ public final class JavaPackageScope extends JavaBaseScope {
|
||||
return memberResolver.resolveClass(packageFQN.child(name), IGNORE_KOTLIN_SOURCES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
ClassDescriptor classDescriptor = memberResolver.resolveClass(packageFQN.child(name), IGNORE_KOTLIN_SOURCES);
|
||||
if (classDescriptor != null && classDescriptor.getKind().isSingleton()) {
|
||||
return classDescriptor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return memberResolver.resolveNamespace(packageFQN.child(name), INCLUDE_KOTLIN_SOURCES);
|
||||
|
||||
@@ -55,11 +55,6 @@ public abstract class AbstractScopeAdapter implements JetScope {
|
||||
return getWorkerScope().getClassifier(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return getWorkerScope().getObjectDescriptor(name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
|
||||
@@ -57,15 +57,6 @@ public class ChainedScope implements JetScope {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
for (JetScope scope : scopeChain) {
|
||||
ClassDescriptor objectDescriptor = scope.getObjectDescriptor(name);
|
||||
if (objectDescriptor != null) return objectDescriptor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
for (JetScope jetScope : scopeChain) {
|
||||
|
||||
@@ -65,11 +65,6 @@ public class FilteringScope implements JetScope {
|
||||
return filterDescriptor(workerScope.getClassifier(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return filterDescriptor(workerScope.getObjectDescriptor(name));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
|
||||
@@ -52,9 +52,6 @@ public interface JetScope {
|
||||
*/
|
||||
@Nullable
|
||||
ClassifierDescriptor getClassifier(@NotNull Name name);
|
||||
|
||||
@Nullable
|
||||
ClassDescriptor getObjectDescriptor(@NotNull Name name);
|
||||
|
||||
@Nullable
|
||||
NamespaceDescriptor getNamespace(@NotNull Name name);
|
||||
|
||||
@@ -33,11 +33,6 @@ public abstract class JetScopeImpl implements JetScope {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
|
||||
@@ -98,11 +98,6 @@ public class SubstitutingScope implements JetScope {
|
||||
return substitute(workerScope.getClassifier(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return substitute(workerScope.getObjectDescriptor(name));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||
|
||||
@@ -35,8 +35,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
private final Multimap<Name, DeclarationDescriptor> declaredDescriptorsAccessibleBySimpleName = HashMultimap.create();
|
||||
private boolean allDescriptorsDone = false;
|
||||
|
||||
private Set<ClassDescriptor> allObjectDescriptors = null;
|
||||
|
||||
@NotNull
|
||||
private final DeclarationDescriptor ownerDeclarationDescriptor;
|
||||
|
||||
@@ -54,9 +52,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
|
||||
@Nullable
|
||||
private Map<LabelName, List<DeclarationDescriptor>> labelsToDescriptors;
|
||||
|
||||
@Nullable
|
||||
private Map<Name, ClassDescriptor> objectDescriptors;
|
||||
|
||||
@Nullable
|
||||
private ReceiverParameterDescriptor implicitReceiver;
|
||||
@@ -146,14 +141,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
return labelsToDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Map<Name, ClassDescriptor> getObjectDescriptorsMap() {
|
||||
if (objectDescriptors == null) {
|
||||
objectDescriptors = Maps.newHashMap();
|
||||
}
|
||||
return objectDescriptors;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName) {
|
||||
@@ -384,17 +371,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
||||
return super.getClassifier(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
ClassDescriptor descriptor = getObjectDescriptorsMap().get(name);
|
||||
if (descriptor != null) return descriptor;
|
||||
|
||||
ClassDescriptor fromWorker = getWorkerScope().getObjectDescriptor(name);
|
||||
if (fromWorker != null) return fromWorker;
|
||||
|
||||
return super.getObjectDescriptor(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||
checkMayWrite();
|
||||
|
||||
-13
@@ -176,19 +176,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
for (JetScope imported : getImports()) {
|
||||
ClassDescriptor objectDescriptor = imported.getObjectDescriptor(name);
|
||||
if (objectDescriptor != null) {
|
||||
return objectDescriptor;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
checkMayRead();
|
||||
|
||||
@@ -88,11 +88,6 @@ public class ErrorUtils {
|
||||
return ERROR_CLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
return ERROR_CLASS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||
@@ -169,12 +164,6 @@ public class ErrorUtils {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
|
||||
Reference in New Issue
Block a user