From 50af9c4bf7f6e7f7e4b17970dbb044a291ed0c01 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sun, 8 Sep 2019 19:38:47 +0200 Subject: Support remapping @At(NEW) targets (i.e. jvm class name targets) --- src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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\"") -- cgit