use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-community by JetBrains.
the class PythonConsoleView method printHyperlink.
private void printHyperlink(@NotNull String text, @NotNull ConsoleViewContentType contentType) {
if (!StringUtil.isEmpty(text)) {
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(text.trim());
if (vFile != null) {
OpenFileHyperlinkInfo hyperlink = new OpenFileHyperlinkInfo(getProject(), vFile, -1);
super.printHyperlink(text, hyperlink);
} else {
super.print(text, contentType);
}
}
}
use of com.intellij.execution.filters.OpenFileHyperlinkInfo in project intellij-community by JetBrains.
the class CustomRegexpFilter method createOpenFileHyperlink.
protected HyperlinkInfo createOpenFileHyperlink(String fileName, final int line, int column) {
if ((fileName == null || fileName.length() == 0)) {
if (myBase != null) {
fileName = myBase.getPresentableUrl();
} else {
return null;
}
}
fileName = fileName.replace(File.separatorChar, '/');
VirtualFile file;
// try to interpret the filename as URL
if (URLUtil.containsScheme(fileName)) {
try {
file = VfsUtil.findFileByURL(new URL(fileName));
} catch (MalformedURLException e) {
file = VirtualFileManager.getInstance().findFileByUrl(VfsUtil.pathToUrl(fileName));
}
} else {
file = VfsUtil.findRelativeFile(fileName, myBase);
}
if (file == null) {
//noinspection ConstantConditions
return null;
}
final FileType fileType = file.getFileType();
if (fileType != null && column > 0) {
final Document document = FileDocumentManager.getInstance().getDocument(file);
final int start = document.getLineStartOffset(line);
final int max = document.getLineEndOffset(line);
final int tabSize = CodeStyleSettingsManager.getInstance(myProject).getCurrentSettings().getTabSize(fileType);
column = EditorUtil.calcColumnNumber(null, document.getCharsSequence(), start, Math.min(start + column, max), tabSize);
}
return new OpenFileHyperlinkInfo(myProject, file, line, column);
}
use of com.intellij.execution.filters.OpenFileHyperlinkInfo 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;
}
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;
}
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;
}
Aggregations