From 6e464ea251cab63c776ece0b2a356f1498ffa294 Mon Sep 17 00:00:00 2001 From: Thog Date: Wed, 8 Mar 2017 08:17:04 +0100 Subject: Follow Fabric guidelines --- .../enigma/analysis/MethodInheritanceTreeNode.java | 167 ++++++++++----------- 1 file changed, 83 insertions(+), 84 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 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 @@ * Contributors: * Jeff Martin - initial API and implementation ******************************************************************************/ + package cuchaz.enigma.analysis; import com.google.common.collect.Lists; - -import java.util.List; - -import javax.swing.tree.DefaultMutableTreeNode; - import cuchaz.enigma.mapping.ClassEntry; import cuchaz.enigma.mapping.MethodEntry; import cuchaz.enigma.mapping.Translator; +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.List; + public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { - private Translator deobfuscatingTranslator; - private MethodEntry entry; - private boolean isImplemented; - - public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { - this.deobfuscatingTranslator = deobfuscatingTranslator; - this.entry = entry; - this.isImplemented = isImplemented; - } - - public MethodEntry getMethodEntry() { - return this.entry; - } - - public String getDeobfClassName() { - return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); - } - - public String getDeobfMethodName() { - return this.deobfuscatingTranslator.translate(this.entry); - } - - public boolean isImplemented() { - return this.isImplemented; - } - - @Override - public String toString() { - String className = getDeobfClassName(); - if (className == null) { - className = this.entry.getClassName(); - } - - if (!this.isImplemented) { - return className; - } else { - String methodName = getDeobfMethodName(); - if (methodName == null) { - methodName = this.entry.getName(); - } - return className + "." + methodName + "()"; - } - } - - public void load(JarIndex index, boolean recurse) { - // get all the child nodes - List nodes = Lists.newArrayList(); - for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(this.entry.getClassEntry())) { - MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getSignature() - ); - nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfBehavior(methodEntry) - )); - } - - // add them to this node - nodes.forEach(this::add); - - if (recurse) { - for (MethodInheritanceTreeNode node : nodes) { - node.load(index, true); - } - } - } - - public static MethodInheritanceTreeNode findNode(MethodInheritanceTreeNode node, MethodEntry entry) { - // is this the node? - if (node.getMethodEntry().equals(entry)) { - return node; - } - - // recurse - for (int i = 0; i < node.getChildCount(); i++) { - MethodInheritanceTreeNode foundNode = findNode((MethodInheritanceTreeNode) node.getChildAt(i), entry); - if (foundNode != null) { - return foundNode; - } - } - return null; - } + private Translator deobfuscatingTranslator; + private MethodEntry entry; + private boolean isImplemented; + + public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { + this.deobfuscatingTranslator = deobfuscatingTranslator; + this.entry = entry; + this.isImplemented = isImplemented; + } + + public static MethodInheritanceTreeNode findNode(MethodInheritanceTreeNode node, MethodEntry entry) { + // is this the node? + if (node.getMethodEntry().equals(entry)) { + return node; + } + + // recurse + for (int i = 0; i < node.getChildCount(); i++) { + MethodInheritanceTreeNode foundNode = findNode((MethodInheritanceTreeNode) node.getChildAt(i), entry); + if (foundNode != null) { + return foundNode; + } + } + return null; + } + + public MethodEntry getMethodEntry() { + return this.entry; + } + + public String getDeobfClassName() { + return this.deobfuscatingTranslator.translateClass(this.entry.getClassName()); + } + + public String getDeobfMethodName() { + return this.deobfuscatingTranslator.translate(this.entry); + } + + public boolean isImplemented() { + return this.isImplemented; + } + + @Override + public String toString() { + String className = getDeobfClassName(); + if (className == null) { + className = this.entry.getClassName(); + } + + if (!this.isImplemented) { + return className; + } else { + String methodName = getDeobfMethodName(); + if (methodName == null) { + methodName = this.entry.getName(); + } + return className + "." + methodName + "()"; + } + } + + public void load(JarIndex index, boolean recurse) { + // get all the child nodes + List nodes = Lists.newArrayList(); + for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(this.entry.getClassEntry())) { + MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getSignature() + ); + nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfBehavior(methodEntry) + )); + } + + // add them to this node + nodes.forEach(this::add); + + if (recurse) { + for (MethodInheritanceTreeNode node : nodes) { + node.load(index, true); + } + } + } } -- cgit v1.2.3