Search in sources :

Example 6 with JavaValue

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

the class FieldDescriptorImpl method getModifier.

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

        @Override
        protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
            final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
            FieldDescriptorImpl fieldDescriptor = FieldDescriptorImpl.this;
            final Field field = fieldDescriptor.getField();
            if (!field.isStatic()) {
                final ObjectReference object = fieldDescriptor.getObject();
                if (object != null) {
                    set(expression, callback, debuggerContext, new SetValueRunnable() {

                        public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
                            object.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
                            update(debuggerContext);
                        }

                        public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
                            return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader());
                        }
                    });
                }
            } else {
                // field is static
                ReferenceType refType = field.declaringType();
                if (refType instanceof ClassType) {
                    final ClassType classType = (ClassType) refType;
                    set(expression, callback, debuggerContext, new SetValueRunnable() {

                        public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
                            classType.setValue(field, preprocessValue(evaluationContext, newValue, field.type()));
                            update(debuggerContext);
                        }

                        public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
                            return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, field.declaringType().classLoader());
                        }
                    });
                }
            }
        }
    };
}
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)

Example 7 with JavaValue

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

the class ArrayElementDescriptorImpl method getModifier.

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

        @Override
        protected void setValueImpl(@NotNull String expression, @NotNull XModificationCallback callback) {
            final ArrayElementDescriptorImpl elementDescriptor = ArrayElementDescriptorImpl.this;
            final ArrayReference array = elementDescriptor.getArray();
            if (array != null) {
                if (VirtualMachineProxyImpl.isCollected(array)) {
                    // will only be the case if debugger does not use ObjectReference.disableCollection() because of Patches.IBM_JDK_DISABLE_COLLECTION_BUG
                    Messages.showWarningDialog(getProject(), DebuggerBundle.message("evaluation.error.array.collected") + "\n" + DebuggerBundle.message("warning.recalculate"), DebuggerBundle.message("title.set.value"));
                    //node.getParent().calcValue();
                    return;
                }
                final ArrayType arrType = (ArrayType) array.referenceType();
                final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(getProject()).getContext();
                set(expression, callback, debuggerContext, new SetValueRunnable() {

                    public void setValue(EvaluationContextImpl evaluationContext, Value newValue) throws ClassNotLoadedException, InvalidTypeException, EvaluateException {
                        array.setValue(elementDescriptor.getIndex(), preprocessValue(evaluationContext, newValue, arrType.componentType()));
                        update(debuggerContext);
                    }

                    public ReferenceType loadClass(EvaluationContextImpl evaluationContext, String className) throws InvocationException, ClassNotLoadedException, IncompatibleThreadStateException, InvalidTypeException, EvaluateException {
                        return evaluationContext.getDebugProcess().loadClass(evaluationContext, className, arrType.classLoader());
                    }
                });
            }
        }
    };
}
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)

Example 8 with JavaValue

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

the class CustomFieldInplaceEditor method editNew.

public static void editNew(@NotNull XValueNodeImpl parentNode) {
    ValueDescriptorImpl descriptor = ((JavaValue) parentNode.getValueContainer()).getDescriptor();
    EnumerationChildrenRenderer renderer = EnumerationChildrenRenderer.getCurrent(descriptor);
    XDebuggerTreeNode newNode = parentNode.addTemporaryEditorNode();
    DebuggerUIUtil.invokeLater(() -> new CustomFieldInplaceEditor(newNode, null, renderer) {

        @Override
        public void cancelEditing() {
            super.cancelEditing();
            parentNode.removeTemporaryEditorNode(newNode);
        }

        @Override
        protected List<Pair<String, TextWithImports>> getRendererChildren() {
            if (myRenderer != null) {
                return myRenderer.getChildren();
            }
            String name = getTypeName(descriptor);
            EnumerationChildrenRenderer enumerationChildrenRenderer = new EnumerationChildrenRenderer();
            enumerationChildrenRenderer.setAppendDefaultChildren(true);
            Renderer lastRenderer = descriptor.getLastRenderer();
            if (lastRenderer instanceof CompoundNodeRenderer && NodeRendererSettings.getInstance().getCustomRenderers().contains((NodeRenderer) lastRenderer) && !(((CompoundNodeRenderer) lastRenderer).getChildrenRenderer() instanceof ExpressionChildrenRenderer)) {
                ((CompoundNodeRenderer) lastRenderer).setChildrenRenderer(enumerationChildrenRenderer);
            } else {
                NodeRenderer renderer = NodeRendererSettings.getInstance().createCompoundTypeRenderer(name, name, null, enumerationChildrenRenderer);
                renderer.setEnabled(true);
                NodeRendererSettings.getInstance().getCustomRenderers().addRenderer(renderer);
                NodeRendererSettings.getInstance().fireRenderersChanged();
            }
            return enumerationChildrenRenderer.getChildren();
        }
    }.show());
}
Also used : ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) JavaValue(com.intellij.debugger.engine.JavaValue) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) Pair(com.intellij.openapi.util.Pair)

