Search in sources :

Example 1 with TraceBackParser

use of com.jetbrains.python.traceBackParsers.TraceBackParser in project intellij-community by JetBrains.

the class PythonTracebackFilter method applyFilter.

@Override
@Nullable
public final Result applyFilter(@NotNull final String line, final int entireLength) {
    for (final TraceBackParser parser : TraceBackParser.PARSERS) {
        final LinkInTrace linkInTrace = parser.findLinkInTrace(line);
        if (linkInTrace == null) {
            continue;
        }
        final int lineNumber = linkInTrace.getLineNumber();
        final VirtualFile vFile = findFileByName(linkInTrace.getFileName());
        if (vFile != null) {
            final OpenFileHyperlinkInfo hyperlink = new OpenFileHyperlinkInfo(myProject, vFile, lineNumber - 1);
            final int textStartOffset = entireLength - line.length();
            final int startPos = linkInTrace.getStartPos();
            final int endPos = linkInTrace.getEndPos();
            return new Result(startPos + textStartOffset, endPos + textStartOffset, hyperlink);
        }
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) TraceBackParser(com.jetbrains.python.traceBackParsers.TraceBackParser) LinkInTrace(com.jetbrains.python.traceBackParsers.LinkInTrace) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LinkInTrace (com.jetbrains.python.traceBackParsers.LinkInTrace)1 TraceBackParser (com.jetbrains.python.traceBackParsers.TraceBackParser)1 Nullable (org.jetbrains.annotations.Nullable)1