Delete JetScope.getObjectDescriptors()
This commit is contained in:
-5
@@ -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();
|
ClassDescriptor classObject = classDescriptor.getClassObjectDescriptor();
|
||||||
if (classObject != null) {
|
if (classObject != null) {
|
||||||
builder.setClassObject(classObjectProto(classObject));
|
builder.setClassObject(classObjectProto(classObject));
|
||||||
|
|||||||
-6
@@ -179,12 +179,6 @@ public abstract class DeserializedMemberScope implements JetScope {
|
|||||||
@NotNull
|
@NotNull
|
||||||
protected abstract Collection<ClassDescriptor> computeAllObjectDescriptors();
|
protected abstract Collection<ClassDescriptor> computeAllObjectDescriptors();
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return objectDescriptors.invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||||
|
|||||||
+29
-23
@@ -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;
|
package org.jetbrains.jet.descriptors.serialization.descriptors;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
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.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.storage.StorageManager;
|
import org.jetbrains.jet.storage.StorageManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
public class DeserializedPackageMemberScope extends DeserializedMemberScope {
|
public class DeserializedPackageMemberScope extends DeserializedMemberScope {
|
||||||
private final DescriptorFinder descriptorFinder;
|
private final DescriptorFinder descriptorFinder;
|
||||||
@@ -47,45 +63,35 @@ public class DeserializedPackageMemberScope extends DeserializedMemberScope {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
protected ClassifierDescriptor getClassDescriptor(@NotNull Name name) {
|
protected ClassifierDescriptor getClassDescriptor(@NotNull Name name) {
|
||||||
return findClassDescriptor(name, false);
|
return findClassDescriptor(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
public ClassDescriptor getObjectDescriptor(@NotNull Name name) {
|
||||||
return findClassDescriptor(name, true);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ClassDescriptor findClassDescriptor(Name name, boolean object) {
|
private ClassDescriptor findClassDescriptor(Name name) {
|
||||||
ClassDescriptor classDescriptor = descriptorFinder.findClass(new ClassId(packageFqName, FqNameUnsafe.topLevel(name)));
|
return descriptorFinder.findClass(new ClassId(packageFqName, FqNameUnsafe.topLevel(name)));
|
||||||
if (classDescriptor == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return classDescriptor.getKind().isSingleton() == object ? classDescriptor : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addAllClassDescriptors(@NotNull Collection<DeclarationDescriptor> result) {
|
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
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected Collection<ClassDescriptor> computeAllObjectDescriptors() {
|
protected Collection<ClassDescriptor> computeAllObjectDescriptors() {
|
||||||
return findClassifiers(new ArrayList<ClassDescriptor>(), true);
|
return Collections.emptySet();
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -250,12 +250,6 @@ public class LazyImportScope implements JetScope {
|
|||||||
return selectFirstFromImports(name, LookupMode.ONLY_CLASSES, JetScopeSelectorUtil.NAMED_OBJECT_SCOPE_SELECTOR);
|
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
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||||
|
|||||||
-6
@@ -183,12 +183,6 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
|||||||
|
|
||||||
protected abstract void getNonDeclaredProperties(@NotNull Name name, @NotNull Set<VariableDescriptor> result);
|
protected abstract void getNonDeclaredProperties(@NotNull Name name, @NotNull Set<VariableDescriptor> result);
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
public VariableDescriptor getLocalVariable(@NotNull Name name) {
|
||||||
return null;
|
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 =
|
public static final ScopeDescriptorSelector<DeclarationDescriptor> ALL_DESCRIPTORS_SCOPE_SELECTOR =
|
||||||
new ScopeDescriptorSelector<DeclarationDescriptor>() {
|
new ScopeDescriptorSelector<DeclarationDescriptor>() {
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -139,18 +139,6 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
|||||||
return super.getObjectDescriptor(name); // Imports
|
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
|
@Override
|
||||||
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) {
|
||||||
checkMayWrite();
|
checkMayWrite();
|
||||||
|
|||||||
-3
@@ -130,9 +130,6 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
|
|||||||
classes.add((ClassDescriptor) descriptor);
|
classes.add((ClassDescriptor) descriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ClassDescriptor descriptor : scope.getObjectDescriptors()) {
|
|
||||||
classes.add(descriptor);
|
|
||||||
}
|
|
||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ public class ClassSerializationUtil {
|
|||||||
|
|
||||||
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors(), serializer, sink);
|
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getAllDescriptors(), serializer, sink);
|
||||||
|
|
||||||
serializeClasses(classDescriptor.getUnsubstitutedInnerClassesScope().getObjectDescriptors(), serializer, sink);
|
|
||||||
|
|
||||||
ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor();
|
ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor();
|
||||||
if (classObjectDescriptor != null) {
|
if (classObjectDescriptor != null) {
|
||||||
serializeClass(classObjectDescriptor, serializer, sink);
|
serializeClass(classObjectDescriptor, serializer, sink);
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ public class NamespaceComparator {
|
|||||||
List<DeclarationDescriptor> subDescriptors = Lists.newArrayList();
|
List<DeclarationDescriptor> subDescriptors = Lists.newArrayList();
|
||||||
|
|
||||||
subDescriptors.addAll(memberScope.getAllDescriptors());
|
subDescriptors.addAll(memberScope.getAllDescriptors());
|
||||||
subDescriptors.addAll(memberScope.getObjectDescriptors());
|
|
||||||
subDescriptors.addAll(extraSubDescriptors);
|
subDescriptors.addAll(extraSubDescriptors);
|
||||||
|
|
||||||
Collections.sort(subDescriptors, MemberComparator.INSTANCE);
|
Collections.sort(subDescriptors, MemberComparator.INSTANCE);
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ public class RecursiveDescriptorProcessor {
|
|||||||
&& visitChildren(descriptor.getConstructors(), data)
|
&& visitChildren(descriptor.getConstructors(), data)
|
||||||
&& visitChildren(descriptor.getTypeConstructor().getParameters(), data)
|
&& visitChildren(descriptor.getTypeConstructor().getParameters(), data)
|
||||||
&& visitChildren(descriptor.getClassObjectDescriptor(), data)
|
&& visitChildren(descriptor.getClassObjectDescriptor(), data)
|
||||||
&& visitChildren(descriptor.getDefaultType().getMemberScope().getObjectDescriptors(), data)
|
|
||||||
&& visitChildren(descriptor.getDefaultType().getMemberScope().getAllDescriptors(), data);
|
&& visitChildren(descriptor.getDefaultType().getMemberScope().getAllDescriptors(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-6
@@ -127,12 +127,6 @@ public abstract class JavaBaseScope extends JetScopeImpl {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
protected abstract Collection<ClassDescriptor> computeInnerClasses();
|
protected abstract Collection<ClassDescriptor> computeInnerClasses();
|
||||||
|
|
||||||
|
|||||||
@@ -60,12 +60,6 @@ public abstract class AbstractScopeAdapter implements JetScope {
|
|||||||
return getWorkerScope().getObjectDescriptor(name);
|
return getWorkerScope().getObjectDescriptor(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return getWorkerScope().getObjectDescriptors();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||||
|
|||||||
@@ -66,16 +66,6 @@ public class ChainedScope implements JetScope {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
Set<ClassDescriptor> objectDescriptors = Sets.newHashSet();
|
|
||||||
for (JetScope scope : scopeChain) {
|
|
||||||
objectDescriptors.addAll(scope.getObjectDescriptors());
|
|
||||||
}
|
|
||||||
return objectDescriptors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||||
for (JetScope jetScope : scopeChain) {
|
for (JetScope jetScope : scopeChain) {
|
||||||
|
|||||||
@@ -70,12 +70,6 @@ public class FilteringScope implements JetScope {
|
|||||||
return filterDescriptor(workerScope.getObjectDescriptor(name));
|
return filterDescriptor(workerScope.getObjectDescriptor(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return Collections2.filter(workerScope.getObjectDescriptors(), predicate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||||
|
|||||||
@@ -56,10 +56,6 @@ public interface JetScope {
|
|||||||
@Nullable
|
@Nullable
|
||||||
ClassDescriptor getObjectDescriptor(@NotNull Name name);
|
ClassDescriptor getObjectDescriptor(@NotNull Name name);
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@ReadOnly
|
|
||||||
Collection<ClassDescriptor> getObjectDescriptors();
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
NamespaceDescriptor getNamespace(@NotNull Name name);
|
NamespaceDescriptor getNamespace(@NotNull Name name);
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import org.jetbrains.jet.utils.Printer;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public abstract class JetScopeImpl implements JetScope {
|
public abstract class JetScopeImpl implements JetScope {
|
||||||
@Override
|
@Override
|
||||||
@@ -39,12 +38,6 @@ public abstract class JetScopeImpl implements JetScope {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
public Collection<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||||
@@ -95,4 +88,4 @@ public abstract class JetScopeImpl implements JetScope {
|
|||||||
@TestOnly
|
@TestOnly
|
||||||
@Override
|
@Override
|
||||||
public abstract void printScopeStructure(@NotNull Printer p);
|
public abstract void printScopeStructure(@NotNull Printer p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,12 +103,6 @@ public class SubstitutingScope implements JetScope {
|
|||||||
return substitute(workerScope.getObjectDescriptor(name));
|
return substitute(workerScope.getObjectDescriptor(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return substitute(workerScope.getObjectDescriptors());
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
|
||||||
|
|||||||
@@ -395,19 +395,6 @@ public class WritableScopeImpl extends WritableScopeWithImports {
|
|||||||
return super.getObjectDescriptor(name);
|
return super.getObjectDescriptor(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
if (allObjectDescriptors == null) {
|
|
||||||
allObjectDescriptors = Sets.newHashSet(getObjectDescriptorsMap().values());
|
|
||||||
allObjectDescriptors.addAll(getWorkerScope().getObjectDescriptors());
|
|
||||||
for (JetScope imported : getImports()) {
|
|
||||||
allObjectDescriptors.addAll(imported.getObjectDescriptors());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return allObjectDescriptors;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) {
|
||||||
checkMayWrite();
|
checkMayWrite();
|
||||||
|
|||||||
@@ -93,12 +93,6 @@ public class ErrorUtils {
|
|||||||
return ERROR_CLASS;
|
return ERROR_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
public Set<VariableDescriptor> getProperties(@NotNull Name name) {
|
||||||
@@ -181,12 +175,6 @@ public class ErrorUtils {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Collection<ClassDescriptor> getObjectDescriptors() {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user