aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod
diff options
context:
space:
mode:
authorJonas Herzig <me@johni0702.de>2019-11-02 01:07:30 +0100
committerJonas Herzig <me@johni0702.de>2019-11-02 01:19:36 +0100
commit5b9805a803d193ac5ae68ac758ed847bf15efca7 (patch)
tree225488b8992d730163313eb11a195b29b2d9d95d /src/main/kotlin/com/replaymod
parent7f7e3709331ece09a3a91ad3520e71bad53a2997 (diff)
downloadRemap-5b9805a803d193ac5ae68ac758ed847bf15efca7.tar.gz
Remap-5b9805a803d193ac5ae68ac758ed847bf15efca7.tar.bz2
Remap-5b9805a803d193ac5ae68ac758ed847bf15efca7.zip
Support remapping in mixins with string-typed targets
i.e. Fields and methods in @Mixin("package.SomeClass$Inner") but not the class string itself
Diffstat (limited to 'src/main/kotlin/com/replaymod')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index 6a7424b..6065cbe 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -208,16 +208,22 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
}
}
- // Note: Supports only Mixins with a single target (ignores others) and only ones specified via class literals
- private fun getMixinTarget(annotation: PsiAnnotation): PsiClass? {
+ // Note: Supports only Mixins with a single target (ignores others)
+ private fun getMixinTarget(annotation: PsiAnnotation): String? {
for (pair in annotation.parameterList.attributes) {
val name = pair.name
- if (name != null && "value" != name) continue
- val value = pair.value
- if (value !is PsiClassObjectAccessExpression) continue
- val type = value.operand
- val reference = type.innermostComponentReferenceElement ?: continue
- return reference.resolve() as PsiClass?
+ if (name == null || "value" == name) {
+ val value = pair.value
+ if (value !is PsiClassObjectAccessExpression) continue
+ val type = value.operand
+ val reference = type.innermostComponentReferenceElement ?: continue
+ return (reference.resolve() as PsiClass?)?.dollarQualifiedName
+ }
+ if ("targets" == name) {
+ val value = pair.value
+ if (value !is PsiLiteral) continue
+ return value.value as? String ?: continue
+ }
}
return null
}
@@ -396,8 +402,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile)
remapAtTargets()
- val target = getMixinTarget(annotation) ?: return
- val qualifiedName = target.dollarQualifiedName ?: return
+ val qualifiedName = getMixinTarget(annotation) ?: return
val mapping = map.findClassMapping(qualifiedName) ?: return