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/MethodInheritanceTreeNode.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/MethodInheritanceTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java index dc34197..f0fd1d2 100644 --- a/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java +++ b/src/main/java/cuchaz/enigma/analysis/MethodInheritanceTreeNode.java | |||
| @@ -12,21 +12,24 @@ | |||
| 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; |
| 20 | import java.util.List; | 23 | import java.util.List; |
| 21 | 24 | ||
| 22 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | 25 | public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { |
| 23 | 26 | ||
| 24 | private Translator deobfuscatingTranslator; | 27 | private final Translator translator; |
| 25 | private MethodEntry entry; | 28 | private MethodEntry entry; |
| 26 | private boolean isImplemented; | 29 | private boolean isImplemented; |
| 27 | 30 | ||
| 28 | public MethodInheritanceTreeNode(Translator deobfuscatingTranslator, MethodEntry entry, boolean isImplemented) { | 31 | public MethodInheritanceTreeNode(Translator translator, MethodEntry entry, boolean isImplemented) { |
| 29 | this.deobfuscatingTranslator = deobfuscatingTranslator; | 32 | this.translator = translator; |
| 30 | this.entry = entry; | 33 | this.entry = entry; |
| 31 | this.isImplemented = isImplemented; | 34 | this.isImplemented = isImplemented; |
| 32 | } | 35 | } |
| @@ -51,32 +54,19 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 51 | return this.entry; | 54 | return this.entry; |
| 52 | } | 55 | } |
| 53 | 56 | ||
| 54 | public String getDeobfClassName() { | ||
| 55 | return this.deobfuscatingTranslator.getTranslatedClass(this.entry.getOwnerClassEntry()).getName(); | ||
| 56 | } | ||
| 57 | |||
| 58 | public String getDeobfMethodName() { | ||
| 59 | return this.deobfuscatingTranslator.getTranslatedMethod(this.entry).getName(); | ||
| 60 | } | ||
| 61 | |||
| 62 | public boolean isImplemented() { | 57 | public boolean isImplemented() { |
| 63 | return this.isImplemented; | 58 | return this.isImplemented; |
| 64 | } | 59 | } |
| 65 | 60 | ||
| 66 | @Override | 61 | @Override |
| 67 | public String toString() { | 62 | public String toString() { |
| 68 | String className = getDeobfClassName(); | 63 | MethodEntry translatedEntry = translator.translate(entry); |
| 69 | if (className == null) { | 64 | String className = translatedEntry.getContainingClass().getFullName(); |
| 70 | className = this.entry.getClassName(); | ||
| 71 | } | ||
| 72 | 65 | ||
| 73 | if (!this.isImplemented) { | 66 | if (!this.isImplemented) { |
| 74 | return className; | 67 | return className; |
| 75 | } else { | 68 | } else { |
| 76 | String methodName = getDeobfMethodName(); | 69 | String methodName = translatedEntry.getName(); |
| 77 | if (methodName == null) { | ||
| 78 | methodName = this.entry.getName(); | ||
| 79 | } | ||
| 80 | return className + "." + methodName + "()"; | 70 | return className + "." + methodName + "()"; |
| 81 | } | 71 | } |
| 82 | } | 72 | } |
| @@ -84,14 +74,12 @@ public class MethodInheritanceTreeNode extends DefaultMutableTreeNode { | |||
| 84 | public void load(JarIndex index, boolean recurse) { | 74 | public void load(JarIndex index, boolean recurse) { |
| 85 | // get all the child nodes | 75 | // get all the child nodes |
| 86 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); | 76 | List<MethodInheritanceTreeNode> nodes = Lists.newArrayList(); |
| 87 | for (ClassEntry subclassEntry : index.getTranslationIndex().getSubclass(this.entry.getOwnerClassEntry())) { | 77 | EntryIndex entryIndex = index.getEntryIndex(); |
| 88 | MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getDesc()); | 78 | InheritanceIndex inheritanceIndex = index.getInheritanceIndex(); |
| 89 | nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfMethod(methodEntry))); | ||
| 90 | } | ||
| 91 | 79 | ||
| 92 | for (ClassEntry subclassEntry : index.getTranslationIndex().getImplementers(this.entry.getOwnerClassEntry())) { | 80 | for (ClassEntry inheritorEntry : inheritanceIndex.getChildren(this.entry.getParent())) { |
| 93 | MethodEntry methodEntry = new MethodEntry(subclassEntry, this.entry.getName(), this.entry.getDesc()); | 81 | MethodEntry methodEntry = new MethodEntry(inheritorEntry, this.entry.getName(), this.entry.getDesc()); |
| 94 | nodes.add(new MethodInheritanceTreeNode(this.deobfuscatingTranslator, methodEntry, index.containsObfMethod(methodEntry))); | 82 | nodes.add(new MethodInheritanceTreeNode(translator, methodEntry, entryIndex.hasMethod(methodEntry))); |
| 95 | } | 83 | } |
| 96 | 84 | ||
| 97 | // add them to this node | 85 | // add them to this node |