diff options
author | Jonas Herzig <me@johni0702.de> | 2019-04-29 21:52:08 +0200 |
---|---|---|
committer | Jonas Herzig <me@johni0702.de> | 2019-04-29 21:52:08 +0200 |
commit | 7ab0cc8025b77bf23128e754160fa552a0bf03b0 (patch) | |
tree | bfee301d6b66dad4f23b08be9080454d5fe10d63 | |
parent | a9724e3546b7696a299080d98c8216b9c88dcf96 (diff) | |
download | Remap-7ab0cc8025b77bf23128e754160fa552a0bf03b0.tar.gz Remap-7ab0cc8025b77bf23128e754160fa552a0bf03b0.tar.bz2 Remap-7ab0cc8025b77bf23128e754160fa552a0bf03b0.zip |
Support FIELD targets in @At
-rw-r--r-- | src/main/java/com/replaymod/gradle/remap/Transformer.java | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/main/java/com/replaymod/gradle/remap/Transformer.java b/src/main/java/com/replaymod/gradle/remap/Transformer.java index 2d41083..ae3b385 100644 --- a/src/main/java/com/replaymod/gradle/remap/Transformer.java +++ b/src/main/java/com/replaymod/gradle/remap/Transformer.java @@ -308,35 +308,43 @@ class Transformer { return null; } - private String remapFullyQualifiedMethod(String signature) { + private String remapFullyQualifiedMethodOrField(String signature) { int ownerEnd = signature.indexOf(';'); int argsBegin = signature.indexOf('('); int argsEnd = signature.indexOf(')'); + boolean method = argsBegin != -1; + if (!method) { + argsBegin = argsEnd = signature.indexOf(':'); + } String owner = signature.substring(0, ownerEnd + 1); - String method = signature.substring(ownerEnd + 1, argsBegin); - String args = signature.substring(argsBegin + 1, argsEnd); + String name = signature.substring(ownerEnd + 1, argsBegin); String returnType = signature.substring(argsEnd + 1); StringBuilder builder = new StringBuilder(signature.length() + 32); Mapping mapping = remapInternalType(owner, builder); String mapped = null; if (mapping != null) { - mapped = mapping.methods.get(method); + mapped = (method ? mapping.methods : mapping.fields).get(name); } - builder.append(mapped != null ? mapped : method); - builder.append('('); - for (int i = 0; i < args.length(); i++) { - char c = args.charAt(i); - if (c != 'L') { - builder.append(c); - continue; + builder.append(mapped != null ? mapped : name); + if (method) { + builder.append('('); + String args = signature.substring(argsBegin + 1, argsEnd); + for (int i = 0; i < args.length(); i++) { + char c = args.charAt(i); + if (c != 'L') { + builder.append(c); + continue; + } + int end = args.indexOf(';', i); + String arg = args.substring(i, end + 1); + remapInternalType(arg, builder); + i = end; } - int end = args.indexOf(';', i); - String arg = args.substring(i, end + 1); - remapInternalType(arg, builder); - i = end; + builder.append(')'); + } else { + builder.append(':'); } - builder.append(')'); remapInternalType(returnType, builder); return builder.toString(); } @@ -358,7 +366,7 @@ class Transformer { StringLiteral value = (StringLiteral) pair.getValue(); String signature = value.getLiteralValue(); - String newSignature = remapFullyQualifiedMethod(signature); + String newSignature = remapFullyQualifiedMethodOrField(signature); if (!newSignature.equals(signature)) { value.setLiteralValue(newSignature); changed.set(true); |