diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java deleted file mode 100644 index e77b5cc..0000000 --- a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ /dev/null | |||
| @@ -1,95 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma.analysis; | ||
| 13 | |||
| 14 | import cuchaz.enigma.analysis.index.EntryIndex; | ||
| 15 | import cuchaz.enigma.analysis.index.InheritanceIndex; | ||
| 16 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 17 | import cuchaz.enigma.translation.Translator; | ||
| 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 20 | |||
| 21 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 22 | |||
| 23 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | ||
| 24 | |||
| 25 | private final Translator translator; | ||
| 26 | private MethodEntry entry; | ||
| 27 | private boolean implemented; | ||
| 28 | |||
| 29 | public MethodInheritanceTreeNode(Translator translator, MethodEntry entry, boolean implemented) { | ||
| 30 | this.translator = translator; | ||
| 31 | this.entry = entry; | ||
| 32 | this.implemented = implemented; | ||
| 33 | } | ||
| 34 | |||
| 35 | public static MethodInheritanceTreeNode findNode(MethodInheritanceTreeNode node, MethodEntry entry) { | ||
| 36 | // is this the node? | ||
| 37 | if (node.getMethodEntry().equals(entry)) { | ||
| 38 | return node; | ||
| 39 | } | ||
| 40 | |||
| 41 | // recurse | ||
| 42 | for (int i = 0; i < node.getChildCount(); i++) { | ||
| 43 | MethodInheritanceTreeNode foundNode = findNode((MethodInheritanceTreeNode) node.getChildAt(i), entry); | ||
| 44 | if (foundNode != null) { | ||
| 45 | return foundNode; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | return null; | ||
| 49 | } | ||
| 50 | |||
| 51 | public MethodEntry getMethodEntry() { | ||
| 52 | return this.entry; | ||
| 53 | } | ||
| 54 | |||
| 55 | public boolean isImplemented() { | ||
| 56 | return this.implemented; | ||
| 57 | } | ||
| 58 | |||
| 59 | @Override | ||
| 60 | public String toString() { | ||
| 61 | MethodEntry translatedEntry = translator.translate(entry); | ||
| 62 | String className = translatedEntry.getContainingClass().getFullName(); | ||
| 63 | |||
| 64 | if (!this.implemented) { | ||
| 65 | return className; | ||
| 66 | } else { | ||
| 67 | String methodName = translatedEntry.getName(); | ||
| 68 | return className + "." + methodName + "()"; | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Returns true if there is sub-node worthy to display. | ||
| 74 | */ | ||
| 75 | public boolean load(JarIndex index) { | ||
| 76 | // get all the child nodes | ||
| 77 | EntryIndex entryIndex = index.getEntryIndex(); | ||
| 78 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); | ||
| 79 | |||
| 80 | boolean ret = false; | ||
| 81 | for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) { | ||
| 82 | MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.entry.getName(), this.entry.getDesc()); | ||
| 83 | |||
| 84 | MethodInheritanceTreeNode node = new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry)); | ||
| 85 | boolean childOverride = node.load(index); | ||
| 86 | |||
| 87 | if (childOverride || node.implemented) { | ||
| 88 | this.add(node); | ||
| 89 | ret = true; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | return ret; | ||
| 94 | } | ||
| 95 | } | ||