|
1 | 1 | package org.quiltmc.enigma.gui.panel; |
2 | 2 |
|
| 3 | +import org.quiltmc.enigma.api.EnigmaProject; |
3 | 4 | import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex; |
4 | | -import org.quiltmc.enigma.api.analysis.index.jar.JarIndex; |
5 | | -import org.quiltmc.enigma.api.translation.representation.AccessFlags; |
6 | | -import org.quiltmc.enigma.api.translation.representation.ArgumentDescriptor; |
7 | 5 | import org.quiltmc.enigma.api.translation.representation.TypeDescriptor; |
| 6 | +import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableDefEntry; |
8 | 7 | import org.quiltmc.enigma.gui.EditableType; |
9 | 8 | import org.quiltmc.enigma.gui.Gui; |
10 | 9 | import org.quiltmc.enigma.gui.config.Config; |
|
27 | 26 | import java.awt.GridBagConstraints; |
28 | 27 | import java.awt.GridBagLayout; |
29 | 28 | import java.awt.event.MouseEvent; |
| 29 | +import javax.annotation.Nullable; |
30 | 30 | import javax.swing.BorderFactory; |
31 | 31 | import javax.swing.JLabel; |
32 | 32 | import javax.swing.JPanel; |
@@ -77,7 +77,8 @@ public boolean startRenaming(String text) { |
77 | 77 | } |
78 | 78 |
|
79 | 79 | public void refreshReference() { |
80 | | - this.deobfEntry = this.entry == null ? null : this.gui.getController().getProject().getRemapper().deobfuscate(this.entry); |
| 80 | + final EnigmaProject project = this.gui.getController().getProject(); |
| 81 | + this.deobfEntry = this.entry == null ? null : project.getRemapper().deobfuscate(this.entry); |
81 | 82 |
|
82 | 83 | // Prevent IdentifierPanel from being rebuilt if you didn't click off. |
83 | 84 | if (this.lastEntry == this.entry && this.nameField != null) { |
@@ -159,19 +160,20 @@ public void refreshReference() { |
159 | 160 | th.addStringRow(I18n.translate("info_panel.identifier.index"), Integer.toString(local.getIndex())); |
160 | 161 |
|
161 | 162 | // type |
162 | | - EntryIndex index = this.gui.getController().getProject().getJarIndex().getIndex(EntryIndex.class); |
163 | | - final String paramDesc = local.getParent().streamParameters(index) |
164 | | - .filter(param -> param.getIndex() == local.getIndex()) |
165 | | - .findAny() |
166 | | - .map(param -> toReadableType(param.getDesc())) |
167 | | - .orElseGet(() -> I18n.translate("info_panel.identifier.type.unknown")); |
168 | | - |
169 | | - th.addCopiableStringRow(I18n.translate("info_panel.identifier.type"), paramDesc); |
| 163 | + EntryIndex index = project.getJarIndex().getIndex(EntryIndex.class); |
| 164 | + // EntryIndex only contains obf entries, so use the obf entry to look up the local's descriptor |
| 165 | + @Nullable |
| 166 | + final LocalVariableDefEntry obfLocal = index.getDefinition((LocalVariableEntry) this.entry); |
| 167 | + final String localDesc = obfLocal == null |
| 168 | + ? I18n.translate("info_panel.identifier.type.unknown") |
| 169 | + : toReadableType(project.getRemapper().deobfuscate(obfLocal.getDesc())); |
| 170 | + |
| 171 | + th.addCopiableStringRow(I18n.translate("info_panel.identifier.type"), localDesc); |
170 | 172 | } else { |
171 | 173 | throw new IllegalStateException("unreachable"); |
172 | 174 | } |
173 | 175 |
|
174 | | - var mapping = this.gui.getController().getProject().getRemapper().getMapping(this.entry); |
| 176 | + var mapping = project.getRemapper().getMapping(this.entry); |
175 | 177 | if (Config.main().development.showMappingSourcePlugin.value() && mapping.tokenType().isProposed()) { |
176 | 178 | th.addStringRow(I18n.translate("dev.source_plugin"), mapping.sourcePluginId()); |
177 | 179 | } |
|
0 commit comments