Skip to content

Commit 3299bf1

Browse files
committed
Fixed sorting & toString() of some nodes
1 parent 2d89867 commit 3299bf1

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/InstanceReferenceNode.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,11 @@
2929
import org.graalvm.visualvm.lib.jfluid.heap.Instance;
3030
import org.graalvm.visualvm.lib.jfluid.heap.ObjectFieldValue;
3131
import org.graalvm.visualvm.lib.jfluid.heap.Value;
32-
import org.openide.util.NbBundle;
3332

3433
/**
3534
*
3635
* @author Jiri Sedlacek
3736
*/
38-
@NbBundle.Messages({
39-
"InstanceReferenceNode_NodeNameField={0} {1}",
40-
"InstanceReferenceNode_NodeNameReference={0} in {1}"
41-
})
4237
public abstract class InstanceReferenceNode extends InstanceNode.IncludingNull {
4338

4439
private final Mode mode;
@@ -89,8 +84,8 @@ public String getFieldName() {
8984

9085
public String toString() {
9186
// TODO: should not be called directly when sorting the tree
92-
if (Mode.INCOMING_REFERENCE.equals(mode)) return Bundle.InstanceReferenceNode_NodeNameReference(getFieldName(), getName(null));
93-
else return Bundle.InstanceReferenceNode_NodeNameField(getFieldName(), getName(null));
87+
if (Mode.INCOMING_REFERENCE.equals(mode)) return getFieldName() + " in " + getName(null); // NOI18N
88+
else return getFieldName() + " = " + getName(null); // NOI18N
9489
}
9590

9691
public boolean equals(Object o) {

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/PrimitiveNode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,16 @@ public String getFieldName() {
5353
public abstract String getValue();
5454

5555

56+
private String getName() {
57+
return getFieldName() + " = " + getType() + " " + getValue(); // NOI18N
58+
}
59+
5660
public String toString() {
57-
return getFieldName();
61+
return getName();
5862
}
5963

6064
protected Object getValue(DataType type, Heap heap) {
61-
if (type == DataType.NAME) return getFieldName();
65+
if (type == DataType.NAME) return getName();
6266
if (type == DataType.OWN_SIZE) return DataType.OWN_SIZE.getNoValue();
6367
if (type == DataType.RETAINED_SIZE) return DataType.RETAINED_SIZE.getNoValue();
6468
if (type == DataType.OBJECT_ID) return DataType.OBJECT_ID.getNoValue();

visualvm/heapviewer/src/org/graalvm/visualvm/heapviewer/java/impl/JavaFieldsPlugin.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,13 @@ int getValuesCount() {
337337
return valuesCount;
338338
}
339339

340-
public String toString() {
340+
341+
private String getName() {
341342
if (valuesCount == -1) return fieldName;
342343
else return fieldName + " " + Bundle.JavaFieldsPlugin_ValuesCountHint(valuesCount); // NOI18N
343344
}
344345

346+
345347
abstract int instancesCount();
346348

347349
abstract InterruptibleIterator<Instance> instancesIterator();
@@ -460,6 +462,18 @@ protected String getNodesContainerString(String firstNodeIdx, String lastNodeIdx
460462

461463
}
462464

465+
466+
protected Object getValue(DataType type, Heap heap) {
467+
if (type == DataType.NAME) return getName();
468+
469+
return super.getValue(type, heap);
470+
}
471+
472+
473+
public String toString() {
474+
return getName();
475+
}
476+
463477
}
464478

465479

@@ -495,7 +509,17 @@ public int getValuesCount() {
495509
abstract InterruptibleIterator<Instance> instancesIterator();
496510

497511

512+
public String getName() {
513+
return getType() + " " + getValue();
514+
}
515+
516+
public String toString() {
517+
return getName();
518+
}
519+
520+
498521
protected Object getValue(DataType type, Heap heap) {
522+
if (type == DataType.NAME) return getName();
499523
if (type == DataType.COUNT) return getValuesCount();
500524

501525
return super.getValue(type, heap);

0 commit comments

Comments
 (0)