Skip to content

Commit

Permalink
Skip simple-type names from delegate parameters name proposer
Browse files Browse the repository at this point in the history
  • Loading branch information
IotaBread committed Apr 10, 2024
1 parent 3e3259f commit 8eabe88
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> IGNORED_SOURCE_PLUGIN_IDS = Stream.of(ID, SimpleTypeFieldNameProposer.ID).map(NameProposer::getSourcePluginId).toList();
private final DelegateParametersIndex index;

public DelegateParametersNameProposer(JarIndexer index) {
Expand All @@ -42,6 +45,14 @@ public DelegateParametersNameProposer(JarIndexer index) {
public void insertProposedNames(JarIndex index, Map<Entry<?>, 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<Entry<?>, EntryMapping> mappings, LocalVariableEntry entry) {
if (entry == null) {
return null;
Expand All @@ -53,11 +64,11 @@ private String resolveName(EntryRemapper remapper, Map<Entry<?>, 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Entry<?>, EntryMapping> mappings, Entry<?> entry, EntryMapping mapping) {
Expand Down

0 comments on commit 8eabe88

Please sign in to comment.