Debug names for chained scopes in lazy resolve

This commit is contained in:
Nikolay Krasko
2012-12-27 17:52:47 +04:00
parent 6141d0305a
commit 73785e74bc
3 changed files with 26 additions and 5 deletions
@@ -135,7 +135,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
scope.changeLockLevel(WritableScope.LockLevel.READING);
PsiElement scopeAnchor = declarationProvider.getOwnerInfo().getScopeAnchor();
scopeForClassHeaderResolution = new ChainedScope(this, scope, getScopeProvider().getResolutionScopeForDeclaration(scopeAnchor));
scopeForClassHeaderResolution = new ChainedScope(
this,
"ScopeForClassHeaderResolution: " + getName(),
scope, getScopeProvider().getResolutionScopeForDeclaration(scopeAnchor));
}
return scopeForClassHeaderResolution;
}
@@ -147,7 +150,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
scope.addLabeledDeclaration(this);
scope.changeLockLevel(WritableScope.LockLevel.READING);
scopeForMemberDeclarationResolution = new ChainedScope(this, scope, getScopeForMemberLookup(), getScopeForClassHeaderResolution());
scopeForMemberDeclarationResolution = new ChainedScope(
this,
"ScopeForMemberDeclarationResolution: " + getName(),
scope, getScopeForMemberLookup(), getScopeForClassHeaderResolution());
}
return scopeForMemberDeclarationResolution;
}
@@ -167,7 +173,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
scope.changeLockLevel(WritableScope.LockLevel.READING);
scopeForPropertyInitializerResolution = new ChainedScope(this, scope, getScopeForMemberDeclarationResolution());
scopeForPropertyInitializerResolution = new ChainedScope(
this,
"ScopeForPropertyInitializerResolution: " + getName(),
scope, getScopeForMemberDeclarationResolution());
}
return scopeForPropertyInitializerResolution;
}
@@ -46,7 +46,7 @@ public class LazyPackageDescriptor extends AbstractNamespaceDescriptorImpl imple
this.lazyScope = new LazyPackageMemberScope(resolveSession, declarationProvider, this);
this.memberScope = new ChainedScope(this, lazyScope, scope);
this.memberScope = new ChainedScope(this, "Lazy package members scope: " + name, lazyScope, scope);
}
@NotNull
@@ -30,13 +30,20 @@ import java.util.Set;
public class ChainedScope implements JetScope {
private final DeclarationDescriptor containingDeclaration;
private final String debugName;
private final JetScope[] scopeChain;
private Collection<DeclarationDescriptor> allDescriptors;
private List<ReceiverParameterDescriptor> implicitReceiverHierarchy;
public ChainedScope(DeclarationDescriptor containingDeclaration, JetScope... scopes) {
this(containingDeclaration, "Untitled chained scope", scopes);
}
public ChainedScope(DeclarationDescriptor containingDeclaration, String debugName, JetScope... scopes) {
this.containingDeclaration = containingDeclaration;
scopeChain = scopes.clone();
this.debugName = debugName;
}
@Override
@@ -133,7 +140,7 @@ public class ChainedScope implements JetScope {
@NotNull
@Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(LabelName labelName) {
public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName) {
for (JetScope jetScope : scopeChain) {
Collection<DeclarationDescriptor> declarationsByLabel = jetScope.getDeclarationsByLabel(labelName);
if (!declarationsByLabel.isEmpty()) return declarationsByLabel; // TODO : merge?
@@ -169,4 +176,9 @@ public class ChainedScope implements JetScope {
public Collection<DeclarationDescriptor> getOwnDeclaredDescriptors() {
throw new UnsupportedOperationException();
}
@Override
public String toString() {
return debugName;
}
}