diff options
author | Jonas Herzig <me@johni0702.de> | 2020-11-22 14:14:14 +0100 |
---|---|---|
committer | Jonas Herzig <me@johni0702.de> | 2020-11-22 14:27:51 +0100 |
commit | 6073541e763da17de3d51db0e9ee30ddafc01bb9 (patch) | |
tree | 7e69a921155aa83bdc66d81da7ddc8c0d2f50e53 /src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | |
parent | e49dc899920dce06383cb7f9bd3cba5316cda09b (diff) | |
download | Remap-6073541e763da17de3d51db0e9ee30ddafc01bb9.tar.gz Remap-6073541e763da17de3d51db0e9ee30ddafc01bb9.tar.bz2 Remap-6073541e763da17de3d51db0e9ee30ddafc01bb9.zip |
Support remapping of mixin targets declared in static fields
String literals in annotations can be specified in a static final field instead
of inline (so you can e.g. use the same literal in multiple places).
This commit adds support for remapping those external literals.
Diffstat (limited to 'src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt')
-rw-r--r-- | src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt index 9ddb78a..b131478 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt @@ -298,7 +298,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile) for (attribute in annotation.parameterList.attributes) { if ("method" != attribute.name) continue // Note: mixin supports multiple targets, we do not (yet) - val literalValue = attribute.literalValue ?: continue + val (literalExpr, literalValue) = attribute.resolvedLiteralValue ?: continue val methodMapping = if ('(' in literalValue) { val signature = MethodSignature.of(literalValue) // mapping.findMethodMapping(signature) @@ -323,8 +323,7 @@ internal class PsiMapper(private val map: MappingSet, private val file: PsiFile) } if (mapped != literalValue) { - val value = attribute.value!! - replace(value, '"'.toString() + mapped + '"'.toString()) + replace(literalExpr, '"'.toString() + mapped + '"'.toString()) } } } @@ -418,10 +417,9 @@ 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 (value, signature) = attribute.resolvedLiteralValue ?: continue val newSignature = remapMixinTarget(signature) if (newSignature != signature) { - val value = attribute.value!! replace(value, "\"$newSignature\"") } } |