aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com
diff options
context:
space:
mode:
authorJonas Herzig <me@johni0702.de>2019-11-02 01:20:10 +0100
committerJonas Herzig <me@johni0702.de>2019-11-02 01:30:24 +0100
commit64d841acfff4f515173120202172800e1be88f2e (patch)
tree2e075741e8a36affdfd3b257364e541c15e24333 /src/main/kotlin/com
parent5b9805a803d193ac5ae68ac758ed847bf15efca7 (diff)
downloadRemap-64d841acfff4f515173120202172800e1be88f2e.tar.gz
Remap-64d841acfff4f515173120202172800e1be88f2e.tar.bz2
Remap-64d841acfff4f515173120202172800e1be88f2e.zip
Support remapping of string-typed mixin targets
i.e. the class string in @Mixin("package.SomeClass$Inner")
Diffstat (limited to 'src/main/kotlin/com')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt17
1 files 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