diff options
| author | 2019-02-23 17:04:20 +0200 | |
|---|---|---|
| committer | 2019-02-23 17:04:20 +0200 | |
| commit | 924ab1cfe379d5744d5c864b3236934a037a21ae (patch) | |
| tree | 363ac1384c95565f9d60aaca1382d757ff39a2a5 /src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java | |
| parent | Drop final modifiers from displayed source ast for easier readability (diff) | |
| download | enigma-fork-924ab1cfe379d5744d5c864b3236934a037a21ae.tar.gz enigma-fork-924ab1cfe379d5744d5c864b3236934a037a21ae.tar.xz enigma-fork-924ab1cfe379d5744d5c864b3236934a037a21ae.zip | |
Tweak inheritance and implementation tree generation
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java b/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java index 4ca7cd1..0c2dfd7 100644 --- a/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java +++ b/src/main/java/cuchaz/enigma/analysis/IndexTreeBuilder.java | |||
| @@ -1,13 +1,14 @@ | |||
| 1 | package cuchaz.enigma.analysis; | 1 | package cuchaz.enigma.analysis; |
| 2 | 2 | ||
| 3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
| 4 | import cuchaz.enigma.analysis.index.EntryIndex; | ||
| 5 | import cuchaz.enigma.analysis.index.JarIndex; | 4 | import cuchaz.enigma.analysis.index.JarIndex; |
| 6 | import cuchaz.enigma.translation.Translator; | 5 | import cuchaz.enigma.translation.Translator; |
| 6 | import cuchaz.enigma.translation.mapping.EntryResolver; | ||
| 7 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; | 7 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; |
| 8 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 8 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 9 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 9 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 10 | 10 | ||
| 11 | import java.util.Collection; | ||
| 11 | import java.util.List; | 12 | import java.util.List; |
| 12 | 13 | ||
| 13 | public class IndexTreeBuilder { | 14 | public class IndexTreeBuilder { |
| @@ -52,34 +53,20 @@ public class IndexTreeBuilder { | |||
| 52 | ); | 53 | ); |
| 53 | 54 | ||
| 54 | // expand the full tree | 55 | // expand the full tree |
| 55 | rootNode.load(index, true); | 56 | rootNode.load(index); |
| 56 | 57 | ||
| 57 | return rootNode; | 58 | return rootNode; |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | public List<MethodImplementationsTreeNode> buildMethodImplementations(Translator translator, MethodEntry obfMethodEntry) { | 61 | public List<MethodImplementationsTreeNode> buildMethodImplementations(Translator translator, MethodEntry obfMethodEntry) { |
| 61 | EntryIndex entryIndex = index.getEntryIndex(); | 62 | EntryResolver resolver = index.getEntryResolver(); |
| 62 | 63 | Collection<MethodEntry> resolvedEntries = resolver.resolveEntry(obfMethodEntry, ResolutionStrategy.RESOLVE_ROOT); | |
| 63 | List<MethodEntry> ancestorMethodEntries = Lists.newArrayList(); | ||
| 64 | |||
| 65 | if (entryIndex.hasMethod(obfMethodEntry)) { | ||
| 66 | ancestorMethodEntries.add(obfMethodEntry); | ||
| 67 | } | ||
| 68 | |||
| 69 | for (ClassEntry ancestorEntry : index.getInheritanceIndex().getAncestors(obfMethodEntry.getParent())) { | ||
| 70 | MethodEntry ancestorMethod = obfMethodEntry.withParent(ancestorEntry); | ||
| 71 | if (entryIndex.hasMethod(ancestorMethod)) { | ||
| 72 | ancestorMethodEntries.add(ancestorMethod); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | 64 | ||
| 76 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); | 65 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 77 | if (!ancestorMethodEntries.isEmpty()) { | 66 | for (MethodEntry resolvedEntry : resolvedEntries) { |
| 78 | for (MethodEntry interfaceMethodEntry : ancestorMethodEntries) { | 67 | MethodImplementationsTreeNode node = new MethodImplementationsTreeNode(translator, resolvedEntry); |
| 79 | MethodImplementationsTreeNode node = new MethodImplementationsTreeNode(translator, interfaceMethodEntry); | 68 | node.load(index); |
| 80 | node.load(index); | 69 | nodes.add(node); |
| 81 | nodes.add(node); | ||
| 82 | } | ||
| 83 | } | 70 | } |
| 84 | 71 | ||
| 85 | return nodes; | 72 | return nodes; |