diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 2 | ||||
-rw-r--r-- | src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt index bcade7e..edb867c 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt @@ -359,7 +359,7 @@ internal class PsiMapper( else -> "" } - if (mapped != literalValue) { + if (mapped != literalValue && valid(literalExpr)) { replace(literalExpr, '"'.toString() + mapped + '"'.toString()) } } diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt index fd4c1cb..b473dbe 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt @@ -139,6 +139,29 @@ class TestMixinInjections { } @Test + fun `remaps method in constant`() { + TestData.remap(""" + @org.spongepowered.asm.mixin.Mixin(a.pkg.A.class) + class MixinA { + private static final String TARGET = "aMethod"; + @org.spongepowered.asm.mixin.injection.Inject(method = TARGET) + private void test1() {} + @org.spongepowered.asm.mixin.injection.Inject(method = TARGET) + private void test2() {} + } + """.trimIndent()) shouldBe """ + @org.spongepowered.asm.mixin.Mixin(b.pkg.B.class) + class MixinA { + private static final String TARGET = "bMethod"; + @org.spongepowered.asm.mixin.injection.Inject(method = TARGET) + private void test1() {} + @org.spongepowered.asm.mixin.injection.Inject(method = TARGET) + private void test2() {} + } + """.trimIndent() + } + + @Test fun `remaps @At target`() { TestData.remap(""" import org.spongepowered.asm.mixin.injection.At; |