diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java b/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java deleted file mode 100644 index 0c2dfd7..0000000 --- a/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 1 | package cuchaz.enigma.analysis; | ||
| 2 | |||
| 3 | import com.google.common.collect.Lists; | ||
| 4 | import cuchaz.enigma.analysis.index.JarIndex; | ||
| 5 | import cuchaz.enigma.translation.Translator; | ||
| 6 | import cuchaz.enigma.translation.mapping.EntryResolver; | ||
| 7 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; | ||
| 8 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 9 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 10 | |||
| 11 | import java.util.Collection; | ||
| 12 | import java.util.List; | ||
| 13 | |||
| 14 | public class IndexTreeBuilder { | ||
| 15 | private final JarIndex index; | ||
| 16 | |||
| 17 | public IndexTreeBuilder(JarIndex index) { | ||
| 18 | this.index = index; | ||
| 19 | } | ||
| 20 | |||
| 21 | public ClassInheritanceTreeNode buildClassInheritance(Translator translator, ClassEntry obfClassEntry) { | ||
| 22 | // get the root node | ||
| 23 | List<String> ancestry = Lists.newArrayList(); | ||
| 24 | ancestry.add(obfClassEntry.getFullName()); | ||
| 25 | for (ClassEntry classEntry : index.getInheritanceIndex().getAncestors(obfClassEntry)) { | ||
| 26 | ancestry.add(classEntry.getFullName()); | ||
| 27 | } | ||
| 28 | |||
| 29 | ClassInheritanceTreeNode rootNode = new ClassInheritanceTreeNode(translator, ancestry.get(ancestry.size() - 1)); | ||
| 30 | |||
| 31 | // expand all children recursively | ||
| 32 | rootNode.load(index.getInheritanceIndex(), true); | ||
| 33 | |||
| 34 | return rootNode; | ||
| 35 | } | ||
| 36 | |||
| 37 | public ClassImplementationsTreeNode buildClassImplementations(Translator translator, ClassEntry obfClassEntry) { | ||
| 38 | if (index.getInheritanceIndex().isParent(obfClassEntry)) { | ||
| 39 | ClassImplementationsTreeNode node = new ClassImplementationsTreeNode(translator, obfClassEntry); | ||
| 40 | node.load(index); | ||
| 41 | return node; | ||
| 42 | } | ||
| 43 | return null; | ||
| 44 | } | ||
| 45 | |||
| 46 | public MethodInheritanceTreeNode buildMethodInheritance(Translator translator, MethodEntry obfMethodEntry) { | ||
| 47 | MethodEntry resolvedEntry = index.getEntryResolver().resolveFirstEntry(obfMethodEntry, ResolutionStrategy.RESOLVE_ROOT); | ||
| 48 | |||
| 49 | // make a root node at the base | ||
| 50 | MethodInheritanceTreeNode rootNode = new MethodInheritanceTreeNode( | ||
| 51 | translator, resolvedEntry, | ||
| 52 | index.getEntryIndex().hasMethod(resolvedEntry) | ||
| 53 | ); | ||
| 54 | |||
| 55 | // expand the full tree | ||
| 56 | rootNode.load(index); | ||
| 57 | |||
| 58 | return rootNode; | ||
| 59 | } | ||
| 60 | |||
| 61 | public List<MethodImplementationsTreeNode> buildMethodImplementations(Translator translator, MethodEntry obfMethodEntry) { | ||
| 62 | EntryResolver resolver = index.getEntryResolver(); | ||
| 63 | Collection<MethodEntry> resolvedEntries = resolver.resolveEntry(obfMethodEntry, ResolutionStrategy.RESOLVE_ROOT); | ||
| 64 | |||
| 65 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); | ||
| 66 | for (MethodEntry resolvedEntry : resolvedEntries) { | ||
| 67 | MethodImplementationsTreeNode node = new MethodImplementationsTreeNode(translator, resolvedEntry); | ||
| 68 | node.load(index); | ||
| 69 | nodes.add(node); | ||
| 70 | } | ||
| 71 | |||
| 72 | return nodes; | ||
| 73 | } | ||
| 74 | } | ||