Delete JetScope.getObjectDescriptors()

This commit is contained in:
Alexander Udalov
2013-11-15 20:51:43 +04:00
parent 31c84951dc
commit 550df37056
20 changed files with 30 additions and 145 deletions
@@ -126,11 +126,6 @@ public class DescriptorSerializer {
}
}
for (ClassDescriptor descriptor : sort(classDescriptor.getUnsubstitutedInnerClassesScope().getObjectDescriptors())) {
int nameIndex = nameTable.getSimpleNameIndex(descriptor.getName());
builder.addNestedObjectName(nameIndex);
}
ClassDescriptor classObject = classDescriptor.getClassObjectDescriptor();
if (classObject != null) {
builder.setClassObject(classObjectProto(classObject));
@@ -179,12 +179,6 @@ public abstract class DeserializedMemberScope implements JetScope {
@NotNull
protected abstract Collection<ClassDescriptor> computeAllObjectDescriptors();
@NotNull
@Override
public Collection<ClassDescriptor> getObjectDescriptors() {
return objectDescriptors.invoke();
}
@Nullable
@Override
public NamespaceDescriptor getNamespace(@NotNull Name name) {
@@ -1,3 +1,19 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.descriptors.serialization.descriptors;
import org.jetbrains.annotations.NotNull;
@@ -10,8 +26,8 @@ import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.storage.StorageManager;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
public class DeserializedPackageMemberScope extends DeserializedMemberScope {
private final DescriptorFinder descriptorFinder;
@@ -47,45 +63,35 @@ public class DeserializedPackageMemberScope extends DeserializedMemberScope {
@Nullable
@Override
protected ClassifierDescriptor getClassDescriptor(@NotNull Name name) {
return findClassDescriptor(name, false);
return findClassDescriptor(name);
}
@Nullable
@Override
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
return findClassDescriptor(name, true);
return null;
}
@Nullable
private ClassDescriptor findClassDescriptor(Name name, boolean object) {
ClassDescriptor classDescriptor = descriptorFinder.findClass(new ClassId(packageFqName, FqNameUnsafe.topLevel(name)));
if (classDescriptor == null) {
return null;
}
return classDescriptor.getKind().isSingleton() == object ? classDescriptor : null;
private ClassDescriptor findClassDescriptor(Name name) {
return descriptorFinder.findClass(new ClassId(packageFqName, FqNameUnsafe.topLevel(name)));
}
@Override
protected void addAllClassDescriptors(@NotNull Collection<DeclarationDescriptor> result) {
findClassifiers(result, false);
for (Name className : descriptorFinder.getClassNames(packageFqName)) {
ClassDescriptor classDescriptor = findClassDescriptor(className);
if (classDescriptor != null) {
result.add(classDescriptor);
}
}
}
@NotNull
@Override
protected Collection<ClassDescriptor> computeAllObjectDescriptors() {
return findClassifiers(new ArrayList<ClassDescriptor>(), true);
}
private <T extends Collection<? super ClassDescriptor>> T findClassifiers(T result, boolean object) {
for (Name className : descriptorFinder.getClassNames(packageFqName)) {
ClassDescriptor classDescriptor = findClassDescriptor(className, object);
if (classDescriptor != null) {
assert classDescriptor.getKind().isSingleton() == object;
result.add(classDescriptor);
}
}
return result;
return Collections.emptySet();
}
@Override
@@ -250,12 +250,6 @@ public class LazyImportScope implements JetScope {
return selectFirstFromImports(name, LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.NAMED_OBJECT_SCOPE_SELECTOR);
}
@NotNull
@Override
public Collection<ClassDescriptor> getObjectDescriptors() {
return collectFromImports(LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.OBJECTS_SCOPE_SELECTOR);
}
@Nullable
@Override
public NamespaceDescriptor getNamespace(@NotNull Name name) {
@@ -183,12 +183,6 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
protected abstract void getNonDeclaredProperties(@NotNull Name name, @NotNull Set<VariableDescriptor> result);
@NotNull
@Override
public Collection<ClassDescriptor> getObjectDescriptors() {
return Collections.emptySet();
}
@Override
public VariableDescriptor getLocalVariable(@NotNull Name name) {
return null;
@@ -111,15 +111,6 @@ public class JetScopeSelectorUtil {
}
};
public static final ScopeDescriptorSelector<ClassDescriptor> OBJECTS_SCOPE_SELECTOR =
new ScopeDescriptorSelector<ClassDescriptor>() {
@NotNull
@Override
public Collection<ClassDescriptor> get(@NotNull JetScope scope) {
return scope.getObjectDescriptors();
}
};
public static final ScopeDescriptorSelector<DeclarationDescriptor> ALL_DESCRIPTORS_SCOPE_SELECTOR =
new ScopeDescriptorSelector<DeclarationDescriptor>() {
@NotNull
@@ -139,18 +139,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
return super.getObjectDescriptor(name); // Imports
}
@NotNull
@Override
public Set<ClassDescriptor> getObjectDescriptors() {
checkMayRead();
Set<ClassDescriptor> objectDescriptors = Sets.newHashSet();
objectDescriptors.addAll(super.getObjectDescriptors());
objectDescriptors.addAll(getWorkerScope().getObjectDescriptors());
objectDescriptors.addAll(writableWorker.getObjectDescriptors());
return objectDescriptors;
}
@Override
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
checkMayWrite();
@@ -130,9 +130,6 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
classes.add((ClassDescriptor) descriptor);
}
}
for (ClassDescriptor descriptor : scope.getObjectDescriptors()) {
classes.add(descriptor);
}
return classes;
}
@@ -42,8 +42,6 @@ public class ClassSerializationUtil {
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors(), serializer, sink);
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getObjectDescriptors(), serializer, sink);
ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor();
if (classObjectDescriptor != null) {
serializeClass(classObjectDescriptor, serializer, sink);
@@ -153,7 +153,6 @@ public class NamespaceComparator {
List<DeclarationDescriptor> subDescriptors = Lists.newArrayList();
subDescriptors.addAll(memberScope.getAllDescriptors());
subDescriptors.addAll(memberScope.getObjectDescriptors());
subDescriptors.addAll(extraSubDescriptors);
Collections.sort(subDescriptors, MemberComparator.INSTANCE);
@@ -100,7 +100,6 @@ public class RecursiveDescriptorProcessor {
&& visitChildren(descriptor.getConstructors(), data)
&& visitChildren(descriptor.getTypeConstructor().getParameters(), data)
&& visitChildren(descriptor.getClassObjectDescriptor(), data)
&& visitChildren(descriptor.getDefaultType().getMemberScope().getObjectDescriptors(), data)
&& visitChildren(descriptor.getDefaultType().getMemberScope().getAllDescriptors(), data);
}