Search in sources :

Example 1 with XErrorValuePresentation

use of com.intellij.xdebugger.frame.presentation.XErrorValuePresentation in project intellij-community by JetBrains.

the class JavaValue method computePresentation.

@Override
public void computePresentation(@NotNull final XValueNode node, @NotNull XValuePlace place) {
    final SuspendContextImpl suspendContext = myEvaluationContext.getSuspendContext();
    myEvaluationContext.getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {

        @Override
        public Priority getPriority() {
            return Priority.NORMAL;
        }

        @Override
        protected void commandCancelled() {
            node.setPresentation(null, new XErrorValuePresentation(DebuggerBundle.message("error.context.has.changed")), false);
        }

        @Override
        public void contextAction() throws Exception {
            if (node.isObsolete()) {
                return;
            }
            if (!myContextSet) {
                myValueDescriptor.setContext(myEvaluationContext);
            }
            myValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {

                @Override
                public void labelChanged() {
                    Icon nodeIcon = DebuggerTreeRenderer.getValueIcon(myValueDescriptor);
                    final String value = getValueString();
                    @SuppressWarnings("ThrowableResultOfMethodCallIgnored") EvaluateException exception = myValueDescriptor.getEvaluateException();
                    XValuePresentation presentation = new JavaValuePresentation(value, myValueDescriptor.getIdLabel(), exception != null ? exception.getMessage() : null, myValueDescriptor);
                    if (myValueDescriptor.getLastRenderer() instanceof FullValueEvaluatorProvider) {
                        XFullValueEvaluator evaluator = ((FullValueEvaluatorProvider) myValueDescriptor.getLastRenderer()).getFullValueEvaluator(myEvaluationContext, myValueDescriptor);
                        if (evaluator != null) {
                            node.setFullValueEvaluator(evaluator);
                        }
                    } else if (value.length() > XValueNode.MAX_VALUE_LENGTH) {
                        node.setFullValueEvaluator(new JavaFullValueEvaluator(myEvaluationContext) {

                            @Override
                            public void evaluate(@NotNull final XFullValueEvaluationCallback callback) {
                                final ValueDescriptorImpl fullValueDescriptor = myValueDescriptor.getFullValueDescriptor();
                                fullValueDescriptor.updateRepresentation(myEvaluationContext, new DescriptorLabelListener() {

                                    @Override
                                    public void labelChanged() {
                                        callback.evaluated(fullValueDescriptor.getValueText());
                                    }
                                });
                            }
                        });
                    }
                    node.setPresentation(nodeIcon, presentation, myValueDescriptor.isExpandable());
                }
            });
        }
    });
}
Also used : XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) NotNull(org.jetbrains.annotations.NotNull) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) XErrorValuePresentation(com.intellij.xdebugger.frame.presentation.XErrorValuePresentation)

Aggregations

EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 XErrorValuePresentation (com.intellij.xdebugger.frame.presentation.XErrorValuePresentation)1 XValuePresentation (com.intellij.xdebugger.frame.presentation.XValuePresentation)1 NotNull (org.jetbrains.annotations.NotNull)1