diff options
| author | 2019-12-02 15:43:23 +0200 | |
|---|---|---|
| committer | 2019-12-02 13:43:23 +0000 | |
| commit | a9e03fa0e75b5b338021de982acbbb8277e08706 (patch) | |
| tree | 94233d173c5937584a3376895bf864fb24697a8c /src/main/java/cuchaz/enigma/translation/representation | |
| parent | Correctly decompile bridges, and add command to add bridges to mappings (#180) (diff) | |
| download | enigma-fork-a9e03fa0e75b5b338021de982acbbb8277e08706.tar.gz enigma-fork-a9e03fa0e75b5b338021de982acbbb8277e08706.tar.xz enigma-fork-a9e03fa0e75b5b338021de982acbbb8277e08706.zip | |
Allow attaching class, method, field, and parameter javadocs (#185)
* bring liach pr to modern enigma
* bump version
* fuck off vscode
* switch to COMMENT and write comments before
* it was already after, what do you want
* oops
* put inner classes at the end
* remove indents and use all caps
* add refreshmappings command
* Update src/main/java/cuchaz/enigma/translation/mapping/serde/EnigmaMappingsWriter.java
* Delete RefreshEnigmaMappingsCommand.java
* Update CommandMain.java
* ok
Diffstat (limited to 'src/main/java/cuchaz/enigma/translation/representation')
10 files changed, 86 insertions, 43 deletions
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java index c4df891..4b245bc 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassDefEntry.java | |||
| @@ -28,11 +28,16 @@ public class ClassDefEntry extends ClassEntry implements DefEntry<ClassEntry> { | |||
| 28 | private final ClassEntry[] interfaces; | 28 | private final ClassEntry[] interfaces; |
| 29 | 29 | ||
| 30 | public ClassDefEntry(String className, Signature signature, AccessFlags access, @Nullable ClassEntry superClass, ClassEntry[] interfaces) { | 30 | public ClassDefEntry(String className, Signature signature, AccessFlags access, @Nullable ClassEntry superClass, ClassEntry[] interfaces) { |
| 31 | this(getOuterClass(className), getInnerName(className), signature, access, superClass, interfaces); | 31 | this(getOuterClass(className), getInnerName(className), signature, access, superClass, interfaces, null); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | public ClassDefEntry(ClassEntry parent, String className, Signature signature, AccessFlags access, @Nullable ClassEntry superClass, ClassEntry[] interfaces) { | 34 | public ClassDefEntry(ClassEntry parent, String className, Signature signature, AccessFlags access, @Nullable ClassEntry superClass, ClassEntry[] interfaces) { |
| 35 | super(parent, className); | 35 | this(parent, className, signature, access, superClass, interfaces, null); |
| 36 | } | ||
| 37 | |||
| 38 | public ClassDefEntry(ClassEntry parent, String className, Signature signature, AccessFlags access, @Nullable ClassEntry superClass, | ||
| 39 | ClassEntry[] interfaces, String javadocs) { | ||
| 40 | super(parent, className, javadocs); | ||
| 36 | Preconditions.checkNotNull(signature, "Class signature cannot be null"); | 41 | Preconditions.checkNotNull(signature, "Class signature cannot be null"); |
| 37 | Preconditions.checkNotNull(access, "Class access cannot be null"); | 42 | Preconditions.checkNotNull(access, "Class access cannot be null"); |
| 38 | 43 | ||
| @@ -82,16 +87,17 @@ public class ClassDefEntry extends ClassEntry implements DefEntry<ClassEntry> { | |||
| 82 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; | 87 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; |
| 83 | ClassEntry translatedSuper = translator.translate(superClass); | 88 | ClassEntry translatedSuper = translator.translate(superClass); |
| 84 | ClassEntry[] translatedInterfaces = Arrays.stream(interfaces).map(translator::translate).toArray(ClassEntry[]::new); | 89 | ClassEntry[] translatedInterfaces = Arrays.stream(interfaces).map(translator::translate).toArray(ClassEntry[]::new); |
| 85 | return new ClassDefEntry(parent, translatedName, translatedSignature, translatedAccess, translatedSuper, translatedInterfaces); | 90 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 91 | return new ClassDefEntry(parent, translatedName, translatedSignature, translatedAccess, translatedSuper, translatedInterfaces, docs); | ||
| 86 | } | 92 | } |
| 87 | 93 | ||
| 88 | @Override | 94 | @Override |
| 89 | public ClassDefEntry withName(String name) { | 95 | public ClassDefEntry withName(String name) { |
| 90 | return new ClassDefEntry(parent, name, signature, access, superClass, interfaces); | 96 | return new ClassDefEntry(parent, name, signature, access, superClass, interfaces, javadocs); |
| 91 | } | 97 | } |
| 92 | 98 | ||
| 93 | @Override | 99 | @Override |
| 94 | public ClassDefEntry withParent(ClassEntry parent) { | 100 | public ClassDefEntry withParent(ClassEntry parent) { |
| 95 | return new ClassDefEntry(parent, name, signature, access, superClass, interfaces); | 101 | return new ClassDefEntry(parent, name, signature, access, superClass, interfaces, javadocs); |
| 96 | } | 102 | } |
| 97 | } | 103 | } |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java index 6bf4f96..23ce4a2 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/ClassEntry.java | |||
| @@ -27,11 +27,15 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 27 | private final String fullName; | 27 | private final String fullName; |
| 28 | 28 | ||
| 29 | public ClassEntry(String className) { | 29 | public ClassEntry(String className) { |
| 30 | this(getOuterClass(className), getInnerName(className)); | 30 | this(getOuterClass(className), getInnerName(className), null); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | public ClassEntry(@Nullable ClassEntry parent, String className) { | 33 | public ClassEntry(@Nullable ClassEntry parent, String className) { |
| 34 | super(parent, className); | 34 | this(parent, className, null); |
| 35 | } | ||
| 36 | |||
| 37 | public ClassEntry(@Nullable ClassEntry parent, String className, @Nullable String javadocs) { | ||
| 38 | super(parent, className, javadocs); | ||
| 35 | if (parent != null) { | 39 | if (parent != null) { |
| 36 | fullName = parent.getFullName() + "$" + name; | 40 | fullName = parent.getFullName() + "$" + name; |
| 37 | } else { | 41 | } else { |
| @@ -69,7 +73,8 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 69 | } | 73 | } |
| 70 | 74 | ||
| 71 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 75 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 72 | return new ClassEntry(parent, translatedName); | 76 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 77 | return new ClassEntry(parent, translatedName, docs); | ||
| 73 | } | 78 | } |
| 74 | 79 | ||
| 75 | @Override | 80 | @Override |
| @@ -103,12 +108,12 @@ public class ClassEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 103 | 108 | ||
| 104 | @Override | 109 | @Override |
| 105 | public ClassEntry withName(String name) { | 110 | public ClassEntry withName(String name) { |
| 106 | return new ClassEntry(parent, name); | 111 | return new ClassEntry(parent, name, javadocs); |
| 107 | } | 112 | } |
| 108 | 113 | ||
| 109 | @Override | 114 | @Override |
| 110 | public ClassEntry withParent(ClassEntry parent) { | 115 | public ClassEntry withParent(ClassEntry parent) { |
| 111 | return new ClassEntry(parent, name); | 116 | return new ClassEntry(parent, name, javadocs); |
| 112 | } | 117 | } |
| 113 | 118 | ||
| 114 | @Override | 119 | @Override |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java index 29a55d8..72b0391 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/Entry.java | |||
| @@ -22,6 +22,8 @@ import java.util.List; | |||
| 22 | public interface Entry<P extends Entry<?>> extends Translatable { | 22 | public interface Entry<P extends Entry<?>> extends Translatable { |
| 23 | String getName(); | 23 | String getName(); |
| 24 | 24 | ||
| 25 | String getJavadocs(); | ||
| 26 | |||
| 25 | default String getSourceRemapName() { | 27 | default String getSourceRemapName() { |
| 26 | return getName(); | 28 | return getName(); |
| 27 | } | 29 | } |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java index 74176fd..46c0b00 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/FieldDefEntry.java | |||
| @@ -26,7 +26,11 @@ public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { | |||
| 26 | private final Signature signature; | 26 | private final Signature signature; |
| 27 | 27 | ||
| 28 | public FieldDefEntry(ClassEntry owner, String name, TypeDescriptor desc, Signature signature, AccessFlags access) { | 28 | public FieldDefEntry(ClassEntry owner, String name, TypeDescriptor desc, Signature signature, AccessFlags access) { |
| 29 | super(owner, name, desc); | 29 | this(owner, name, desc, signature, access, null); |
| 30 | } | ||
| 31 | |||
| 32 | public FieldDefEntry(ClassEntry owner, String name, TypeDescriptor desc, Signature signature, AccessFlags access, String javadocs) { | ||
| 33 | super(owner, name, desc, javadocs); | ||
| 30 | Preconditions.checkNotNull(access, "Field access cannot be null"); | 34 | Preconditions.checkNotNull(access, "Field access cannot be null"); |
| 31 | Preconditions.checkNotNull(signature, "Field signature cannot be null"); | 35 | Preconditions.checkNotNull(signature, "Field signature cannot be null"); |
| 32 | this.access = access; | 36 | this.access = access; |
| @@ -34,7 +38,7 @@ public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { | |||
| 34 | } | 38 | } |
| 35 | 39 | ||
| 36 | public static FieldDefEntry parse(ClassEntry owner, int access, String name, String desc, String signature) { | 40 | public static FieldDefEntry parse(ClassEntry owner, int access, String name, String desc, String signature) { |
| 37 | return new FieldDefEntry(owner, name, new TypeDescriptor(desc), Signature.createTypedSignature(signature), new AccessFlags(access)); | 41 | return new FieldDefEntry(owner, name, new TypeDescriptor(desc), Signature.createTypedSignature(signature), new AccessFlags(access), null); |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | public static FieldDefEntry parse(FieldDefinition definition) { | 44 | public static FieldDefEntry parse(FieldDefinition definition) { |
| @@ -42,7 +46,7 @@ public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { | |||
| 42 | TypeDescriptor descriptor = new TypeDescriptor(definition.getErasedSignature()); | 46 | TypeDescriptor descriptor = new TypeDescriptor(definition.getErasedSignature()); |
| 43 | Signature signature = Signature.createTypedSignature(definition.getSignature()); | 47 | Signature signature = Signature.createTypedSignature(definition.getSignature()); |
| 44 | AccessFlags access = new AccessFlags(definition.getModifiers()); | 48 | AccessFlags access = new AccessFlags(definition.getModifiers()); |
| 45 | return new FieldDefEntry(owner, definition.getName(), descriptor, signature, access); | 49 | return new FieldDefEntry(owner, definition.getName(), descriptor, signature, access, null); |
| 46 | } | 50 | } |
| 47 | 51 | ||
| 48 | @Override | 52 | @Override |
| @@ -60,16 +64,17 @@ public class FieldDefEntry extends FieldEntry implements DefEntry<ClassEntry> { | |||
| 60 | Signature translatedSignature = translator.translate(signature); | 64 | Signature translatedSignature = translator.translate(signature); |
| 61 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 65 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 62 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; | 66 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; |
| 63 | return new FieldDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess); | 67 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 68 | return new FieldDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess, docs); | ||
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | @Override | 71 | @Override |
| 67 | public FieldDefEntry withName(String name) { | 72 | public FieldDefEntry withName(String name) { |
| 68 | return new FieldDefEntry(parent, name, desc, signature, access); | 73 | return new FieldDefEntry(parent, name, desc, signature, access, javadocs); |
| 69 | } | 74 | } |
| 70 | 75 | ||
| 71 | @Override | 76 | @Override |
| 72 | public FieldDefEntry withParent(ClassEntry owner) { | 77 | public FieldDefEntry withParent(ClassEntry owner) { |
| 73 | return new FieldDefEntry(owner, this.name, this.desc, signature, access); | 78 | return new FieldDefEntry(owner, this.name, this.desc, signature, access, javadocs); |
| 74 | } | 79 | } |
| 75 | } | 80 | } |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java index 700512e..bef0edf 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/FieldEntry.java | |||
| @@ -23,7 +23,11 @@ public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 23 | protected final TypeDescriptor desc; | 23 | protected final TypeDescriptor desc; |
| 24 | 24 | ||
| 25 | public FieldEntry(ClassEntry parent, String name, TypeDescriptor desc) { | 25 | public FieldEntry(ClassEntry parent, String name, TypeDescriptor desc) { |
| 26 | super(parent, name); | 26 | this(parent, name, desc, null); |
| 27 | } | ||
| 28 | |||
| 29 | public FieldEntry(ClassEntry parent, String name, TypeDescriptor desc, String javadocs) { | ||
| 30 | super(parent, name, javadocs); | ||
| 27 | 31 | ||
| 28 | Preconditions.checkNotNull(parent, "Owner cannot be null"); | 32 | Preconditions.checkNotNull(parent, "Owner cannot be null"); |
| 29 | Preconditions.checkNotNull(desc, "Field descriptor cannot be null"); | 33 | Preconditions.checkNotNull(desc, "Field descriptor cannot be null"); |
| @@ -32,7 +36,7 @@ public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 32 | } | 36 | } |
| 33 | 37 | ||
| 34 | public static FieldEntry parse(String owner, String name, String desc) { | 38 | public static FieldEntry parse(String owner, String name, String desc) { |
| 35 | return new FieldEntry(new ClassEntry(owner), name, new TypeDescriptor(desc)); | 39 | return new FieldEntry(new ClassEntry(owner), name, new TypeDescriptor(desc), null); |
| 36 | } | 40 | } |
| 37 | 41 | ||
| 38 | @Override | 42 | @Override |
| @@ -46,18 +50,19 @@ public class FieldEntry extends ParentedEntry<ClassEntry> implements Comparable< | |||
| 46 | 50 | ||
| 47 | @Override | 51 | @Override |
| 48 | public FieldEntry withName(String name) { | 52 | public FieldEntry withName(String name) { |
| 49 | return new FieldEntry(parent, name, desc); | 53 | return new FieldEntry(parent, name, desc, null); |
| 50 | } | 54 | } |
| 51 | 55 | ||
| 52 | @Override | 56 | @Override |
| 53 | public FieldEntry withParent(ClassEntry parent) { | 57 | public FieldEntry withParent(ClassEntry parent) { |
| 54 | return new FieldEntry(parent, this.name, this.desc); | 58 | return new FieldEntry(parent, this.name, this.desc, null); |
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | @Override | 61 | @Override |
| 58 | protected FieldEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 62 | protected FieldEntry translate(Translator translator, @Nullable EntryMapping mapping) { |
| 59 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 63 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 60 | return new FieldEntry(parent, translatedName, translator.translate(desc)); | 64 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 65 | return new FieldEntry(parent, translatedName, translator.translate(desc), docs); | ||
| 61 | } | 66 | } |
| 62 | 67 | ||
| 63 | @Override | 68 | @Override |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java index c6f32b6..aad4236 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableDefEntry.java | |||
| @@ -15,8 +15,8 @@ import javax.annotation.Nullable; | |||
| 15 | public class LocalVariableDefEntry extends LocalVariableEntry { | 15 | public class LocalVariableDefEntry extends LocalVariableEntry { |
| 16 | protected final TypeDescriptor desc; | 16 | protected final TypeDescriptor desc; |
| 17 | 17 | ||
| 18 | public LocalVariableDefEntry(MethodEntry ownerEntry, int index, String name, boolean parameter, TypeDescriptor desc) { | 18 | public LocalVariableDefEntry(MethodEntry ownerEntry, int index, String name, boolean parameter, TypeDescriptor desc, String javadoc) { |
| 19 | super(ownerEntry, index, name, parameter); | 19 | super(ownerEntry, index, name, parameter, javadoc); |
| 20 | Preconditions.checkNotNull(desc, "Variable desc cannot be null"); | 20 | Preconditions.checkNotNull(desc, "Variable desc cannot be null"); |
| 21 | 21 | ||
| 22 | this.desc = desc; | 22 | this.desc = desc; |
| @@ -30,17 +30,18 @@ public class LocalVariableDefEntry extends LocalVariableEntry { | |||
| 30 | public LocalVariableDefEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 30 | public LocalVariableDefEntry translate(Translator translator, @Nullable EntryMapping mapping) { |
| 31 | TypeDescriptor translatedDesc = translator.translate(desc); | 31 | TypeDescriptor translatedDesc = translator.translate(desc); |
| 32 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 32 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 33 | return new LocalVariableDefEntry(parent, index, translatedName, parameter, translatedDesc); | 33 | String javadoc = mapping != null ? mapping.getJavadoc() : javadocs; |
| 34 | return new LocalVariableDefEntry(parent, index, translatedName, parameter, translatedDesc, javadoc); | ||
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | @Override | 37 | @Override |
| 37 | public LocalVariableDefEntry withName(String name) { | 38 | public LocalVariableDefEntry withName(String name) { |
| 38 | return new LocalVariableDefEntry(parent, index, name, parameter, desc); | 39 | return new LocalVariableDefEntry(parent, index, name, parameter, desc, javadocs); |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | @Override | 42 | @Override |
| 42 | public LocalVariableDefEntry withParent(MethodEntry entry) { | 43 | public LocalVariableDefEntry withParent(MethodEntry entry) { |
| 43 | return new LocalVariableDefEntry(entry, index, name, parameter, desc); | 44 | return new LocalVariableDefEntry(entry, index, name, parameter, desc, javadocs); |
| 44 | } | 45 | } |
| 45 | 46 | ||
| 46 | @Override | 47 | @Override |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java index 6fdb79f..3ccb1fa 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/LocalVariableEntry.java | |||
| @@ -17,8 +17,8 @@ public class LocalVariableEntry extends ParentedEntry<MethodEntry> implements Co | |||
| 17 | protected final int index; | 17 | protected final int index; |
| 18 | protected final boolean parameter; | 18 | protected final boolean parameter; |
| 19 | 19 | ||
| 20 | public LocalVariableEntry(MethodEntry parent, int index, String name, boolean parameter) { | 20 | public LocalVariableEntry(MethodEntry parent, int index, String name, boolean parameter, String javadoc) { |
| 21 | super(parent, name); | 21 | super(parent, name, javadoc); |
| 22 | 22 | ||
| 23 | Preconditions.checkNotNull(parent, "Variable owner cannot be null"); | 23 | Preconditions.checkNotNull(parent, "Variable owner cannot be null"); |
| 24 | Preconditions.checkArgument(index >= 0, "Index must be positive"); | 24 | Preconditions.checkArgument(index >= 0, "Index must be positive"); |
| @@ -48,17 +48,18 @@ public class LocalVariableEntry extends ParentedEntry<MethodEntry> implements Co | |||
| 48 | @Override | 48 | @Override |
| 49 | public LocalVariableEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 49 | public LocalVariableEntry translate(Translator translator, @Nullable EntryMapping mapping) { |
| 50 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 50 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 51 | return new LocalVariableEntry(parent, index, translatedName, parameter); | 51 | String javadoc = mapping != null ? mapping.getJavadoc() : null; |
| 52 | return new LocalVariableEntry(parent, index, translatedName, parameter, javadoc); | ||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | @Override | 55 | @Override |
| 55 | public LocalVariableEntry withName(String name) { | 56 | public LocalVariableEntry withName(String name) { |
| 56 | return new LocalVariableEntry(parent, index, name, parameter); | 57 | return new LocalVariableEntry(parent, index, name, parameter, javadocs); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | @Override | 60 | @Override |
| 60 | public LocalVariableEntry withParent(MethodEntry parent) { | 61 | public LocalVariableEntry withParent(MethodEntry parent) { |
| 61 | return new LocalVariableEntry(parent, index, name, parameter); | 62 | return new LocalVariableEntry(parent, index, name, parameter, javadocs); |
| 62 | } | 63 | } |
| 63 | 64 | ||
| 64 | @Override | 65 | @Override |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java index 7e89f6a..280b605 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/MethodDefEntry.java | |||
| @@ -26,7 +26,11 @@ public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> | |||
| 26 | private final Signature signature; | 26 | private final Signature signature; |
| 27 | 27 | ||
| 28 | public MethodDefEntry(ClassEntry owner, String name, MethodDescriptor descriptor, Signature signature, AccessFlags access) { | 28 | public MethodDefEntry(ClassEntry owner, String name, MethodDescriptor descriptor, Signature signature, AccessFlags access) { |
| 29 | super(owner, name, descriptor); | 29 | this(owner, name, descriptor, signature, access, null); |
| 30 | } | ||
| 31 | |||
| 32 | public MethodDefEntry(ClassEntry owner, String name, MethodDescriptor descriptor, Signature signature, AccessFlags access, String docs) { | ||
| 33 | super(owner, name, descriptor, docs); | ||
| 30 | Preconditions.checkNotNull(access, "Method access cannot be null"); | 34 | Preconditions.checkNotNull(access, "Method access cannot be null"); |
| 31 | Preconditions.checkNotNull(signature, "Method signature cannot be null"); | 35 | Preconditions.checkNotNull(signature, "Method signature cannot be null"); |
| 32 | this.access = access; | 36 | this.access = access; |
| @@ -34,7 +38,7 @@ public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> | |||
| 34 | } | 38 | } |
| 35 | 39 | ||
| 36 | public static MethodDefEntry parse(ClassEntry owner, int access, String name, String desc, String signature) { | 40 | public static MethodDefEntry parse(ClassEntry owner, int access, String name, String desc, String signature) { |
| 37 | return new MethodDefEntry(owner, name, new MethodDescriptor(desc), Signature.createSignature(signature), new AccessFlags(access)); | 41 | return new MethodDefEntry(owner, name, new MethodDescriptor(desc), Signature.createSignature(signature), new AccessFlags(access), null); |
| 38 | } | 42 | } |
| 39 | 43 | ||
| 40 | public static MethodDefEntry parse(MethodDefinition definition) { | 44 | public static MethodDefEntry parse(MethodDefinition definition) { |
| @@ -42,7 +46,7 @@ public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> | |||
| 42 | MethodDescriptor descriptor = new MethodDescriptor(definition.getErasedSignature()); | 46 | MethodDescriptor descriptor = new MethodDescriptor(definition.getErasedSignature()); |
| 43 | Signature signature = Signature.createSignature(definition.getSignature()); | 47 | Signature signature = Signature.createSignature(definition.getSignature()); |
| 44 | AccessFlags access = new AccessFlags(definition.getModifiers()); | 48 | AccessFlags access = new AccessFlags(definition.getModifiers()); |
| 45 | return new MethodDefEntry(classEntry, definition.getName(), descriptor, signature, access); | 49 | return new MethodDefEntry(classEntry, definition.getName(), descriptor, signature, access, null); |
| 46 | } | 50 | } |
| 47 | 51 | ||
| 48 | @Override | 52 | @Override |
| @@ -60,16 +64,17 @@ public class MethodDefEntry extends MethodEntry implements DefEntry<ClassEntry> | |||
| 60 | Signature translatedSignature = translator.translate(signature); | 64 | Signature translatedSignature = translator.translate(signature); |
| 61 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 65 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 62 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; | 66 | AccessFlags translatedAccess = mapping != null ? mapping.getAccessModifier().transform(access) : access; |
| 63 | return new MethodDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess); | 67 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 68 | return new MethodDefEntry(parent, translatedName, translatedDesc, translatedSignature, translatedAccess, docs); | ||
| 64 | } | 69 | } |
| 65 | 70 | ||
| 66 | @Override | 71 | @Override |
| 67 | public MethodDefEntry withName(String name) { | 72 | public MethodDefEntry withName(String name) { |
| 68 | return new MethodDefEntry(parent, name, descriptor, signature, access); | 73 | return new MethodDefEntry(parent, name, descriptor, signature, access, javadocs); |
| 69 | } | 74 | } |
| 70 | 75 | ||
| 71 | @Override | 76 | @Override |
| 72 | public MethodDefEntry withParent(ClassEntry parent) { | 77 | public MethodDefEntry withParent(ClassEntry parent) { |
| 73 | return new MethodDefEntry(new ClassEntry(parent.getFullName()), name, descriptor, signature, access); | 78 | return new MethodDefEntry(new ClassEntry(parent.getFullName()), name, descriptor, signature, access, javadocs); |
| 74 | } | 79 | } |
| 75 | } | 80 | } |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java index f5d5c74..e1ffad3 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/MethodEntry.java | |||
| @@ -24,7 +24,11 @@ public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable | |||
| 24 | protected final MethodDescriptor descriptor; | 24 | protected final MethodDescriptor descriptor; |
| 25 | 25 | ||
| 26 | public MethodEntry(ClassEntry parent, String name, MethodDescriptor descriptor) { | 26 | public MethodEntry(ClassEntry parent, String name, MethodDescriptor descriptor) { |
| 27 | super(parent, name); | 27 | this(parent, name, descriptor, null); |
| 28 | } | ||
| 29 | |||
| 30 | public MethodEntry(ClassEntry parent, String name, MethodDescriptor descriptor, String javadocs) { | ||
| 31 | super(parent, name, javadocs); | ||
| 28 | 32 | ||
| 29 | Preconditions.checkNotNull(parent, "Parent cannot be null"); | 33 | Preconditions.checkNotNull(parent, "Parent cannot be null"); |
| 30 | Preconditions.checkNotNull(descriptor, "Method descriptor cannot be null"); | 34 | Preconditions.checkNotNull(descriptor, "Method descriptor cannot be null"); |
| @@ -33,7 +37,7 @@ public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable | |||
| 33 | } | 37 | } |
| 34 | 38 | ||
| 35 | public static MethodEntry parse(String owner, String name, String desc) { | 39 | public static MethodEntry parse(String owner, String name, String desc) { |
| 36 | return new MethodEntry(new ClassEntry(owner), name, new MethodDescriptor(desc)); | 40 | return new MethodEntry(new ClassEntry(owner), name, new MethodDescriptor(desc), null); |
| 37 | } | 41 | } |
| 38 | 42 | ||
| 39 | @Override | 43 | @Override |
| @@ -52,17 +56,18 @@ public class MethodEntry extends ParentedEntry<ClassEntry> implements Comparable | |||
| 52 | @Override | 56 | @Override |
| 53 | public MethodEntry translate(Translator translator, @Nullable EntryMapping mapping) { | 57 | public MethodEntry translate(Translator translator, @Nullable EntryMapping mapping) { |
| 54 | String translatedName = mapping != null ? mapping.getTargetName() : name; | 58 | String translatedName = mapping != null ? mapping.getTargetName() : name; |
| 55 | return new MethodEntry(parent, translatedName, translator.translate(descriptor)); | 59 | String docs = mapping != null ? mapping.getJavadoc() : null; |
| 60 | return new MethodEntry(parent, translatedName, translator.translate(descriptor), docs); | ||
| 56 | } | 61 | } |
| 57 | 62 | ||
| 58 | @Override | 63 | @Override |
| 59 | public MethodEntry withName(String name) { | 64 | public MethodEntry withName(String name) { |
| 60 | return new MethodEntry(parent, name, descriptor); | 65 | return new MethodEntry(parent, name, descriptor, javadocs); |
| 61 | } | 66 | } |
| 62 | 67 | ||
| 63 | @Override | 68 | @Override |
| 64 | public MethodEntry withParent(ClassEntry parent) { | 69 | public MethodEntry withParent(ClassEntry parent) { |
| 65 | return new MethodEntry(new ClassEntry(parent.getFullName()), name, descriptor); | 70 | return new MethodEntry(new ClassEntry(parent.getFullName()), name, descriptor, javadocs); |
| 66 | } | 71 | } |
| 67 | 72 | ||
| 68 | @Override | 73 | @Override |
diff --git a/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java b/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java index b753d3a..cbc5faf 100644 --- a/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java +++ b/src/main/java/cuchaz/enigma/translation/representation/entry/ParentedEntry.java | |||
| @@ -24,10 +24,12 @@ import javax.annotation.Nullable; | |||
| 24 | public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { | 24 | public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { |
| 25 | protected final P parent; | 25 | protected final P parent; |
| 26 | protected final String name; | 26 | protected final String name; |
| 27 | protected final @Nullable String javadocs; | ||
| 27 | 28 | ||
| 28 | protected ParentedEntry(P parent, String name) { | 29 | protected ParentedEntry(P parent, String name, String javadocs) { |
| 29 | this.parent = parent; | 30 | this.parent = parent; |
| 30 | this.name = name; | 31 | this.name = name; |
| 32 | this.javadocs = javadocs; | ||
| 31 | 33 | ||
| 32 | Preconditions.checkNotNull(name, "Name cannot be null"); | 34 | Preconditions.checkNotNull(name, "Name cannot be null"); |
| 33 | } | 35 | } |
| @@ -51,6 +53,12 @@ public abstract class ParentedEntry<P extends Entry<?>> implements Entry<P> { | |||
| 51 | return parent; | 53 | return parent; |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 56 | @Nullable | ||
| 57 | @Override | ||
| 58 | public String getJavadocs() { | ||
| 59 | return javadocs; | ||
| 60 | } | ||
| 61 | |||
| 54 | @Override | 62 | @Override |
| 55 | public ParentedEntry<P> translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { | 63 | public ParentedEntry<P> translate(Translator translator, EntryResolver resolver, EntryMap<EntryMapping> mappings) { |
| 56 | P parent = getParent(); | 64 | P parent = getParent(); |