Add method for getting all classifiers with given name from the scope
This commit is contained in:
@@ -55,6 +55,12 @@ 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,6 +51,12 @@ 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,6 +66,12 @@ 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,6 +53,10 @@ public interface JetScope {
|
||||
@Nullable
|
||||
ClassifierDescriptor getClassifier(@NotNull Name name);
|
||||
|
||||
@NotNull
|
||||
@ReadOnly
|
||||
Collection<ClassifierDescriptor> getClassifiers(@NotNull Name name);
|
||||
|
||||
@Nullable
|
||||
PackageViewDescriptor getPackage(@NotNull Name name);
|
||||
|
||||
|
||||
@@ -34,6 +34,12 @@ 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,6 +112,15 @@ 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,6 +98,12 @@ 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,6 +85,12 @@ 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) {
|
||||
@@ -161,6 +167,12 @@ 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) {
|
||||
@@ -254,6 +266,7 @@ 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) {
|
||||
|
||||
Reference in New Issue
Block a user