aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Herzig <me@johni0702.de>2019-09-08 19:38:47 +0200
committerJonas Herzig <me@johni0702.de>2019-09-08 19:38:47 +0200
commit50af9c4bf7f6e7f7e4b17970dbb044a291ed0c01 (patch)
treeddcf44f67fe5d36d305467931957bc89a1eadc0f
parent9e9816d54d3d05afa8df345c808d50c0381d265f (diff)
downloadRemap-50af9c4bf7f6e7f7e4b17970dbb044a291ed0c01.tar.gz
Remap-50af9c4bf7f6e7f7e4b17970dbb044a291ed0c01.tar.bz2
Remap-50af9c4bf7f6e7f7e4b17970dbb044a291ed0c01.zip
Support remapping @At(NEW) targets (i.e. jvm class name targets)
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index 0e5395a..ca11e96 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -215,6 +215,9 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
})
}
+ private fun remapInternalType(internalType: String): String =
+ StringBuilder().apply { remapInternalType(internalType, this) }.toString()
+
private fun remapInternalType(internalType: String, result: StringBuilder): ClassMapping<*, *>? {
if (internalType[0] == 'L') {
val type = internalType.substring(1, internalType.length - 1).replace('/', '.')
@@ -228,6 +231,18 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
return null
}
+ private fun remapMixinTarget(target: String): String {
+ return if (target.contains(':') || target.contains('(')) {
+ remapFullyQualifiedMethodOrField(target)
+ } else {
+ if (target[0] == 'L') {
+ remapInternalType(target)
+ } else {
+ remapInternalType("L$target;").drop(1).dropLast(1)
+ }
+ }
+ }
+
private fun remapFullyQualifiedMethodOrField(signature: String): String {
val ownerEnd = signature.indexOf(';')
var argsBegin = signature.indexOf('(')
@@ -288,7 +303,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
for (attribute in annotation.parameterList.attributes) {
if ("target" != attribute.name) continue
val signature = attribute.literalValue ?: continue
- val newSignature = remapFullyQualifiedMethodOrField(signature)
+ val newSignature = remapMixinTarget(signature)
if (newSignature != signature) {
val value = attribute.value!!
replace(value, "\"$newSignature\"")