diff options
| author | 2020-07-06 12:33:43 +0200 | |
|---|---|---|
| committer | 2020-07-06 12:33:43 +0200 | |
| commit | 1a08b8abf721d375db83cec78e2f520a802ab1e4 (patch) | |
| tree | 098df663a83341c24fa33abd942e929fdc1b80c4 | |
| parent | Only try to set decompiler service on the class handle provider if it exists. (diff) | |
| download | enigma-fork-1a08b8abf721d375db83cec78e2f520a802ab1e4.tar.gz enigma-fork-1a08b8abf721d375db83cec78e2f520a802ab1e4.tar.xz enigma-fork-1a08b8abf721d375db83cec78e2f520a802ab1e4.zip | |
Fix "Mark as Deobfuscated" menu entry not working... this time without breaking all the things hopefully (#284)
* Fix "Mark as Deobfuscated" menu entry not working... this time hopefully without breaking all the things
* Use ungrouped() for MappingDelta
* Fix *DefEntry overriding the wrong translate() version
26 files changed, 313 insertions, 120 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java index 72ec965..ec68d0d 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -647,7 +647,7 @@ public class Gui { | |||
| 647 | 647 | ||
| 648 | Entry<?> obfEntry = cursorReference.entry; | 648 | Entry<?> obfEntry = cursorReference.entry; |
| 649 | 649 | ||
| 650 | if (controller.project.getMapper().hasDeobfMapping(obfEntry)) { | 650 | if (controller.project.getMapper().extendedDeobfuscate(obfEntry).isDeobfuscated()) { |
| 651 | if (!validateImmediateAction(vc -> this.controller.removeMapping(vc, cursorReference))) return; | 651 | if (!validateImmediateAction(vc -> this.controller.removeMapping(vc, cursorReference))) return; |
| 652 | this.controller.sendPacket(new RemoveMappingC2SPacket(cursorReference.getNameableEntry())); | 652 | this.controller.sendPacket(new RemoveMappingC2SPacket(cursorReference.getNameableEntry())); |
| 653 | } else { | 653 | } else { |
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java index 135a529..1ba0bbb 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java | |||
| @@ -475,7 +475,7 @@ public class EditorPanel { | |||
| 475 | this.popupMenu.openNextMenu.setEnabled(this.controller.hasNextReference()); | 475 | this.popupMenu.openNextMenu.setEnabled(this.controller.hasNextReference()); |
| 476 | this.popupMenu.toggleMappingMenu.setEnabled(isRenamable); | 476 | this.popupMenu.toggleMappingMenu.setEnabled(isRenamable); |
| 477 | 477 | ||
| 478 | if (referenceEntry != null && this.controller.project.getMapper().hasDeobfMapping(referenceEntry)) { | 478 | if (referenceEntry != null && this.controller.project.getMapper().extendedDeobfuscate(referenceEntry).isDeobfuscated()) { |
| 479 | this.popupMenu.toggleMappingMenu.setText(I18n.translate("popup_menu.reset_obfuscated")); | 479 | this.popupMenu.toggleMappingMenu.setText(I18n.translate("popup_menu.reset_obfuscated")); |
| 480 | } else { | 480 | } else { |
| 481 | this.popupMenu.toggleMappingMenu.setText(I18n.translate("popup_menu.mark_deobfuscated")); | 481 | this.popupMenu.toggleMappingMenu.setText(I18n.translate("popup_menu.mark_deobfuscated")); |
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/EntryReference.java b/enigma/src/main/java/cuchaz/enigma/analysis/EntryReference.java index 9d6bc4e..cccabd0 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/EntryReference.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/EntryReference.java | |||
| @@ -16,6 +16,7 @@ import java.util.List; | |||
| 16 | import java.util.Objects; | 16 | import java.util.Objects; |
| 17 | 17 | ||
| 18 | import cuchaz.enigma.translation.Translatable; | 18 | import cuchaz.enigma.translation.Translatable; |
| 19 | import cuchaz.enigma.translation.TranslateResult; | ||
| 19 | import cuchaz.enigma.translation.Translator; | 20 | import cuchaz.enigma.translation.Translator; |
| 20 | import cuchaz.enigma.translation.mapping.EntryMap; | 21 | import cuchaz.enigma.translation.mapping.EntryMap; |
| 21 | import cuchaz.enigma.translation.mapping.EntryMapping; | 22 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| @@ -136,7 +137,8 @@ public class EntryReference<E extends Entry<?>, C extends Entry<?>> implements T | |||
| 136 | } | 137 | } |
| 137 | 138 | ||
| 138 | @Override | 139 | @Override |
| 139 | public Translatable translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 140 | public TranslateResult<EntryReference<E, C>> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 140 | return new EntryReference<>(translator.translate(entry), translator.translate(context), this); | 141 | return translator.extendedTranslate(this.entry).map(e -> new EntryReference<>(e, translator.translate(context), this)); |
| 141 | } | 142 | } |
| 143 | |||
| 142 | } | 144 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java b/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java index ac7c434..e4a7115 100644 --- a/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java +++ b/enigma/src/main/java/cuchaz/enigma/source/DecompiledClassSource.java | |||
| @@ -9,6 +9,7 @@ import cuchaz.enigma.EnigmaServices; | |||
| 9 | import cuchaz.enigma.analysis.EntryReference; | 9 | import cuchaz.enigma.analysis.EntryReference; |
| 10 | import cuchaz.enigma.api.service.NameProposalService; | 10 | import cuchaz.enigma.api.service.NameProposalService; |
| 11 | import cuchaz.enigma.translation.LocalNameGenerator; | 11 | import cuchaz.enigma.translation.LocalNameGenerator; |
| 12 | import cuchaz.enigma.translation.TranslateResult; | ||
| 12 | import cuchaz.enigma.translation.Translator; | 13 | import cuchaz.enigma.translation.Translator; |
| 13 | import cuchaz.enigma.translation.mapping.EntryRemapper; | 14 | import cuchaz.enigma.translation.mapping.EntryRemapper; |
| 14 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; | 15 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; |
| @@ -48,12 +49,12 @@ public class DecompiledClassSource { | |||
| 48 | EntryReference<Entry<?>, Entry<?>> reference = obfuscatedIndex.getReference(token); | 49 | EntryReference<Entry<?>, Entry<?>> reference = obfuscatedIndex.getReference(token); |
| 49 | 50 | ||
| 50 | Entry<?> entry = reference.getNameableEntry(); | 51 | Entry<?> entry = reference.getNameableEntry(); |
| 51 | Entry<?> translatedEntry = translator.translate(entry); | 52 | TranslateResult<Entry<?>> translatedEntry = translator.extendedTranslate(entry); |
| 52 | 53 | ||
| 53 | if (project.isRenamable(reference)) { | 54 | if (project.isRenamable(reference)) { |
| 54 | if (project.getMapper().hasDeobfMapping(entry)) { | 55 | if (!translatedEntry.isObfuscated()) { |
| 55 | highlightToken(movedToken, RenamableTokenType.DEOBFUSCATED); | 56 | highlightToken(movedToken, translatedEntry.getType()); |
| 56 | return translatedEntry.getSourceRemapName(); | 57 | return translatedEntry.getValue().getSourceRemapName(); |
| 57 | } else { | 58 | } else { |
| 58 | Optional<String> proposedName = proposeName(project, entry); | 59 | Optional<String> proposedName = proposeName(project, entry); |
| 59 | if (proposedName.isPresent()) { | 60 | if (proposedName.isPresent()) { |
| @@ -65,7 +66,7 @@ public class DecompiledClassSource { | |||
| 65 | } | 66 | } |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | String defaultName = generateDefaultName(translatedEntry); | 69 | String defaultName = generateDefaultName(translatedEntry.getValue()); |
| 69 | if (defaultName != null) { | 70 | if (defaultName != null) { |
| 70 | return defaultName; | 71 | return defaultName; |
| 71 | } | 72 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/MappingTranslator.java b/enigma/src/main/java/cuchaz/enigma/translation/MappingTranslator.java index 529d0ed..51e5d86 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/MappingTranslator.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/MappingTranslator.java | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | package cuchaz.enigma.translation; | 1 | package cuchaz.enigma.translation; |
| 2 | 2 | ||
| 3 | import javax.annotation.Nullable; | ||
| 4 | |||
| 5 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 3 | import cuchaz.enigma.translation.mapping.EntryMapping; | 6 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 4 | import cuchaz.enigma.translation.mapping.EntryResolver; | 7 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 5 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 6 | 8 | ||
| 7 | public class MappingTranslator implements Translator { | 9 | public class MappingTranslator implements Translator { |
| 8 | private final EntryMap<EntryMapping> mappings; | 10 | private final EntryMap<EntryMapping> mappings; |
| @@ -13,12 +15,14 @@ public class MappingTranslator implements Translator { | |||
| 13 | this.resolver = resolver; | 15 | this.resolver = resolver; |
| 14 | } | 16 | } |
| 15 | 17 | ||
| 18 | @Nullable | ||
| 16 | @SuppressWarnings("unchecked") | 19 | @SuppressWarnings("unchecked") |
| 17 | @Override | 20 | @Override |
| 18 | public <T extends Translatable> T translate(T translatable) { | 21 | public <T extends Translatable> TranslateResult<T> extendedTranslate(T translatable) { |
| 19 | if (translatable == null) { | 22 | if (translatable == null) { |
| 20 | return null; | 23 | return null; |
| 21 | } | 24 | } |
| 22 | return (T) translatable.translate(this, resolver, mappings); | 25 | return (TranslateResult<T>) translatable.extendedTranslate(this, resolver, mappings); |
| 23 | } | 26 | } |
| 27 | |||
| 24 | } | 28 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/ProposingTranslator.java b/enigma/src/main/java/cuchaz/enigma/translation/ProposingTranslator.java index 97866e9..5ab16c8 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/ProposingTranslator.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/ProposingTranslator.java | |||
| @@ -1,13 +1,15 @@ | |||
| 1 | package cuchaz.enigma.translation; | 1 | package cuchaz.enigma.translation; |
| 2 | 2 | ||
| 3 | import java.util.Arrays; | ||
| 4 | import java.util.Optional; | ||
| 5 | |||
| 6 | import javax.annotation.Nullable; | ||
| 7 | |||
| 3 | import cuchaz.enigma.api.service.NameProposalService; | 8 | import cuchaz.enigma.api.service.NameProposalService; |
| 4 | import cuchaz.enigma.translation.mapping.EntryRemapper; | 9 | import cuchaz.enigma.translation.mapping.EntryRemapper; |
| 5 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; | 10 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; |
| 6 | import cuchaz.enigma.translation.representation.entry.Entry; | 11 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 7 | 12 | ||
| 8 | import java.util.Arrays; | ||
| 9 | import java.util.Optional; | ||
| 10 | |||
| 11 | public class ProposingTranslator implements Translator { | 13 | public class ProposingTranslator implements Translator { |
| 12 | private final EntryRemapper mapper; | 14 | private final EntryRemapper mapper; |
| 13 | private final NameProposalService[] nameProposalServices; | 15 | private final NameProposalService[] nameProposalServices; |
| @@ -17,16 +19,16 @@ public class ProposingTranslator implements Translator { | |||
| 17 | this.nameProposalServices = nameProposalServices; | 19 | this.nameProposalServices = nameProposalServices; |
| 18 | } | 20 | } |
| 19 | 21 | ||
| 22 | @Nullable | ||
| 20 | @Override | 23 | @Override |
| 21 | @SuppressWarnings("unchecked") | 24 | public <T extends Translatable> TranslateResult<T> extendedTranslate(T translatable) { |
| 22 | public <T extends Translatable> T translate(T translatable) { | ||
| 23 | if (translatable == null) { | 25 | if (translatable == null) { |
| 24 | return null; | 26 | return null; |
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | T deobfuscated = mapper.deobfuscate(translatable); | 29 | TranslateResult<T> deobfuscated = mapper.extendedDeobfuscate(translatable); |
| 28 | 30 | ||
| 29 | if (translatable instanceof Entry && ((Entry) deobfuscated).getName().equals(((Entry<?>) translatable).getName())) { | 31 | if (translatable instanceof Entry && ((Entry) deobfuscated.getValue()).getName().equals(((Entry<?>) translatable).getName())) { |
| 30 | return mapper.getObfResolver() | 32 | return mapper.getObfResolver() |
| 31 | .resolveEntry((Entry<?>) translatable, ResolutionStrategy.RESOLVE_ROOT) | 33 | .resolveEntry((Entry<?>) translatable, ResolutionStrategy.RESOLVE_ROOT) |
| 32 | .stream() | 34 | .stream() |
| @@ -34,7 +36,7 @@ public class ProposingTranslator implements Translator { | |||
| 34 | .filter(Optional::isPresent) | 36 | .filter(Optional::isPresent) |
| 35 | .map(Optional::get) | 37 | .map(Optional::get) |
| 36 | .findFirst() | 38 | .findFirst() |
| 37 | .map(newName -> (T) ((Entry) deobfuscated).withName(newName)) | 39 | .map(newName -> TranslateResult.proposed((T) ((Entry) deobfuscated.getValue()).withName(newName))) |
| 38 | .orElse(deobfuscated); | 40 | .orElse(deobfuscated); |
| 39 | } | 41 | } |
| 40 | 42 | ||
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/Translatable.java b/enigma/src/main/java/cuchaz/enigma/translation/Translatable.java index 0370ef1..7061bfa 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/Translatable.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/Translatable.java | |||
| @@ -1,9 +1,16 @@ | |||
| 1 | package cuchaz.enigma.translation; | 1 | package cuchaz.enigma.translation; |
| 2 | 2 | ||
| 3 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 3 | import cuchaz.enigma.translation.mapping.EntryMapping; | 4 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 4 | import cuchaz.enigma.translation.mapping.EntryResolver; | 5 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 5 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 6 | 6 | ||
| 7 | public interface Translatable { | 7 | public interface Translatable { |
| 8 | Translatable translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings); | 8 | |
| 9 | TranslateResult<? extends Translatable> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings); | ||
| 10 | |||
| 11 | @Deprecated | ||
| 12 | default Translatable translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | ||
| 13 | return this.extendedTranslate(translator, resolver, mappings).getValue(); | ||
| 14 | } | ||
| 15 | |||
| 9 | } | 16 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/TranslateResult.java b/enigma/src/main/java/cuchaz/enigma/translation/TranslateResult.java new file mode 100644 index 0000000..bb26235 --- /dev/null +++ b/enigma/src/main/java/cuchaz/enigma/translation/TranslateResult.java | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | package cuchaz.enigma.translation; | ||
| 2 | |||
| 3 | import java.util.Objects; | ||
| 4 | import java.util.function.Function; | ||
| 5 | |||
| 6 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 7 | |||
| 8 | public final class TranslateResult<T> { | ||
| 9 | |||
| 10 | private final RenamableTokenType type; | ||
| 11 | private final T value; | ||
| 12 | |||
| 13 | private TranslateResult(RenamableTokenType type, T value) { | ||
| 14 | this.type = type; | ||
| 15 | this.value = value; | ||
| 16 | } | ||
| 17 | |||
| 18 | public static <T> TranslateResult<T> of(RenamableTokenType type, T value) { | ||
| 19 | Objects.requireNonNull(type, "type must not be null"); | ||
| 20 | return new TranslateResult<>(type, value); | ||
| 21 | } | ||
| 22 | |||
| 23 | // Used for translatables that don't have a concept of | ||
| 24 | // obfuscated/deobfuscated (e.g. method descriptors) for example because | ||
| 25 | // they don't have an identifier attached to them | ||
| 26 | public static <T> TranslateResult<T> ungrouped(T value) { | ||
| 27 | return TranslateResult.obfuscated(value); | ||
| 28 | } | ||
| 29 | |||
| 30 | public static <T> TranslateResult<T> obfuscated(T value) { | ||
| 31 | return TranslateResult.of(RenamableTokenType.OBFUSCATED, value); | ||
| 32 | } | ||
| 33 | |||
| 34 | public static <T> TranslateResult<T> deobfuscated(T value) { | ||
| 35 | return TranslateResult.of(RenamableTokenType.DEOBFUSCATED, value); | ||
| 36 | } | ||
| 37 | |||
| 38 | public static <T> TranslateResult<T> proposed(T value) { | ||
| 39 | return TranslateResult.of(RenamableTokenType.PROPOSED, value); | ||
| 40 | } | ||
| 41 | |||
| 42 | public RenamableTokenType getType() { | ||
| 43 | return type; | ||
| 44 | } | ||
| 45 | |||
| 46 | public T getValue() { | ||
| 47 | return value; | ||
| 48 | } | ||
| 49 | |||
| 50 | public <R> TranslateResult<R> map(Function<T, R> op) { | ||
| 51 | return TranslateResult.of(this.type, op.apply(this.value)); | ||
| 52 | } | ||
| 53 | |||
| 54 | public boolean isObfuscated() { | ||
| 55 | return this.type == RenamableTokenType.OBFUSCATED; | ||
| 56 | } | ||
| 57 | |||
| 58 | public boolean isDeobfuscated() { | ||
| 59 | return this.type == RenamableTokenType.DEOBFUSCATED; | ||
| 60 | } | ||
| 61 | |||
| 62 | public boolean isProposed() { | ||
| 63 | return this.type == RenamableTokenType.PROPOSED; | ||
| 64 | } | ||
| 65 | |||
| 66 | @Override | ||
| 67 | public boolean equals(Object o) { | ||
| 68 | if (this == o) return true; | ||
| 69 | if (o == null || getClass() != o.getClass()) return false; | ||
| 70 | TranslateResult<?> that = (TranslateResult<?>) o; | ||
| 71 | return type == that.type && | ||
| 72 | Objects.equals(value, that.value); | ||
| 73 | } | ||
| 74 | |||
| 75 | @Override | ||
| 76 | public int hashCode() { | ||
| 77 | return Objects.hash(type, value); | ||
| 78 | } | ||
| 79 | |||
| 80 | @Override | ||
| 81 | public String toString() { | ||
| 82 | return String.format("TranslateResult { type: %s, value: %s }", type, value); | ||
| 83 | } | ||
| 84 | |||
| 85 | } | ||
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/Translator.java b/enigma/src/main/java/cuchaz/enigma/translation/Translator.java index c70141f..d3bc188 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/Translator.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/Translator.java | |||
| @@ -11,17 +11,27 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation; | 12 | package cuchaz.enigma.translation; |
| 13 | 13 | ||
| 14 | import com.google.common.collect.HashMultimap; | ||
| 15 | import com.google.common.collect.Multimap; | ||
| 16 | |||
| 17 | import java.util.Collection; | 14 | import java.util.Collection; |
| 18 | import java.util.HashMap; | 15 | import java.util.HashMap; |
| 19 | import java.util.Map; | 16 | import java.util.Map; |
| 20 | import java.util.Set; | 17 | import java.util.Set; |
| 21 | import java.util.stream.Collectors; | 18 | import java.util.stream.Collectors; |
| 22 | 19 | ||
| 20 | import javax.annotation.Nullable; | ||
| 21 | |||
| 22 | import com.google.common.collect.HashMultimap; | ||
| 23 | import com.google.common.collect.Multimap; | ||
| 24 | |||
| 23 | public interface Translator { | 25 | public interface Translator { |
| 24 | <T extends Translatable> T translate(T translatable); | 26 | @Nullable |
| 27 | <T extends Translatable> TranslateResult<T> extendedTranslate(@Nullable T translatable); | ||
| 28 | |||
| 29 | @Deprecated | ||
| 30 | @Nullable | ||
| 31 | default <T extends Translatable> T translate(@Nullable T translatable) { | ||
| 32 | TranslateResult<T> res = this.extendedTranslate(translatable); | ||
| 33 | return res == null ? null : res.getValue(); | ||
| 34 | } | ||
| 25 | 35 | ||
| 26 | default <T extends Translatable> Collection<T> translate(Collection<T> translatable) { | 36 | default <T extends Translatable> Collection<T> translate(Collection<T> translatable) { |
| 27 | return translatable.stream() | 37 | return translatable.stream() |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/VoidTranslator.java b/enigma/src/main/java/cuchaz/enigma/translation/VoidTranslator.java index c010833..28364f7 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/VoidTranslator.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/VoidTranslator.java | |||
| @@ -4,7 +4,8 @@ public enum VoidTranslator implements Translator { | |||
| 4 | INSTANCE; | 4 | INSTANCE; |
| 5 | 5 | ||
| 6 | @Override | 6 | @Override |
| 7 | public <T extends Translatable> T translate(T translatable) { | 7 | public <T extends Translatable> TranslateResult<T> extendedTranslate(T translatable) { |
| 8 | return translatable; | 8 | return TranslateResult.obfuscated(translatable); |
| 9 | } | 9 | } |
| 10 | |||
| 10 | } | 11 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/mapping/EntryRemapper.java b/enigma/src/main/java/cuchaz/enigma/translation/mapping/EntryRemapper.java index 932b5bb..a183d2b 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/mapping/EntryRemapper.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/mapping/EntryRemapper.java | |||
| @@ -8,6 +8,7 @@ import javax.annotation.Nullable; | |||
| 8 | import cuchaz.enigma.analysis.index.JarIndex; | 8 | import cuchaz.enigma.analysis.index.JarIndex; |
| 9 | import cuchaz.enigma.translation.MappingTranslator; | 9 | import cuchaz.enigma.translation.MappingTranslator; |
| 10 | import cuchaz.enigma.translation.Translatable; | 10 | import cuchaz.enigma.translation.Translatable; |
| 11 | import cuchaz.enigma.translation.TranslateResult; | ||
| 11 | import cuchaz.enigma.translation.Translator; | 12 | import cuchaz.enigma.translation.Translator; |
| 12 | import cuchaz.enigma.translation.mapping.tree.DeltaTrackingTree; | 13 | import cuchaz.enigma.translation.mapping.tree.DeltaTrackingTree; |
| 13 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 14 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| @@ -78,6 +79,10 @@ public class EntryRemapper { | |||
| 78 | return obfToDeobf.contains(obfEntry); | 79 | return obfToDeobf.contains(obfEntry); |
| 79 | } | 80 | } |
| 80 | 81 | ||
| 82 | public <T extends Translatable> TranslateResult<T> extendedDeobfuscate(T translatable) { | ||
| 83 | return deobfuscator.extendedTranslate(translatable); | ||
| 84 | } | ||
| 85 | |||
| 81 | public <T extends Translatable> T deobfuscate(T translatable) { | 86 | public <T extends Translatable> T deobfuscate(T translatable) { |
| 82 | return deobfuscator.translate(translatable); | 87 | return deobfuscator.translate(translatable); |
| 83 | } | 88 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/mapping/MappingDelta.java b/enigma/src/main/java/cuchaz/enigma/translation/mapping/MappingDelta.java index 1407bb6..250851c 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/mapping/MappingDelta.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/mapping/MappingDelta.java | |||
| @@ -1,14 +1,15 @@ | |||
| 1 | package cuchaz.enigma.translation.mapping; | 1 | package cuchaz.enigma.translation.mapping; |
| 2 | 2 | ||
| 3 | import java.util.stream.Stream; | ||
| 4 | |||
| 3 | import cuchaz.enigma.translation.Translatable; | 5 | import cuchaz.enigma.translation.Translatable; |
| 6 | import cuchaz.enigma.translation.TranslateResult; | ||
| 4 | import cuchaz.enigma.translation.Translator; | 7 | import cuchaz.enigma.translation.Translator; |
| 5 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 8 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 6 | import cuchaz.enigma.translation.mapping.tree.EntryTreeNode; | 9 | import cuchaz.enigma.translation.mapping.tree.EntryTreeNode; |
| 7 | import cuchaz.enigma.translation.mapping.tree.HashEntryTree; | 10 | import cuchaz.enigma.translation.mapping.tree.HashEntryTree; |
| 8 | import cuchaz.enigma.translation.representation.entry.Entry; | 11 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 9 | 12 | ||
| 10 | import java.util.stream.Stream; | ||
| 11 | |||
| 12 | public class MappingDelta<T> implements Translatable { | 13 | public class MappingDelta<T> implements Translatable { |
| 13 | public static final Object PLACEHOLDER = new Object(); | 14 | public static final Object PLACEHOLDER = new Object(); |
| 14 | 15 | ||
| @@ -45,10 +46,12 @@ public class MappingDelta<T> implements Translatable { | |||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | @Override | 48 | @Override |
| 48 | public MappingDelta<T> translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 49 | public TranslateResult<MappingDelta<T>> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 49 | return new MappingDelta<>( | 50 | // there's no concept of deobfuscated for this as far as I can see, so |
| 51 | // it will always be marked as obfuscated | ||
| 52 | return TranslateResult.ungrouped(new MappingDelta<>( | ||
| 50 | translator.translate(baseMappings), | 53 | translator.translate(baseMappings), |
| 51 | translator.translate(changes) | 54 | translator.translate(changes) |
| 52 | ); | 55 | )); |
| 53 | } | 56 | } |
| 54 | } | 57 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/mapping/tree/EntryTree.java b/enigma/src/main/java/cuchaz/enigma/translation/mapping/tree/EntryTree.java index daaefcc..e1c8e8d 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/mapping/tree/EntryTree.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/mapping/tree/EntryTree.java | |||
| @@ -1,16 +1,18 @@ | |||
| 1 | package cuchaz.enigma.translation.mapping.tree; | 1 | package cuchaz.enigma.translation.mapping.tree; |
| 2 | 2 | ||
| 3 | import java.util.Collection; | ||
| 4 | import java.util.stream.Stream; | ||
| 5 | |||
| 6 | import javax.annotation.Nullable; | ||
| 7 | |||
| 3 | import cuchaz.enigma.translation.Translatable; | 8 | import cuchaz.enigma.translation.Translatable; |
| 9 | import cuchaz.enigma.translation.TranslateResult; | ||
| 4 | import cuchaz.enigma.translation.Translator; | 10 | import cuchaz.enigma.translation.Translator; |
| 5 | import cuchaz.enigma.translation.mapping.EntryMap; | 11 | import cuchaz.enigma.translation.mapping.EntryMap; |
| 6 | import cuchaz.enigma.translation.mapping.EntryMapping; | 12 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 7 | import cuchaz.enigma.translation.mapping.EntryResolver; | 13 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 8 | import cuchaz.enigma.translation.representation.entry.Entry; | 14 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 9 | 15 | ||
| 10 | import javax.annotation.Nullable; | ||
| 11 | import java.util.Collection; | ||
| 12 | import java.util.stream.Stream; | ||
| 13 | |||
| 14 | public interface EntryTree<T> extends EntryMap<T>, Iterable<EntryTreeNode<T>>, Translatable { | 16 | public interface EntryTree<T> extends EntryMap<T>, Iterable<EntryTreeNode<T>>, Translatable { |
| 15 | Collection<Entry<?>> getChildren(Entry<?> entry); | 17 | Collection<Entry<?>> getChildren(Entry<?> entry); |
| 16 | 18 | ||
| @@ -22,5 +24,10 @@ public interface EntryTree<T> extends EntryMap<T>, Iterable<EntryTreeNode<T>>, T | |||
| 22 | Stream<EntryTreeNode<T>> getRootNodes(); | 24 | Stream<EntryTreeNode<T>> getRootNodes(); |
| 23 | 25 | ||
| 24 | @Override | 26 | @Override |
| 27 | default TranslateResult<? extends EntryTree<T>> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | ||
| 28 | return TranslateResult.ungrouped(this.translate(translator, resolver, mappings)); | ||
| 29 | } | ||
| 30 | |||
| 31 | @Override | ||
| 25 | EntryTree<T> translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings); | 32 | EntryTree<T> translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings); |
| 26 | } | 33 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/Lambda.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/Lambda.java index ad9389c..a6aed73 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/Lambda.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/Lambda.java | |||
| @@ -1,6 +1,10 @@ | |||
| 1 | package cuchaz.enigma.translation.representation; | 1 | package cuchaz.enigma.translation.representation; |
| 2 | 2 | ||
| 3 | import java.util.Objects; | ||
| 4 | |||
| 5 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 3 | import cuchaz.enigma.translation.Translatable; | 6 | import cuchaz.enigma.translation.Translatable; |
| 7 | import cuchaz.enigma.translation.TranslateResult; | ||
| 4 | import cuchaz.enigma.translation.Translator; | 8 | import cuchaz.enigma.translation.Translator; |
| 5 | import cuchaz.enigma.translation.mapping.EntryMap; | 9 | import cuchaz.enigma.translation.mapping.EntryMap; |
| 6 | import cuchaz.enigma.translation.mapping.EntryMapping; | 10 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| @@ -10,8 +14,6 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry; | |||
| 10 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 14 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 11 | import cuchaz.enigma.translation.representation.entry.ParentedEntry; | 15 | import cuchaz.enigma.translation.representation.entry.ParentedEntry; |
| 12 | 16 | ||
| 13 | import java.util.Objects; | ||
| 14 | |||
| 15 | public class Lambda implements Translatable { | 17 | public class Lambda implements Translatable { |
| 16 | private final String invokedName; | 18 | private final String invokedName; |
| 17 | private final MethodDescriptor invokedType; | 19 | private final MethodDescriptor invokedType; |
| @@ -28,16 +30,19 @@ public class Lambda implements Translatable { | |||
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | @Override | 32 | @Override |
| 31 | public Lambda translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 33 | public TranslateResult<Lambda> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 32 | MethodEntry samMethod = new MethodEntry(getInterface(), invokedName, samMethodType); | 34 | MethodEntry samMethod = new MethodEntry(getInterface(), invokedName, samMethodType); |
| 33 | EntryMapping samMethodMapping = resolveMapping(resolver, mappings, samMethod); | 35 | EntryMapping samMethodMapping = resolveMapping(resolver, mappings, samMethod); |
| 34 | 36 | ||
| 35 | return new Lambda( | 37 | return TranslateResult.of( |
| 36 | samMethodMapping != null ? samMethodMapping.getTargetName() : invokedName, | 38 | samMethodMapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, |
| 37 | invokedType.translate(translator, resolver, mappings), | 39 | new Lambda( |
| 38 | samMethodType.translate(translator, resolver, mappings), | 40 | samMethodMapping != null ? samMethodMapping.getTargetName() : invokedName, |
| 39 | implMethod.translate(translator, resolver, mappings), | 41 | invokedType.extendedTranslate(translator, resolver, mappings).getValue(), |
| 40 | instantiatedMethodType.translate(translator, resolver, mappings) | 42 | samMethodType.extendedTranslate(translator, resolver, mappings).getValue(), |
| 43 | implMethod.extendedTranslate(translator, resolver, mappings).getValue(), | ||
| 44 | instantiatedMethodType.extendedTranslate(translator, resolver, mappings).getValue() | ||
| 45 | ) | ||
| 41 | ); | 46 | ); |
| 42 | } | 47 | } |
| 43 | 48 | ||
| @@ -81,10 +86,10 @@ public class Lambda implements Translatable { | |||
| 81 | if (o == null || getClass() != o.getClass()) return false; | 86 | if (o == null || getClass() != o.getClass()) return false; |
| 82 | Lambda lambda = (Lambda) o; | 87 | Lambda lambda = (Lambda) o; |
| 83 | return Objects.equals(invokedName, lambda.invokedName) && | 88 | return Objects.equals(invokedName, lambda.invokedName) && |
| 84 | Objects.equals(invokedType, lambda.invokedType) && | 89 | Objects.equals(invokedType, lambda.invokedType) && |
| 85 | Objects.equals(samMethodType, lambda.samMethodType) && | 90 | Objects.equals(samMethodType, lambda.samMethodType) && |
| 86 | Objects.equals(implMethod, lambda.implMethod) && | 91 | Objects.equals(implMethod, lambda.implMethod) && |
| 87 | Objects.equals(instantiatedMethodType, lambda.instantiatedMethodType); | 92 | Objects.equals(instantiatedMethodType, lambda.instantiatedMethodType); |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | @Override | 95 | @Override |
| @@ -95,11 +100,11 @@ public class Lambda implements Translatable { | |||
| 95 | @Override | 100 | @Override |
| 96 | public String toString() { | 101 | public String toString() { |
| 97 | return "Lambda{" + | 102 | return "Lambda{" + |
| 98 | "invokedName='" + invokedName + '\'' + | 103 | "invokedName='" + invokedName + '\'' + |
| 99 | ", invokedType=" + invokedType + | 104 | ", invokedType=" + invokedType + |
| 100 | ", samMethodType=" + samMethodType + | 105 | ", samMethodType=" + samMethodType + |
| 101 | ", implMethod=" + implMethod + | 106 | ", implMethod=" + implMethod + |
| 102 | ", instantiatedMethodType=" + instantiatedMethodType + | 107 | ", instantiatedMethodType=" + instantiatedMethodType + |
| 103 | '}'; | 108 | '}'; |
| 104 | } | 109 | } |
| 105 | } | 110 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/MethodDescriptor.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/MethodDescriptor.java index 03c8686..998c944 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/MethodDescriptor.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/MethodDescriptor.java | |||
| @@ -11,19 +11,21 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation; | 12 | package cuchaz.enigma.translation.representation; |
| 13 | 13 | ||
| 14 | import java.util.ArrayList; | ||
| 15 | import java.util.List; | ||
| 16 | import java.util.Objects; | ||
| 17 | import java.util.function.Function; | ||
| 18 | |||
| 14 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
| 20 | |||
| 15 | import cuchaz.enigma.translation.Translatable; | 21 | import cuchaz.enigma.translation.Translatable; |
| 22 | import cuchaz.enigma.translation.TranslateResult; | ||
| 16 | import cuchaz.enigma.translation.Translator; | 23 | import cuchaz.enigma.translation.Translator; |
| 24 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 17 | import cuchaz.enigma.translation.mapping.EntryMapping; | 25 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 18 | import cuchaz.enigma.translation.mapping.EntryResolver; | 26 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 19 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 20 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 27 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 21 | 28 | ||
| 22 | import java.util.ArrayList; | ||
| 23 | import java.util.List; | ||
| 24 | import java.util.Objects; | ||
| 25 | import java.util.function.Function; | ||
| 26 | |||
| 27 | public class MethodDescriptor implements Translatable { | 29 | public class MethodDescriptor implements Translatable { |
| 28 | 30 | ||
| 29 | private List<TypeDescriptor> argumentDescs; | 31 | private List<TypeDescriptor> argumentDescs; |
| @@ -118,12 +120,12 @@ public class MethodDescriptor implements Translatable { | |||
| 118 | } | 120 | } |
| 119 | 121 | ||
| 120 | @Override | 122 | @Override |
| 121 | public MethodDescriptor translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 123 | public TranslateResult<MethodDescriptor> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 122 | List<TypeDescriptor> translatedArguments = new ArrayList<>(argumentDescs.size()); | 124 | List<TypeDescriptor> translatedArguments = new ArrayList<>(argumentDescs.size()); |
| 123 | for (TypeDescriptor argument : argumentDescs) { | 125 | for (TypeDescriptor argument : argumentDescs) { |
| 124 | translatedArguments.add(translator.translate(argument)); | 126 | translatedArguments.add(translator.translate(argument)); |
| 125 | } | 127 | } |
| 126 | return new MethodDescriptor(translatedArguments, translator.translate(returnDesc)); | 128 | return TranslateResult.ungrouped(new MethodDescriptor(translatedArguments, translator.translate(returnDesc))); |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 129 | public boolean canConflictWith(MethodDescriptor descriptor) { | 131 | public boolean canConflictWith(MethodDescriptor descriptor) { |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/Signature.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/Signature.java index 424088a..33b9797 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/Signature.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/Signature.java | |||
| @@ -1,18 +1,20 @@ | |||
| 1 | package cuchaz.enigma.translation.representation; | 1 | package cuchaz.enigma.translation.representation; |
| 2 | 2 | ||
| 3 | import java.util.function.Function; | ||
| 4 | import java.util.regex.Pattern; | ||
| 5 | |||
| 6 | import org.objectweb.asm.signature.SignatureReader; | ||
| 7 | import org.objectweb.asm.signature.SignatureVisitor; | ||
| 8 | import org.objectweb.asm.signature.SignatureWriter; | ||
| 9 | |||
| 3 | import cuchaz.enigma.bytecode.translators.TranslationSignatureVisitor; | 10 | import cuchaz.enigma.bytecode.translators.TranslationSignatureVisitor; |
| 4 | import cuchaz.enigma.translation.Translatable; | 11 | import cuchaz.enigma.translation.Translatable; |
| 12 | import cuchaz.enigma.translation.TranslateResult; | ||
| 5 | import cuchaz.enigma.translation.Translator; | 13 | import cuchaz.enigma.translation.Translator; |
| 6 | import cuchaz.enigma.translation.mapping.EntryMap; | 14 | import cuchaz.enigma.translation.mapping.EntryMap; |
| 7 | import cuchaz.enigma.translation.mapping.EntryMapping; | 15 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 8 | import cuchaz.enigma.translation.mapping.EntryResolver; | 16 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 9 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 10 | import org.objectweb.asm.signature.SignatureReader; | ||
| 11 | import org.objectweb.asm.signature.SignatureVisitor; | ||
| 12 | import org.objectweb.asm.signature.SignatureWriter; | ||
| 13 | |||
| 14 | import java.util.function.Function; | ||
| 15 | import java.util.regex.Pattern; | ||
| 16 | 18 | ||
| 17 | public class Signature implements Translatable { | 19 | public class Signature implements Translatable { |
| 18 | private static final Pattern OBJECT_PATTERN = Pattern.compile(".*:Ljava/lang/Object;:.*"); | 20 | private static final Pattern OBJECT_PATTERN = Pattern.compile(".*:Ljava/lang/Object;:.*"); |
| @@ -92,7 +94,8 @@ public class Signature implements Translatable { | |||
| 92 | } | 94 | } |
| 93 | 95 | ||
| 94 | @Override | 96 | @Override |
| 95 | public Translatable translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 97 | public TranslateResult<Signature> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 96 | return remap(name -> translator.translate(new ClassEntry(name)).getFullName()); | 98 | return TranslateResult.ungrouped(this.remap(name -> translator.translate(new ClassEntry(name)).getFullName())); |
| 97 | } | 99 | } |
| 100 | |||
| 98 | } | 101 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java index f7ba849..9b79887 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/TypeDescriptor.java | |||
| @@ -11,18 +11,20 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation; | 12 | package cuchaz.enigma.translation.representation; |
| 13 | 13 | ||
| 14 | import java.util.Map; | ||
| 15 | import java.util.function.Function; | ||
| 16 | |||
| 14 | import com.google.common.base.Preconditions; | 17 | import com.google.common.base.Preconditions; |
| 15 | import com.google.common.collect.Maps; | 18 | import com.google.common.collect.Maps; |
| 19 | |||
| 16 | import cuchaz.enigma.translation.Translatable; | 20 | import cuchaz.enigma.translation.Translatable; |
| 21 | import cuchaz.enigma.translation.TranslateResult; | ||
| 17 | import cuchaz.enigma.translation.Translator; | 22 | import cuchaz.enigma.translation.Translator; |
| 23 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 18 | import cuchaz.enigma.translation.mapping.EntryMapping; | 24 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 19 | import cuchaz.enigma.translation.mapping.EntryResolver; | 25 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 20 | import cuchaz.enigma.translation.mapping.EntryMap; | ||
| 21 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 26 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| 22 | 27 | ||
| 23 | import java.util.Map; | ||
| 24 | import java.util.function.Function; | ||
| 25 | |||
| 26 | public class TypeDescriptor implements Translatable { | 28 | public class TypeDescriptor implements Translatable { |
| 27 | 29 | ||
| 28 | protected final String desc; | 30 | protected final String desc; |
| @@ -228,8 +230,8 @@ public class TypeDescriptor implements Translatable { | |||
| 228 | } | 230 | } |
| 229 | 231 | ||
| 230 | @Override | 232 | @Override |
| 231 | public Translatable translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 233 | public TranslateResult<TypeDescriptor> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 232 | return remap(name -> translator.translate(new ClassEntry(name)).getFullName()); | 234 | return TranslateResult.ungrouped(this.remap(name -> translator.translate(new ClassEntry(name)).getFullName())); |
| 233 | } | 235 | } |
| 234 | 236 | ||
| 235 | public enum Primitive { | 237 | public enum Primitive { |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java index 6930765..b0fd286 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java | |||
| @@ -11,15 +11,19 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation.entry; | 12 | package cuchaz.enigma.translation.representation.entry; |
| 13 | 13 | ||
| 14 | import java.util.Arrays; | ||
| 15 | |||
| 16 | import javax.annotation.Nullable; | ||
| 17 | |||
| 14 | import com.google.common.base.Preconditions; | 18 | import com.google.common.base.Preconditions; |
| 19 | |||
| 20 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 21 | import cuchaz.enigma.translation.TranslateResult; | ||
| 15 | import cuchaz.enigma.translation.Translator; | 22 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.translation.mapping.EntryMapping; | 23 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 17 | import cuchaz.enigma.translation.representation.AccessFlags; | 24 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 18 | import cuchaz.enigma.translation.representation.Signature; | 25 | import cuchaz.enigma.translation.representation.Signature; |
| 19 | 26 | ||
| 20 | import javax.annotation.Nullable; | ||
| 21 | import java.util.Arrays; | ||
| 22 | |||
| 23 | public class ClassDefEntry extends ClassEntry implements DefEntry<ClassEntry> { | 27 | public class ClassDefEntry extends ClassEntry implements DefEntry<ClassEntry> { |
| 24 | private final AccessFlags access; | 28 | private final AccessFlags access; |
| 25 | private final Signature signature; | 29 | private final Signature signature; |
| @@ -71,14 +75,17 @@ public class ClassDefEntry extends ClassEntry implements DefEntry<ClassEntry> { | |||
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | @Override | 77 | @Override |
| 74 | public ClassDefEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 78 | public TranslateResult<ClassDefEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 75 | Signature translatedSignature = translator.translate(signature); | 79 | Signature translatedSignature = translator.translate(signature); |
| 76 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 80 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 77 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; | 81 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; |
| 78 | ClassEntry translatedSuper = translator.translate(superClass); | 82 | ClassEntry translatedSuper = translator.translate(superClass); |
| 79 | ClassEntry[] translatedInterfaces = Arrays.stream(interfaces).map(translator::translate).toArray(ClassEntry[]::new); | 83 | ClassEntry[] translatedInterfaces = Arrays.stream(interfaces).map(translator::translate).toArray(ClassEntry[]::new); |
| 80 | String docs = mapping != null ? mapping.getJavadoc() : null; | 84 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 81 | return new ClassDefEntry(parent, translatedName, translatedSignature, translatedAccess, translatedSuper, translatedInterfaces, docs); | 85 | return TranslateResult.of( |
| 86 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 87 | new ClassDefEntry(parent, translatedName, translatedSignature, translatedAccess, translatedSuper, translatedInterfaces, docs) | ||
| 88 | ); | ||
| 82 | } | 89 | } |
| 83 | 90 | ||
| 84 | @Override | 91 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java index a167e21..de6d6e1 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java | |||
| @@ -17,6 +17,8 @@ import java.util.Objects; | |||
| 17 | import javax.annotation.Nonnull; | 17 | import javax.annotation.Nonnull; |
| 18 | import javax.annotation.Nullable; | 18 | import javax.annotation.Nullable; |
| 19 | 19 | ||
| 20 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 21 | import cuchaz.enigma.translation.TranslateResult; | ||
| 20 | import cuchaz.enigma.translation.Translator; | 22 | import cuchaz.enigma.translation.Translator; |
| 21 | import cuchaz.enigma.translation.mapping.EntryMapping; | 23 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 22 | import cuchaz.enigma.translation.mapping.IdentifierValidation; | 24 | import cuchaz.enigma.translation.mapping.IdentifierValidation; |
| @@ -62,15 +64,18 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | @Override | 66 | @Override |
| 65 | public ClassEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 67 | public TranslateResult<? extends ClassEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 66 | if (name.charAt(0) == '[') { | 68 | if (name.charAt(0) == '[') { |
| 67 | String translatedName = translator.translate(new TypeDescriptor(name)).toString(); | 69 | TranslateResult<TypeDescriptor> translatedName = translator.extendedTranslate(new TypeDescriptor(name)); |
| 68 | return new ClassEntry(parent, translatedName); | 70 | return translatedName.map(desc -> new ClassEntry(parent, desc.toString())); |
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 73 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 72 | String docs = mapping != null ? mapping.getJavadoc() : null; | 74 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 73 | return new ClassEntry(parent, translatedName, docs); | 75 | return TranslateResult.of( |
| 76 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 77 | new ClassEntry(parent, translatedName, docs) | ||
| 78 | ); | ||
| 74 | } | 79 | } |
| 75 | 80 | ||
| 76 | @Override | 81 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java index f9282b2..b9da6cc 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java | |||
| @@ -11,15 +11,18 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation.entry; | 12 | package cuchaz.enigma.translation.representation.entry; |
| 13 | 13 | ||
| 14 | import javax.annotation.Nullable; | ||
| 15 | |||
| 14 | import com.google.common.base.Preconditions; | 16 | import com.google.common.base.Preconditions; |
| 17 | |||
| 18 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 19 | import cuchaz.enigma.translation.TranslateResult; | ||
| 15 | import cuchaz.enigma.translation.Translator; | 20 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.translation.mapping.EntryMapping; | 21 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 17 | import cuchaz.enigma.translation.representation.AccessFlags; | 22 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 18 | import cuchaz.enigma.translation.representation.Signature; | 23 | import cuchaz.enigma.translation.representation.Signature; |
| 19 | import cuchaz.enigma.translation.representation.TypeDescriptor; | 24 | import cuchaz.enigma.translation.representation.TypeDescriptor; |
| 20 | 25 | ||
| 21 | import javax.annotation.Nullable; | ||
| 22 | |||
| 23 | public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { | 26 | public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { |
| 24 | private final AccessFlags access; | 27 | private final AccessFlags access; |
| 25 | private final Signature signature; | 28 | private final Signature signature; |
| @@ -50,15 +53,19 @@ public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { | |||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | @Override | 55 | @Override |
| 53 | public FieldDefEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 56 | protected TranslateResult<FieldEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 54 | TypeDescriptor translatedDesc = translator.translate(desc); | 57 | TypeDescriptor translatedDesc = translator.translate(desc); |
| 55 | Signature translatedSignature = translator.translate(signature); | 58 | Signature translatedSignature = translator.translate(signature); |
| 56 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 59 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 57 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; | 60 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; |
| 58 | String docs = mapping != null ? mapping.getJavadoc() : null; | 61 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 59 | return new FieldDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess, docs); | 62 | return TranslateResult.of( |
| 63 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 64 | new FieldDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess, docs) | ||
| 65 | ); | ||
| 60 | } | 66 | } |
| 61 | 67 | ||
| 68 | |||
| 62 | @Override | 69 | @Override |
| 63 | public FieldDefEntry withName(String name) { | 70 | public FieldDefEntry withName(String name) { |
| 64 | return new FieldDefEntry(parent, name, desc, signature, access, javadocs); | 71 | return new FieldDefEntry(parent, name, desc, signature, access, javadocs); |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java index 0e47878..3c54468 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java | |||
| @@ -11,14 +11,18 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation.entry; | 12 | package cuchaz.enigma.translation.representation.entry; |
| 13 | 13 | ||
| 14 | import java.util.Objects; | ||
| 15 | |||
| 16 | import javax.annotation.Nullable; | ||
| 17 | |||
| 14 | import com.google.common.base.Preconditions; | 18 | import com.google.common.base.Preconditions; |
| 19 | |||
| 20 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 21 | import cuchaz.enigma.translation.TranslateResult; | ||
| 15 | import cuchaz.enigma.translation.Translator; | 22 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.translation.mapping.EntryMapping; | 23 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 17 | import cuchaz.enigma.translation.representation.TypeDescriptor; | 24 | import cuchaz.enigma.translation.representation.TypeDescriptor; |
| 18 | 25 | ||
| 19 | import javax.annotation.Nullable; | ||
| 20 | import java.util.Objects; | ||
| 21 | |||
| 22 | public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable<FieldEntry> { | 26 | public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable<FieldEntry> { |
| 23 | protected final TypeDescriptor desc; | 27 | protected final TypeDescriptor desc; |
| 24 | 28 | ||
| @@ -59,10 +63,13 @@ public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 59 | } | 63 | } |
| 60 | 64 | ||
| 61 | @Override | 65 | @Override |
| 62 | protected FieldEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 66 | protected TranslateResult<FieldEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 63 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 67 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 64 | String docs = mapping != null ? mapping.getJavadoc() : null; | 68 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 65 | return new FieldEntry(parent, translatedName, translator.translate(desc), docs); | 69 | return TranslateResult.of( |
| 70 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 71 | new FieldEntry(parent, translatedName, translator.translate(desc), docs) | ||
| 72 | ); | ||
| 66 | } | 73 | } |
| 67 | 74 | ||
| 68 | @Override | 75 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java index aad4236..2712c65 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java | |||
| @@ -1,12 +1,15 @@ | |||
| 1 | package cuchaz.enigma.translation.representation.entry; | 1 | package cuchaz.enigma.translation.representation.entry; |
| 2 | 2 | ||
| 3 | import javax.annotation.Nullable; | ||
| 4 | |||
| 3 | import com.google.common.base.Preconditions; | 5 | import com.google.common.base.Preconditions; |
| 6 | |||
| 7 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 8 | import cuchaz.enigma.translation.TranslateResult; | ||
| 4 | import cuchaz.enigma.translation.Translator; | 9 | import cuchaz.enigma.translation.Translator; |
| 5 | import cuchaz.enigma.translation.mapping.EntryMapping; | 10 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 6 | import cuchaz.enigma.translation.representation.TypeDescriptor; | 11 | import cuchaz.enigma.translation.representation.TypeDescriptor; |
| 7 | 12 | ||
| 8 | import javax.annotation.Nullable; | ||
| 9 | |||
| 10 | /** | 13 | /** |
| 11 | * TypeDescriptor... | 14 | * TypeDescriptor... |
| 12 | * Created by Thog | 15 | * Created by Thog |
| @@ -27,11 +30,14 @@ public class LocalVariableDefEntry extends LocalVariableEntry { | |||
| 27 | } | 30 | } |
| 28 | 31 | ||
| 29 | @Override | 32 | @Override |
| 30 | public LocalVariableDefEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 33 | protected TranslateResult<LocalVariableEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 31 | TypeDescriptor translatedDesc = translator.translate(desc); | 34 | TypeDescriptor translatedDesc = translator.translate(desc); |
| 32 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 35 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 33 | String javadoc = mapping != null ? mapping.getJavadoc() : javadocs; | 36 | String javadoc = mapping != null ? mapping.getJavadoc() : javadocs; |
| 34 | return new LocalVariableDefEntry(parent, index, translatedName, parameter, translatedDesc, javadoc); | 37 | return TranslateResult.of( |
| 38 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 39 | new LocalVariableDefEntry(parent, index, translatedName, parameter, translatedDesc, javadoc) | ||
| 40 | ); | ||
| 35 | } | 41 | } |
| 36 | 42 | ||
| 37 | @Override | 43 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java index 3f98f03..154f11f 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | package cuchaz.enigma.translation.representation.entry; | 1 | package cuchaz.enigma.translation.representation.entry; |
| 2 | 2 | ||
| 3 | import java.util.Objects; | ||
| 4 | |||
| 5 | import javax.annotation.Nullable; | ||
| 6 | |||
| 3 | import com.google.common.base.Preconditions; | 7 | import com.google.common.base.Preconditions; |
| 8 | |||
| 9 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 10 | import cuchaz.enigma.translation.TranslateResult; | ||
| 4 | import cuchaz.enigma.translation.Translator; | 11 | import cuchaz.enigma.translation.Translator; |
| 5 | import cuchaz.enigma.translation.mapping.EntryMapping; | 12 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 6 | 13 | ||
| 7 | import javax.annotation.Nullable; | ||
| 8 | import java.util.Objects; | ||
| 9 | |||
| 10 | /** | 14 | /** |
| 11 | * TypeDescriptor... | 15 | * TypeDescriptor... |
| 12 | * Created by Thog | 16 | * Created by Thog |
| @@ -46,10 +50,13 @@ public class LocalVariableEntry extends ParentedEntry<MethodEntry> implements Co | |||
| 46 | } | 50 | } |
| 47 | 51 | ||
| 48 | @Override | 52 | @Override |
| 49 | public LocalVariableEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 53 | protected TranslateResult<LocalVariableEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 50 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 54 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 51 | String javadoc = mapping != null ? mapping.getJavadoc() : null; | 55 | String javadoc = mapping != null ? mapping.getJavadoc() : null; |
| 52 | return new LocalVariableEntry(parent, index, translatedName, parameter, javadoc); | 56 | return TranslateResult.of( |
| 57 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 58 | new LocalVariableEntry(parent, index, translatedName, parameter, javadoc) | ||
| 59 | ); | ||
| 53 | } | 60 | } |
| 54 | 61 | ||
| 55 | @Override | 62 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java index 4e75a5c..cc326d6 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java | |||
| @@ -11,15 +11,18 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation.entry; | 12 | package cuchaz.enigma.translation.representation.entry; |
| 13 | 13 | ||
| 14 | import javax.annotation.Nullable; | ||
| 15 | |||
| 14 | import com.google.common.base.Preconditions; | 16 | import com.google.common.base.Preconditions; |
| 17 | |||
| 18 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 19 | import cuchaz.enigma.translation.TranslateResult; | ||
| 15 | import cuchaz.enigma.translation.Translator; | 20 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.translation.mapping.EntryMapping; | 21 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 17 | import cuchaz.enigma.translation.representation.AccessFlags; | 22 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 18 | import cuchaz.enigma.translation.representation.MethodDescriptor; | 23 | import cuchaz.enigma.translation.representation.MethodDescriptor; |
| 19 | import cuchaz.enigma.translation.representation.Signature; | 24 | import cuchaz.enigma.translation.representation.Signature; |
| 20 | 25 | ||
| 21 | import javax.annotation.Nullable; | ||
| 22 | |||
| 23 | public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> { | 26 | public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> { |
| 24 | private final AccessFlags access; | 27 | private final AccessFlags access; |
| 25 | private final Signature signature; | 28 | private final Signature signature; |
| @@ -50,13 +53,16 @@ public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> | |||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | @Override | 55 | @Override |
| 53 | public MethodDefEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 56 | protected TranslateResult<MethodDefEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 54 | MethodDescriptor translatedDesc = translator.translate(descriptor); | 57 | MethodDescriptor translatedDesc = translator.translate(descriptor); |
| 55 | Signature translatedSignature = translator.translate(signature); | 58 | Signature translatedSignature = translator.translate(signature); |
| 56 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 59 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 57 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; | 60 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; |
| 58 | String docs = mapping != null ? mapping.getJavadoc() : null; | 61 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 59 | return new MethodDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess, docs); | 62 | return TranslateResult.of( |
| 63 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 64 | new MethodDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess, docs) | ||
| 65 | ); | ||
| 60 | } | 66 | } |
| 61 | 67 | ||
| 62 | @Override | 68 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java index 086a5c1..4698aa4 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java | |||
| @@ -11,14 +11,18 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation.entry; | 12 | package cuchaz.enigma.translation.representation.entry; |
| 13 | 13 | ||
| 14 | import java.util.Objects; | ||
| 15 | |||
| 16 | import javax.annotation.Nullable; | ||
| 17 | |||
| 14 | import com.google.common.base.Preconditions; | 18 | import com.google.common.base.Preconditions; |
| 19 | |||
| 20 | import cuchaz.enigma.source.RenamableTokenType; | ||
| 21 | import cuchaz.enigma.translation.TranslateResult; | ||
| 15 | import cuchaz.enigma.translation.Translator; | 22 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.translation.mapping.EntryMapping; | 23 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 17 | import cuchaz.enigma.translation.representation.MethodDescriptor; | 24 | import cuchaz.enigma.translation.representation.MethodDescriptor; |
| 18 | 25 | ||
| 19 | import javax.annotation.Nullable; | ||
| 20 | import java.util.Objects; | ||
| 21 | |||
| 22 | public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable<MethodEntry> { | 26 | public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable<MethodEntry> { |
| 23 | 27 | ||
| 24 | protected final MethodDescriptor descriptor; | 28 | protected final MethodDescriptor descriptor; |
| @@ -54,10 +58,13 @@ public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable | |||
| 54 | } | 58 | } |
| 55 | 59 | ||
| 56 | @Override | 60 | @Override |
| 57 | public MethodEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 61 | protected TranslateResult<? extends MethodEntry> extendedTranslate(Translator translator, @Nullable EntryMapping mapping) { |
| 58 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 62 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 59 | String docs = mapping != null ? mapping.getJavadoc() : null; | 63 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 60 | return new MethodEntry(parent, translatedName, translator.translate(descriptor), docs); | 64 | return TranslateResult.of( |
| 65 | mapping == null ? RenamableTokenType.OBFUSCATED : RenamableTokenType.DEOBFUSCATED, | ||
| 66 | new MethodEntry(parent, translatedName, translator.translate(descriptor), docs) | ||
| 67 | ); | ||
| 61 | } | 68 | } |
| 62 | 69 | ||
| 63 | @Override | 70 | @Override |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java index 95be22c..b12f9d0 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java | |||
| @@ -11,15 +11,17 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.translation.representation.entry; | 12 | package cuchaz.enigma.translation.representation.entry; |
| 13 | 13 | ||
| 14 | import javax.annotation.Nullable; | ||
| 15 | |||
| 14 | import com.google.common.base.Preconditions; | 16 | import com.google.common.base.Preconditions; |
| 17 | |||
| 18 | import cuchaz.enigma.translation.TranslateResult; | ||
| 15 | import cuchaz.enigma.translation.Translator; | 19 | import cuchaz.enigma.translation.Translator; |
| 16 | import cuchaz.enigma.translation.mapping.EntryMap; | 20 | import cuchaz.enigma.translation.mapping.EntryMap; |
| 17 | import cuchaz.enigma.translation.mapping.EntryMapping; | 21 | import cuchaz.enigma.translation.mapping.EntryMapping; |
| 18 | import cuchaz.enigma.translation.mapping.EntryResolver; | 22 | import cuchaz.enigma.translation.mapping.EntryResolver; |
| 19 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; | 23 | import cuchaz.enigma.translation.mapping.ResolutionStrategy; |
| 20 | 24 | ||
| 21 | import javax.annotation.Nullable; | ||
| 22 | |||
| 23 | public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { | 25 | public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { |
| 24 | protected final P parent; | 26 | protected final P parent; |
| 25 | protected final String name; | 27 | protected final String name; |
| @@ -39,7 +41,7 @@ public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { | |||
| 39 | @Override | 41 | @Override |
| 40 | public abstract ParentedEntry<P> withName(String name); | 42 | public abstract ParentedEntry<P> withName(String name); |
| 41 | 43 | ||
| 42 | protected abstract ParentedEntry<P> translate(Translator translator, @Nullable EntryMapping mapping); | 44 | protected abstract TranslateResult<? extends ParentedEntry<P>> extendedTranslate(Translator translator, @Nullable EntryMapping mapping); |
| 43 | 45 | ||
| 44 | @Override | 46 | @Override |
| 45 | public String getName() { | 47 | public String getName() { |
| @@ -59,14 +61,14 @@ public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { | |||
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | @Override | 63 | @Override |
| 62 | public ParentedEntry<P> translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 64 | public TranslateResult<? extends ParentedEntry<P>> extendedTranslate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 63 | P parent = getParent(); | 65 | P parent = getParent(); |
| 64 | EntryMapping mapping = resolveMapping(resolver, mappings); | 66 | EntryMapping mapping = resolveMapping(resolver, mappings); |
| 65 | if (parent == null) { | 67 | if (parent == null) { |
| 66 | return translate(translator, mapping); | 68 | return this.extendedTranslate(translator, mapping); |
| 67 | } | 69 | } |
| 68 | P translatedParent = translator.translate(parent); | 70 | P translatedParent = translator.translate(parent); |
| 69 | return withParent(translatedParent).translate(translator, mapping); | 71 | return this.withParent(translatedParent).extendedTranslate(translator, mapping); |
| 70 | } | 72 | } |
| 71 | 73 | ||
| 72 | private EntryMapping resolveMapping(EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 74 | private EntryMapping resolveMapping(EntryResolver resolver, EntryMap<EntryMapping> mappings) { |