summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java')
-rw-r--r--src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java
index f0fd1d2..862bb92 100644
--- a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java
+++ b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java
@@ -11,7 +11,6 @@
11 11
12package cuchaz.enigma.analysis; 12package cuchaz.enigma.analysis;
13 13
14import com.google.common.collect.Lists;
15import cuchaz.enigma.analysis.index.EntryIndex; 14import cuchaz.enigma.analysis.index.EntryIndex;
16import cuchaz.enigma.analysis.index.InheritanceIndex; 15import cuchaz.enigma.analysis.index.InheritanceIndex;
17import cuchaz.enigma.analysis.index.JarIndex; 16import cuchaz.enigma.analysis.index.JarIndex;
@@ -20,7 +19,6 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry;
20import cuchaz.enigma.translation.representation.entry.MethodEntry; 19import cuchaz.enigma.translation.representation.entry.MethodEntry;
21 20
22import javax.swing.tree.DefaultMutableTreeNode; 21import javax.swing.tree.DefaultMutableTreeNode;
23import java.util.List;
24 22
25public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { 23public class MethodInheritanceTreeNode extends DefaultMutableTreeNode {
26 24
@@ -58,6 +56,10 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode {
58 return this.isImplemented; 56 return this.isImplemented;
59 } 57 }
60 58
59 public boolean shouldExpand() {
60 return this.isImplemented || !this.isLeaf();
61 }
62
61 @Override 63 @Override
62 public String toString() { 64 public String toString() {
63 MethodEntry translatedEntry = translator.translate(entry); 65 MethodEntry translatedEntry = translator.translate(entry);
@@ -71,23 +73,19 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode {
71 } 73 }
72 } 74 }
73 75
74 public void load(JarIndex index, boolean recurse) { 76 public void load(JarIndex index) {
75 // get all the child nodes 77 // get all the child nodes
76 List<MethodInheritanceTreeNode> nodes = Lists.newArrayList();
77 EntryIndex entryIndex = index.getEntryIndex(); 78 EntryIndex entryIndex = index.getEntryIndex();
78 InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); 79 InheritanceIndex inheritanceIndex = index.getInheritanceIndex();
79 80
80 for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) { 81 for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) {
81 MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.entry.getName(), this.entry.getDesc()); 82 MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.entry.getName(), this.entry.getDesc());
82 nodes.add(new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry)));
83 }
84 83
85 // add them to this node 84 MethodInheritanceTreeNode node = new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry));
86 nodes.forEach(this::add); 85 node.load(index);
87 86
88 if (recurse) { 87 if (node.shouldExpand()) {
89 for (MethodInheritanceTreeNode node : nodes) { 88 this.add(node);
90 node.load(index, true);
91 } 89 }
92 } 90 }
93 } 91 }