Search in sources :

Example 1 with LineTokenizer

use of com.intellij.openapi.diff.LineTokenizer in project intellij-community by JetBrains.

the class JavaAwareTestConsoleProperties method getErrorNavigatable.

@Nullable
@Override
public Navigatable getErrorNavigatable(@NotNull Location<?> location, @NotNull String stacktrace) {
    //navigate to the first stack trace
    final String[] stackTrace = new LineTokenizer(stacktrace).execute();
    final PsiLocation<?> psiLocation = location.toPsiLocation();
    final PsiClass containingClass = psiLocation.getParentElement(PsiClass.class);
    if (containingClass == null)
        return null;
    final String qualifiedName = containingClass.getQualifiedName();
    if (qualifiedName == null)
        return null;
    String containingMethod = null;
    for (Iterator<Location<PsiMethod>> iterator = psiLocation.getAncestors(PsiMethod.class, false); iterator.hasNext(); ) {
        final PsiMethod psiMethod = iterator.next().getPsiElement();
        if (containingClass.equals(psiMethod.getContainingClass()))
            containingMethod = psiMethod.getName();
    }
    if (containingMethod == null)
        return null;
    StackTraceLine lastLine = null;
    for (String aStackTrace : stackTrace) {
        final StackTraceLine line = new StackTraceLine(containingClass.getProject(), aStackTrace);
        if (containingMethod.equals(line.getMethodName()) && qualifiedName.equals(line.getClassName())) {
            lastLine = line;
            break;
        }
    }
    return lastLine != null ? lastLine.getOpenFileDescriptor(containingClass.getContainingFile().getVirtualFile()) : null;
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) StackTraceLine(com.intellij.execution.stacktrace.StackTraceLine) LineTokenizer(com.intellij.openapi.diff.LineTokenizer) PsiClass(com.intellij.psi.PsiClass) PsiLocation(com.intellij.execution.PsiLocation) Location(com.intellij.execution.Location) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with LineTokenizer

use of com.intellij.openapi.diff.LineTokenizer in project intellij-community by JetBrains.

the class AbstractVcsTestCase method verify.

private static void verify(final ProcessOutput runResult, final boolean sorted, final String... stdoutLines) {
    verify(runResult);
    final String[] lines = new LineTokenizer(runResult.getStdout()).execute();
    if (sorted) {
        Arrays.sort(lines);
    }
    Assert.assertEquals(runResult.getStdout(), stdoutLines.length, lines.length);
    for (int i = 0; i < stdoutLines.length; i++) {
        Assert.assertEquals(stdoutLines[i], compressWhitespace(lines[i]));
    }
}
Also used : LineTokenizer(com.intellij.openapi.diff.LineTokenizer)

Aggregations

LineTokenizer (com.intellij.openapi.diff.LineTokenizer)2 Location (com.intellij.execution.Location)1 PsiLocation (com.intellij.execution.PsiLocation)1 StackTraceLine (com.intellij.execution.stacktrace.StackTraceLine)1 PsiClass (com.intellij.psi.PsiClass)1 PsiMethod (com.intellij.psi.PsiMethod)1 Nullable (org.jetbrains.annotations.Nullable)1