Search in sources :

Example 6 with HyperlinkInfo

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

the class StackTraceElementObjectRenderer method getFullValueEvaluator.

@Nullable
@Override
public XFullValueEvaluator getFullValueEvaluator(final EvaluationContextImpl evaluationContext, final ValueDescriptorImpl valueDescriptor) {
    return new JavaValue.JavaFullValueEvaluator(DebuggerBundle.message("message.node.navigate"), evaluationContext) {

        @Override
        public void evaluate(@NotNull XFullValueEvaluationCallback callback) {
            Value value = valueDescriptor.getValue();
            ClassType type = ((ClassType) value.type());
            Method toString = type.concreteMethodByName("toString", "()Ljava/lang/String;");
            if (toString != null) {
                try {
                    Value res = evaluationContext.getDebugProcess().invokeMethod(evaluationContext, (ObjectReference) value, toString, Collections.emptyList());
                    if (res instanceof StringReference) {
                        callback.evaluated("");
                        final String line = ((StringReference) res).value();
                        ApplicationManager.getApplication().runReadAction(() -> {
                            ExceptionFilter filter = new ExceptionFilter(evaluationContext.getDebugProcess().getSession().getSearchScope());
                            Filter.Result result = filter.applyFilter(line, line.length());
                            if (result != null) {
                                final HyperlinkInfo info = result.getFirstHyperlinkInfo();
                                if (info != null) {
                                    DebuggerUIUtil.invokeLater(() -> info.navigate(valueDescriptor.getProject()));
                                }
                            }
                        });
                    }
                } catch (EvaluateException e) {
                    LOG.info("Exception while getting stack info", e);
                }
            }
        }

        @Override
        public boolean isShowValuePopup() {
            return false;
        }
    };
}
Also used : ExceptionFilter(com.intellij.execution.filters.ExceptionFilter) NotNull(org.jetbrains.annotations.NotNull) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ExceptionFilter(com.intellij.execution.filters.ExceptionFilter) Filter(com.intellij.execution.filters.Filter) JavaValue(com.intellij.debugger.engine.JavaValue) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with HyperlinkInfo

use of com.intellij.execution.filters.HyperlinkInfo 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)

Example 8 with HyperlinkInfo

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

the class EditorHyperlinkSupport method getNextOccurrence.

@Nullable
public static OccurenceNavigator.OccurenceInfo getNextOccurrence(final Editor editor, final int delta, final Consumer<RangeHighlighter> action) {
    final List<RangeHighlighter> ranges = getHyperlinks(0, editor.getDocument().getTextLength(), editor);
    if (ranges.isEmpty()) {
        return null;
    }
    int i;
    for (i = 0; i < ranges.size(); i++) {
        RangeHighlighter range = ranges.get(i);
        if (range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES) != null) {
            break;
        }
    }
    i %= ranges.size();
    int newIndex = i;
    while (newIndex < ranges.size() && newIndex >= 0) {
        newIndex = (newIndex + delta + ranges.size()) % ranges.size();
        final RangeHighlighter next = ranges.get(newIndex);
        HyperlinkInfo info = getHyperlinkInfo(next);
        assert info != null;
        if (info.includeInOccurenceNavigation()) {
            boolean inCollapsedRegion = editor.getFoldingModel().getCollapsedRegionAtOffset(next.getStartOffset()) != null;
            if (!inCollapsedRegion) {
                return new OccurenceNavigator.OccurenceInfo(new NavigatableAdapter() {

                    @Override
                    public void navigate(final boolean requestFocus) {
                        action.consume(next);
                        linkFollowed(editor, ranges, next);
                    }
                }, newIndex == -1 ? -1 : newIndex + 1, ranges.size());
            }
        }
        if (newIndex == i) {
            // cycled through everything, found no next/prev hyperlink
            break;
        }
    }
    return null;
}
Also used : RangeHighlighter(com.intellij.openapi.editor.markup.RangeHighlighter) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) RelativePoint(com.intellij.ui.awt.RelativePoint) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with HyperlinkInfo

