Search in sources :

Example 1 with JavaValue

use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.

the class ViewAsGroup method getSelectedValues.

@NotNull
public static List<JavaValue> getSelectedValues(AnActionEvent event) {
    List<XValueNodeImpl> selectedNodes = XDebuggerTreeActionBase.getSelectedNodes(event.getDataContext());
    if (selectedNodes.isEmpty())
        return Collections.emptyList();
    List<JavaValue> res = new ArrayList<>(selectedNodes.size());
    for (XValueNodeImpl node : selectedNodes) {
        XValue container = node.getValueContainer();
        if (container instanceof JavaValue) {
            res.add((JavaValue) container);
        }
    }
    return res;
}
Also used : JavaValue(com.intellij.debugger.engine.JavaValue) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) ArrayList(java.util.ArrayList) XValue(com.intellij.xdebugger.frame.XValue) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JavaValue

use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.

the class ViewAsGroup method update.

public void update(final AnActionEvent event) {
    if (!DebuggerAction.isFirstStart(event)) {
        return;
    }
    myChildren = AnAction.EMPTY_ARRAY;
    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(event.getDataContext());
    final List<JavaValue> values = getSelectedValues(event);
    if (values.isEmpty()) {
        event.getPresentation().setEnabledAndVisible(false);
        return;
    }
    final DebugProcessImpl process = debuggerContext.getDebugProcess();
    if (process == null) {
        event.getPresentation().setEnabled(false);
        return;
    }
    process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

        public void threadAction() {
            myChildren = calcChildren(values);
            DebuggerAction.enableAction(event, myChildren.length > 0);
        }
    });
}
Also used : DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) JavaValue(com.intellij.debugger.engine.JavaValue) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 3 with JavaValue

use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.

the class CreateRendererAction method actionPerformed.

public void actionPerformed(@NotNull final AnActionEvent event) {
    final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(event.getDataContext());
    final List<JavaValue> values = ViewAsGroup.getSelectedValues(event);
    if (values.size() != 1) {
        return;
    }
    final JavaValue javaValue = values.get(0);
    final DebugProcessImpl process = debuggerContext.getDebugProcess();
    if (process == null) {
        return;
    }
    final Project project = event.getProject();
    process.getManagerThread().schedule(new DebuggerContextCommandImpl(debuggerContext) {

        public void threadAction() {
            Type type = javaValue.getDescriptor().getType();
            final String name = type != null ? type.name() : null;
            DebuggerUIUtil.invokeLater(() -> {
                final UserRenderersConfigurable ui = new UserRenderersConfigurable();
                ConfigurableBase<UserRenderersConfigurable, NodeRendererSettings> configurable = new ConfigurableBase<UserRenderersConfigurable, NodeRendererSettings>("reference.idesettings.debugger.typerenderers", DebuggerBundle.message("user.renderers.configurable.display.name"), "reference.idesettings.debugger.typerenderers") {

                    @NotNull
                    @Override
                    protected NodeRendererSettings getSettings() {
                        return NodeRendererSettings.getInstance();
                    }

                    @Override
                    protected UserRenderersConfigurable createUi() {
                        return ui;
                    }
                };
                SingleConfigurableEditor editor = new SingleConfigurableEditor(project, configurable);
                if (name != null) {
                    NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, null);
                    renderer.setEnabled(true);
                    ui.addRenderer(renderer);
                }
                editor.show();
            });
        }
    });
}
Also used : ConfigurableBase(com.intellij.openapi.options.ConfigurableBase) SingleConfigurableEditor(com.intellij.openapi.options.ex.SingleConfigurableEditor) JavaValue(com.intellij.debugger.engine.JavaValue) NotNull(org.jetbrains.annotations.NotNull) NodeRenderer(com.intellij.debugger.ui.tree.render.NodeRenderer) Project(com.intellij.openapi.project.Project) Type(com.sun.jdi.Type) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeRendererSettings(com.intellij.debugger.settings.NodeRendererSettings) UserRenderersConfigurable(com.intellij.debugger.settings.UserRenderersConfigurable) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 4 with JavaValue

use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.

