diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | 167 |
1 files changed, 83 insertions, 84 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index b65b8c1..4f84dd0 100644 --- a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |||
| @@ -8,97 +8,96 @@ | |||
| 8 | * Contributors: | 8 | * Contributors: |
| 9 | * Jeff Martin - initial API and implementation | 9 | * Jeff Martin - initial API and implementation |
| 10 | ******************************************************************************/ | 10 | ******************************************************************************/ |
| 11 | |||
| 11 | package cuchaz.enigma.analysis; | 12 | package cuchaz.enigma.analysis; |
| 12 | 13 | ||
| 13 | import com.google.common.collect.Lists; | 14 | import com.google.common.collect.Lists; |
| 14 | |||
| 15 | import java.util.List; | ||
| 16 | |||
| 17 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 18 | |||
| 19 | import cuchaz.enigma.mapping.ClassEntry; | 15 | import cuchaz.enigma.mapping.ClassEntry; |
| 20 | import cuchaz.enigma.mapping.MethodEntry; | 16 | import cuchaz.enigma.mapping.MethodEntry; |
| 21 | import cuchaz.enigma.mapping.Translator; | 17 | import cuchaz.enigma.mapping.Translator; |
| 22 | 18 | ||
| 19 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 20 | import java.util.List; | ||
| 21 | |||
| 23 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | 22 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { |
| 24 | 23 | ||
| 25 | private Translator deobfuscatingTranslator; | 24 | private Translator deobfuscatingTranslator; |
| 26 | private MethodEntry entry; | 25 | private MethodEntry entry; |
| 27 | private boolean isImplemented; | 26 | private boolean isImplemented; |
| 28 | 27 | ||
| 29 | public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { | 28 | public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { |
| 30 | this.deobfuscatingTranslator = deobfuscatingTranslator; | 29 | this.deobfuscatingTranslator = deobfuscatingTranslator; |
| 31 | this.entry = entry; | 30 | this.entry = entry; |
| 32 | this.isImplemented = isImplemented; | 31 | this.isImplemented = isImplemented; |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | public MethodEntry getMethodEntry() { | 34 | public static MethodInheritanceTreeNode findNode(MethodInheritanceTreeNode node, MethodEntry entry) { |
| 36 | return this.entry; | 35 | // is this the node? |
| 37 | } | 36 | if (node.getMethodEntry().equals(entry)) { |
| 38 | 37 | return node; | |
| 39 | public String getDeobfClassName() { | 38 | } |
| 40 | return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); | 39 | |
| 41 | } | 40 | // recurse |
| 42 | 41 | for (int i = 0; i < node.getChildCount(); i++) { | |
| 43 | public String getDeobfMethodName() { | 42 | MethodInheritanceTreeNode foundNode = findNode((MethodInheritanceTreeNode) node.getChildAt(i), entry); |
| 44 | return this.deobfuscatingTranslator.translate(this.entry); | 43 | if (foundNode != null) { |
| 45 | } | 44 | return foundNode; |
| 46 | 45 | } | |
| 47 | public boolean isImplemented() { | 46 | } |
| 48 | return this.isImplemented; | 47 | return null; |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | @Override | 50 | public MethodEntry getMethodEntry() { |
| 52 | public String toString() { | 51 | return this.entry; |
| 53 | String className = getDeobfClassName(); | 52 | } |
| 54 | if (className == null) { | 53 | |
| 55 | className = this.entry.getClassName(); | 54 | public String getDeobfClassName() { |
| 56 | } | 55 | return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); |
| 57 | 56 | } | |
| 58 | if (!this.isImplemented) { | 57 | |
| 59 | return className; | 58 | public String getDeobfMethodName() { |
| 60 | } else { | 59 | return this.deobfuscatingTranslator.translate(this.entry); |
| 61 | String methodName = getDeobfMethodName(); | 60 | } |
| 62 | if (methodName == null) { | 61 | |
| 63 | methodName = this.entry.getName(); | 62 | public boolean isImplemented() { |
| 64 | } | 63 | return this.isImplemented; |
| 65 | return className + "." + methodName + "()"; | 64 | } |
| 66 | } | 65 | |
| 67 | } | 66 | @Override |
| 68 | 67 | public String toString() { | |
| 69 | public void load(JarIndex index, boolean recurse) { | 68 | String className = getDeobfClassName(); |
| 70 | // get all the child nodes | 69 | if (className == null) { |
| 71 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); | 70 | className = this.entry.getClassName(); |
| 72 | for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(this.entry.getClassEntry())) { | 71 | } |
| 73 | MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getSignature() | 72 | |
| 74 | ); | 73 | if (!this.isImplemented) { |
| 75 | nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfBehavior(methodEntry) | 74 | return className; |
| 76 | )); | 75 | } else { |
| 77 | } | 76 | String methodName = getDeobfMethodName(); |
| 78 | 77 | if (methodName == null) { | |
| 79 | // add them to this node | 78 | methodName = this.entry.getName(); |
| 80 | nodes.forEach(this::add); | 79 | } |
| 81 | 80 | return className + "." + methodName + "()"; | |
| 82 | if (recurse) { | 81 | } |
| 83 | for (MethodInheritanceTreeNode node : nodes) { | 82 | } |
| 84 | node.load(index, true); | 83 | |
| 85 | } | 84 | public void load(JarIndex index, boolean recurse) { |
| 86 | } | 85 | // get all the child nodes |
| 87 | } | 86 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); |
| 88 | 87 | for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(this.entry.getClassEntry())) { | |
| 89 | public static MethodInheritanceTreeNode findNode(MethodInheritanceTreeNode node, MethodEntry entry) { | 88 | MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getSignature() |
| 90 | // is this the node? | 89 | ); |
| 91 | if (node.getMethodEntry().equals(entry)) { | 90 | nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfBehavior(methodEntry) |
| 92 | return node; | 91 | )); |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 95 | // recurse | 94 | // add them to this node |
| 96 | for (int i = 0; i < node.getChildCount(); i++) { | 95 | nodes.forEach(this::add); |
| 97 | MethodInheritanceTreeNode foundNode = findNode((MethodInheritanceTreeNode) node.getChildAt(i), entry); | 96 | |
| 98 | if (foundNode != null) { | 97 | if (recurse) { |
| 99 | return foundNode; | 98 | for (MethodInheritanceTreeNode node : nodes) { |
| 100 | } | 99 | node.load(index, true); |
| 101 | } | 100 | } |
| 102 | return null; | 101 | } |
| 103 | } | 102 | } |
| 104 | } | 103 | } |