Revert "Add method for getting all classifiers with given name from the scope"

This reverts commit 97759f5bb7.
This commit is contained in:
Nikolay Krasko
2014-01-15 19:13:05 +04:00
parent 0d141d959a
commit 72d3b46fc6
12 changed files with 6 additions and 83 deletions
@@ -160,13 +160,6 @@ public abstract class DeserializedMemberScope implements JetScope {
return getClassDescriptor(name);
}
@NotNull
@Override
public final Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
ClassifierDescriptor classifier = getClassifier(name);
return classifier != null ? Collections.singleton(classifier) : Collections.<ClassifierDescriptor>emptyList();
}
@Nullable
protected abstract ClassifierDescriptor getClassDescriptor(@NotNull Name name);
@@ -244,12 +244,6 @@ public class LazyImportScope implements JetScope {
return selectFirstFromImports(name, LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.CLASSIFIER_DESCRIPTOR_SCOPE_SELECTOR);
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return collectFromImports(name, LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.NAMED_CLASSIFIERS_SCOPE_SELECTOR);
}
@Nullable
@Override
public PackageViewDescriptor getPackage(@NotNull Name name) {
@@ -46,7 +46,7 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
protected final DP declarationProvider;
protected final D thisDescriptor;
private final MemoizedFunctionToNotNull<Name, List<ClassifierDescriptor>> classDescriptors;
private final MemoizedFunctionToNotNull<Name, List<ClassDescriptor>> classDescriptors;
private final MemoizedFunctionToNotNull<Name, Set<FunctionDescriptor>> functionDescriptors;
private final MemoizedFunctionToNotNull<Name, Set<VariableDescriptor>> propertyDescriptors;
@@ -63,9 +63,9 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
this.thisDescriptor = thisDescriptor;
StorageManager storageManager = resolveSession.getStorageManager();
this.classDescriptors = storageManager.createMemoizedFunction(new Function1<Name, List<ClassifierDescriptor>>() {
this.classDescriptors = storageManager.createMemoizedFunction(new Function1<Name, List<ClassDescriptor>>() {
@Override
public List<ClassifierDescriptor> invoke(Name name) {
public List<ClassDescriptor> invoke(Name name) {
return resolveClassDescriptor(name);
}
});
@@ -92,12 +92,12 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
}
@Nullable
private List<ClassifierDescriptor> resolveClassDescriptor(@NotNull final Name name) {
private List<ClassDescriptor> resolveClassDescriptor(@NotNull final Name name) {
Collection<JetClassOrObject> classOrObjectDeclarations = declarationProvider.getClassOrObjectDeclarations(name);
return ContainerUtil.mapNotNull(classOrObjectDeclarations, new Function<JetClassOrObject, ClassifierDescriptor>() {
return ContainerUtil.mapNotNull(classOrObjectDeclarations, new Function<JetClassOrObject, ClassDescriptor>() {
@Override
public ClassifierDescriptor fun(JetClassOrObject classOrObject) {
public ClassDescriptor fun(JetClassOrObject classOrObject) {
return new LazyClassDescriptor(resolveSession, thisDescriptor, name, JetClassInfoUtil.createClassLikeInfo(classOrObject));
}
});
@@ -108,12 +108,6 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
return first(classDescriptors.invoke(name));
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return classDescriptors.invoke(name);
}
private static <T> T first(@NotNull List<T> list) {
if (list.isEmpty()) return null;
return list.get(0);
@@ -272,8 +272,6 @@ public abstract class LazyJavaMemberScope(
override fun getLocalVariable(name: Name): VariableDescriptor? = null
override fun getDeclarationsByLabel(labelName: LabelName) = listOf<DeclarationDescriptor>()
override fun getClassifiers(name: Name) = emptyOrSingletonList(getClassifier(name))
override fun getOwnDeclaredDescriptors() = getAllDescriptors()
override fun getAllDescriptors() = allDescriptors()
@@ -55,12 +55,6 @@ public abstract class AbstractScopeAdapter implements JetScope {
return getWorkerScope().getClassifier(name);
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return getWorkerScope().getClassifiers(name);
}
@NotNull
@Override
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
@@ -51,12 +51,6 @@ public class ChainedScope implements JetScope {
return getFirstMatch(scopeChain, name, CLASSIFIER_DESCRIPTOR_SCOPE_SELECTOR);
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return getFromAllScopes(scopeChain, name, NAMED_CLASSIFIERS_SCOPE_SELECTOR);
}
@Override
public PackageViewDescriptor getPackage(@NotNull Name name) {
return getFirstMatch(scopeChain, name, PACKAGE_SCOPE_SELECTOR);
@@ -66,12 +66,6 @@ public class FilteringScope implements JetScope {
return filterDescriptor(workerScope.getClassifier(name));
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return Collections2.filter(workerScope.getClassifiers(name), predicate);
}
@NotNull
@Override
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
@@ -53,10 +53,6 @@ public interface JetScope {
@Nullable
ClassifierDescriptor getClassifier(@NotNull Name name);
@NotNull
@ReadOnly
Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name);
@Nullable
PackageViewDescriptor getPackage(@NotNull Name name);
@@ -34,12 +34,6 @@ public abstract class JetScopeImpl implements JetScope {
return null;
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return Collections.emptySet();
}
@NotNull
@Override
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
@@ -112,15 +112,6 @@ public class JetScopeSelectorUtil {
}
};
public static final ScopeByNameMultiSelector<ClassifierDescriptor> NAMED_CLASSIFIERS_SCOPE_SELECTOR =
new ScopeByNameMultiSelector<ClassifierDescriptor>() {
@NotNull
@Override
public Collection<ClassifierDescriptor> get(@NotNull JetScope scope, @NotNull Name name) {
return scope.getClassifiers(name);
}
};
public static final ScopeDescriptorSelector<DeclarationDescriptor> ALL_DESCRIPTORS_SCOPE_SELECTOR =
new ScopeDescriptorSelector<DeclarationDescriptor>() {
@NotNull
@@ -98,12 +98,6 @@ public class SubstitutingScope implements JetScope {
return substitute(workerScope.getClassifier(name));
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return substitute(workerScope.getClassifiers(name));
}
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
@@ -85,12 +85,6 @@ public class ErrorUtils {
return ERROR_CLASS;
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
return ERROR_CLASSIFIER_GROUP;
}
@NotNull
@Override
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
@@ -167,12 +161,6 @@ public class ErrorUtils {
throw new IllegalStateException();
}
@NotNull
@Override
public Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name) {
throw new IllegalStateException();
}
@Nullable
@Override
public PackageViewDescriptor getPackage(@NotNull Name name) {
@@ -266,7 +254,6 @@ public class ErrorUtils {
ERROR_PROPERTY_TYPE,
CallableMemberDescriptor.Kind.DECLARATION);
private static final Set<VariableDescriptor> ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY);
private static final Set<ClassifierDescriptor> ERROR_CLASSIFIER_GROUP = Collections.<ClassifierDescriptor>singleton(ERROR_CLASS);
@NotNull
private static SimpleFunctionDescriptor createErrorFunction(@NotNull ErrorScope ownerScope) {