From 64d841acfff4f515173120202172800e1be88f2e Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sat, 2 Nov 2019 01:20:10 +0100 Subject: Support remapping of string-typed mixin targets i.e. the class string in @Mixin("package.SomeClass$Inner") --- src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt index 6065cbe..b2be523 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt @@ -209,7 +209,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile) } // Note: Supports only Mixins with a single target (ignores others) - private fun getMixinTarget(annotation: PsiAnnotation): String? { + private fun getMixinTarget(annotation: PsiAnnotation): ClassMapping<*, *>? { for (pair in annotation.parameterList.attributes) { val name = pair.name if (name == null || "value" == name) { @@ -217,12 +217,19 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile) if (value !is PsiClassObjectAccessExpression) continue val type = value.operand val reference = type.innermostComponentReferenceElement ?: continue - return (reference.resolve() as PsiClass?)?.dollarQualifiedName + val qualifiedName = (reference.resolve() as PsiClass?)?.dollarQualifiedName ?: continue + return map.findClassMapping(qualifiedName) ?: continue } if ("targets" == name) { val value = pair.value if (value !is PsiLiteral) continue - return value.value as? String ?: continue + val qualifiedName = value.value as? String ?: continue + val mapping = map.findClassMapping(qualifiedName) ?: continue + val mapped = mapping.fullDeobfuscatedName?.replace('/', '.') + if (mapped != qualifiedName) { + replace(value, "\"$mapped\"") + } + return mapping } } return null @@ -402,9 +409,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile) remapAtTargets() - val qualifiedName = getMixinTarget(annotation) ?: return - - val mapping = map.findClassMapping(qualifiedName) ?: return + val mapping = getMixinTarget(annotation) ?: return mixinMappings[psiClass.qualifiedName!!] = mapping -- cgit