Search in sources :

Example 6 with OpenFileHyperlinkInfo

use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-community by JetBrains.

the class XDebugSessionImpl method breakpointReached.

private boolean breakpointReached(@NotNull final XBreakpoint<?> breakpoint, @Nullable String evaluatedLogExpression, @NotNull XSuspendContext suspendContext, boolean doProcessing) {
    if (doProcessing) {
        if (breakpoint.isLogMessage()) {
            XSourcePosition position = breakpoint.getSourcePosition();
            OpenFileHyperlinkInfo hyperlinkInfo = position != null ? new OpenFileHyperlinkInfo(myProject, position.getFile(), position.getLine()) : null;
            printMessage(XDebuggerBundle.message("xbreakpoint.reached.text") + " ", XBreakpointUtil.getShortText(breakpoint), hyperlinkInfo);
        }
        if (evaluatedLogExpression != null) {
            printMessage(evaluatedLogExpression, null, null);
        }
        processDependencies(breakpoint);
        if (breakpoint.getSuspendPolicy() == SuspendPolicy.NONE) {
            return false;
        }
    }
    myActiveNonLineBreakpoint = (!(breakpoint instanceof XLineBreakpoint) || ((XLineBreakpoint) breakpoint).getType().canBeHitInOtherPlaces()) ? breakpoint : null;
    // set this session active on breakpoint, update execution position will be called inside positionReached
    myDebuggerManager.setCurrentSession(this);
    positionReachedInternal(suspendContext, true);
    if (doProcessing && breakpoint instanceof XLineBreakpoint<?> && ((XLineBreakpoint) breakpoint).isTemporary()) {
        handleTemporaryBreakpointHit(breakpoint);
    }
    return true;
}
Also used : OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo)

Example 7 with OpenFileHyperlinkInfo

use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-plugins by JetBrains.

the class DartConsoleFilter method applyFilter.

@Nullable
public Result applyFilter(final String line, final int entireLength) {
    if (line.startsWith(OBSERVATORY_LISTENING_ON + "http://")) {
        return getObservatoryUrlResult(line, entireLength - line.length());
    }
    final DartPositionInfo info = DartPositionInfo.parsePositionInfo(line);
    if (info == null)
        return null;
    final VirtualFile file;
    switch(info.type) {
        case FILE:
            String path = URLUtil.unescapePercentSequences(info.path);
            if (SystemInfo.isWindows) {
                path = StringUtil.trimLeading(path, '/');
            }
            file = LocalFileSystem.getInstance().findFileByPath(path);
            break;
        case DART:
            file = DartUrlResolver.findFileInDartSdkLibFolder(myProject, mySdk, DART_PREFIX + info.path);
            break;
        case PACKAGE:
            if (myDartUrlResolver != null) {
                file = myDartUrlResolver.findFileByDartUrl(PACKAGE_PREFIX + info.path);
            } else {
                if (myAllPubspecYamlFiles == null) {
                    myAllPubspecYamlFiles = FilenameIndex.getVirtualFilesByName(myProject, PUBSPEC_YAML, GlobalSearchScope.projectScope(myProject));
                }
                VirtualFile inPackage = null;
                for (VirtualFile yamlFile : myAllPubspecYamlFiles) {
                    inPackage = DartUrlResolver.getInstance(myProject, yamlFile).findFileByDartUrl(PACKAGE_PREFIX + info.path);
                    if (inPackage != null) {
                        break;
                    }
                }
                file = inPackage;
            }
            break;
        default:
            file = null;
    }
    if (file != null && !file.isDirectory()) {
        final int highlightStartOffset = entireLength - line.length() + info.highlightingStartIndex;
        final int highlightEndOffset = entireLength - line.length() + info.highlightingEndIndex;
        return new Result(highlightStartOffset, highlightEndOffset, new OpenFileHyperlinkInfo(myProject, file, info.line, info.column));
    }
    return null;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with OpenFileHyperlinkInfo

use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-community by JetBrains.

the class GradleConsoleFilter method applyFilter.

@Nullable
@Override
public Result applyFilter(final String line, final int entireLength) {
    String[] filePrefixes = new String[] { "Build file '", "build file '" };
    String[] linePrefixes = new String[] { "' line: ", "': " };
    String filePrefix = null;
    String linePrefix = null;
    for (int i = 0; i < filePrefixes.length; i++) {
        int filePrefixIndex = StringUtil.indexOf(line, filePrefixes[i]);
        if (filePrefixIndex != -1) {
            filePrefix = filePrefixes[i];
            linePrefix = linePrefixes[i];
            break;
        }
    }
    if (filePrefix == null || linePrefix == null) {
        return null;
    }
    int filePrefixIndex = StringUtil.indexOf(line, filePrefix);
    final String fileAndLineNumber = line.substring(filePrefix.length() + filePrefixIndex);
    int linePrefixIndex = StringUtil.indexOf(fileAndLineNumber, linePrefix);
    if (linePrefixIndex == -1) {
        return null;
    }
    final String fileName = fileAndLineNumber.substring(0, linePrefixIndex);
    myFilteredFileName = fileName;
    String lineNumberStr = fileAndLineNumber.substring(linePrefixIndex + linePrefix.length(), fileAndLineNumber.length()).trim();
    int lineNumberEndIndex = 0;
    for (int i = 0; i < lineNumberStr.length(); i++) {
        if (Character.isDigit(lineNumberStr.charAt(i))) {
            lineNumberEndIndex = i;
        } else {
            break;
        }
    }
    lineNumberStr = lineNumberStr.substring(0, lineNumberEndIndex + 1);
    int lineNumber;
    try {
        lineNumber = Integer.parseInt(lineNumberStr);
        myFilteredLineNumber = lineNumber;
    } catch (NumberFormatException e) {
        return null;
    }
    final VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fileName.replace(File.separatorChar, '/'));
    if (file == null) {
        return null;
    }
    int textStartOffset = entireLength - line.trim().length() + filePrefix.length() - 1;
    int highlightEndOffset = textStartOffset + fileName.length();
    OpenFileHyperlinkInfo info = new OpenFileHyperlinkInfo(myProject, file, Math.max(lineNumber - 1, 0));
    TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone();
    if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(file)) {
        Color color = UIUtil.getInactiveTextColor();
        attributes.setForegroundColor(color);
        attributes.setEffectColor(color);
    }
    return new Result(textStartOffset, highlightEndOffset, info, attributes);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with OpenFileHyperlinkInfo

