Search in sources :

Example 1 with ExceptionFilter

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

Aggregations

JavaValue (com.intellij.debugger.engine.JavaValue)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 ExceptionFilter (com.intellij.execution.filters.ExceptionFilter)1 Filter (com.intellij.execution.filters.Filter)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1