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/MethodImplementationsTreeNode.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/MethodImplementationsTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java index 4b47c5f..e4b0304 100644 --- a/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/MethodImplementationsTreeNode.java | |||
| @@ -12,24 +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.EntryIndex; |
| 16 | import cuchaz.enigma.mapping.entry.MethodEntry; | 16 | import cuchaz.enigma.analysis.index.InheritanceIndex; |
| 17 | import cuchaz.enigma.mapping.Translator; | 17 | import cuchaz.enigma.analysis.index.JarIndex; |
| 18 | import cuchaz.enigma.translation.Translator; | ||
| 19 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 20 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 18 | 21 | ||
| 19 | import javax.swing.tree.DefaultMutableTreeNode; | 22 | import javax.swing.tree.DefaultMutableTreeNode; |
| 23 | import java.util.Collection; | ||
| 20 | import java.util.List; | 24 | import java.util.List; |
| 21 | 25 | ||
| 22 | public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | 26 | public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { |
| 23 | 27 | ||
| 24 | private Translator deobfuscatingTranslator; | 28 | private final Translator translator; |
| 25 | private MethodEntry entry; | 29 | private MethodEntry entry; |
| 26 | 30 | ||
| 27 | public MethodImplementationsTreeNode(Translator deobfuscatingTranslator, MethodEntry entry) { | 31 | public MethodImplementationsTreeNode(Translator translator, MethodEntry entry) { |
| 32 | this.translator = translator; | ||
| 28 | if (entry == null) { | 33 | if (entry == null) { |
| 29 | throw new IllegalArgumentException("Entry cannot be null!"); | 34 | throw new IllegalArgumentException("Entry cannot be null!"); |
| 30 | } | 35 | } |
| 31 | 36 | ||
| 32 | this.deobfuscatingTranslator = deobfuscatingTranslator; | ||
| 33 | this.entry = entry; | 37 | this.entry = entry; |
| 34 | } | 38 | } |
| 35 | 39 | ||
| @@ -53,35 +57,25 @@ public class MethodImplementationsTreeNode extends DefaultMutableTreeNode { | |||
| 53 | return this.entry; | 57 | return this.entry; |
| 54 | } | 58 | } |
| 55 | 59 | ||
| 56 | public String getDeobfClassName() { | ||
| 57 | return this.deobfuscatingTranslator.getTranslatedClass(this.entry.getOwnerClassEntry()).getClassName(); | ||
| 58 | } | ||
| 59 | |||
| 60 | public String getDeobfMethodName() { | ||
| 61 | return this.deobfuscatingTranslator.getTranslatedMethod(this.entry).getName(); | ||
| 62 | } | ||
| 63 | |||
| 64 | @Override | 60 | @Override |
| 65 | public String toString() { | 61 | public String toString() { |
| 66 | String className = getDeobfClassName(); | 62 | MethodEntry translatedEntry = translator.translate(entry); |
| 67 | if (className == null) { | 63 | String className = translatedEntry.getParent().getFullName(); |
| 68 | className = this.entry.getClassName(); | 64 | String methodName = translatedEntry.getName(); |
| 69 | } | ||
| 70 | |||
| 71 | String methodName = getDeobfMethodName(); | ||
| 72 | if (methodName == null) { | ||
| 73 | methodName = this.entry.getName(); | ||
| 74 | } | ||
| 75 | return className + "." + methodName + "()"; | 65 | return className + "." + methodName + "()"; |
| 76 | } | 66 | } |
| 77 | 67 | ||
| 78 | public void load(JarIndex index) { | 68 | public void load(JarIndex index) { |
| 79 | // get all method implementations | 69 | // get all method implementations |
| 80 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); | 70 | List<MethodImplementationsTreeNode> nodes = Lists.newArrayList(); |
| 81 | for (String implementingClassName : index.getImplementingClasses(this.entry.getClassName())) { | 71 | EntryIndex entryIndex = index.getEntryIndex(); |
| 82 | MethodEntry methodEntry = new MethodEntry(new ClassEntry(implementingClassName), this.entry.getName(), this.entry.getDesc()); | 72 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); |
| 83 | if (index.containsObfMethod(methodEntry)) { | 73 | |
| 84 | nodes.add(new MethodImplementationsTreeNode(this.deobfuscatingTranslator, methodEntry)); | 74 | Collection<ClassEntry> inheritors = inheritanceIndex.getChildren(entry.getParent()); |
| 75 | for (ClassEntry inheritor : inheritors) { | ||
| 76 | MethodEntry methodEntry = entry.withParent(inheritor); | ||
| 77 | if (entryIndex.hasMethod(methodEntry)) { | ||
| 78 | nodes.add(new MethodImplementationsTreeNode(translator, methodEntry)); | ||
| 85 | } | 79 | } |
| 86 | } | 80 | } |
| 87 | 81 | ||