Search in sources :

Example 1 with FileHyperlinkInfo

use of com.intellij.execution.filters.FileHyperlinkInfo 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;
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) FileHyperlinkInfo(com.intellij.execution.filters.FileHyperlinkInfo) FileHyperlinkInfo(com.intellij.execution.filters.FileHyperlinkInfo) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) CalledWithReadLock(org.jetbrains.annotations.CalledWithReadLock) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with FileHyperlinkInfo

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

the class SMTRunnerConsoleProperties method getErrorNavigatable.

@Nullable
@Override
public Navigatable getErrorNavigatable(@NotNull final Project project, @NotNull final String stacktrace) {
    if (myCustomFilter.isEmpty()) {
        return null;
    }
    // iterate stacktrace lines find first navigatable line using
    // stacktrace filters
    final int stacktraceLength = stacktrace.length();
    final String[] lines = StringUtil.splitByLines(stacktrace);
    for (String line : lines) {
        Filter.Result result;
        try {
            result = myCustomFilter.applyFilter(line, stacktraceLength);
        } catch (Throwable t) {
            throw new RuntimeException("Error while applying " + myCustomFilter + " to '" + line + "'", t);
        }
        final HyperlinkInfo info = result != null ? result.getFirstHyperlinkInfo() : null;
        if (info != null) {
            // covers 99% use existing cases
            if (info instanceof FileHyperlinkInfo) {
                return ((FileHyperlinkInfo) info).getDescriptor();
            }
            // otherwise
            return new Navigatable() {

                @Override
                public void navigate(boolean requestFocus) {
                    info.navigate(project);
                }

                @Override
                public boolean canNavigate() {
                    return true;
                }

                @Override
                public boolean canNavigateToSource() {
                    return true;
                }
            };
        }
    }
    return null;
}
Also used : CompositeFilter(com.intellij.execution.filters.CompositeFilter) Filter(com.intellij.execution.filters.Filter) FileHyperlinkInfo(com.intellij.execution.filters.FileHyperlinkInfo) FileHyperlinkInfo(com.intellij.execution.filters.FileHyperlinkInfo) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) Navigatable(com.intellij.pom.Navigatable) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

FileHyperlinkInfo (com.intellij.execution.filters.FileHyperlinkInfo)2 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)2 Nullable (org.jetbrains.annotations.Nullable)2 CompositeFilter (com.intellij.execution.filters.CompositeFilter)1 Filter (com.intellij.execution.filters.Filter)1 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 Navigatable (com.intellij.pom.Navigatable)1 CalledWithReadLock (org.jetbrains.annotations.CalledWithReadLock)1