From ad49f6d08133253b5e2e54cc13fe3a54d85bf8d6 Mon Sep 17 00:00:00 2001 From: liach Date: Sun, 24 Feb 2019 12:43:41 -0800 Subject: Adds a red highlight for overridden methods in method inheritance tree gui (#112) * Make implemented method nodes in inheritance ui more obvious Signed-off-by: liach * Make the text green and italic instead Signed-off-by: liach * Update again for the new tree gen Also tweaked new tree gen to show only useful branch nodes Signed-off-by: liach --- .../enigma/analysis/MethodInheritanceTreeNode.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java') diff --git a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index 862bb92..e77b5cc 100644 --- a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java @@ -24,12 +24,12 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { private final Translator translator; private MethodEntry entry; - private boolean isImplemented; + private boolean implemented; - public MethodInheritanceTreeNode(Translator translator, MethodEntry entry, boolean isImplemented) { + public MethodInheritanceTreeNode(Translator translator, MethodEntry entry, boolean implemented) { this.translator = translator; this.entry = entry; - this.isImplemented = isImplemented; + this.implemented = implemented; } public static MethodInheritanceTreeNode findNode(MethodInheritanceTreeNode node, MethodEntry entry) { @@ -53,11 +53,7 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { } public boolean isImplemented() { - return this.isImplemented; - } - - public boolean shouldExpand() { - return this.isImplemented || !this.isLeaf(); + return this.implemented; } @Override @@ -65,7 +61,7 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { MethodEntry translatedEntry = translator.translate(entry); String className = translatedEntry.getContainingClass().getFullName(); - if (!this.isImplemented) { + if (!this.implemented) { return className; } else { String methodName = translatedEntry.getName(); @@ -73,20 +69,27 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { } } - public void load(JarIndex index) { + /** + * Returns true if there is sub-node worthy to display. + */ + public boolean load(JarIndex index) { // get all the child nodes EntryIndex entryIndex = index.getEntryIndex(); InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); + boolean ret = false; for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) { MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.entry.getName(), this.entry.getDesc()); MethodInheritanceTreeNode node = new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry)); - node.load(index); + boolean childOverride = node.load(index); - if (node.shouldExpand()) { + if (childOverride || node.implemented) { this.add(node); + ret = true; } } + + return ret; } } -- cgit v1.2.3