use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-plugins by JetBrains.

the class CfmlStackTraceFilterProvider method applyFilter.

public Result applyFilter(String line, int entireLength) {
    Pattern p = WIN_MXUNIT_PATTERN_ERROR;
    Matcher m = p.matcher(line);
    int numberOfReferenceGroup = 0;
    String fileName = "";
    String lineNumberString = "";
    if (!m.find()) {
        p = UNIX_MXUNIT_PATTERN_ERROR;
        m = p.matcher(line);
        if (!m.find()) {
            return null;
        }
    }
    numberOfReferenceGroup = 1;
    fileName = m.group(2);
    lineNumberString = m.group(3);
    if (fileName == null) {
        return null;
    }
    final File file = new File(fileName);
    int lineNumber = StringUtil.isEmpty(lineNumberString) ? 0 : Integer.parseInt(lineNumberString) - 1;
    if (lineNumber == 0) {
        return null;
    }
    final Ref<VirtualFile> vFile = new Ref<>();
    if (!file.isFile()) {
        return null;
    }
    try {
        GuiUtils.runOrInvokeAndWait(() -> vFile.set(LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file)));
    } catch (InvocationTargetException e) {
    // skip
    } catch (InterruptedException e) {
    // skip
    }
    if (vFile.isNull()) {
        return null;
    }
    final int textStartOffset = entireLength - line.length();
    final int highlightStartOffset = textStartOffset + m.start(numberOfReferenceGroup);
    final int highlightEndOffset = textStartOffset + m.end(numberOfReferenceGroup);
    final OpenFileHyperlinkInfo info = new OpenFileHyperlinkInfo(myProject, vFile.get(), lineNumber);
    TextAttributes attributes = HYPERLINK_ATTRIBUTES.clone();
    if (!ProjectRootManager.getInstance(myProject).getFileIndex().isInContent(vFile.get())) {
        Color color = UIUtil.getInactiveTextColor();
        attributes.setForegroundColor(color);
        attributes.setEffectColor(color);
    }
    return new Result(highlightStartOffset, highlightEndOffset, info, attributes);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) InvocationTargetException(java.lang.reflect.InvocationTargetException) Ref(com.intellij.openapi.util.Ref) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 10 with OpenFileHyperlinkInfo

use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-elixir by KronicDeth.

the class FileReferenceFilter method applyFilter.

@Nullable
@Override
public Result applyFilter(@NotNull String line, int entireLength) {
    Matcher matcher = myPattern.matcher(line);
    if (!matcher.find()) {
        return null;
    }
    String filePath = matcher.group(myFileMatchGroup);
    int fileLine = matchGroupToNumber(matcher, myLineMatchGroup);
    int fileColumn = matchGroupToNumber(matcher, myColumnMatchGroup);
    int highlightStartOffset = entireLength - line.length() + matcher.start(0) + 1;
    int highlightEndOffset = highlightStartOffset + matcher.end(0) - matcher.start(0) - 1;
    VirtualFile absolutePath = resolveAbsolutePath(filePath);
    HyperlinkInfo hyperlinkInfo = absolutePath != null ? new OpenFileHyperlinkInfo(myProject, absolutePath, fileLine, fileColumn) : null;
    return new Result(highlightStartOffset, highlightEndOffset, hyperlinkInfo);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Matcher(java.util.regex.Matcher) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)15 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 Nullable (org.jetbrains.annotations.Nullable)7 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)4 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)3 Matcher (java.util.regex.Matcher)3 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)2 JsErrorMessage (com.google.jstestdriver.idea.common.JsErrorMessage)1 Filter (com.intellij.execution.filters.Filter)1 GotoFileCellRenderer (com.intellij.ide.util.gotoByName.GotoFileCellRenderer)1 AccessToken (com.intellij.openapi.application.AccessToken)1 Document (com.intellij.openapi.editor.Document)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)1 FileType (com.intellij.openapi.fileTypes.FileType)1 Project (com.intellij.openapi.project.Project)1 JBPopup (com.intellij.openapi.ui.popup.JBPopup)1 Ref (com.intellij.openapi.util.Ref)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1