diff options
author | Jonas Herzig <jonas@spark-squared.com> | 2021-11-12 11:05:14 +0100 |
---|---|---|
committer | Jonas Herzig <jonas@spark-squared.com> | 2021-11-12 15:23:25 +0100 |
commit | 9a048424d3273152b02aafff690b8a420eae17e4 (patch) | |
tree | 257c25bf40aefc9d18f308d77475824e28441912 | |
parent | 117d1cf035edc83017e344a6142c40cd72420642 (diff) | |
download | Remap-9a048424d3273152b02aafff690b8a420eae17e4.tar.gz Remap-9a048424d3273152b02aafff690b8a420eae17e4.tar.bz2 Remap-9a048424d3273152b02aafff690b8a420eae17e4.zip |
Fix inject method in constant being duplicated if remapped twice
-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; |