diff options
| author | 2019-02-23 17:04:20 +0200 | |
|---|---|---|
| committer | 2019-02-23 17:04:20 +0200 | |
| commit | 924ab1cfe379d5744d5c864b3236934a037a21ae (patch) | |
| tree | 363ac1384c95565f9d60aaca1382d757ff39a2a5 /src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |
| parent | Drop final modifiers from displayed source ast for easier readability (diff) | |
| download | enigma-fork-924ab1cfe379d5744d5c864b3236934a037a21ae.tar.gz enigma-fork-924ab1cfe379d5744d5c864b3236934a037a21ae.tar.xz enigma-fork-924ab1cfe379d5744d5c864b3236934a037a21ae.zip | |
Tweak inheritance and implementation tree generation
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | 20 |
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 | ||
| 12 | package cuchaz.enigma.analysis; | 12 | package cuchaz.enigma.analysis; |
| 13 | 13 | ||
| 14 | import com.google.common.collect.Lists; | ||
| 15 | import cuchaz.enigma.analysis.index.EntryIndex; | 14 | import cuchaz.enigma.analysis.index.EntryIndex; |
| 16 | import cuchaz.enigma.analysis.index.InheritanceIndex; | 15 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 17 | import cuchaz.enigma.analysis.index.JarIndex; | 16 | import cuchaz.enigma.analysis.index.JarIndex; |
| @@ -20,7 +19,6 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry; | |||
| 20 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 21 | 20 | ||
| 22 | import javax.swing.tree.DefaultMutableTreeNode; | 21 | import javax.swing.tree.DefaultMutableTreeNode; |
| 23 | import java.util.List; | ||
| 24 | 22 | ||
| 25 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | 23 | public 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 | } |