JetScope.get* return Collection, not Set

This commit is contained in:
Stepan Koltsov
2012-06-16 06:44:12 +04:00
parent 45990f4beb
commit 7116beb95a
18 changed files with 42 additions and 37 deletions
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeProjection;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@@ -46,7 +47,7 @@ public class WhenChecker {
ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor();
assert classObjectDescriptor != null;
JetScope memberScope = classObjectDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Set<ClassDescriptor> objectDescriptors = memberScope.getObjectDescriptors();
Collection<ClassDescriptor> objectDescriptors = memberScope.getObjectDescriptors();
boolean isExhaust = true;
boolean notEmpty = false;
for (ClassDescriptor descriptor : objectDescriptors) {
@@ -142,7 +142,7 @@ public class FunctionDescriptorUtil {
ClassifierDescriptor classDescriptorForFunction = functionType.getConstructor().getDeclarationDescriptor();
assert classDescriptorForFunction instanceof ClassDescriptor;
Set<FunctionDescriptor> invokeFunctions = ((ClassDescriptor) classDescriptorForFunction).getMemberScope(functionType.getArguments()).getFunctions(Name.identifier("invoke"));
Collection<FunctionDescriptor> invokeFunctions = ((ClassDescriptor) classDescriptorForFunction).getMemberScope(functionType.getArguments()).getFunctions(Name.identifier("invoke"));
assert invokeFunctions.size() == 1;
return invokeFunctions.iterator().next();
}
@@ -49,7 +49,7 @@ public abstract class AbstractScopeAdapter implements JetScope {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
return getWorkerScope().getFunctions(name);
}
@@ -70,13 +70,13 @@ public abstract class AbstractScopeAdapter implements JetScope {
@NotNull
@Override
public Set<ClassDescriptor> getObjectDescriptors() {
public Collection<ClassDescriptor> getObjectDescriptors() {
return getWorkerScope().getObjectDescriptors();
}
@NotNull
@Override
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
return getWorkerScope().getProperties(name);
}
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -206,7 +207,7 @@ public class DescriptorUtils {
}
@Nullable
public static VariableDescriptor filterNonExtensionProperty(Set<VariableDescriptor> variables) {
public static VariableDescriptor filterNonExtensionProperty(Collection<VariableDescriptor> variables) {
for (VariableDescriptor variable : variables) {
if (!variable.getReceiverParameter().exists()) {
return variable;
@@ -164,7 +164,7 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
@NotNull
@Override
public Set<ClassDescriptor> getObjectDescriptors() {
public Collection<ClassDescriptor> getObjectDescriptors() {
throw new UnsupportedOperationException(); // TODO
}
@@ -51,19 +51,19 @@ public interface JetScope {
ClassDescriptor getObjectDescriptor(@NotNull Name name);
@NotNull
Set<ClassDescriptor> getObjectDescriptors();
Collection<ClassDescriptor> getObjectDescriptors();
@Nullable
NamespaceDescriptor getNamespace(@NotNull Name name);
@NotNull
Set<VariableDescriptor> getProperties(@NotNull Name name);
Collection<VariableDescriptor> getProperties(@NotNull Name name);
@Nullable
VariableDescriptor getLocalVariable(@NotNull Name name);
@NotNull
Set<FunctionDescriptor> getFunctions(@NotNull Name name);
Collection<FunctionDescriptor> getFunctions(@NotNull Name name);
@NotNull
DeclarationDescriptor getContainingDeclaration();
@@ -49,7 +49,7 @@ public abstract class JetScopeImpl implements JetScope {
@NotNull
@Override
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
return Collections.emptySet();
}
@@ -71,7 +71,7 @@ public abstract class JetScopeImpl implements JetScope {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
return Collections.emptySet();
}
@@ -66,7 +66,7 @@ public class SubstitutingScope implements JetScope {
}
@NotNull
private <D extends DeclarationDescriptor> Set<D> substitute(@NotNull Set<D> descriptors) {
private <D extends DeclarationDescriptor> Collection<D> substitute(@NotNull Collection<D> descriptors) {
if (substitutor.isEmpty()) return descriptors;
if (descriptors.isEmpty()) return descriptors;
@@ -83,7 +83,7 @@ public class SubstitutingScope implements JetScope {
@NotNull
@Override
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
return substitute(workerScope.getProperties(name));
}
@@ -104,13 +104,13 @@ public class SubstitutingScope implements JetScope {
@NotNull
@Override
public Set<ClassDescriptor> getObjectDescriptors() {
public Collection<ClassDescriptor> getObjectDescriptors() {
return substitute(workerScope.getObjectDescriptors());
}
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
return substitute(workerScope.getFunctions(name));
}
@@ -290,7 +290,7 @@ public class WritableScopeImpl extends WritableScopeWithImports {
@Override
@NotNull
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
checkMayRead();
Set<FunctionDescriptor> result = Sets.newLinkedHashSet(getFunctionGroups().get(name));
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -145,7 +146,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
checkMayRead();
if (getImports().isEmpty()) {
@@ -76,7 +76,7 @@ public class WriteThroughScope extends WritableScopeWithImports {
@Override
@NotNull
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
checkMayRead();
Set<FunctionDescriptor> result = Sets.newLinkedHashSet();