From 8eabe886a3f4845c1f97c89c15723485e94c94b0 Mon Sep 17 00:00:00 2001 From: IotaBread Date: Tue, 9 Apr 2024 22:06:39 -0400 Subject: [PATCH] Skip simple-type names from delegate parameters name proposer --- build.gradle | 6 +++--- gradle/libs.versions.toml | 4 ++-- .../proposal/DelegateParametersNameProposer.java | 15 +++++++++++++-- .../enigma_plugin/proposal/NameProposer.java | 6 +++++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 67f409f..7a2ad9e 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { id 'org.quiltmc.gradle.licenser' version '2.0.1' } -version '2.2.0' +version '2.2.1' group 'org.quiltmc' version = version + (System.getenv("GITHUB_ACTIONS") ? "" : "+local") @@ -42,9 +42,9 @@ repositories { includeModule('net.fabricmc', 'cfr') } } + // remove when ASM fix is released maven { - // Vineflower snapshots - url "https://s01.oss.sonatype.org/content/repositories/snapshots/" + url = "https://repository.ow2.org/nexus/content/repositories/snapshots/" } // Test inputs dependencies diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3856b28..259b0b1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -enigma = "2.2.0" +enigma = "2.3.0" -asm = "9.6" +asm = "9.8-20240409.145119-3" quilt_json5 = "1.0.3" tinylog = "2.6.2" annotations = "23.0.0" diff --git a/src/main/java/org/quiltmc/enigma_plugin/proposal/DelegateParametersNameProposer.java b/src/main/java/org/quiltmc/enigma_plugin/proposal/DelegateParametersNameProposer.java index 9b6e28e..edb024f 100644 --- a/src/main/java/org/quiltmc/enigma_plugin/proposal/DelegateParametersNameProposer.java +++ b/src/main/java/org/quiltmc/enigma_plugin/proposal/DelegateParametersNameProposer.java @@ -27,10 +27,13 @@ import org.tinylog.Logger; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.stream.Stream; public class DelegateParametersNameProposer extends NameProposer { public static final String ID = "delegate_params"; + private static final List IGNORED_SOURCE_PLUGIN_IDS = Stream.of(ID, SimpleTypeFieldNameProposer.ID).map(NameProposer::getSourcePluginId).toList(); private final DelegateParametersIndex index; public DelegateParametersNameProposer(JarIndexer index) { @@ -42,6 +45,14 @@ public DelegateParametersNameProposer(JarIndexer index) { public void insertProposedNames(JarIndex index, Map, EntryMapping> mappings) { } + private static boolean shouldNotIgnoreMapping(EntryMapping mapping) { + if (mapping == null) { + return false; + } + + return mapping.sourcePluginId() == null || !IGNORED_SOURCE_PLUGIN_IDS.contains(mapping.sourcePluginId()); + } + private String resolveName(EntryRemapper remapper, Map, EntryMapping> mappings, LocalVariableEntry entry) { if (entry == null) { return null; @@ -53,11 +64,11 @@ private String resolveName(EntryRemapper remapper, Map, EntryMapping> m } var mapping = remapper.getMapping(entry); - if (mapping.targetName() != null) { + if (mapping.targetName() != null && shouldNotIgnoreMapping(mapping)) { return mapping.targetName(); } else { mapping = mappings.get(entry); - if (mapping != null && mapping.targetName() != null) { + if (mapping != null && mapping.targetName() != null && shouldNotIgnoreMapping(mapping)) { return mapping.targetName(); } else { return this.resolveName(remapper, mappings, this.index.get(entry)); diff --git a/src/main/java/org/quiltmc/enigma_plugin/proposal/NameProposer.java b/src/main/java/org/quiltmc/enigma_plugin/proposal/NameProposer.java index bf0556b..e35f2e7 100644 --- a/src/main/java/org/quiltmc/enigma_plugin/proposal/NameProposer.java +++ b/src/main/java/org/quiltmc/enigma_plugin/proposal/NameProposer.java @@ -33,7 +33,11 @@ public NameProposer(String id) { } public String getSourcePluginId() { - return QuiltEnigmaPlugin.NAME_PROPOSAL_SERVICE_ID + "/" + this.id; + return getSourcePluginId(this.id); + } + + public static String getSourcePluginId(String id) { + return QuiltEnigmaPlugin.NAME_PROPOSAL_SERVICE_ID + "/" + id; } public void insertProposal(Map, EntryMapping> mappings, Entry entry, EntryMapping mapping) {