Debug name for DESCRIPTOR_TO_DECLARATION fixed
This commit is contained in:
@@ -43,7 +43,7 @@ public class BindingContextUtils {
|
||||
if (declarationDescriptor instanceof CallableMemberDescriptor) {
|
||||
CallableMemberDescriptor callable = (CallableMemberDescriptor) declarationDescriptor;
|
||||
if (callable.getKind() != CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
throw new IllegalStateException("non-declaration descriptors should be filtered out earler: " + callable);
|
||||
throw new IllegalStateException("non-declaration descriptors should be filtered out earlier: " + callable);
|
||||
}
|
||||
}
|
||||
//if (declarationDescriptor instanceof VariableAsFunctionDescriptor) {
|
||||
@@ -56,8 +56,8 @@ public class BindingContextUtils {
|
||||
}
|
||||
};
|
||||
|
||||
static final ReadOnlySlice<DeclarationDescriptor, PsiElement> DESCRIPTOR_TO_DECLARATION =
|
||||
Slices.<DeclarationDescriptor, PsiElement>sliceBuilder().setKeyNormalizer(DECLARATION_DESCRIPTOR_NORMALIZER).build();
|
||||
/*package*/ static final ReadOnlySlice<DeclarationDescriptor, PsiElement> DESCRIPTOR_TO_DECLARATION =
|
||||
Slices.<DeclarationDescriptor, PsiElement>sliceBuilder().setKeyNormalizer(DECLARATION_DESCRIPTOR_NORMALIZER).setDebugName("DESCRIPTOR_TO_DECLARATION").build();
|
||||
|
||||
@Nullable
|
||||
public static PsiElement resolveToDeclarationPsiElement(@NotNull BindingContext bindingContext, @Nullable JetReferenceExpression referenceExpression) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
@@ -87,6 +89,13 @@ public class BasicWritableSlice<K, V> implements WritableSlice<K, V> {
|
||||
return isCollective;
|
||||
}
|
||||
|
||||
public void setDebugName(@NotNull String debugName) {
|
||||
if (this.debugName != null) {
|
||||
throw new IllegalStateException("Debug name already set for " + this);
|
||||
}
|
||||
this.debugName = debugName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return debugName;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.jet.util.slicedmap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,6 +84,8 @@ public class Slices {
|
||||
|
||||
private RewritePolicy rewritePolicy;
|
||||
|
||||
private String debugName;
|
||||
|
||||
private SliceBuilder(RewritePolicy rewritePolicy) {
|
||||
this.rewritePolicy = rewritePolicy;
|
||||
}
|
||||
@@ -101,12 +105,25 @@ public class Slices {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SliceBuilder<K, V> setDebugName(@NotNull String debugName) {
|
||||
this.debugName = debugName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SliceBuilder<K, V> setKeyNormalizer(KeyNormalizer<K> keyNormalizer) {
|
||||
this.keyNormalizer = keyNormalizer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RemovableSlice<K, V> build() {
|
||||
SliceWithOpposite<K, V> result = doBuild();
|
||||
if (debugName != null) {
|
||||
result.setDebugName(debugName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private SliceWithOpposite<K, V> doBuild() {
|
||||
if (defaultValue != null) {
|
||||
return new SliceWithOpposite<K, V>(rewritePolicy, opposite, keyNormalizer) {
|
||||
@Override
|
||||
@@ -133,7 +150,6 @@ public class Slices {
|
||||
}
|
||||
return new SliceWithOpposite<K, V>(rewritePolicy, opposite, keyNormalizer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class BasicRemovableSlice<K, V> extends BasicWritableSlice<K, V> implements RemovableSlice<K, V> {
|
||||
|
||||
Reference in New Issue
Block a user