From aed6b68d441ef552ec86aa0a18ed3cbc19adf788 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Tue, 6 Jun 2017 15:40:18 +0300 Subject: [PATCH] remember 100 last debugger tree states to keep expansion across frames --- .../util/resources/misc/registry.properties | 1 + .../impl/frame/XVariablesViewBase.java | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 429de9f36601..1e07581f188c 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -277,6 +277,7 @@ debugger.capture.points.annotations=false debugger.resume.yourkit.threads=false debugger.keep.step.requests=false debugger.enable.memory.view=true +debugger.tree.states.depth=100 analyze.exceptions.on.the.fly=false analyze.exceptions.on.the.fly.description=Automatically analyze clipboard on frame activation,\ diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java index 2474d73f95b3..205f176968c0 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/frame/XVariablesViewBase.java @@ -51,18 +51,24 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; +import java.util.LinkedHashMap; +import java.util.Map; /** * @author nik */ public abstract class XVariablesViewBase extends XDebugView { private final XDebuggerTreePanel myTreePanel; - private XDebuggerTreeState myTreeState; - private XDebuggerTreeRestorer myTreeRestorer; - - private Object myFrameEqualityObject; private MySelectionListener mySelectionListener; + private XDebuggerTreeRestorer myTreeRestorer; + private final Map myTreeStates = new LinkedHashMap() { + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > Registry.get("debugger.tree.states.depth").asInteger(); + } + }; + protected XVariablesViewBase(@NotNull Project project, @NotNull XDebuggerEditorsProvider editorsProvider, @Nullable XValueMarkers markers) { myTreePanel = new XDebuggerTreePanel( project, editorsProvider, this, null, this instanceof XWatchesView ? XDebuggerActions.WATCHES_TREE_POPUP_GROUP : XDebuggerActions.VARIABLES_TREE_POPUP_GROUP, markers); @@ -79,11 +85,14 @@ public abstract class XVariablesViewBase extends XDebugView { project.putUserData(XVariablesView.DEBUG_VARIABLES, new XVariablesView.InlineVariablesInfo()); clearInlays(tree); Object newEqualityObject = stackFrame.getEqualityObject(); - if (myFrameEqualityObject != null && newEqualityObject != null && myFrameEqualityObject.equals(newEqualityObject) - && myTreeState != null) { - disposeTreeRestorer(); - myTreeRestorer = myTreeState.restoreState(tree); + if (newEqualityObject != null) { + XDebuggerTreeState state = myTreeStates.get(newEqualityObject); + if (state != null) { + disposeTreeRestorer(); + myTreeRestorer = state.restoreState(tree); + } } + if (position != null && Registry.is("debugger.valueTooltipAutoShowOnSelection")) { registerInlineEvaluator(stackFrame, position, project); } @@ -120,9 +129,9 @@ public abstract class XVariablesViewBase extends XDebugView { protected void saveCurrentTreeState(@Nullable XStackFrame stackFrame) { removeSelectionListener(); - myFrameEqualityObject = stackFrame != null ? stackFrame.getEqualityObject() : null; - if (myTreeRestorer == null || myTreeRestorer.isFinished()) { - myTreeState = XDebuggerTreeState.saveState(getTree()); + Object equalityObject = stackFrame != null ? stackFrame.getEqualityObject() : null; + if (equalityObject != null && (myTreeRestorer == null || myTreeRestorer.isFinished())) { + myTreeStates.put(equalityObject, XDebuggerTreeState.saveState(getTree())); } disposeTreeRestorer(); }