com.intellij.execution.filters.OpenFileHyperlinkInfo Java Examples
The following examples show how to use
com.intellij.execution.filters.OpenFileHyperlinkInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericFileMessageFilter.java From intellij with Apache License 2.0 | 6 votes |
@Nullable @Override public Result applyFilter(String line, int entireLength) { Matcher matcher = FILE_LINE_COLUMN.matcher(line); if (!matcher.find()) { return null; } String filePath = matcher.group(1); if (filePath == null) { return null; } VirtualFile file = FileResolver.resolveToVirtualFile(project, filePath); if (file == null) { return null; } int lineNumber = parseNumber(matcher.group(2)); int columnNumber = parseNumber(matcher.group(3)); OpenFileHyperlinkInfo hyperlink = new CustomOpenFileHyperlinkInfo(project, file, lineNumber - 1, columnNumber - 1); int startIx = matcher.start(1); int endIx = matcher.end(3); int offset = entireLength - line.length(); return new Result(startIx + offset, endIx + offset, hyperlink); }
Example #2
Source File: TestLogFilter.java From intellij with Apache License 2.0 | 6 votes |
@Nullable @Override public Result applyFilter(String line, int entireLength) { Matcher matcher = OLD_REGEX.matcher(line); if (!matcher.matches()) { matcher = NEW_REGEX.matcher(line); } if (!matcher.matches()) { return null; } String filePath = matcher.group(1); if (filePath == null) { return null; } VirtualFile file = FileResolver.resolveToVirtualFile(project, filePath); if (file == null) { return null; } int offset = entireLength - line.length(); return new Result( matcher.start(1) + offset, matcher.end(1) + offset, new OpenFileHyperlinkInfo(project, file, /* line= */ 0)); }
Example #3
Source File: BlazeCppPathConsoleFilter.java From intellij with Apache License 2.0 | 6 votes |
@Nullable @Override public Result applyFilter(String line, int entireLength) { Matcher matcher = PATTERN.matcher(line); if (!matcher.find()) { return null; } String filePath = matcher.group(1); if (filePath == null) { return null; } VirtualFile file = resolveFile(filePath); if (file == null) { return null; } int lineNumber = parseLineNumber(matcher.group(2)); OpenFileHyperlinkInfo hyperlink = new OpenFileHyperlinkInfo(project, file, lineNumber - 1); int offset = entireLength - line.length(); return new Result(matcher.start() + offset, matcher.end() + offset, hyperlink); }
Example #4
Source File: BsConsoleFilter.java From reasonml-idea-plugin with MIT License | 5 votes |
@Nullable @Override public Result applyFilter(@NotNull String line, int entireLength) { int startPoint = entireLength - line.length(); Matcher matcher = LINE_PATTERN.matcher(line); if (matcher.find()) { String filePath = matcher.group(1); VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath); if (virtualFile != null) { return new Result(startPoint + matcher.start(1), entireLength, new OpenFileHyperlinkInfo(m_project, virtualFile, parseInt(matcher.group(2)) - 1, parseInt(matcher.group(3)) - 1)); } } return null; }
Example #5
Source File: TestLogFilterTest.java From intellij with Apache License 2.0 | 5 votes |
private void assertLinksToMockFile(@Nullable Result result) { assertThat(result).isNotNull(); assertThat(result.getFirstHyperlinkInfo()).isInstanceOf(OpenFileHyperlinkInfo.class); OpenFileHyperlinkInfo link = (OpenFileHyperlinkInfo) result.getFirstHyperlinkInfo(); assertThat(link.getVirtualFile().getName()).isEqualTo(mockFile.getName()); }
Example #6
Source File: BlazePyTracebackFilter.java From intellij with Apache License 2.0 | 5 votes |
@Nullable @Override public Result applyFilter(String line, int entireLength) { Matcher matcher = TRACEBACK_FILE_LINE.matcher(line); if (!matcher.find()) { return null; } String filePath = matcher.group(1); if (filePath == null) { return null; } if (filePath.startsWith("//")) { filePath = filePath.substring(2); } VirtualFile file = FileResolver.resolveToVirtualFile(project, filePath); if (file == null) { return null; } int lineNumber = parseLineNumber(matcher.group(2)); OpenFileHyperlinkInfo hyperlink = new OpenFileHyperlinkInfo(project, file, lineNumber - 1); int startIx = matcher.start(2) - "line ".length(); int endIx = matcher.end(2); if (startIx < 0) { startIx = matcher.start(1); endIx = matcher.end(1); } int offset = entireLength - line.length(); return new Result(startIx + offset, endIx + offset, hyperlink); }
Example #7
Source File: PantsMakeBeforeRun.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private void showPantsMakeTaskMessage(String message, ConsoleViewContentType type, Project project) { ConsoleView executionConsole = PantsConsoleManager.getConsole(project); // Create a filter that monitors console outputs, and turns them into a hyperlink if applicable. Filter filter = (line, entireLength) -> { Optional<ParseResult> result = ParseResult.parseErrorLocation(line, ERROR_TAG); if (result.isPresent()) { OpenFileHyperlinkInfo linkInfo = new OpenFileHyperlinkInfo( project, result.get().getFile(), result.get().getLineNumber() - 1, // line number needs to be 0 indexed result.get().getColumnNumber() - 1 // column number needs to be 0 indexed ); int startHyperlink = entireLength - line.length() + line.indexOf(ERROR_TAG); return new Filter.Result( startHyperlink, entireLength, linkInfo, null // TextAttributes, going with default hence null ); } return null; }; ApplicationManager.getApplication().invokeLater(() -> { executionConsole.addMessageFilter(filter); executionConsole.print(message, type); }, ModalityState.NON_MODAL); }
Example #8
Source File: ErrorFilter.java From intellij-haxe with Apache License 2.0 | 5 votes |
protected HyperlinkInfo createOpenFileHyperlink(String filePath, int line) { ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule); List<VirtualFile> roots = rootManager.getSourceRoots(JavaSourceRootType.TEST_SOURCE); VirtualFile virtualFile = null; for (VirtualFile testSourceRoot : roots) { String fullPath = testSourceRoot.getPath() + "/" + filePath; virtualFile = LocalFileSystem.getInstance().findFileByPath(fullPath); if(virtualFile != null) { break; } } return virtualFile == null ? null : new OpenFileHyperlinkInfo(myModule.getProject(), virtualFile, line - 1); }
Example #9
Source File: XDebugSessionImpl.java From consulo with Apache License 2.0 | 5 votes |
private boolean breakpointReached(@Nonnull final XBreakpoint<?> breakpoint, @Nullable String evaluatedLogExpression, @Nonnull 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; }
Example #10
Source File: ExtendedRegexFilter.java From BashSupport with Apache License 2.0 | 4 votes |
@Nullable protected HyperlinkInfo createOpenFileHyperlink(String fileName, final int line, final int column) { fileName = fileName.replace(File.separatorChar, '/'); VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fileName); return file != null ? new OpenFileHyperlinkInfo(myProject, file, line, column) : null; }