Search in sources :

Example 1 with XValuePresentation

use of com.intellij.xdebugger.frame.presentation.XValuePresentation in project go-lang-idea-plugin by go-lang-plugin-org.

the class DlvXValue method computePresentation.

@Override
public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
    XValuePresentation presentation = getPresentation();
    boolean hasChildren = myVariable.children.length > 0;
    node.setPresentation(myIcon, presentation, hasChildren);
}
Also used : XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation)

Example 2 with XValuePresentation

use of com.intellij.xdebugger.frame.presentation.XValuePresentation in project go-lang-idea-plugin by go-lang-plugin-org.

the class DlvXValue method getPresentation.

@NotNull
private XValuePresentation getPresentation() {
    String value = myVariable.value;
    if (myVariable.isNumber())
        return new XNumericValuePresentation(value);
    if (myVariable.isString())
        return new XStringValuePresentation(value);
    if (myVariable.isBool()) {
        return new XValuePresentation() {

            @Override
            public void renderValue(@NotNull XValueTextRenderer renderer) {
                renderer.renderValue(value);
            }
        };
    }
    String type = myVariable.type;
    boolean isSlice = myVariable.isSlice();
    boolean isArray = myVariable.isArray();
    if (isSlice || isArray) {
        return new XRegularValuePresentation("len:" + myVariable.len + (isSlice ? ", cap:" + myVariable.cap : ""), type.replaceFirst("struct ", ""));
    }
    String prefix = myVariable.type + " ";
    return new XRegularValuePresentation(StringUtil.startsWith(value, prefix) ? value.replaceFirst(Pattern.quote(prefix), "") : value, type);
}
Also used : XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) XNumericValuePresentation(com.intellij.xdebugger.frame.presentation.XNumericValuePresentation) XStringValuePresentation(com.intellij.xdebugger.frame.presentation.XStringValuePresentation) NotNull(org.jetbrains.annotations.NotNull) XRegularValuePresentation(com.intellij.xdebugger.frame.presentation.XRegularValuePresentation) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with XValuePresentation

use of com.intellij.xdebugger.frame.presentation.XValuePresentation 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)

Example 4 with XValuePresentation

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

the class XValueHint method evaluateAndShowHint.

