Skip to content

Commit

Permalink
Support renaming refmapless accessor methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Apr 4, 2024
1 parent 614a666 commit d37c8f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ versionForge=47.1.3
versionForgeAutoRenamingTool=1.0.11
versionFabricLoader=2.7.2+0.15.3+1.20.1
versionAccessWidener=2.1.0
versionFabricApi=0.92.0+1.11.2+1.20.1
versionFabricApi=0.92.0+1.11.3+1.20.1
versionMixin=0.12.9+mixin.0.8.5
versionMixinTransmog=0.4.4+1.20.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.objectweb.asm.tree.MethodNode;
import org.sinytra.adapter.patch.selector.AnnotationHandle;
import org.sinytra.adapter.patch.util.MethodQualifier;
import org.spongepowered.asm.mixin.gen.AccessorInfo;

import java.io.IOException;
import java.util.Collection;
Expand All @@ -45,6 +46,7 @@ public final class OptimizedRenamingTransformer extends RenamingTransformer {
private static final String FQN_CLASS_NAME_PATTERN = "^(?:[a-zA-Z0-9$_]+\\.)*[a-zA-Z0-9$_]+$";
private static final String INTERNAL_CLASS_NAME_PATTERN = "^(?:[a-zA-Z0-9$_]+/)*[a-zA-Z0-9$_]+$";
private static final Pattern FIELD_QUALIFIER_PATTERN = Pattern.compile("^(?<owner>L[\\\\\\w/$]+;)?(?<name>\\w+)(?::(?<desc>\\[*[ZCBSIFJD]|\\[*L[a-zA-Z0-9/_$]+;))?$");
private static final String ACCESSOR_METHOD_PATTERN = "^.*(Method_|Field_|Comp_).*$";

private final boolean remapRefs;

Expand Down Expand Up @@ -273,6 +275,15 @@ public String mapMethodName(String owner, String name, String descriptor) {
String mapped = fastMappedLambda != null ? fastMappedLambda : mapMethodName(owner, actualName, descriptor);
return name.substring(0, interfacePrefix + 1) + mapped;
}
if (name.matches(ACCESSOR_METHOD_PATTERN)) {
AccessorInfo.AccessorName accessorName = AccessorInfo.AccessorName.of(name);
if (accessorName != null) {
String mapped = this.flatMappings.mapMethod(accessorName.name, descriptor);
if (mapped != null) {
return accessorName.prefix + mapped.substring(0, 1).toUpperCase() + mapped.substring(1);
}
}
}
}
return null;
})
Expand Down

0 comments on commit d37c8f3

Please sign in to comment.