Search in sources :

Example 1 with ValueDescriptor

use of com.intellij.debugger.ui.tree.ValueDescriptor in project intellij-community by JetBrains.

the class GroovyRefRenderer method buildChildren.

@Override
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
    ValueDescriptor fieldDescriptor = getWrappedDescriptor(value, evaluationContext.getProject());
    getDelegateRenderer(evaluationContext.getDebugProcess(), fieldDescriptor).buildChildren(fieldDescriptor.getValue(), builder, evaluationContext);
}
Also used : ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor)

Example 2 with ValueDescriptor

use of com.intellij.debugger.ui.tree.ValueDescriptor in project intellij-community by JetBrains.

the class JavaMarkObjectActionHandler method perform.

@Override
public void perform(@NotNull Project project, AnActionEvent event) {
    final DebuggerTreeNodeImpl node = DebuggerAction.getSelectedNode(event.getDataContext());
    if (node == null) {
        return;
    }
    final NodeDescriptorImpl descriptor = node.getDescriptor();
    if (!(descriptor instanceof ValueDescriptorImpl)) {
        return;
    }
    final DebuggerTree tree = node.getTree();
    tree.saveState(node);
    final Component parent = event.getData(CONTEXT_COMPONENT);
    final ValueDescriptorImpl valueDescriptor = ((ValueDescriptorImpl) descriptor);
    final DebuggerContextImpl debuggerContext = tree.getDebuggerContext();
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    final ValueMarkup markup = valueDescriptor.getMarkup(debugProcess);
    debugProcess.getManagerThread().invoke(new DebuggerContextCommandImpl(debuggerContext) {

        public Priority getPriority() {
            return Priority.HIGH;
        }

        public void threadAction() {
            boolean sessionRefreshNeeded = true;
            try {
                if (markup != null) {
                    valueDescriptor.setMarkup(debugProcess, null);
                } else {
                    final String defaultText = valueDescriptor.getName();
                    final Ref<Pair<ValueMarkup, Boolean>> result = new Ref<>(null);
                    try {
                        final boolean suggestAdditionalMarkup = canSuggestAdditionalMarkup(debugProcess, valueDescriptor.getValue());
                        SwingUtilities.invokeAndWait(() -> {
                            ObjectMarkupPropertiesDialog dialog = new ObjectMarkupPropertiesDialog(parent, defaultText, suggestAdditionalMarkup);
                            if (dialog.showAndGet()) {
                                result.set(Pair.create(dialog.getConfiguredMarkup(), dialog.isMarkAdditionalFields()));
                            }
                        });
                    } catch (InterruptedException ignored) {
                    } catch (InvocationTargetException e) {
                        LOG.error(e);
                    }
                    final Pair<ValueMarkup, Boolean> pair = result.get();
                    if (pair != null) {
                        valueDescriptor.setMarkup(debugProcess, pair.first);
                        if (pair.second) {
                            final Value value = valueDescriptor.getValue();
                            final Map<ObjectReference, ValueMarkup> additionalMarkup = suggestMarkup((ObjectReference) value);
                            if (!additionalMarkup.isEmpty()) {
                                final Map<ObjectReference, ValueMarkup> map = NodeDescriptorImpl.getMarkupMap(debugProcess);
                                if (map != null) {
                                    for (Map.Entry<ObjectReference, ValueMarkup> entry : additionalMarkup.entrySet()) {
                                        final ObjectReference key = entry.getKey();
                                        if (!map.containsKey(key)) {
                                            map.put(key, entry.getValue());
                                        }
                                    }
                                }
                            }
                        }
                    } else {
                        sessionRefreshNeeded = false;
                    }
                }
            } finally {
                final boolean _sessionRefreshNeeded = sessionRefreshNeeded;
                SwingUtilities.invokeLater(new Runnable() {

                    public void run() {
                        tree.restoreState(node);
                        final TreeBuilder model = tree.getMutableModel();
                        refreshLabelsRecursively(model.getRoot(), model, valueDescriptor.getValue());
                        if (_sessionRefreshNeeded) {
                            final DebuggerSession session = debuggerContext.getDebuggerSession();
                            if (session != null) {
                                session.refresh(true);
                            }
                        }
                    }

                    private void refreshLabelsRecursively(Object node, TreeBuilder model, Value value) {
                        if (node instanceof DebuggerTreeNodeImpl) {
                            final DebuggerTreeNodeImpl _node = (DebuggerTreeNodeImpl) node;
                            final NodeDescriptorImpl descriptor = _node.getDescriptor();
                            if (descriptor instanceof ValueDescriptor && Comparing.equal(value, ((ValueDescriptor) descriptor).getValue())) {
                                _node.labelChanged();
                            }
                        }
                        final int childCount = model.getChildCount(node);
                        for (int idx = 0; idx < childCount; idx++) {
                            refreshLabelsRecursively(model.getChild(node, idx), model, value);
                        }
                    }
                });
            }
        }
    });
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) ValueDescriptorImpl(com.intellij.debugger.ui.impl.watch.ValueDescriptorImpl) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl) Pair(com.intellij.openapi.util.Pair) DebuggerTree(com.intellij.debugger.ui.impl.watch.DebuggerTree) ValueMarkup(com.intellij.xdebugger.impl.ui.tree.ValueMarkup) InvocationTargetException(java.lang.reflect.InvocationTargetException) TreeBuilder(com.intellij.debugger.ui.impl.tree.TreeBuilder) Ref(com.intellij.openapi.util.Ref) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) HashMap(com.intellij.util.containers.HashMap) Map(java.util.Map) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl)

