Skip to content

Commit 9ab9d8f

Browse files
committed
Use the new API to resolve renderer for a node
1 parent ecc08c2 commit 9ab9d8f

File tree

3 files changed

+14
-36
lines changed

3 files changed

+14
-36
lines changed

visualvm/heapviewer.truffle/src/org/graalvm/visualvm/heapviewer/truffle/TruffleObjectMergedFields.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.graalvm.visualvm.heapviewer.model.HeapViewerNodeFilter;
4444
import org.graalvm.visualvm.heapviewer.model.HeapViewerNodeWrapper;
4545
import org.graalvm.visualvm.heapviewer.model.Progress;
46+
import org.graalvm.visualvm.heapviewer.model.RootNode;
4647
import org.graalvm.visualvm.heapviewer.truffle.dynamicobject.DynamicObject;
4748
import org.graalvm.visualvm.heapviewer.truffle.dynamicobject.DynamicObjectNode;
4849
import org.graalvm.visualvm.heapviewer.ui.HeapViewerRenderer;
@@ -511,13 +512,12 @@ public String getShortName() {
511512
private static class ObjectFieldValueNodeRenderer extends HeapViewerRendererWrapper {
512513

513514
@Override
514-
protected HeapViewerNode getNode(Object value) {
515-
return ((TruffleObjectMergedFields.ObjectFieldValueNode)value).getNode();
516-
}
517-
518-
@Override
519-
protected HeapViewerRenderer getRenderer(HeapViewerNode node) {
520-
return TruffleObjectPropertyPlugin.resolveRenderer(node);
515+
protected HeapViewerRenderer getRenderer(Object value, int row) {
516+
TruffleObjectMergedFields.ObjectFieldValueNode vnode = (TruffleObjectMergedFields.ObjectFieldValueNode)value;
517+
HeapViewerNode node = vnode.getNode();
518+
HeapViewerRenderer renderer = RootNode.get(vnode).resolveRenderer(node);
519+
renderer.setValue(node, row);
520+
return renderer;
521521
}
522522

523523
}

visualvm/heapviewer.truffle/src/org/graalvm/visualvm/heapviewer/truffle/TruffleObjectMergedReferences.java

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.graalvm.visualvm.heapviewer.model.HeapViewerNodeFilter;
4141
import org.graalvm.visualvm.heapviewer.model.HeapViewerNodeWrapper;
4242
import org.graalvm.visualvm.heapviewer.model.Progress;
43+
import org.graalvm.visualvm.heapviewer.model.RootNode;
4344
import org.graalvm.visualvm.heapviewer.model.TextNode;
4445
import org.graalvm.visualvm.heapviewer.truffle.nodes.TruffleObjectReferenceNode;
4546
import org.graalvm.visualvm.heapviewer.ui.HeapViewerRenderer;
@@ -99,7 +100,7 @@ protected HeapViewerNode[] getNodes(HeapViewerNode parent, String viewID, HeapVi
99100

100101
final Map<Long, Integer> values = new HashMap();
101102
FieldValue refFV = null;
102-
103+
103104
progress.setupKnownSteps(objectsCount());
104105

105106
Iterator<O> objectsI = objectsIterator();
@@ -243,28 +244,15 @@ protected Object getValue(DataType type, Heap heap) {
243244
}
244245

245246

246-
// private static class MergedObjectReferenceNodeRenderer extends HeapViewerRendererWrapper {
247-
//
248-
// @Override
249-
// protected HeapViewerNode getNode(Object value) {
250-
// return ((TruffleObjectMergedReferences.MergedObjectReferenceNode)value).getNode();
251-
// }
252-
//
253-
// @Override
254-
// protected HeapViewerRenderer getRenderer(HeapViewerNode node) {
255-
// return TruffleObjectPropertyPlugin.resolveRenderer(node);
256-
// }
257-
//
258-
// }
259-
260-
private static class MergedObjectReferenceNodeRenderer2 extends NormalBoldGrayRenderer implements HeapViewerRenderer {
247+
private static class MergedObjectReferenceNodeRenderer extends NormalBoldGrayRenderer implements HeapViewerRenderer {
261248

262249
private HeapViewerRenderer renderer;
263250

264251
@Override
265252
public void setValue(Object value, int row) {
266-
HeapViewerNode node = ((TruffleObjectMergedReferences.MergedObjectReferenceNode)value).getNode();
267-
renderer = TruffleObjectPropertyPlugin.resolveRenderer(node);
253+
TruffleObjectMergedReferences.MergedObjectReferenceNode vnode = (TruffleObjectMergedReferences.MergedObjectReferenceNode)value;
254+
HeapViewerNode node = vnode.getNode();
255+
renderer = RootNode.get(vnode).resolveRenderer(node);
268256
renderer.setValue(node, row);
269257

270258
if (renderer instanceof NormalBoldGrayRenderer) {
@@ -314,7 +302,7 @@ public boolean supportsView(HeapContext context, String viewID) {
314302

315303
@Override
316304
public void registerRenderers(Map<Class<? extends HeapViewerNode>, HeapViewerRenderer> renderers, HeapContext context) {
317-
renderers.put(TruffleObjectMergedReferences.MergedObjectReferenceNode.class, new MergedObjectReferenceNodeRenderer2());
305+
renderers.put(TruffleObjectMergedReferences.MergedObjectReferenceNode.class, new MergedObjectReferenceNodeRenderer());
318306
}
319307

320308
}

visualvm/heapviewer.truffle/src/org/graalvm/visualvm/heapviewer/truffle/TruffleObjectPropertyPlugin.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import javax.swing.JCheckBoxMenuItem;
4646
import javax.swing.JPopupMenu;
4747
import javax.swing.SwingUtilities;
48-
import org.graalvm.visualvm.heapviewer.ui.HeapViewerRenderer;
4948
import org.openide.util.NbBundle;
5049
import org.openide.util.NbPreferences;
5150

@@ -76,14 +75,6 @@ public class TruffleObjectPropertyPlugin<O extends TruffleObject, T extends Truf
7675
private final TreeTableView objectsView;
7776

7877

79-
// TODO: temporary workaround, delete ASAP!
80-
private static TreeTableView SHARED_VIEW;
81-
// TODO: temporary workaround, delete ASAP!
82-
static HeapViewerRenderer resolveRenderer(HeapViewerNode node) {
83-
return SHARED_VIEW == null ? null : SHARED_VIEW.getNodeRenderer(node);
84-
}
85-
86-
8778
public TruffleObjectPropertyPlugin(String name, String description, Icon icon, String viewID, HeapContext context, HeapViewerActions actions, TruffleObjectPropertyProvider<O, T, F, L, ? extends Object> provider) {
8879
super(name, description, icon);
8980

@@ -160,7 +151,6 @@ public void run() {
160151
});
161152
}
162153
};
163-
if (SHARED_VIEW == null) SHARED_VIEW = objectsView;
164154
}
165155

166156
protected JComponent createComponent() {

0 commit comments

Comments
 (0)