From b31f5f8ced39a94566fcb4bcadc256dfa42715be Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 26 Jul 2013 18:33:34 +0200 Subject: [PATCH] =?UTF-8?q?XValueChildrenProvider:=20reduce=20memory=20usa?= =?UTF-8?q?ge=20=E2=80=94=20avoid=20names=20list=20WEB-8440=20Debugger:=20?= =?UTF-8?q?Variables=20view:=20incorrect=20folding=20of=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xdebugger/frame/XCompositeNode.java | 8 +------ .../xdebugger/frame/XValueChildrenList.java | 7 ++++-- .../frame/XValueChildrenProvider.java | 24 +++++++++++++++++++ .../xdebugger/frame/XValueContainer.java | 2 +- .../intellij/xdebugger/frame/XValueNode.java | 4 ++-- .../ui/tree/nodes/XValueContainerNode.java | 16 ++++--------- .../xdebugger/XTestCompositeNode.java | 4 ++-- 7 files changed, 40 insertions(+), 25 deletions(-) create mode 100644 platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenProvider.java diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java index 8f5e7ec4ce7d..3f58e2ce0b25 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XCompositeNode.java @@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.List; /** * Represents a node with children in a debugger tree. This interface isn't supposed to be implemented by a plugin. @@ -36,12 +35,7 @@ public interface XCompositeNode extends Obsolescent { * @param children child nodes to add * @param last true if all children added */ - void addChildren(@NotNull XValueChildrenList children, final boolean last); - - /** - * @deprecated use {@link #addChildren(XValueChildrenList, boolean)} instead - */ - void addChildren(List children, final boolean last); + void addChildren(@NotNull XValueChildrenProvider children, final boolean last); /** * Add an ellipsis node ("...") indicating that the node has too many children. If user double-click on that node diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenList.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenList.java index aff088a71ee4..f37d1d2b9173 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenList.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenList.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import java.util.List; /** * @author nik */ -public class XValueChildrenList { +public class XValueChildrenList extends XValueChildrenProvider { public static final XValueChildrenList EMPTY = new XValueChildrenList(Collections.emptyList(), Collections.emptyList()); private final List myNames; @@ -56,14 +56,17 @@ public class XValueChildrenList { myValues.add(value); } + @Override public int size() { return myNames.size(); } + @Override public String getName(int i) { return myNames.get(i); } + @Override public XValue getValue(int i) { return myValues.get(i); } diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenProvider.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenProvider.java new file mode 100644 index 000000000000..83261e6cb5e6 --- /dev/null +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueChildrenProvider.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.xdebugger.frame; + +public abstract class XValueChildrenProvider { + public abstract String getName(int i); + + public abstract XValue getValue(int i); + + public abstract int size(); +} \ No newline at end of file diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueContainer.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueContainer.java index 437759d1bb47..abb84d57084c 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueContainer.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueContainer.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; */ public abstract class XValueContainer { /** - * Start computing children of the value. Call {@link XCompositeNode#addChildren(XValueChildrenList, boolean)} to add child nodes. + * Start computing children of the value. Call {@link XCompositeNode#addChildren(XValueChildrenProvider, boolean)} to add child nodes. * Note that this method is called from the Event Dispatch thread so it should return quickly. * @param node node in the tree */ diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueNode.java b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueNode.java index c87bd3c7e3bd..b932b0335c1b 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueNode.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/frame/XValueNode.java @@ -92,13 +92,13 @@ public interface XValueNode extends Obsolescent { /** * @deprecated use {@link #setPresentation(javax.swing.Icon, String, String, boolean)} instead. Names for values should be passed to - * {@link XCompositeNode#addChildren(com.intellij.xdebugger.frame.XValueChildrenList, boolean)} + * {@link XCompositeNode#addChildren(XValueChildrenProvider, boolean)} */ void setPresentation(@NonNls String name, @Nullable Icon icon, @NonNls @Nullable String type, @NonNls @NotNull String value, boolean hasChildren); /** * @deprecated use {@link #setPresentation(javax.swing.Icon, String, String, String, boolean)} instead. Names for values should be passed to - * {@link XCompositeNode#addChildren(com.intellij.xdebugger.frame.XValueChildrenList, boolean)} + * {@link XCompositeNode#addChildren(XValueChildrenProvider, boolean)} */ void setPresentation(@NonNls String name, @Nullable Icon icon, @NonNls @Nullable String type, @NonNls @NotNull String separator, @NonNls @NotNull String value, boolean hasChildren); } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java index e8fe7ed2394d..afc718bac915 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/tree/nodes/XValueContainerNode.java @@ -19,7 +19,10 @@ import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.SortedList; -import com.intellij.xdebugger.frame.*; +import com.intellij.xdebugger.frame.XCompositeNode; +import com.intellij.xdebugger.frame.XDebuggerTreeNodeHyperlink; +import com.intellij.xdebugger.frame.XValueChildrenProvider; +import com.intellij.xdebugger.frame.XValueContainer; import com.intellij.xdebugger.impl.settings.XDebuggerSettingsManager; import com.intellij.xdebugger.impl.ui.DebuggerUIUtil; import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants; @@ -77,7 +80,7 @@ public abstract class XValueContainerNode children, final boolean last) { - final XValueChildrenList list = new XValueChildrenList(children.size()); - for (XValue child : children) { - list.add(null, child); - } - addChildren(list, last); - } - @Override public void tooManyChildren(final int remaining) { DebuggerUIUtil.invokeLater(new Runnable() { diff --git a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestCompositeNode.java b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestCompositeNode.java index 6c7fc7190d60..1f0f2d19222c 100644 --- a/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestCompositeNode.java +++ b/platform/xdebugger-impl/testSrc/com/intellij/xdebugger/XTestCompositeNode.java @@ -2,7 +2,7 @@ package com.intellij.xdebugger; import com.intellij.xdebugger.frame.XCompositeNode; import com.intellij.xdebugger.frame.XValue; -import com.intellij.xdebugger.frame.XValueChildrenList; +import com.intellij.xdebugger.frame.XValueChildrenProvider; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -12,7 +12,7 @@ public class XTestCompositeNode extends XTestContainer implements XCompo private volatile boolean myAlreadySorted; @Override - public void addChildren(@NotNull XValueChildrenList children, boolean last) { + public void addChildren(@NotNull XValueChildrenProvider children, boolean last) { final List list = new ArrayList(); for (int i = 0; i < children.size(); i++) { list.add(children.getValue(i));