the class AdjustArrayRangeAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext());
    DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
        return;
    }
    final Project project = debuggerContext.getProject();
    final XValueNodeImpl node = XDebuggerTreeActionBase.getSelectedNode(e.getDataContext());
    if (node == null) {
        return;
    }
    final XValue container = node.getValueContainer();
    if (!(container instanceof JavaValue)) {
        return;
    }
    final ValueDescriptorImpl descriptor = ((JavaValue) container).getDescriptor();
    ArrayRenderer renderer = getArrayRenderer(descriptor);
    if (renderer == null) {
        return;
    }
    //String title = createNodeTitle("", selectedNode);
    //String label = selectedNode.toString();
    //int index = label.indexOf('=');
    //if (index > 0) {
    //  title = title + " " + label.substring(index);
    //}
    String title = node.getName();
    final ArrayRenderer clonedRenderer = renderer.clone();
    clonedRenderer.setForced(true);
    if (ShowSettingsUtil.getInstance().editConfigurable(project, new NamedArrayConfigurable(title, clonedRenderer))) {
        debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {

            @Override
            public void contextAction() throws Exception {
                final Renderer lastRenderer = descriptor.getLastRenderer();
                if (lastRenderer instanceof ArrayRenderer) {
                    ((JavaValue) container).setRenderer(clonedRenderer, node);
                } else if (lastRenderer instanceof CompoundNodeRenderer) {
                    final CompoundNodeRenderer compoundRenderer = (CompoundNodeRenderer) lastRenderer;
                    final ChildrenRenderer childrenRenderer = compoundRenderer.getChildrenRenderer();
                    if (childrenRenderer instanceof ExpressionChildrenRenderer) {
                        ExpressionChildrenRenderer.setPreferableChildrenRenderer(descriptor, clonedRenderer);
                        ((JavaValue) container).reBuild(node);
                    }
                }
            }
        });
    }
}
Also used : JavaValue(com.intellij.debugger.engine.JavaValue) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) XValue(com.intellij.xdebugger.frame.XValue) Project(com.intellij.openapi.project.Project) ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) XValueNodeImpl(com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl)

Example 5 with JavaValue

use of com.intellij.debugger.engine.JavaValue in project intellij-community by JetBrains.

the class EvaluationDescriptor method getModifier.

@Override
public XValueModifier getModifier(JavaValue value) {
    return new JavaValueModifier(value) {

        @Override
        protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
            final EvaluationDescriptor evaluationDescriptor = EvaluationDescriptor.this;
            if (evaluationDescriptor.canSetValue()) {
                final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
                set(expression, callback, debuggerContext, new SetValueRunnable() {

                    public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
                        final Modifier modifier = evaluationDescriptor.getModifier();
                        modifier.setValue(preprocessValue(evaluationContext, newValue, modifier.getExpectedType()));
                        update(debuggerContext);
                    }

                    public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
                        return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, evaluationContext.getClassLoader());
                    }
                });
            }
        }
    };
}
Also used : NotNull(org.jetbrains.annotations.NotNull) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) JavaValueModifier(com.intellij.debugger.engine.JavaValueModifier) EvaluationContextImpl(com.intellij.debugger.engine.evaluation.EvaluationContextImpl) JavaValue(com.intellij.debugger.engine.JavaValue) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) Modifier(com.intellij.debugger.engine.evaluation.expression.Modifier) XValueModifier(com.intellij.xdebugger.frame.XValueModifier) JavaValueModifier(com.intellij.debugger.engine.JavaValueModifier)

Aggregations

JavaValue (com.intellij.debugger.engine.JavaValue)15 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)9 NotNull (org.jetbrains.annotations.NotNull)7 JavaValueModifier (com.intellij.debugger.engine.JavaValueModifier)5 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)5 EvaluationContextImpl (com.intellij.debugger.engine.evaluation.EvaluationContextImpl)5 ValueDescriptorImpl (com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl)5 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)4 XValue (com.intellij.xdebugger.frame.XValue)4 XValueNodeImpl (com.intellij.xdebugger.impl.ui.tree.nodes.XValueNodeImpl)4 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)3 NodeRenderer (com.intellij.debugger.ui.tree.render.NodeRenderer)2 Project (com.intellij.openapi.project.Project)2 ArrayList (java.util.ArrayList)2 Modifier (com.intellij.debugger.engine.evaluation.expression.Modifier)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 DecompiledLocalVariable (com.intellij.debugger.jdi.DecompiledLocalVariable)1 LocalVariableProxyImpl (com.intellij.debugger.jdi.LocalVariableProxyImpl)1 NodeRendererSettings (com.intellij.debugger.settings.NodeRendererSettings)1 UserRenderersConfigurable (com.intellij.debugger.settings.UserRenderersConfigurable)1