summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java
diff options
context:
space:
mode:
authorGravatar Thog2017-03-08 08:17:04 +0100
committerGravatar Thog2017-03-08 08:17:04 +0100
commit6e464ea251cab63c776ece0b2a356f1498ffa294 (patch)
tree5ed30c03f5ac4cd2d6877874f5ede576049954f7 /src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java
parentDrop unix case style and implement hashCode when equals is overrided (diff)
downloadenigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.gz
enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.tar.xz
enigma-fork-6e464ea251cab63c776ece0b2a356f1498ffa294.zip
Follow Fabric guidelines
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java')
-rw-r--r--src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java95
1 files changed, 47 insertions, 48 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java
index 70ece24..f2fb2f8 100644
--- a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java
+++ b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java
@@ -8,69 +8,68 @@
8 * Contributors: 8 * Contributors:
9 * Jeff Martin - initial API and implementation 9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/ 10 ******************************************************************************/
11
11package cuchaz.enigma.analysis; 12package cuchaz.enigma.analysis;
12 13
13import com.google.common.collect.Lists; 14import com.google.common.collect.Lists;
14
15import java.util.List;
16
17import javax.swing.tree.DefaultMutableTreeNode;
18
19import cuchaz.enigma.mapping.ClassEntry; 15import cuchaz.enigma.mapping.ClassEntry;
20import cuchaz.enigma.mapping.MethodEntry; 16import cuchaz.enigma.mapping.MethodEntry;
21import cuchaz.enigma.mapping.Translator; 17import cuchaz.enigma.mapping.Translator;
22 18
19import javax.swing.tree.DefaultMutableTreeNode;
20import java.util.List;
21
23public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { 22public class ClassImplementationsTreeNode extends DefaultMutableTreeNode {
24 23
25 private Translator deobfuscatingTranslator; 24 private Translator deobfuscatingTranslator;
26 private ClassEntry entry; 25 private ClassEntry entry;
27 26
28 public ClassImplementationsTreeNode(Translator deobfuscatingTranslator, ClassEntry entry) { 27 public ClassImplementationsTreeNode(Translator deobfuscatingTranslator, ClassEntry entry) {
29 this.deobfuscatingTranslator = deobfuscatingTranslator; 28 this.deobfuscatingTranslator = deobfuscatingTranslator;
30 this.entry = entry; 29 this.entry = entry;
31 } 30 }
32 31
33 public ClassEntry getClassEntry() { 32 public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) {
34 return this.entry; 33 // is this the node?
35 } 34 if (node.entry.equals(entry.getClassEntry())) {
35 return node;
36 }
36 37
37 public String getDeobfClassName() { 38 // recurse
38 return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); 39 for (int i = 0; i < node.getChildCount(); i++) {
39 } 40 ClassImplementationsTreeNode foundNode = findNode((ClassImplementationsTreeNode) node.getChildAt(i), entry);
41 if (foundNode != null) {
42 return foundNode;
43 }
44 }
45 return null;
46 }
40 47
41 @Override 48 public ClassEntry getClassEntry() {
42 public String toString() { 49 return this.entry;
43 String className = getDeobfClassName(); 50 }
44 if (className == null) {
45 className = this.entry.getClassName();
46 }
47 return className;
48 }
49 51
50 public void load(JarIndex index) { 52 public String getDeobfClassName() {
51 // get all method implementations 53 return this.deobfuscatingTranslator.translateClass(this.entry.getClassName());
52 List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); 54 }
53 for (String implementingClassName : index.getImplementingClasses(this.entry.getClassName())) {
54 nodes.add(new ClassImplementationsTreeNode(this.deobfuscatingTranslator, new ClassEntry(implementingClassName)));
55 }
56 55
57 // add them to this node 56 @Override
58 nodes.forEach(this::add); 57 public String toString() {
59 } 58 String className = getDeobfClassName();
59 if (className == null) {
60 className = this.entry.getClassName();
61 }
62 return className;
63 }
60 64
61 public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { 65 public void load(JarIndex index) {
62 // is this the node? 66 // get all method implementations
63 if (node.entry.equals(entry.getClassEntry())) { 67 List<ClassImplementationsTreeNode> nodes = Lists.newArrayList();
64 return node; 68 for (String implementingClassName : index.getImplementingClasses(this.entry.getClassName())) {
65 } 69 nodes.add(new ClassImplementationsTreeNode(this.deobfuscatingTranslator, new ClassEntry(implementingClassName)));
70 }
66 71
67 // recurse 72 // add them to this node
68 for (int i = 0; i < node.getChildCount(); i++) { 73 nodes.forEach(this::add);
69 ClassImplementationsTreeNode foundNode = findNode((ClassImplementationsTreeNode) node.getChildAt(i), entry); 74 }
70 if (foundNode != null) {
71 return foundNode;
72 }
73 }
74 return null;
75 }
76} 75}