diff options
| author | 2019-01-24 14:48:32 +0200 | |
|---|---|---|
| committer | 2019-01-24 13:48:32 +0100 | |
| commit | 00fcd0550fcdda621c2e4662f6ddd55ce673b931 (patch) | |
| tree | 6f9e4c24dbcc6d118fceec56adf7bf9d747a485c /src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java | |
| parent | mark as 0.13.0-SNAPSHOT for preliminary development (diff) | |
| download | enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.gz enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.xz enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.zip | |
[WIP] Mapping rework (#91)
* Move packages
* Mapping & entry refactor: first pass
* Fix deobf -> obf tree remapping
* Resolve various issues
* Give all entries the potential for parents and treat inner classes as children
* Deobf UI tree elements
* Tests pass
* Sort mapping output
* Fix delta tracking
* Index separation and first pass for #97
* Keep track of remapped jar index
* Fix child entries not being remapped
* Drop non-root entries
* Track dropped mappings
* Fix enigma mapping ordering
* EntryTreeNode interface
* Small tweaks
* Naive full index remap on rename
* Entries can resolve to more than one root entry
* Support alternative resolution strategies
* Bridge method resolution
* Tests pass
* Fix mappings being used where there are none
* Fix methods with different descriptors being considered unique. closes #89
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java index e876bb0..0fc44ca 100644 --- a/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/ClassImplementationsTreeNode.java | |||
| @@ -12,26 +12,28 @@ | |||
| 12 | package cuchaz.enigma.analysis; | 12 | package cuchaz.enigma.analysis; |
| 13 | 13 | ||
| 14 | import com.google.common.collect.Lists; | 14 | import com.google.common.collect.Lists; |
| 15 | import cuchaz.enigma.mapping.entry.ClassEntry; | 15 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 16 | import cuchaz.enigma.mapping.entry.MethodEntry; | 16 | import cuchaz.enigma.analysis.index.JarIndex; |
| 17 | import cuchaz.enigma.mapping.Translator; | 17 | import cuchaz.enigma.translation.Translator; |
| 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 19 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 18 | 20 | ||
| 19 | import javax.swing.tree.DefaultMutableTreeNode; | 21 | import javax.swing.tree.DefaultMutableTreeNode; |
| 22 | import java.util.Collection; | ||
| 20 | import java.util.List; | 23 | import java.util.List; |
| 21 | 24 | ||
| 22 | public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | 25 | public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { |
| 23 | 26 | private final Translator translator; | |
| 24 | private final Translator deobfuscatingTranslator; | ||
| 25 | private final ClassEntry entry; | 27 | private final ClassEntry entry; |
| 26 | 28 | ||
| 27 | public ClassImplementationsTreeNode(Translator deobfuscatingTranslator, ClassEntry entry) { | 29 | public ClassImplementationsTreeNode(Translator translator, ClassEntry entry) { |
| 28 | this.deobfuscatingTranslator = deobfuscatingTranslator; | 30 | this.translator = translator; |
| 29 | this.entry = entry; | 31 | this.entry = entry; |
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { | 34 | public static ClassImplementationsTreeNode findNode(ClassImplementationsTreeNode node, MethodEntry entry) { |
| 33 | // is this the node? | 35 | // is this the node? |
| 34 | if (node.entry.equals(entry.getOwnerClassEntry())) { | 36 | if (node.entry.equals(entry.getParent())) { |
| 35 | return node; | 37 | return node; |
| 36 | } | 38 | } |
| 37 | 39 | ||
| @@ -49,24 +51,19 @@ public class ClassImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 49 | return this.entry; | 51 | return this.entry; |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | public String getDeobfClassName() { | ||
| 53 | return this.deobfuscatingTranslator.getTranslatedClass(entry).getClassName(); | ||
| 54 | } | ||
| 55 | |||
| 56 | @Override | 54 | @Override |
| 57 | public String toString() { | 55 | public String toString() { |
| 58 | String className = getDeobfClassName(); | 56 | return translator.translate(entry).toString(); |
| 59 | if (className == null) { | ||
| 60 | className = this.entry.getClassName(); | ||
| 61 | } | ||
| 62 | return className; | ||
| 63 | } | 57 | } |
| 64 | 58 | ||
| 65 | public void load(JarIndex index) { | 59 | public void load(JarIndex index) { |
| 66 | // get all method implementations | 60 | // get all method implementations |
| 67 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); | 61 | List<ClassImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 68 | for (String implementingClassName : index.getImplementingClasses(this.entry.getClassName())) { | 62 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); |
| 69 | nodes.add(new ClassImplementationsTreeNode(this.deobfuscatingTranslator, new ClassEntry(implementingClassName))); | 63 | |
| 64 | Collection<ClassEntry> inheritors = inheritanceIndex.getChildren(entry); | ||
| 65 | for (ClassEntry inheritor : inheritors) { | ||
| 66 | nodes.add(new ClassImplementationsTreeNode(translator, inheritor)); | ||
| 70 | } | 67 | } |
| 71 | 68 | ||
| 72 | // add them to this node | 69 | // add them to this node |