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/EntryReference.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/EntryReference.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/EntryReference.java | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/EntryReference.java b/src/main/java/cuchaz/enigma/analysis/EntryReference.java index df36c23..e122210 100644 --- a/src/main/java/cuchaz/enigma/analysis/EntryReference.java +++ b/src/main/java/cuchaz/enigma/analysis/EntryReference.java | |||
| @@ -11,15 +11,20 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.analysis; | 12 | package cuchaz.enigma.analysis; |
| 13 | 13 | ||
| 14 | import cuchaz.enigma.mapping.entry.ClassEntry; | 14 | import cuchaz.enigma.translation.Translatable; |
| 15 | import cuchaz.enigma.mapping.entry.Entry; | 15 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.mapping.entry.MethodEntry; | 16 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 17 | import cuchaz.enigma.translation.mapping.EntryResolver; | ||
| 18 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 19 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 20 | import cuchaz.enigma.translation.representation.entry.Entry; | ||
| 21 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | ||
| 17 | import cuchaz.enigma.utils.Utils; | 22 | import cuchaz.enigma.utils.Utils; |
| 18 | 23 | ||
| 19 | import java.util.Arrays; | 24 | import java.util.Arrays; |
| 20 | import java.util.List; | 25 | import java.util.List; |
| 21 | 26 | ||
| 22 | public class EntryReference<E extends Entry, C extends Entry> { | 27 | public class EntryReference<E extends Entry<?>, C extends Entry<?>> implements Translatable { |
| 23 | 28 | ||
| 24 | private static final List<String> CONSTRUCTOR_NON_NAMES = Arrays.asList("this", "super", "static"); | 29 | private static final List<String> CONSTRUCTOR_NON_NAMES = Arrays.asList("this", "super", "static"); |
| 25 | public E entry; | 30 | public E entry; |
| @@ -53,32 +58,24 @@ public class EntryReference<E extends Entry, C extends Entry> { | |||
| 53 | 58 | ||
| 54 | public ClassEntry getLocationClassEntry() { | 59 | public ClassEntry getLocationClassEntry() { |
| 55 | if (context != null) { | 60 | if (context != null) { |
| 56 | return context.getOwnerClassEntry(); | 61 | return context.getContainingClass(); |
| 57 | } | 62 | } |
| 58 | return entry.getOwnerClassEntry(); | 63 | return entry.getContainingClass(); |
| 59 | } | 64 | } |
| 60 | 65 | ||
| 61 | public boolean isNamed() { | 66 | public boolean isNamed() { |
| 62 | return this.sourceName; | 67 | return this.sourceName; |
| 63 | } | 68 | } |
| 64 | 69 | ||
| 65 | public Entry getNameableEntry() { | 70 | public Entry<?> getNameableEntry() { |
| 66 | if (entry instanceof MethodEntry && ((MethodEntry) entry).isConstructor()) { | 71 | if (entry instanceof MethodEntry && ((MethodEntry) entry).isConstructor()) { |
| 67 | // renaming a constructor really means renaming the class | 72 | // renaming a constructor really means renaming the class |
| 68 | return entry.getOwnerClassEntry(); | 73 | return entry.getContainingClass(); |
| 69 | } | 74 | } |
| 70 | return entry; | 75 | return entry; |
| 71 | } | 76 | } |
| 72 | 77 | ||
| 73 | public String getNameableName() { | 78 | public String getNameableName() { |
| 74 | if (getNameableEntry() instanceof ClassEntry) { | ||
| 75 | ClassEntry classEntry = (ClassEntry) getNameableEntry(); | ||
| 76 | if (classEntry.isInnerClass()) { | ||
| 77 | // make sure we only rename the inner class name | ||
| 78 | return classEntry.getInnermostClassName(); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | return getNameableEntry().getName(); | 79 | return getNameableEntry().getName(); |
| 83 | } | 80 | } |
| 84 | 81 | ||
| @@ -121,4 +118,9 @@ public class EntryReference<E extends Entry, C extends Entry> { | |||
| 121 | } | 118 | } |
| 122 | return buf.toString(); | 119 | return buf.toString(); |
| 123 | } | 120 | } |
| 121 | |||
| 122 | @Override | ||
| 123 | public Translatable translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | ||
| 124 | return new EntryReference<>(translator.translate(entry), translator.translate(context), this); | ||
| 125 | } | ||
| 124 | } | 126 | } |