added extra diagnostics on assertions so its clear which bit of code caused the problem
This commit is contained in:
@@ -25,6 +25,11 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,6 +40,25 @@ public class DiagnosticUtils {
|
||||
private DiagnosticUtils() {
|
||||
}
|
||||
|
||||
public static String atLocation(BindingContext bindingContext, DeclarationDescriptor descriptor) {
|
||||
PsiElement element = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
if (element == null) {
|
||||
element = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor.getOriginal());
|
||||
}
|
||||
if (element == null && descriptor instanceof ASTNode) {
|
||||
element = DiagnosticUtils.getClosestPsiElement((ASTNode) descriptor);
|
||||
}
|
||||
if (element != null) {
|
||||
return DiagnosticUtils.atLocation(element);
|
||||
} else {
|
||||
return "unknown location";
|
||||
}
|
||||
}
|
||||
|
||||
public static String atLocation(JetExpression expression) {
|
||||
return atLocation(expression.getNode());
|
||||
}
|
||||
|
||||
public static String atLocation(@NotNull PsiElement element) {
|
||||
return atLocation(element.getNode());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user