Search in sources :

Example 1 with NodeRenderer

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

the class RendererConfiguration method clone.

public RendererConfiguration clone() {
    RendererConfiguration result = null;
    try {
        result = (RendererConfiguration) super.clone();
    } catch (CloneNotSupportedException e) {
        LOG.error(e);
    }
    result.myRepresentationNodes = new CopyOnWriteArrayList<>();
    final ArrayList<NodeRenderer> cloned = new ArrayList<>();
    for (NodeRenderer renderer : myRepresentationNodes) {
        cloned.add((NodeRenderer) renderer.clone());
    }
    result.setRenderers(cloned);
    return result;
}
Also used : NodeRenderer(com.intellij.debugger.ui.tree.render.NodeRenderer) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 2 with NodeRenderer

use of com.intellij.debugger.ui.tree.render.NodeRenderer 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)

Example 3 with NodeRenderer

use of com.intellij.debugger.ui.tree.render.NodeRenderer 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 NodeRenderer

use of com.intellij.debugger.ui.tree.render.NodeRenderer 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)

Example 5 with NodeRenderer

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

the class RendererConfiguration method readExternal.

@SuppressWarnings({ "HardCodedStringLiteral" })
public void readExternal(final Element root) {
    String versionAttrib = root.getAttributeValue("VERSION");
    int configurationVersion = -1;
    if (versionAttrib != null) {
        try {
            configurationVersion = Integer.parseInt(versionAttrib);
        } catch (NumberFormatException e) {
            configurationVersion = -1;
        }
    }
    if (configurationVersion != VERSION) {
        return;
    }
    final List<Element> children = root.getChildren(NodeRendererSettings.RENDERER_TAG);
    final List<NodeRenderer> renderers = new ArrayList<>(children.size());
    for (Element nodeElement : children) {
        try {
            renderers.add((NodeRenderer) myRendererSettings.readRenderer(nodeElement));
        } catch (Exception e) {
            LOG.debug(e);
        }
    }
    setRenderers(renderers);
}
Also used : NodeRenderer(com.intellij.debugger.ui.tree.render.NodeRenderer) Element(org.jdom.Element) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Aggregations

NodeRenderer (com.intellij.debugger.ui.tree.render.NodeRenderer)5 JavaValue (com.intellij.debugger.engine.JavaValue)2 DebuggerContextCommandImpl (com.intellij.debugger.engine.events.DebuggerContextCommandImpl)2 NodeRendererSettings (com.intellij.debugger.settings.NodeRendererSettings)2 Project (com.intellij.openapi.project.Project)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 Patches (com.intellij.Patches)1 com.intellij.debugger (com.intellij.debugger)1 DebuggerAction (com.intellij.debugger.actions.DebuggerAction)1 DebuggerActions (com.intellij.debugger.actions.DebuggerActions)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 com.intellij.debugger.engine.evaluation (com.intellij.debugger.engine.evaluation)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 ThreadReferenceProxy (com.intellij.debugger.engine.jdi.ThreadReferenceProxy)1 MethodReturnValueWatcher (com.intellij.debugger.engine.requests.MethodReturnValueWatcher)1 RequestManagerImpl (com.intellij.debugger.engine.requests.RequestManagerImpl)1 com.intellij.debugger.impl (com.intellij.debugger.impl)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1