use of com.intellij.execution.filters.HyperlinkInfo in project intellij-plugins by JetBrains.

the class FlexUnitExecutionTest method checkOutput.

private static void checkOutput(AbstractTestProxy testProxy, @Nullable FlexUnitRunnerParameters.OutputLogLevel logLevel) {
    final StringBuilder stdout = new StringBuilder();
    final StringBuilder stderr = new StringBuilder();
    final StringBuilder system = new StringBuilder();
    testProxy.printOn(new Printer() {

        @Override
        public void print(String text, ConsoleViewContentType contentType) {
            if (contentType == ConsoleViewContentType.NORMAL_OUTPUT) {
                stdout.append(text);
            } else if (contentType == ConsoleViewContentType.ERROR_OUTPUT) {
                stderr.append(text);
            } else if (contentType == ConsoleViewContentType.SYSTEM_OUTPUT) {
                system.append(text);
            } else {
                assert false;
            }
        }

        @Override
        public void onNewAvailable(@NotNull Printable printable) {
            printable.printOn(this);
        }

        @Override
        public void printHyperlink(String text, HyperlinkInfo info) {
        }

        @Override
        public void mark() {
        }
    });
    if (logLevel == null) {
        Assert.assertTrue("Test std output should be empty but was '" + stdout + "'", stdout.length() == 0);
    } else {
        for (FlexUnitRunnerParameters.OutputLogLevel level : FlexUnitRunnerParameters.OutputLogLevel.values()) {
            String message = LOG_MESSAGES.get(level);
            if (message != null) {
                if (level.ordinal() <= logLevel.ordinal()) {
                    Assert.assertTrue("Expected message '" + message + "' was not found in test output '" + stdout + "'", stdout.indexOf(message) != -1);
                } else {
                    Assert.assertTrue("Message '" + message + "' was not expected in test output '" + stdout + "'", stdout.indexOf(message) == -1);
                }
            }
        }
    }
}
Also used : FlexUnitRunnerParameters(com.intellij.lang.javascript.flex.flexunit.FlexUnitRunnerParameters) Printable(com.intellij.execution.testframework.Printable) Printer(com.intellij.execution.testframework.Printer) ConsoleViewContentType(com.intellij.execution.ui.ConsoleViewContentType) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo)

Example 10 with HyperlinkInfo

use of com.intellij.execution.filters.HyperlinkInfo in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoConsoleFilterTest method doGoGetTest.

private void doGoGetTest(@NotNull String line, int startOffset, int endOffset, @NotNull String packageName) {
    Filter.Result result = myFilter.applyFilter(line, line.length());
    assertNotNull(result);
    HyperlinkInfo info = assertResultAndGetHyperlink(result, startOffset, endOffset);
    assertInstanceOf(info, GoConsoleFilter.GoGetHyperlinkInfo.class);
    assertEquals(packageName, ((GoConsoleFilter.GoGetHyperlinkInfo) info).getPackageName());
}
Also used : Filter(com.intellij.execution.filters.Filter) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) OpenFileHyperlinkInfo(com.intellij.execution.filters.OpenFileHyperlinkInfo)

Aggregations

HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)19 OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)8 Nullable (org.jetbrains.annotations.Nullable)7 Filter (com.intellij.execution.filters.Filter)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 NotNull (org.jetbrains.annotations.NotNull)3 FileHyperlinkInfo (com.intellij.execution.filters.FileHyperlinkInfo)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 RangeHighlighter (com.intellij.openapi.editor.markup.RangeHighlighter)2 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)2 Project (com.intellij.openapi.project.Project)2 Matcher (java.util.regex.Matcher)2 BuckModule (com.facebook.buck.intellij.ideabuck.config.BuckModule)1 JsErrorMessage (com.google.jstestdriver.idea.common.JsErrorMessage)1 JavaValue (com.intellij.debugger.engine.JavaValue)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 CompositeFilter (com.intellij.execution.filters.CompositeFilter)1 ExceptionFilter (com.intellij.execution.filters.ExceptionFilter)1 RegexpFilter (com.intellij.execution.filters.RegexpFilter)1