added more detail to designer display

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4511 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-09-19 14:04:21 +00:00
parent 65b7ded4a0
commit 341923aa48
3 changed files with 27 additions and 1 deletions

View File

@ -30,6 +30,20 @@ public class ASTPrimaryPrefix extends SimpleJavaNode {
return this.usesSuperModifier;
}
public String getLabel() {
String out = getImage();
if (usesSuperModifier) {
return "super." + out;
} else if (usesThisModifier) {
if (getImage() == null) {
return "this";
} else {
return "this." + out;
}
}
return out;
}
public void dump(String prefix) {
String out = getImage();
if (usesSuperModifier) {

View File

@ -67,6 +67,13 @@ public abstract class SimpleNode implements Node {
return beginLine;
}
// A label is a more visually useful image, e.g.
// int[[ for a primary suffix that's a 2D array of ints
// this is used only by the Designer to show nodes more helpfully
public String getLabel() {
return null;
}
public boolean hasImageEqualTo(String arg) {
return image != null && image.equals(arg);
}

View File

@ -236,7 +236,12 @@ public class Designer implements ClipboardOwner {
public String label() {
if (node instanceof SimpleNode) {
SimpleNode sn = (SimpleNode)node;
if (sn.getImage() == null) return node.toString();
if (sn.getLabel() != null) {
return node.toString() + LABEL_IMAGE_SEPARATOR + sn.getLabel();
}
if (sn.getImage() == null) {
return node.toString();
}
return node.toString() + LABEL_IMAGE_SEPARATOR + sn.getImage();
}
return node.toString();