aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt6
-rw-r--r--src/test/kotlin/com/replaymod/gradle/remap/mapper/mixin/TestMixinAccessors.kt17
2 files changed, 21 insertions, 2 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index a71c4d1..210e2d4 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -437,7 +437,9 @@ internal class PsiMapper(
private fun remapAccessors(mapping: ClassMapping<*, *>) {
file.accept(object : JavaRecursiveElementVisitor() {
override fun visitMethod(method: PsiMethod) {
- val annotation = method.getAnnotation(CLASS_ACCESSOR) ?: method.getAnnotation(CLASS_INVOKER) ?: return
+ val accessorAnnotation = method.getAnnotation(CLASS_ACCESSOR)
+ val invokerAnnotation = method.getAnnotation(CLASS_INVOKER)
+ val annotation = accessorAnnotation ?: invokerAnnotation ?: return
val methodName = method.name
val targetByName = when {
@@ -451,7 +453,7 @@ internal class PsiMapper(
it.name == null || it.name == "value"
}?.literalValue ?: targetByName ?: throw IllegalArgumentException("Cannot determine accessor target for $method")
- val mapped = if (methodName.startsWith("invoke")) {
+ val mapped = if (invokerAnnotation != null) {
mapping.methodMappings.find { it.obfuscatedName == target }?.deobfuscatedName
} else {
mapping.findFieldMapping(target)?.deobfuscatedName
diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/mixin/TestMixinAccessors.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/mixin/TestMixinAccessors.kt
index aae4cba..6d9fb38 100644
--- a/src/test/kotlin/com/replaymod/gradle/remap/mapper/mixin/TestMixinAccessors.kt
+++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/mixin/TestMixinAccessors.kt
@@ -27,6 +27,23 @@ class TestMixinAccessors {
}
@Test
+ fun `remaps @Invoker with non-standard method name`() {
+ TestData.remap("""
+ @org.spongepowered.asm.mixin.Mixin(a.pkg.A.class)
+ interface MixinA {
+ @org.spongepowered.asm.mixin.gen.Invoker("aMethod")
+ void arbitraryName();
+ }
+ """.trimIndent()) shouldBe """
+ @org.spongepowered.asm.mixin.Mixin(b.pkg.B.class)
+ interface MixinA {
+ @org.spongepowered.asm.mixin.gen.Invoker("bMethod")
+ void arbitraryName();
+ }
+ """.trimIndent()
+ }
+
+ @Test
fun `remaps @Accessor`() {
TestData.remap("""
@org.spongepowered.asm.mixin.Mixin(a.pkg.A.class)