Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Let enigma suggest "o" for equals parameter for now #4

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Expand Up @@ -26,15 +26,18 @@
import cuchaz.enigma.api.service.NameProposalService;
import cuchaz.enigma.classprovider.ClassProvider;
import cuchaz.enigma.translation.mapping.EntryRemapper;
import cuchaz.enigma.translation.representation.MethodDescriptor;
import cuchaz.enigma.translation.representation.entry.Entry;
import cuchaz.enigma.translation.representation.entry.FieldEntry;
import cuchaz.enigma.translation.representation.entry.LocalVariableEntry;
import cuchaz.enigma.translation.representation.entry.MethodEntry;
import org.objectweb.asm.tree.ClassNode;

import net.fabricmc.nameproposal.MappingEntry;
import net.fabricmc.nameproposal.NameFinder;

public class EnimgaNameProposalService implements JarIndexerService, NameProposalService {
private static final MethodDescriptor EQUALS_DESC = new MethodDescriptor("(Ljava/lang/Object;)Z");
private Map<String, String> recordNames;
Map<MappingEntry, String> fieldNames;

Expand Down Expand Up @@ -65,6 +68,16 @@ public Optional<String> proposeName(Entry<?> obfEntry, EntryRemapper remapper) {
if (methodEntry.getName().startsWith("comp_")) {
return Optional.ofNullable(recordNames.get(methodEntry.getName()));
}
} else if (obfEntry instanceof LocalVariableEntry paramEntry) {
MethodEntry parent = paramEntry.getParent();

if (parent == null) {
return Optional.empty();
}

if (parent.getDesc().equals(EQUALS_DESC) && parent.getName().equals("equals")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checkstyle :)

return Optional.of("o");
}
}

return Optional.empty();
Expand Down