| 
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) {  | 
@@ -144,40 +145,35 @@ public void refreshReference() {  | 
144 | 145 | 
 
  | 
145 | 146 | 				th.addCopiableStringRow(I18n.translate("info_panel.identifier.obfuscated"), this.entry.getName());  | 
146 | 147 | 				th.addCopiableStringRow(I18n.translate("info_panel.identifier.method_descriptor"), me.getDesc().toString());  | 
147 |  | -			} else if (this.deobfEntry instanceof LocalVariableEntry lve) {  | 
 | 148 | +			} else if (this.deobfEntry instanceof LocalVariableEntry local) {  | 
148 | 149 | 				EditableType type;  | 
149 | 150 | 
 
  | 
150 |  | -				if (lve.isArgument()) {  | 
 | 151 | +				if (local.isArgument()) {  | 
151 | 152 | 					type = EditableType.PARAMETER;  | 
152 | 153 | 				} else {  | 
153 | 154 | 					type = EditableType.LOCAL_VARIABLE;  | 
154 | 155 | 				}  | 
155 | 156 | 
 
  | 
156 |  | -				this.nameField = th.addRenameTextField(type, lve.getName());  | 
157 |  | -				th.addStringRow(I18n.translate("info_panel.identifier.class"), lve.getContainingClass().getFullName());  | 
158 |  | -				th.addCopiableStringRow(I18n.translate("info_panel.identifier.method"), lve.getParent().getName());  | 
159 |  | -				th.addStringRow(I18n.translate("info_panel.identifier.index"), Integer.toString(lve.getIndex()));  | 
 | 157 | +				this.nameField = th.addRenameTextField(type, local.getName());  | 
 | 158 | +				th.addStringRow(I18n.translate("info_panel.identifier.class"), local.getContainingClass().getFullName());  | 
 | 159 | +				th.addCopiableStringRow(I18n.translate("info_panel.identifier.method"), local.getParent().getName());  | 
 | 160 | +				th.addStringRow(I18n.translate("info_panel.identifier.index"), Integer.toString(local.getIndex()));  | 
160 | 161 | 
 
  | 
161 | 162 | 				// type  | 
162 |  | -				JarIndex index = this.gui.getController().getProject().getJarIndex();  | 
163 |  | -				AccessFlags access = index.getIndex(EntryIndex.class).getMethodAccess(lve.getParent());  | 
164 |  | -				int i = access != null && access.isStatic() ? 0 : 1;  | 
165 |  | -				var args = lve.getParent().getDesc().getArgumentDescs();  | 
166 |  | - | 
167 |  | -				for (ArgumentDescriptor arg : args) {  | 
168 |  | -					if (i == lve.getIndex()) {  | 
169 |  | -						th.addCopiableStringRow(I18n.translate("info_panel.identifier.type"), toReadableType(arg));  | 
170 |  | -						break;  | 
171 |  | -					}  | 
172 |  | - | 
173 |  | -					var primitive = TypeDescriptor.Primitive.get(arg.toString().charAt(0));  | 
174 |  | -					i += primitive == null ? 1 : primitive.getSize();  | 
175 |  | -				}  | 
 | 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);  | 
176 | 172 | 			} else {  | 
177 | 173 | 				throw new IllegalStateException("unreachable");  | 
178 | 174 | 			}  | 
179 | 175 | 
 
  | 
180 |  | -			var mapping = this.gui.getController().getProject().getRemapper().getMapping(this.entry);  | 
 | 176 | +			var mapping = project.getRemapper().getMapping(this.entry);  | 
181 | 177 | 			if (Config.main().development.showMappingSourcePlugin.value() && mapping.tokenType().isProposed()) {  | 
182 | 178 | 				th.addStringRow(I18n.translate("dev.source_plugin"), mapping.sourcePluginId());  | 
183 | 179 | 			}  | 
 | 
0 commit comments