diff options
| author | 2019-01-30 21:05:32 +0200 | |
|---|---|---|
| committer | 2019-01-30 21:05:32 +0200 | |
| commit | ba7a354efae7d49833c887cf147ac940c975a1fa (patch) | |
| tree | 02e14fda81dd5984e24f2df392c57c6e829fc875 /src/main/java/cuchaz/enigma/analysis/index | |
| parent | Rewrite the Jenkinsfile to use the new declarative pipeline syntax, lets hope... (diff) | |
| download | enigma-fork-ba7a354efae7d49833c887cf147ac940c975a1fa.tar.gz enigma-fork-ba7a354efae7d49833c887cf147ac940c975a1fa.tar.xz enigma-fork-ba7a354efae7d49833c887cf147ac940c975a1fa.zip | |
Remap sources (#106)
* Source remapping beginnings
* Fix navigation to remapped classes
* Translate identifier info reference
* Remap local variables with default names in source
* Caching translator
* Fix lack of highlighting for first opened class
* Fix unicode variable names
* Unicode checker shouldn't be checking just alphanumeric
* Fix package tree being built from obf names
* Don't index `this` as method call for method::reference
* Apply proposed names
* Fix source export issues
* Replace unicode var names at bytecode level uniquely
* Drop imports from editor source
* Class selector fixes
* Delta keep track of base mappings to enable lookup of old names
* Optimize source remapping by remapping source with a StringBuffer instead of copying
* Bump version
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/index')
5 files changed, 4 insertions, 81 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java b/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java index e1903d9..8f6bd46 100644 --- a/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/index/BridgeMethodIndex.java | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | package cuchaz.enigma.analysis.index; | 1 | package cuchaz.enigma.analysis.index; |
| 2 | 2 | ||
| 3 | import com.google.common.collect.Maps; | 3 | import com.google.common.collect.Maps; |
| 4 | import cuchaz.enigma.translation.Translator; | ||
| 5 | import cuchaz.enigma.translation.mapping.EntryResolver; | 4 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 6 | import cuchaz.enigma.translation.representation.AccessFlags; | 5 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 7 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 6 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| @@ -10,7 +9,7 @@ import javax.annotation.Nullable; | |||
| 10 | import java.util.Collection; | 9 | import java.util.Collection; |
| 11 | import java.util.Map; | 10 | import java.util.Map; |
| 12 | 11 | ||
| 13 | public class BridgeMethodIndex implements JarIndexer, RemappableIndex { | 12 | public class BridgeMethodIndex implements JarIndexer { |
| 14 | private final EntryIndex entryIndex; | 13 | private final EntryIndex entryIndex; |
| 15 | private final ReferenceIndex referenceIndex; | 14 | private final ReferenceIndex referenceIndex; |
| 16 | 15 | ||
| @@ -22,19 +21,6 @@ public class BridgeMethodIndex implements JarIndexer, RemappableIndex { | |||
| 22 | } | 21 | } |
| 23 | 22 | ||
| 24 | @Override | 23 | @Override |
| 25 | public void remap(Translator translator) { | ||
| 26 | accessedToBridge = translator.translate(accessedToBridge); | ||
| 27 | } | ||
| 28 | |||
| 29 | @Override | ||
| 30 | public BridgeMethodIndex remapped(Translator translator) { | ||
| 31 | BridgeMethodIndex index = new BridgeMethodIndex(entryIndex, referenceIndex); | ||
| 32 | index.accessedToBridge = translator.translate(accessedToBridge); | ||
| 33 | |||
| 34 | return index; | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | public void processIndex(EntryResolver resolver) { | 24 | public void processIndex(EntryResolver resolver) { |
| 39 | // look for access and bridged methods | 25 | // look for access and bridged methods |
| 40 | for (MethodEntry methodEntry : entryIndex.getMethods()) { | 26 | for (MethodEntry methodEntry : entryIndex.getMethods()) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/index/EntryIndex.java b/src/main/java/cuchaz/enigma/analysis/index/EntryIndex.java index 55bfbc2..773eaf1 100644 --- a/src/main/java/cuchaz/enigma/analysis/index/EntryIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/index/EntryIndex.java | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | package cuchaz.enigma.analysis.index; | 1 | package cuchaz.enigma.analysis.index; |
| 2 | 2 | ||
| 3 | import cuchaz.enigma.translation.Translator; | ||
| 4 | import cuchaz.enigma.translation.representation.AccessFlags; | 3 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 5 | import cuchaz.enigma.translation.representation.entry.*; | 4 | import cuchaz.enigma.translation.representation.entry.*; |
| 6 | 5 | ||
| @@ -9,29 +8,12 @@ import java.util.Collection; | |||
| 9 | import java.util.HashMap; | 8 | import java.util.HashMap; |
| 10 | import java.util.Map; | 9 | import java.util.Map; |
| 11 | 10 | ||
| 12 | public class EntryIndex implements JarIndexer, RemappableIndex { | 11 | public class EntryIndex implements JarIndexer { |
| 13 | private Map<ClassEntry, AccessFlags> classes = new HashMap<>(); | 12 | private Map<ClassEntry, AccessFlags> classes = new HashMap<>(); |
| 14 | private Map<FieldEntry, AccessFlags> fields = new HashMap<>(); | 13 | private Map<FieldEntry, AccessFlags> fields = new HashMap<>(); |
| 15 | private Map<MethodEntry, AccessFlags> methods = new HashMap<>(); | 14 | private Map<MethodEntry, AccessFlags> methods = new HashMap<>(); |
| 16 | 15 | ||
| 17 | @Override | 16 | @Override |
| 18 | public void remap(Translator translator) { | ||
| 19 | classes = translator.translateKeys(classes); | ||
| 20 | fields = translator.translateKeys(fields); | ||
| 21 | methods = translator.translateKeys(methods); | ||
| 22 | } | ||
| 23 | |||
| 24 | @Override | ||
| 25 | public EntryIndex remapped(Translator translator) { | ||
| 26 | EntryIndex index = new EntryIndex(); | ||
| 27 | index.classes = translator.translateKeys(classes); | ||
| 28 | index.fields = translator.translateKeys(fields); | ||
| 29 | index.methods = translator.translateKeys(methods); | ||
| 30 | |||
| 31 | return index; | ||
| 32 | } | ||
| 33 | |||
| 34 | @Override | ||
| 35 | public void indexClass(ClassDefEntry classEntry) { | 17 | public void indexClass(ClassDefEntry classEntry) { |
| 36 | classes.put(classEntry, classEntry.getAccess()); | 18 | classes.put(classEntry, classEntry.getAccess()); |
| 37 | } | 19 | } |
diff --git a/src/main/java/cuchaz/enigma/analysis/index/InheritanceIndex.java b/src/main/java/cuchaz/enigma/analysis/index/InheritanceIndex.java index d165cc8..17bed54 100644 --- a/src/main/java/cuchaz/enigma/analysis/index/InheritanceIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/index/InheritanceIndex.java | |||
| @@ -14,7 +14,6 @@ package cuchaz.enigma.analysis.index; | |||
| 14 | import com.google.common.collect.HashMultimap; | 14 | import com.google.common.collect.HashMultimap; |
| 15 | import com.google.common.collect.Multimap; | 15 | import com.google.common.collect.Multimap; |
| 16 | import com.google.common.collect.Sets; | 16 | import com.google.common.collect.Sets; |
| 17 | import cuchaz.enigma.translation.Translator; | ||
| 18 | import cuchaz.enigma.translation.representation.entry.ClassDefEntry; | 17 | import cuchaz.enigma.translation.representation.entry.ClassDefEntry; |
| 19 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 18 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 20 | 19 | ||
| @@ -22,26 +21,11 @@ import java.util.Collection; | |||
| 22 | import java.util.LinkedList; | 21 | import java.util.LinkedList; |
| 23 | import java.util.Set; | 22 | import java.util.Set; |
| 24 | 23 | ||
| 25 | public class InheritanceIndex implements JarIndexer, RemappableIndex { | 24 | public class InheritanceIndex implements JarIndexer { |
| 26 | private Multimap<ClassEntry, ClassEntry> classParents = HashMultimap.create(); | 25 | private Multimap<ClassEntry, ClassEntry> classParents = HashMultimap.create(); |
| 27 | private Multimap<ClassEntry, ClassEntry> classChildren = HashMultimap.create(); | 26 | private Multimap<ClassEntry, ClassEntry> classChildren = HashMultimap.create(); |
| 28 | 27 | ||
| 29 | @Override | 28 | @Override |
| 30 | public void remap(Translator translator) { | ||
| 31 | classChildren = translator.translate(classChildren); | ||
| 32 | classParents = translator.translate(classParents); | ||
| 33 | } | ||
| 34 | |||
| 35 | @Override | ||
| 36 | public InheritanceIndex remapped(Translator translator) { | ||
| 37 | InheritanceIndex index = new InheritanceIndex(); | ||
| 38 | index.classParents = translator.translate(classParents); | ||
| 39 | index.classChildren = translator.translate(classChildren); | ||
| 40 | |||
| 41 | return index; | ||
| 42 | } | ||
| 43 | |||
| 44 | @Override | ||
| 45 | public void indexClass(ClassDefEntry classEntry) { | 29 | public void indexClass(ClassDefEntry classEntry) { |
| 46 | ClassEntry superClass = classEntry.getSuperClass(); | 30 | ClassEntry superClass = classEntry.getSuperClass(); |
| 47 | if (superClass != null) { | 31 | if (superClass != null) { |
diff --git a/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java b/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java index 0880244..9b21cba 100644 --- a/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java +++ b/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java | |||
| @@ -14,7 +14,6 @@ package cuchaz.enigma.analysis.index; | |||
| 14 | import com.google.common.collect.HashMultimap; | 14 | import com.google.common.collect.HashMultimap; |
| 15 | import com.google.common.collect.Multimap; | 15 | import com.google.common.collect.Multimap; |
| 16 | import cuchaz.enigma.analysis.ParsedJar; | 16 | import cuchaz.enigma.analysis.ParsedJar; |
| 17 | import cuchaz.enigma.translation.Translator; | ||
| 18 | import cuchaz.enigma.translation.mapping.EntryResolver; | 17 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 19 | import cuchaz.enigma.translation.mapping.IndexEntryResolver; | 18 | import cuchaz.enigma.translation.mapping.IndexEntryResolver; |
| 20 | import cuchaz.enigma.translation.representation.entry.*; | 19 | import cuchaz.enigma.translation.representation.entry.*; |
| @@ -25,7 +24,7 @@ import java.util.Arrays; | |||
| 25 | import java.util.Collection; | 24 | import java.util.Collection; |
| 26 | import java.util.function.Consumer; | 25 | import java.util.function.Consumer; |
| 27 | 26 | ||
| 28 | public class JarIndex implements JarIndexer, RemappableIndex { | 27 | public class JarIndex implements JarIndexer { |
| 29 | private final EntryIndex entryIndex; | 28 | private final EntryIndex entryIndex; |
| 30 | private final InheritanceIndex inheritanceIndex; | 29 | private final InheritanceIndex inheritanceIndex; |
| 31 | private final ReferenceIndex referenceIndex; | 30 | private final ReferenceIndex referenceIndex; |
| @@ -53,25 +52,6 @@ public class JarIndex implements JarIndexer, RemappableIndex { | |||
| 53 | return new JarIndex(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex); | 52 | return new JarIndex(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex); |
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | @Override | ||
| 57 | public void remap(Translator translator) { | ||
| 58 | entryIndex.remap(translator); | ||
| 59 | inheritanceIndex.remap(translator); | ||
| 60 | bridgeMethodIndex.remap(translator); | ||
| 61 | } | ||
| 62 | |||
| 63 | @Override | ||
| 64 | public JarIndex remapped(Translator translator) { | ||
| 65 | EntryIndex entryIndex = this.entryIndex.remapped(translator); | ||
| 66 | InheritanceIndex inheritanceIndex = this.inheritanceIndex.remapped(translator); | ||
| 67 | BridgeMethodIndex bridgeMethodIndex = this.bridgeMethodIndex.remapped(translator); | ||
| 68 | |||
| 69 | JarIndex remappedIndex = new JarIndex(entryIndex, inheritanceIndex, this.referenceIndex, bridgeMethodIndex); | ||
| 70 | remappedIndex.methodImplementations.putAll(methodImplementations); | ||
| 71 | |||
| 72 | return remappedIndex; | ||
| 73 | } | ||
| 74 | |||
| 75 | public void indexJar(ParsedJar jar, Consumer<String> progress) { | 55 | public void indexJar(ParsedJar jar, Consumer<String> progress) { |
| 76 | progress.accept("Indexing entries (1/3)"); | 56 | progress.accept("Indexing entries (1/3)"); |
| 77 | jar.visitReader(name -> new IndexClassVisitor(this, Opcodes.ASM5), ClassReader.SKIP_CODE); | 57 | jar.visitReader(name -> new IndexClassVisitor(this, Opcodes.ASM5), ClassReader.SKIP_CODE); |
diff --git a/src/main/java/cuchaz/enigma/analysis/index/RemappableIndex.java b/src/main/java/cuchaz/enigma/analysis/index/RemappableIndex.java deleted file mode 100644 index 537e772..0000000 --- a/src/main/java/cuchaz/enigma/analysis/index/RemappableIndex.java +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | package cuchaz.enigma.analysis.index; | ||
| 2 | |||
| 3 | import cuchaz.enigma.translation.Translator; | ||
| 4 | |||
| 5 | public interface RemappableIndex { | ||
| 6 | void remap(Translator translator); | ||
| 7 | |||
| 8 | RemappableIndex remapped(Translator translator); | ||
| 9 | } | ||