Example 3 with ValueDescriptor

use of com.intellij.debugger.ui.tree.ValueDescriptor in project intellij-community by JetBrains.

the class JumpToObjectAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    if (selectedNode == null) {
        return;
    }
    final NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
    if (!(descriptor instanceof ValueDescriptor)) {
        return;
    }
    DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
        return;
    }
    debugProcess.getManagerThread().schedule(new NavigateCommand(debuggerContext, (ValueDescriptor) descriptor, debugProcess, e));
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 4 with ValueDescriptor

use of com.intellij.debugger.ui.tree.ValueDescriptor in project intellij-community by JetBrains.

the class JumpToObjectAction method update.

@Override
public void update(final AnActionEvent e) {
    if (!isFirstStart(e)) {
        return;
    }
    final DebuggerContextImpl debuggerContext = getDebuggerContext(e.getDataContext());
    final DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
    if (debugProcess == null) {
        e.getPresentation().setVisible(false);
        return;
    }
    DebuggerTreeNodeImpl selectedNode = getSelectedNode(e.getDataContext());
    if (selectedNode == null) {
        e.getPresentation().setVisible(false);
        return;
    }
    final NodeDescriptorImpl descriptor = selectedNode.getDescriptor();
    if (descriptor instanceof ValueDescriptor) {
        debugProcess.getManagerThread().schedule(new EnableCommand(debuggerContext, (ValueDescriptor) descriptor, debugProcess, e));
    } else {
        e.getPresentation().setVisible(false);
    }
}
Also used : DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) NodeDescriptorImpl(com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)

Example 5 with ValueDescriptor

use of com.intellij.debugger.ui.tree.ValueDescriptor in project intellij-community by JetBrains.

the class DebugProcessImpl method getAutoRenderer.