Example 9 with JavaValue

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

the class EditCustomFieldAction method perform.

@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
    ValueDescriptorImpl descriptor = ((JavaValue) node.getValueContainer()).getDescriptor();
    EnumerationChildrenRenderer enumerationChildrenRenderer = getParentEnumerationRenderer(descriptor);
    if (enumerationChildrenRenderer != null) {
        new CustomFieldInplaceEditor(node, (UserExpressionDescriptorImpl) descriptor, enumerationChildrenRenderer).show();
    }
}
Also used : EnumerationChildrenRenderer(com.intellij.debugger.ui.tree.render.EnumerationChildrenRenderer) ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) JavaValue(com.intellij.debugger.engine.JavaValue) UserExpressionDescriptorImpl(com.intellij.debugger.ui.impl.watch.UserExpressionDescriptorImpl) CustomFieldInplaceEditor(com.intellij.debugger.ui.tree.render.CustomFieldInplaceEditor)

Example 10 with JavaValue

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

the class ViewAsGroup method calcChildren.

private static AnAction[] calcChildren(List<JavaValue> values) {
    List<AnAction> renderers = new ArrayList<>();
    List<NodeRenderer> allRenderers = NodeRendererSettings.getInstance().getAllRenderers();
    boolean anyValueDescriptor = false;
    for (NodeRenderer nodeRenderer : allRenderers) {
        boolean allApp = true;
        for (JavaValue value : values) {
            if (value instanceof JavaReferringObjectsValue) {
                // disable for any referrers at all
                return AnAction.EMPTY_ARRAY;
            }
            ValueDescriptorImpl valueDescriptor = value.getDescriptor();
            anyValueDescriptor = true;
            if (!valueDescriptor.isValueValid() || !nodeRenderer.isApplicable(valueDescriptor.getType())) {
                allApp = false;
                break;
            }
        }
        if (!anyValueDescriptor) {
            return AnAction.EMPTY_ARRAY;
        }
        if (allApp) {
            renderers.add(new RendererAction(nodeRenderer));
        }
    }
    List<AnAction> children = new ArrayList<>();
    AnAction[] viewAsActions = ((DefaultActionGroup) ActionManager.getInstance().getAction(DebuggerActions.REPRESENTATION_LIST)).getChildren(null);
    for (AnAction viewAsAction : viewAsActions) {
        if (viewAsAction instanceof AutoRendererAction) {
            if (renderers.size() > 1) {
                viewAsAction.getTemplatePresentation().setVisible(true);
                children.add(viewAsAction);
            }
        } else {
            children.add(viewAsAction);
        }
    }
    if (!children.isEmpty()) {
        children.add(Separator.getInstance());
    }
    children.addAll(renderers);
    return children.toArray(new AnAction[children.size()]);
}
Also used : JavaValue(com.intellij.debugger.engine.JavaValue) ArrayList(java.util.ArrayList) NodeRenderer(com.intellij.debugger.ui.tree.render.NodeRenderer) ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl)

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