@Override
protected void evaluateAndShowHint() {
    myEvaluator.evaluate(myExpression, new XEvaluationCallbackBase() {

        @Override
        public void evaluated(@NotNull final XValue result) {
            result.computePresentation(new XValueNodePresentationConfigurator.ConfigurableXValueNodeImpl() {

                private XFullValueEvaluator myFullValueEvaluator;

                private boolean myShown = false;

                @Override
                public void applyPresentation(@Nullable Icon icon, @NotNull XValuePresentation valuePresenter, boolean hasChildren) {
                    if (isHintHidden()) {
                        return;
                    }
                    SimpleColoredText text = new SimpleColoredText();
                    text.append(StringUtil.trimMiddle(myValueName, 200), XDebuggerUIConstants.VALUE_NAME_ATTRIBUTES);
                    XValueNodeImpl.buildText(valuePresenter, text);
                    if (!hasChildren) {
                        SimpleColoredComponent component = HintUtil.createInformationComponent();
                        text.appendToComponent(component);
                        if (myFullValueEvaluator != null) {
                            component.append(myFullValueEvaluator.getLinkText(), XDebuggerTreeNodeHyperlink.TEXT_ATTRIBUTES, (Consumer<MouseEvent>) event -> DebuggerUIUtil.showValuePopup(myFullValueEvaluator, event, getProject(), getEditor()));
                            LinkMouseListenerBase.installSingleTagOn(component);
                        }
                        showHint(component);
                    } else if (getType() == ValueHintType.MOUSE_CLICK_HINT) {
                        if (!myShown) {
                            showTree(result);
                        }
                    } else {
                        if (getType() == ValueHintType.MOUSE_OVER_HINT) {
                            text.insert(0, "(" + KeymapUtil.getFirstKeyboardShortcutText("ShowErrorDescription") + ") ", SimpleTextAttributes.GRAYED_ATTRIBUTES);
                        }
                        JComponent component = createExpandableHintComponent(text, () -> showTree(result));
                        showHint(component);
                    }
                    myShown = true;
                }

                @Override
                public void setFullValueEvaluator(@NotNull XFullValueEvaluator fullValueEvaluator) {
                    myFullValueEvaluator = fullValueEvaluator;
                }

                @Override
                public boolean isObsolete() {
                    return isHintHidden();
                }
            }, XValuePlace.TOOLTIP);
        }

        @Override
        public void errorOccurred(@NotNull final String errorMessage) {
            if (getType() == ValueHintType.MOUSE_CLICK_HINT) {
                ApplicationManager.getApplication().invokeLater(() -> showHint(HintUtil.createErrorLabel(errorMessage)));
            }
            LOG.debug("Cannot evaluate '" + myExpression + "':" + errorMessage);
        }
    }, myExpressionPosition);
}
Also used : XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) VirtualFile(com.intellij.openapi.vfs.VirtualFile) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) XValue(com.intellij.xdebugger.frame.XValue) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) XDebugSession(com.intellij.xdebugger.XDebugSession) SimpleColoredText(com.intellij.ui.SimpleColoredText) XDebuggerEvaluateActionHandler(com.intellij.xdebugger.impl.actions.handlers.XDebuggerEvaluateActionHandler) HintUtil(com.intellij.codeInsight.hint.HintUtil) XValueNodePresentationConfigurator(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodePresentationConfigurator) XEvaluationCallbackBase(com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationCallbackBase) KeymapUtil(com.intellij.openapi.keymap.KeymapUtil) Nullable(org.jetbrains.annotations.Nullable) ConsoleView(com.intellij.execution.ui.ConsoleView) XSourcePosition(com.intellij.xdebugger.XSourcePosition) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ApplicationManager(com.intellij.openapi.application.ApplicationManager) LanguageConsoleView(com.intellij.execution.console.LanguageConsoleView) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) XDebuggerUtil(com.intellij.xdebugger.XDebuggerUtil) ValueHintType(com.intellij.xdebugger.impl.evaluate.quick.common.ValueHintType) DebuggerUIUtil(com.intellij.xdebugger.impl.ui.DebuggerUIUtil) ActionManager(com.intellij.openapi.actionSystem.ActionManager) ExpressionInfo(com.intellij.xdebugger.evaluation.ExpressionInfo) XDebuggerUIConstants(com.intellij.xdebugger.impl.ui.XDebuggerUIConstants) Project(com.intellij.openapi.project.Project) ShortcutSet(com.intellij.openapi.actionSystem.ShortcutSet) AbstractValueHint(com.intellij.xdebugger.impl.evaluate.quick.common.AbstractValueHint) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent) ConsoleViewImpl(com.intellij.execution.impl.ConsoleViewImpl) XDebuggerTreeNodeHyperlink(com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink) StringUtil(com.intellij.openapi.util.text.StringUtil) XFullValueEvaluator(com.intellij.xdebugger.frame.XFullValueEvaluator) Key(com.intellij.openapi.util.Key) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Editor(com.intellij.openapi.editor.Editor) Disposable(com.intellij.openapi.Disposable) XValuePlace(com.intellij.xdebugger.frame.XValuePlace) MouseEvent(java.awt.event.MouseEvent) java.awt(java.awt) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) LinkMouseListenerBase(com.intellij.openapi.vcs.changes.issueLinks.LinkMouseListenerBase) Pair(com.intellij.openapi.util.Pair) XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) XValueMarkers(com.intellij.xdebugger.impl.frame.XValueMarkers) XDebuggerEvaluator(com.intellij.xdebugger.evaluation.XDebuggerEvaluator) javax.swing(javax.swing) XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) MouseEvent(java.awt.event.MouseEvent) XFullValueEvaluator(com.intellij.xdebugger.frame.XFullValueEvaluator) SimpleColoredText(com.intellij.ui.SimpleColoredText) XEvaluationCallbackBase(com.intellij.xdebugger.impl.ui.tree.nodes.XEvaluationCallbackBase) XValue(com.intellij.xdebugger.frame.XValue) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 5 with XValuePresentation

use of com.intellij.xdebugger.frame.presentation.XValuePresentation in project intellij-elixir by KronicDeth.

the class ElixirArrayXValueBase method computePresentation.

@Override
public final void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) {
    XValuePresentation presentation = getPresentation(node, place);
    if (presentation != null) {
        node.setPresentation(getIcon(), presentation, hasChildren());
    } else {
        String repr = getStringRepr();
        if (repr.length() > XValueNode.MAX_VALUE_LENGTH) {
            node.setFullValueEvaluator(new ImmediateFullValueEvaluator(repr));
            repr = repr.substring(0, XValueNode.MAX_VALUE_LENGTH - 3) + "...";
        }
        node.setPresentation(getIcon(), getType(), repr, hasChildren());
    }
}
Also used : XValuePresentation(com.intellij.xdebugger.frame.presentation.XValuePresentation) ElixirXValuePresentation(org.elixir_lang.debugger.ElixirXValuePresentation)

Aggregations

XValuePresentation (com.intellij.xdebugger.frame.presentation.XValuePresentation)6 NotNull (org.jetbrains.annotations.NotNull)3 XDebugSession (com.intellij.xdebugger.XDebugSession)2 HintUtil (com.intellij.codeInsight.hint.HintUtil)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 LanguageConsoleView (com.intellij.execution.console.LanguageConsoleView)1 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)1 ConsoleView (com.intellij.execution.ui.ConsoleView)1 Disposable (com.intellij.openapi.Disposable)1 ActionManager (com.intellij.openapi.actionSystem.ActionManager)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 ShortcutSet (com.intellij.openapi.actionSystem.ShortcutSet)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 LineExtensionInfo (com.intellij.openapi.editor.LineExtensionInfo)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1