public NodeRenderer getAutoRenderer(ValueDescriptor descriptor) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    Type type = descriptor.getType();
    // in case evaluation is not possible, force default renderer
    if (!DebuggerManagerEx.getInstanceEx(getProject()).getContext().isEvaluationPossible()) {
        return getDefaultRenderer(type);
    }
    try {
        return myNodeRenderersMap.computeIfAbsent(type, t -> myRenderers.stream().filter(r -> DebuggerUtilsImpl.suppressExceptions(() -> r.isApplicable(type), false, true, ClassNotPreparedException.class)).findFirst().orElseGet(() -> getDefaultRenderer(type)));
    } catch (ClassNotPreparedException e) {
        LOG.info(e);
        // use default, but do not cache
        return getDefaultRenderer(type);
    }
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) PrimitiveRenderer(com.intellij.debugger.ui.tree.render.PrimitiveRenderer) MessageType(com.intellij.openapi.ui.MessageType) StackCapturingLineBreakpoint(com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint) HashMap(com.intellij.util.containers.HashMap) com.intellij.execution.process(com.intellij.execution.process) EventRequest(com.sun.jdi.request.EventRequest) XDebugSessionImpl(com.intellij.xdebugger.impl.XDebugSessionImpl) PsiManager(com.intellij.psi.PsiManager) Semaphore(com.intellij.util.concurrency.Semaphore) Disposer(com.intellij.openapi.util.Disposer) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) ClassRenderer(com.intellij.debugger.ui.tree.render.ClassRenderer) ExecutionResult(com.intellij.execution.ExecutionResult) Messages(com.intellij.openapi.ui.Messages) Logger(com.intellij.openapi.diagnostic.Logger) XDebugSession(com.intellij.xdebugger.XDebugSession) MethodReturnValueWatcher(com.intellij.debugger.engine.requests.MethodReturnValueWatcher) StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) Extensions(com.intellij.openapi.extensions.Extensions) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) com.intellij.debugger.engine.evaluation(com.intellij.debugger.engine.evaluation) NodeRenderer(com.intellij.debugger.ui.tree.render.NodeRenderer) BreakpointManager(com.intellij.debugger.ui.breakpoints.BreakpointManager) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) StepIntoBreakpoint(com.intellij.debugger.ui.breakpoints.StepIntoBreakpoint) com.intellij.debugger.impl(com.intellij.debugger.impl) ActionsBundle(com.intellij.idea.ActionsBundle) com.sun.jdi.connect(com.sun.jdi.connect) MagicConstant(org.intellij.lang.annotations.MagicConstant) Nullable(org.jetbrains.annotations.Nullable) ClassFilter(com.intellij.ui.classFilter.ClassFilter) JavaSdkType(com.intellij.openapi.projectRoots.JavaSdkType) ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) XSourcePosition(com.intellij.xdebugger.XSourcePosition) ArrayRenderer(com.intellij.debugger.ui.tree.render.ArrayRenderer) StreamEx(one.util.streamex.StreamEx) com.intellij.debugger(com.intellij.debugger) VirtualMachineProxyImpl(com.intellij.debugger.jdi.VirtualMachineProxyImpl) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ExecutionUtil(com.intellij.execution.runners.ExecutionUtil) com.intellij.util(com.intellij.util) NotNull(org.jetbrains.annotations.NotNull) DebuggerClassFilterProvider(com.intellij.ui.classFilter.DebuggerClassFilterProvider) EventRequestManager(com.sun.jdi.request.EventRequestManager) NodeRendererSettings(com.intellij.debugger.settings.NodeRendererSettings) java.util(java.util) DebuggerAction(com.intellij.debugger.actions.DebuggerAction) ThreadReferenceProxyImpl(com.intellij.debugger.jdi.ThreadReferenceProxyImpl) ExecutionException(com.intellij.execution.ExecutionException) XDebuggerActions(com.intellij.xdebugger.impl.actions.XDebuggerActions) NonNls(org.jetbrains.annotations.NonNls) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ValueDescriptor(com.intellij.debugger.ui.tree.ValueDescriptor) StepRequest(com.sun.jdi.request.StepRequest) ContainerUtil(com.intellij.util.containers.ContainerUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl) DebuggerContextCommandImpl(com.intellij.debugger.engine.events.DebuggerContextCommandImpl) StatusBarUtil(com.intellij.openapi.wm.impl.status.StatusBarUtil) ThreadReferenceProxy(com.intellij.debugger.engine.jdi.ThreadReferenceProxy) RequestManagerImpl(com.intellij.debugger.engine.requests.RequestManagerImpl) RunToCursorBreakpoint(com.intellij.debugger.ui.breakpoints.RunToCursorBreakpoint) ToolWindowId(com.intellij.openapi.wm.ToolWindowId) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) SuspendContextCommandImpl(com.intellij.debugger.engine.events.SuspendContextCommandImpl) UserDataHolderBase(com.intellij.openapi.util.UserDataHolderBase) Patches(com.intellij.Patches) StringUtil(com.intellij.openapi.util.text.StringUtil) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) Disposable(com.intellij.openapi.Disposable) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) CommonClassNames(com.intellij.psi.CommonClassNames) DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) DebuggerActions(com.intellij.debugger.actions.DebuggerActions) Pair(com.intellij.openapi.util.Pair) com.sun.jdi(com.sun.jdi) CantRunException(com.intellij.execution.CantRunException) MessageType(com.intellij.openapi.ui.MessageType) JavaSdkType(com.intellij.openapi.projectRoots.JavaSdkType)

Aggregations

ValueDescriptor (com.intellij.debugger.ui.tree.ValueDescriptor)13 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)6 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)4 NodeDescriptorImpl (com.intellij.debugger.ui.impl.watch.NodeDescriptorImpl)4 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)3 ValueMarkup (com.intellij.xdebugger.impl.ui.tree.ValueMarkup)3 Value (com.sun.jdi.Value)3 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)2 NodeDescriptor (com.intellij.debugger.ui.tree.NodeDescriptor)2 Pair (com.intellij.openapi.util.Pair)2 HashMap (com.intellij.util.containers.HashMap)2 Patches (com.intellij.Patches)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerContext (com.intellij.debugger.DebuggerContext)1 DebuggerAction (com.intellij.debugger.actions.DebuggerAction)1 DebuggerActions (com.intellij.debugger.actions.DebuggerActions)1 DebugProcess (com.intellij.debugger.engine.DebugProcess)1 SuspendContext (com.intellij.debugger.engine.SuspendContext)1 com.intellij.debugger.engine.evaluation (com.intellij.debugger.engine.evaluation)1