Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package org.quiltmc.enigma.gui.panel;

import org.quiltmc.enigma.api.EnigmaProject;
import org.quiltmc.enigma.api.analysis.index.jar.EntryIndex;
import org.quiltmc.enigma.api.analysis.index.jar.JarIndex;
import org.quiltmc.enigma.api.translation.representation.AccessFlags;
import org.quiltmc.enigma.api.translation.representation.ArgumentDescriptor;
import org.quiltmc.enigma.api.translation.representation.TypeDescriptor;
import org.quiltmc.enigma.api.translation.representation.entry.LocalVariableDefEntry;
import org.quiltmc.enigma.gui.EditableType;
import org.quiltmc.enigma.gui.Gui;
import org.quiltmc.enigma.gui.config.Config;
Expand All @@ -27,6 +26,7 @@
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.MouseEvent;
import javax.annotation.Nullable;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand Down Expand Up @@ -77,7 +77,8 @@ public boolean startRenaming(String text) {
}

public void refreshReference() {
this.deobfEntry = this.entry == null ? null : this.gui.getController().getProject().getRemapper().deobfuscate(this.entry);
final EnigmaProject project = this.gui.getController().getProject();
this.deobfEntry = this.entry == null ? null : project.getRemapper().deobfuscate(this.entry);

// Prevent IdentifierPanel from being rebuilt if you didn't click off.
if (this.lastEntry == this.entry && this.nameField != null) {
Expand Down Expand Up @@ -144,40 +145,35 @@ public void refreshReference() {

th.addCopiableStringRow(I18n.translate("info_panel.identifier.obfuscated"), this.entry.getName());
th.addCopiableStringRow(I18n.translate("info_panel.identifier.method_descriptor"), me.getDesc().toString());
} else if (this.deobfEntry instanceof LocalVariableEntry lve) {
} else if (this.deobfEntry instanceof LocalVariableEntry local) {
EditableType type;

if (lve.isArgument()) {
if (local.isArgument()) {
type = EditableType.PARAMETER;
} else {
type = EditableType.LOCAL_VARIABLE;
}

this.nameField = th.addRenameTextField(type, lve.getName());
th.addStringRow(I18n.translate("info_panel.identifier.class"), lve.getContainingClass().getFullName());
th.addCopiableStringRow(I18n.translate("info_panel.identifier.method"), lve.getParent().getName());
th.addStringRow(I18n.translate("info_panel.identifier.index"), Integer.toString(lve.getIndex()));
this.nameField = th.addRenameTextField(type, local.getName());
th.addStringRow(I18n.translate("info_panel.identifier.class"), local.getContainingClass().getFullName());
th.addCopiableStringRow(I18n.translate("info_panel.identifier.method"), local.getParent().getName());
th.addStringRow(I18n.translate("info_panel.identifier.index"), Integer.toString(local.getIndex()));

// type
JarIndex index = this.gui.getController().getProject().getJarIndex();
AccessFlags access = index.getIndex(EntryIndex.class).getMethodAccess(lve.getParent());
int i = access != null && access.isStatic() ? 0 : 1;
var args = lve.getParent().getDesc().getArgumentDescs();

for (ArgumentDescriptor arg : args) {
if (i == lve.getIndex()) {
th.addCopiableStringRow(I18n.translate("info_panel.identifier.type"), toReadableType(arg));
break;
}

var primitive = TypeDescriptor.Primitive.get(arg.toString().charAt(0));
i += primitive == null ? 1 : primitive.getSize();
}
EntryIndex index = project.getJarIndex().getIndex(EntryIndex.class);
// EntryIndex only contains obf entries, so use the obf entry to look up the local's descriptor
@Nullable
final LocalVariableDefEntry obfLocal = index.getDefinition((LocalVariableEntry) this.entry);
final String localDesc = obfLocal == null
? I18n.translate("info_panel.identifier.type.unknown")
: toReadableType(project.getRemapper().deobfuscate(obfLocal.getDesc()));

th.addCopiableStringRow(I18n.translate("info_panel.identifier.type"), localDesc);
} else {
throw new IllegalStateException("unreachable");
}

var mapping = this.gui.getController().getProject().getRemapper().getMapping(this.entry);
var mapping = project.getRemapper().getMapping(this.entry);
if (Config.main().development.showMappingSourcePlugin.value() && mapping.tokenType().isProposed()) {
th.addStringRow(I18n.translate("dev.source_plugin"), mapping.sourcePluginId());
}
Expand Down
1 change: 1 addition & 0 deletions enigma/src/main/resources/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
"info_panel.identifier.outer_class": "Outer class",
"info_panel.identifier.obfuscated": "Obfuscated Name",
"info_panel.identifier.type": "Type",
"info_panel.identifier.type.unknown": "<unknown>",
"info_panel.identifier.method_descriptor": "Method Descriptor",
"info_panel.identifier.index": "Index",
"info_panel.editor.class.decompiling": "(decompiling...)",
Expand Down