Skip to content

Commit e4aabdb

Browse files
use obf local entry to lookup descriptor instead of deobf (which is not in index)
1 parent 36bf71e commit e4aabdb

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

enigma-swing/src/main/java/org/quiltmc/enigma/gui/panel/IdentifierPanel.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package org.quiltmc.enigma.gui.panel;
22

3+
import org.quiltmc.enigma.api.EnigmaProject;
34
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;
75
import org.quiltmc.enigma.api.translation.representation.TypeDescriptor;
6+
import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableDefEntry;
87
import org.quiltmc.enigma.gui.EditableType;
98
import org.quiltmc.enigma.gui.Gui;
109
import org.quiltmc.enigma.gui.config.Config;
@@ -27,6 +26,7 @@
2726
import java.awt.GridBagConstraints;
2827
import java.awt.GridBagLayout;
2928
import java.awt.event.MouseEvent;
29+
import javax.annotation.Nullable;
3030
import javax.swing.BorderFactory;
3131
import javax.swing.JLabel;
3232
import javax.swing.JPanel;
@@ -77,7 +77,8 @@ public boolean startRenaming(String text) {
7777
}
7878

7979
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);
8182

8283
// Prevent IdentifierPanel from being rebuilt if you didn't click off.
8384
if (this.lastEntry == this.entry && this.nameField != null) {
@@ -159,19 +160,20 @@ public void refreshReference() {
159160
th.addStringRow(I18n.translate("info_panel.identifier.index"), Integer.toString(local.getIndex()));
160161

161162
// 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);
170172
} else {
171173
throw new IllegalStateException("unreachable");
172174
}
173175

174-
var mapping = this.gui.getController().getProject().getRemapper().getMapping(this.entry);
176+
var mapping = project.getRemapper().getMapping(this.entry);
175177
if (Config.main().development.showMappingSourcePlugin.value() && mapping.tokenType().isProposed()) {
176178
th.addStringRow(I18n.translate("dev.source_plugin"), mapping.sourcePluginId());
177179
}

0 commit comments

Comments
 (0)