Implement getNamespace() for deserialized scope
DescriptorFinder now can find packages, pull the method up from AbstractDescriptorFinder class
This commit is contained in:
+1
-6
@@ -23,10 +23,8 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeseria
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.storage.MemoizedFunctionToNullable;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.storage.StorageManager;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.lazy.storage.StorageManager.ReferenceKind.STRONG;
|
||||
|
||||
@@ -52,7 +50,7 @@ public abstract class AbstractDescriptorFinder implements DescriptorFinder {
|
||||
ProtoBuf.Class classProto = classData.getClassProto();
|
||||
|
||||
DeclarationDescriptor owner =
|
||||
classId.isTopLevelClass() ? getPackage(classId.getPackageFqName()) : findClass(classId.getOuterClassId());
|
||||
classId.isTopLevelClass() ? findPackage(classId.getPackageFqName()) : findClass(classId.getOuterClassId());
|
||||
assert owner != null : "No owner found for " + classId;
|
||||
|
||||
AbstractDescriptorFinder _this = AbstractDescriptorFinder.this;
|
||||
@@ -74,8 +72,5 @@ public abstract class AbstractDescriptorFinder implements DescriptorFinder {
|
||||
@Nullable
|
||||
protected abstract ClassData getClassData(@NotNull ClassId classId);
|
||||
|
||||
@NotNull
|
||||
protected abstract NamespaceDescriptor getPackage(@NotNull FqName fqName);
|
||||
|
||||
protected abstract void classDescriptorCreated(@NotNull ClassDescriptor classDescriptor);
|
||||
}
|
||||
|
||||
+11
-1
@@ -19,17 +19,27 @@ package org.jetbrains.jet.descriptors.serialization;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
public interface DescriptorFinder {
|
||||
|
||||
DescriptorFinder EMPTY = new DescriptorFinder() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ClassDescriptor findClass(@NotNull ClassId classId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NamespaceDescriptor findPackage(@NotNull FqName name) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
ClassDescriptor findClass(@NotNull ClassId classId);
|
||||
|
||||
@Nullable
|
||||
NamespaceDescriptor findPackage(@NotNull FqName name);
|
||||
}
|
||||
|
||||
+6
@@ -116,4 +116,10 @@ public abstract class DeserializedPackageMemberScope extends DeserializedMemberS
|
||||
protected void addNonDeclaredDescriptors(@NotNull Collection<DeclarationDescriptor> result) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespace(@NotNull Name name) {
|
||||
return descriptorFinder.findPackage(packageFqName.child(name));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user