name and containingDeclaration pulled up

This commit is contained in:
Andrey Breslav
2013-09-24 15:02:17 -07:00
parent 6bed3cdc59
commit 0d84565570
8 changed files with 109 additions and 130 deletions
@@ -64,8 +64,6 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
private final NestedClassDescriptors nestedClasses;
private final NestedClassDescriptors nestedObjects;
private final Name name;
private final DeclarationDescriptor containingDeclaration;
private final DeserializedClassTypeConstructor typeConstructor;
private final Modality modality;
private final Visibility visibility;
@@ -84,20 +82,20 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
@NotNull ProtoBuf.Class classProto,
@Nullable TypeDeserializer outerTypeDeserializer
) {
super(containingDeclaration, nameResolver.getName(classProto.getName()));
this.classId = classId;
this.classProto = classProto;
this.descriptorFinder = descriptorFinder;
this.name = nameResolver.getName(classProto.getName());
TypeDeserializer notNullTypeDeserializer = new TypeDeserializer(storageManager, outerTypeDeserializer, nameResolver,
descriptorFinder, "Deserializer for class " + name, NONE);
descriptorFinder, "Deserializer for class " + getName(), NONE);
DescriptorDeserializer outerDeserializer = DescriptorDeserializer.create(storageManager, notNullTypeDeserializer,
this, nameResolver, annotationResolver);
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(classProto.getTypeParameterCount());
this.deserializer = outerDeserializer.createChildDeserializer(this, classProto.getTypeParameterList(), typeParameters);
this.typeDeserializer = deserializer.getTypeDeserializer();
this.containingDeclaration = containingDeclaration;
this.typeConstructor = new DeserializedClassTypeConstructor(typeParameters);
this.memberScope = new DeserializedClassMemberScope(storageManager, this);
this.innerClassesScope = new InnerClassesScopeWrapper(memberScope);
@@ -153,12 +151,6 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
return result;
}
@NotNull
@Override
public DeclarationDescriptor getContainingDeclaration() {
return containingDeclaration;
}
@NotNull
@Override
public TypeConstructor getTypeConstructor() {
@@ -189,12 +181,6 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
return isInner;
}
@NotNull
@Override
public Name getName() {
return name;
}
private List<AnnotationDescriptor> computeAnnotations() {
if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) {
return Collections.emptyList();
@@ -69,8 +69,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
private final JetClassLikeInfo originalClassInfo;
private final ClassMemberDeclarationProvider declarationProvider;
private final Name name;
private final DeclarationDescriptor containingDeclaration;
private final LazyClassTypeConstructor typeConstructor;
private final Modality modality;
private final Visibility visibility;
@@ -94,8 +92,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
@NotNull Name name,
@NotNull JetClassLikeInfo classLikeInfo
) {
super(containingDeclaration, name);
this.resolveSession = resolveSession;
this.name = name;
if (classLikeInfo.getCorrespondingClassOrObject() != null) {
this.resolveSession.getTrace().record(BindingContext.CLASS, classLikeInfo.getCorrespondingClassOrObject(), this);
@@ -104,8 +102,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
this.originalClassInfo = classLikeInfo;
JetClassLikeInfo classLikeInfoForMembers =
classLikeInfo.getClassKind() != ClassKind.ENUM_CLASS ? classLikeInfo : noEnumEntries(classLikeInfo);
this.declarationProvider = resolveSession.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfoForMembers);
this.containingDeclaration = containingDeclaration;
this.declarationProvider =
resolveSession.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfoForMembers);
this.unsubstitutedMemberScope = new LazyClassMemberScope(resolveSession, declarationProvider, this);
this.unsubstitutedInnerClassesScope = new InnerClassesScopeWrapper(unsubstitutedMemberScope);
@@ -181,7 +179,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
@NotNull
private JetScope computeScopeForClassHeaderResolution() {
WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with type parameters for " + name);
WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with type parameters for " + getName());
for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) {
scope.addClassifierDescriptor(typeParameterDescriptor);
}
@@ -201,7 +199,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
@NotNull
private JetScope computeScopeForMemberDeclarationResolution() {
WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with 'this' for " + name);
WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with 'this' for " + getName());
thisScope.addLabeledDeclaration(this);
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
@@ -227,7 +225,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
ConstructorDescriptor primaryConstructor = getUnsubstitutedPrimaryConstructor();
if (primaryConstructor == null) return getScopeForMemberDeclarationResolution();
WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with constructor parameters in " + name);
WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with constructor parameters in " + getName());
for (ValueParameterDescriptor valueParameterDescriptor : primaryConstructor.getValueParameters()) {
scope.addVariableDescriptor(valueParameterDescriptor);
}
@@ -250,12 +248,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
return unsubstitutedMemberScope.getPrimaryConstructor();
}
@NotNull
@Override
public DeclarationDescriptor getContainingDeclaration() {
return containingDeclaration;
}
@NotNull
@Override
public TypeConstructor getTypeConstructor() {
@@ -352,12 +344,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
}
}
@NotNull
@Override
public Name getName() {
return name;
}
@Override
public String toString() {
return "lazy class " + getName().toString();