use of com.intellij.execution.filters.HyperlinkInfo in project buck by facebook.
the class BuckBuildManager method showNoTargetMessage.
/**
* Print "no selected target" error message to console window.
* Also provide a hyperlink which can directly jump to "Choose Target" GUI window.
*/
public void showNoTargetMessage(Project project) {
BuckModule buckModule = project.getComponent(BuckModule.class);
buckModule.getBuckEventsConsumer().consumeConsoleEvent("Please choose a build target!");
BuckToolWindowFactory.outputConsoleMessage(project, "Please ", ConsoleViewContentType.ERROR_OUTPUT);
BuckToolWindowFactory.outputConsoleHyperlink(project, "choose a build target!\n", new HyperlinkInfo() {
@Override
public void navigate(Project project) {
JComponent frame = WindowManager.getInstance().getIdeFrame(project).getComponent();
AnAction action = ActionManager.getInstance().getAction("buck.ChooseTarget");
action.actionPerformed(new AnActionEvent(null, DataManager.getInstance().getDataContext(frame), ActionPlaces.UNKNOWN, action.getTemplatePresentation(), ActionManager.getInstance(), 0));
}
});
}
use of com.intellij.execution.filters.HyperlinkInfo in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoConsoleFilterTest method doFileLineTest.
private void doFileLineTest(@NotNull String line, int startOffset, int endOffset, String targetPath, int targetLine, int targetColumn) {
Filter.Result result = myFilter.applyFilter(line, line.length());
assertNotNull(result);
HyperlinkInfo info = assertResultAndGetHyperlink(result, startOffset, endOffset);
assertInstanceOf(info, OpenFileHyperlinkInfo.class);
OpenFileDescriptor fileDescriptor = ((OpenFileHyperlinkInfo) info).getDescriptor();
assertNotNull(fileDescriptor);
assertEquals(targetPath, fileDescriptor.getFile().getPath());
assertEquals("line", targetLine, fileDescriptor.getLine() + 1);
assertEquals("column", targetColumn, fileDescriptor.getColumn() + 1);
}
use of com.intellij.execution.filters.HyperlinkInfo in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoConsoleFilter method applyFilter.
@Override
public Result applyFilter(@NotNull String line, int entireLength) {
Matcher goGetMatcher = GO_GET_MESSAGE_PATTERN.matcher(line);
if (goGetMatcher.find() && myModule != null) {
String packageName = goGetMatcher.group(2).trim();
HyperlinkInfo hyperlinkInfo = new GoGetHyperlinkInfo(packageName, myModule);
int lineStart = entireLength - line.length();
return new Result(lineStart + goGetMatcher.start(1), lineStart + goGetMatcher.end(2), hyperlinkInfo);
}
Matcher matcher = MESSAGE_PATTERN.matcher(line);
if (!matcher.find()) {
Matcher fileMatcher = GO_FILE_PATTERN.matcher(line);
List<ResultItem> resultItems = ContainerUtil.newArrayList();
while (fileMatcher.find()) {
VirtualFile file = findSingleFile(fileMatcher.group(1));
if (file != null) {
resultItems.add(createResult(line, entireLength, fileMatcher.start(1), fileMatcher.end(1), 0, 0, file));
}
}
return !resultItems.isEmpty() ? new Result(resultItems) : null;
}
int startOffset = matcher.start(1);
int endOffset = matcher.end(2);
String fileName = matcher.group(1);
int lineNumber = StringUtil.parseInt(matcher.group(2), 1) - 1;
if (lineNumber < 0) {
return null;
}
int columnNumber = -1;
if (matcher.groupCount() > 3) {
columnNumber = StringUtil.parseInt(matcher.group(4), 1) - 1;
endOffset = Math.max(endOffset, matcher.end(4));
}
Matcher appEnginePathMatcher = APP_ENGINE_PATH_PATTERN.matcher(fileName);
if (appEnginePathMatcher.find()) {
fileName = fileName.substring(appEnginePathMatcher.end());
}
VirtualFile virtualFile = null;
if (FileUtil.isAbsolutePlatformIndependent(fileName)) {
virtualFile = ApplicationManager.getApplication().isUnitTestMode() ? TempFileSystem.getInstance().refreshAndFindFileByPath(fileName) : VirtualFileManager.getInstance().refreshAndFindFileByUrl(VfsUtilCore.pathToUrl(fileName));
} else {
if (myWorkingDirectoryUrl != null) {
virtualFile = VirtualFileManager.getInstance().refreshAndFindFileByUrl(myWorkingDirectoryUrl + "/" + fileName);
}
if (virtualFile == null && myModule != null) {
virtualFile = findInGoPath(fileName);
if (virtualFile == null && fileName.startsWith("src/")) {
virtualFile = findInGoPath(StringUtil.trimStart(fileName, "src/"));
}
}
if (virtualFile == null) {
VirtualFile baseDir = myProject.getBaseDir();
if (baseDir != null) {
virtualFile = baseDir.findFileByRelativePath(fileName);
if (virtualFile == null && fileName.startsWith("src/")) {
// exclude src
virtualFile = baseDir.findFileByRelativePath(StringUtil.trimStart(fileName, "src/"));
}
}
}
}
if (virtualFile == null) {
virtualFile = findSingleFile(fileName);
}
if (virtualFile == null) {
return null;
}
return createResult(line, entireLength, startOffset, endOffset, lineNumber, columnNumber, virtualFile);
}
use of com.intellij.execution.filters.HyperlinkInfo in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoConsoleFilter method createResult.
@NotNull
private Result createResult(@NotNull String line, int entireLength, int startOffset, int endOffset, int lineNumber, int columnNumber, @NotNull VirtualFile virtualFile) {
HyperlinkInfo hyperlinkInfo = new OpenFileHyperlinkInfo(myProject, virtualFile, lineNumber, columnNumber);
int lineStart = entireLength - line.length();
return new Result(lineStart + startOffset, lineStart + endOffset, hyperlinkInfo);
}
use of com.intellij.execution.filters.HyperlinkInfo in project intellij-community by JetBrains.
the class AnnotateStackTraceAction method getHyperlinkVirtualFile.
@Nullable
@CalledWithReadLock
private static VirtualFile getHyperlinkVirtualFile(@NotNull List<RangeHighlighter> links) {
RangeHighlighter key = ContainerUtil.getLastItem(links);
if (key == null)
return null;
HyperlinkInfo info = EditorHyperlinkSupport.getHyperlinkInfo(key);
if (!(info instanceof FileHyperlinkInfo))
return null;
OpenFileDescriptor descriptor = ((FileHyperlinkInfo) info).getDescriptor();
return descriptor != null ? descriptor.getFile() : null;
}
Aggregations