diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java deleted file mode 100644 index 0fc44ca..0000000 --- a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java +++ /dev/null | |||
| @@ -1,72 +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 com.google.common.collect.Lists; | ||
| 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 | import java.util.Collection; | ||
| 23 | import java.util.List; | ||
| 24 | |||
| 25 | public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | ||
| 26 | private final Translator translator; | ||
| 27 | private final ClassEntry entry; | ||
| 28 | |||
| 29 | public ClassImplementationsTreeNode(Translator translator, ClassEntry entry) { | ||
| 30 | this.translator = translator; | ||
| 31 | this.entry = entry; | ||
| 32 | } | ||
| 33 | |||
| 34 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { | ||
| 35 | // is this the node? | ||
| 36 | if (node.entry.equals(entry.getParent())) { | ||
| 37 | return node; | ||
| 38 | } | ||
| 39 | |||
| 40 | // recurse | ||
| 41 | for (int i = 0; i < node.getChildCount(); i++) { | ||
| 42 | ClassImplementationsTreeNode foundNode = findNode((ClassImplementationsTreeNode) node.getChildAt(i), entry); | ||
| 43 | if (foundNode != null) { | ||
| 44 | return foundNode; | ||
| 45 | } | ||
| 46 | } | ||
| 47 | return null; | ||
| 48 | } | ||
| 49 | |||
| 50 | public ClassEntry getClassEntry() { | ||
| 51 | return this.entry; | ||
| 52 | } | ||
| 53 | |||
| 54 | @Override | ||
| 55 | public String toString() { | ||
| 56 | return translator.translate(entry).toString(); | ||
| 57 | } | ||
| 58 | |||
| 59 | public void load(JarIndex index) { | ||
| 60 | // get all method implementations | ||
| 61 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); | ||
| 62 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); | ||
| 63 | |||
| 64 | Collection<ClassEntry> inheritors = inheritanceIndex.getChildren(entry); | ||
| 65 | for (ClassEntry inheritor : inheritors) { | ||
| 66 | nodes.add(new ClassImplementationsTreeNode(translator, inheritor)); | ||
| 67 | } | ||
| 68 | |||
| 69 | // add them to this node | ||
| 70 | nodes.forEach(this::add); | ||
| 71 | } | ||
| 72 | } | ||