diff options
5 files changed, 14 insertions, 11 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java index 28b4043e..3b8ecbc5 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/util/GuiUtil.java | |||
| @@ -20,6 +20,7 @@ import javax.swing.tree.TreePath; | |||
| 20 | import com.formdev.flatlaf.extras.FlatSVGIcon; | 20 | import com.formdev.flatlaf.extras.FlatSVGIcon; |
| 21 | import com.google.common.collect.Lists; | 21 | import com.google.common.collect.Lists; |
| 22 | 22 | ||
| 23 | import cuchaz.enigma.analysis.index.EntryIndex; | ||
| 23 | import cuchaz.enigma.gui.Gui; | 24 | import cuchaz.enigma.gui.Gui; |
| 24 | import cuchaz.enigma.translation.representation.AccessFlags; | 25 | import cuchaz.enigma.translation.representation.AccessFlags; |
| 25 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | 26 | import cuchaz.enigma.translation.representation.entry.ClassEntry; |
| @@ -119,7 +120,8 @@ public class GuiUtil { | |||
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | public static Icon getClassIcon(Gui gui, ClassEntry entry) { | 122 | public static Icon getClassIcon(Gui gui, ClassEntry entry) { |
| 122 | AccessFlags access = gui.getController().project.getJarIndex().getEntryIndex().getClassAccess(entry); | 123 | EntryIndex entryIndex = gui.getController().project.getJarIndex().getEntryIndex(); |
| 124 | AccessFlags access = entryIndex.getClassAccess(entry); | ||
| 123 | 125 | ||
| 124 | if (access != null) { | 126 | if (access != null) { |
| 125 | if (access.isAnnotation()) { | 127 | if (access.isAnnotation()) { |
| @@ -128,7 +130,7 @@ public class GuiUtil { | |||
| 128 | return INTERFACE_ICON; | 130 | return INTERFACE_ICON; |
| 129 | } else if (access.isEnum()) { | 131 | } else if (access.isEnum()) { |
| 130 | return ENUM_ICON; | 132 | return ENUM_ICON; |
| 131 | } else if (access.isRecord()) { | 133 | } else if (entryIndex.getDefinition(entry).isRecord()) { |
| 132 | return RECORD_ICON; | 134 | return RECORD_ICON; |
| 133 | } | 135 | } |
| 134 | } | 136 | } |
diff --git a/enigma/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java b/enigma/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java index 4e8940ad..14fd1684 100644 --- a/enigma/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java +++ b/enigma/src/main/java/cuchaz/enigma/source/cfr/EnigmaDumper.java | |||
| @@ -150,7 +150,7 @@ public class EnigmaDumper extends StringStreamDumper { | |||
| 150 | 150 | ||
| 151 | String javaDoc = mapping.javadoc(); | 151 | String javaDoc = mapping.javadoc(); |
| 152 | if (javaDoc != null) { | 152 | if (javaDoc != null) { |
| 153 | recordComponentDocs.add(String.format("@param %s %s", field.getFieldName(), javaDoc)); | 153 | recordComponentDocs.add(String.format("@param %s %s", mapping.targetName(), javaDoc)); |
| 154 | } | 154 | } |
| 155 | } | 155 | } |
| 156 | } | 156 | } |
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 0977b742..0268834d 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/mapping/EntryRemapper.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/mapping/EntryRemapper.java | |||
| @@ -88,9 +88,9 @@ public class EntryRemapper { | |||
| 88 | } | 88 | } |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | // A little bit of a hack to also map the getter method for record fields/components. | 91 | // A little bit of a hack to also map the getter method for record fields. |
| 92 | private void mapRecordComponentGetter(ValidationContext vc, ClassEntry classEntry, FieldEntry fieldEntry, EntryMapping fieldMapping) { | 92 | private void mapRecordComponentGetter(ValidationContext vc, ClassEntry classEntry, FieldEntry fieldEntry, EntryMapping fieldMapping) { |
| 93 | if (!jarIndex.getEntryIndex().getClassAccess(classEntry).isRecord() || jarIndex.getEntryIndex().getFieldAccess(fieldEntry).isStatic()) { | 93 | if (!jarIndex.getEntryIndex().getDefinition(classEntry).isRecord() || jarIndex.getEntryIndex().getFieldAccess(fieldEntry).isStatic()) { |
| 94 | return; | 94 | return; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| @@ -102,7 +102,7 @@ public class EntryRemapper { | |||
| 102 | MethodEntry methodEntry = null; | 102 | MethodEntry methodEntry = null; |
| 103 | 103 | ||
| 104 | for (MethodEntry method : classMethods) { | 104 | for (MethodEntry method : classMethods) { |
| 105 | // Find the matching record component getter via matching the names. My understanding is this is safe, failing this it may need to be a bit more intelligent | 105 | // Find the matching record component getter via matching the names. TODO: Support when the record field and method names do not match |
| 106 | if (method.getName().equals(fieldEntry.getName()) && method.getDesc().toString().equals("()" + fieldEntry.getDesc())) { | 106 | if (method.getName().equals(fieldEntry.getName()) && method.getDesc().toString().equals("()" + fieldEntry.getDesc())) { |
| 107 | methodEntry = method; | 107 | methodEntry = method; |
| 108 | break; | 108 | break; |
| @@ -114,7 +114,8 @@ public class EntryRemapper { | |||
| 114 | return; | 114 | return; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | putMapping(vc, methodEntry, fieldMapping != null ? new EntryMapping(fieldMapping.targetName()) : null); | 117 | // Also remap the associated method, without the javadoc. |
| 118 | doPutMapping(vc, methodEntry, new EntryMapping(fieldMapping.targetName()), false); | ||
| 118 | } | 119 | } |
| 119 | 120 | ||
| 120 | @Nonnull | 121 | @Nonnull |
diff --git a/enigma/src/main/java/cuchaz/enigma/translation/representation/AccessFlags.java b/enigma/src/main/java/cuchaz/enigma/translation/representation/AccessFlags.java index 21e6ef4e..e8480a26 100644 --- a/enigma/src/main/java/cuchaz/enigma/translation/representation/AccessFlags.java +++ b/enigma/src/main/java/cuchaz/enigma/translation/representation/AccessFlags.java | |||
| @@ -39,10 +39,6 @@ public class AccessFlags { | |||
| 39 | return (flags & Opcodes.ACC_ENUM) != 0; | 39 | return (flags & Opcodes.ACC_ENUM) != 0; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | public boolean isRecord() { | ||
| 43 | return (flags & Opcodes.ACC_RECORD) != 0; | ||
| 44 | } | ||
| 45 | |||
| 46 | public boolean isBridge() { | 42 | public boolean isBridge() { |
| 47 | return (flags & Opcodes.ACC_BRIDGE) != 0; | 43 | return (flags & Opcodes.ACC_BRIDGE) != 0; |
| 48 | } | 44 | } |
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 237c93dc..ab5a422f 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 | |||
| @@ -75,6 +75,10 @@ public class ClassDefEntry extends ClassEntry implements DefEntry<ClassEntry> { | |||
| 75 | return interfaces; | 75 | return interfaces; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | public boolean isRecord() { | ||
| 79 | return superClass.getName().equals("java/lang/Record"); | ||
| 80 | } | ||
| 81 | |||
| 78 | @Override | 82 | @Override |
| 79 | public TranslateResult<ClassDefEntry> extendedTranslate(Translator translator, @Nonnull EntryMapping mapping) { | 83 | public TranslateResult<ClassDefEntry> extendedTranslate(Translator translator, @Nonnull EntryMapping mapping) { |
| 80 | Signature translatedSignature = translator.translate(signature); | 84 | Signature translatedSignature = translator.translate(signature); |