Attempt to drop debug name for traces
This commit is contained in:
@@ -32,27 +32,29 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AnalyzingUtils {
|
public class AnalyzingUtils {
|
||||||
|
private static final boolean WRITE_DEBUG_TRACE_NAMES = false;
|
||||||
|
|
||||||
public abstract static class PsiErrorElementVisitor extends KtTreeVisitorVoid {
|
public abstract static class PsiErrorElementVisitor extends KtTreeVisitorVoid {
|
||||||
@Override
|
@Override
|
||||||
public abstract void visitErrorElement(PsiErrorElement element);
|
public abstract void visitErrorElement(@NotNull PsiErrorElement element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void checkForSyntacticErrors(@NotNull PsiElement root) {
|
public static void checkForSyntacticErrors(@NotNull PsiElement root) {
|
||||||
root.acceptChildren(new PsiErrorElementVisitor() {
|
root.acceptChildren(new PsiErrorElementVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void visitErrorElement(PsiErrorElement element) {
|
public void visitErrorElement(@NotNull PsiErrorElement element) {
|
||||||
throw new IllegalArgumentException(element.getErrorDescription() + "; looking at " + element.getNode().getElementType() + " '" + element.getText() + DiagnosticUtils.atLocation(element));
|
throw new IllegalArgumentException(element.getErrorDescription() + "; looking at " +
|
||||||
|
element.getNode().getElementType() + " '" +
|
||||||
|
element.getText() + DiagnosticUtils.atLocation(element));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<PsiErrorElement> getSyntaxErrorRanges(@NotNull PsiElement root) {
|
public static List<PsiErrorElement> getSyntaxErrorRanges(@NotNull PsiElement root) {
|
||||||
final ArrayList<PsiErrorElement> r = new ArrayList<PsiErrorElement>();
|
final List<PsiErrorElement> r = new ArrayList<PsiErrorElement>();
|
||||||
root.acceptChildren(new PsiErrorElementVisitor() {
|
root.acceptChildren(new PsiErrorElementVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void visitErrorElement(PsiErrorElement element) {
|
public void visitErrorElement(@NotNull PsiErrorElement element) {
|
||||||
r.add(element);
|
r.add(element);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -70,17 +72,22 @@ public class AnalyzingUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
public static String formDebugNameForBindingTrace(@NotNull String debugName, @Nullable Object resolutionSubjectForMessage) {
|
public static String formDebugNameForBindingTrace(@NotNull String debugName, @Nullable Object resolutionSubjectForMessage) {
|
||||||
StringBuilder debugInfo = new StringBuilder(debugName);
|
if (WRITE_DEBUG_TRACE_NAMES) {
|
||||||
if (resolutionSubjectForMessage instanceof KtElement) {
|
StringBuilder debugInfo = new StringBuilder(debugName);
|
||||||
KtElement element = (KtElement) resolutionSubjectForMessage;
|
if (resolutionSubjectForMessage instanceof KtElement) {
|
||||||
debugInfo.append(" ").append(DebugTextUtilKt.getDebugText(element));
|
KtElement element = (KtElement) resolutionSubjectForMessage;
|
||||||
debugInfo.append(" in ").append(element.getContainingFile().getName());
|
debugInfo.append(" ").append(DebugTextUtilKt.getDebugText(element));
|
||||||
|
//debugInfo.append(" in ").append(element.getContainingFile().getName());
|
||||||
|
debugInfo.append(" in ").append(element.getContainingKtFile().getName()).append(" ").append(element.getTextOffset());
|
||||||
|
}
|
||||||
|
else if (resolutionSubjectForMessage != null) {
|
||||||
|
debugInfo.append(" ").append(resolutionSubjectForMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
return debugInfo.toString();
|
||||||
}
|
}
|
||||||
else if (resolutionSubjectForMessage != null) {
|
|
||||||
debugInfo.append(" ").append(resolutionSubjectForMessage);
|
return "";
|
||||||
}
|
|
||||||
return debugInfo.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user