use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-community by JetBrains.
the class StackFrameList method navigateToFrame.
private void navigateToFrame(@NotNull XStackFrame frame, boolean focusOnEditor) {
XSourcePosition position = frame.getSourcePosition();
if (position == null)
return;
VirtualFile file = position.getFile();
int line = position.getLine();
Project project = myDebugProcess.getProject();
OpenFileHyperlinkInfo info = new OpenFileHyperlinkInfo(project, file, line);
OpenFileDescriptor descriptor = info.getDescriptor();
if (descriptor != null) {
FileEditorManagerImpl manager = (FileEditorManagerImpl) FileEditorManager.getInstance(project);
VirtualFile lastFile = myEditorState.myLastOpenedFile;
if (myEditorState.myIsNeedToCloseLastOpenedFile && lastFile != null && manager.isFileOpen(lastFile) && !lastFile.equals(descriptor.getFile())) {
manager.closeFile(myEditorState.myLastOpenedFile, false, true);
}
descriptor.setScrollType(ScrollType.CENTER);
descriptor.setUseCurrentWindow(true);
if (lastFile == null || !lastFile.equals(descriptor.getFile())) {
myEditorState.myIsNeedToCloseLastOpenedFile = !manager.isFileOpen(descriptor.getFile());
}
descriptor.navigateInEditor(project, focusOnEditor);
FileEditor[] editors = manager.getEditors(descriptor.getFile());
if (editors.length != 0) {
myEditorState.myLastOpenedFile = descriptor.getFile();
}
}
}
use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project flutter-intellij by flutter.
the class FlutterConsoleFilter method applyFilter.
@Nullable
public Result applyFilter(final String line, final int entireLength) {
if (line.startsWith("Run \"flutter doctor\" for information about installing additional components.")) {
return getFlutterDoctorResult(line, entireLength - line.length());
}
// Check for "restart" action in debugging output.
if (line.startsWith("you may need to restart the app")) {
return getRestartAppResult(line, entireLength - line.length());
}
int lineNumber = 0;
String pathPart = line.trim();
// * "open ios/Runner.xcworkspace"
if (line.startsWith("Launching ") || (line.startsWith("open "))) {
final String[] parts = line.split(" ");
if (parts.length > 1) {
pathPart = parts[1];
}
}
// Check for embedded paths, e.g.,
// * " • MyApp.xzzzz (lib/main.dart:6)"
// * " • _MyHomePageState._incrementCounter (lib/main.dart:49)"
final String[] parts = pathPart.split(" ");
for (String part : parts) {
// "(lib/main.dart:49)"
if (part.startsWith("(") && pathPart.endsWith(")")) {
part = part.substring(1, part.length() - 1);
final String[] split = part.split(":");
if (split.length == 2) {
try {
// Reconcile line number indexing.
lineNumber = Math.max(0, Integer.parseInt(split[1]) - 1);
} catch (NumberFormatException e) {
// Ignored.
}
}
pathPart = part;
}
}
final VirtualFile file = fileAtPath(pathPart);
if (file != null) {
// "open ios/Runner.xcworkspace"
final boolean openAsExternalFile = FlutterUtils.isXcodeFileName(pathPart);
final int lineStart = entireLength - line.length() + line.indexOf(pathPart);
final HyperlinkInfo hyperlinkInfo = openAsExternalFile ? new OpenExternalFileHyperlink(file) : new OpenFileHyperlinkInfo(module.getProject(), file, lineNumber, 0);
return new Result(lineStart, lineStart + pathPart.length(), hyperlinkInfo);
}
return null;
}
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);
Result result = null;
if (matcher.find()) {
String filePath = matcher.group(myFileMatchGroup);
Collection<VirtualFile> virtualFileCollection = resolveVirtualFileCollection(filePath);
if (virtualFileCollection.size() > 0) {
List<ResultItem> resultItemList = new ArrayList<>(virtualFileCollection.size());
int highlightStartOffset = entireLength - line.length() + matcher.start(1);
int highlightEndOffset = highlightStartOffset + matcher.end(matcher.groupCount()) - matcher.start(1);
int fileLine = matchGroupToNumber(matcher, myLineMatchGroup);
int fileColumn = matchGroupToNumber(matcher, myColumnMatchGroup);
for (VirtualFile virtualFile : virtualFileCollection) {
resultItemList.add(new ResultItem(highlightStartOffset, highlightEndOffset, new OpenFileHyperlinkInfo(myProject, virtualFile, fileLine, fileColumn)));
}
result = new Result(resultItemList);
}
}
return result;
}
use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij by bazelbuild.
the class BlazeCppPathConsoleFilter method applyFilter.
@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);
}
Aggregations