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;
}
};
}
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;
}
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;
}
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);
}
}
}
}
}
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());
}
Aggregations