aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt16
-rw-r--r--src/test/java/a/pkg/A.java1
-rw-r--r--src/test/java/b/pkg/B.java1
-rw-r--r--src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt42
4 files changed, 59 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 3adc4f1..07d7d1d 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -399,10 +399,24 @@ internal class PsiMapper(
val name = signature.substring(ownerEnd + 1, argsBegin)
val returnType = signature.substring(argsEnd + 1)
+ val ownerPsi = JavaPsiFacade.getInstance(file.project).findClass(
+ owner.drop(1).dropLast(1).replace('/', '.').replace('$', '.'),
+ GlobalSearchScope.allScope(file.project),
+ )
+ val methodPsi = if (method) {
+ val desc = signature.substring(argsBegin)
+ ownerPsi?.findMethodsByName(name, true)?.find { ClassUtil.getAsmMethodSignature(it) == desc }
+ } else {
+ null
+ }
+
val builder = StringBuilder(signature.length + 32)
val mapping = remapInternalType(owner, builder)
var mapped: String? = null
- if (mapping != null) {
+ if (methodPsi != null) {
+ mapped = findMapping(methodPsi)?.deobfuscatedName
+ }
+ if (mapped == null && mapping != null) {
mapped = (if (method) {
mapping.findMethodMapping(MethodSignature.of(signature.substring(ownerEnd + 1)))
} else {
diff --git a/src/test/java/a/pkg/A.java b/src/test/java/a/pkg/A.java
index 3e20f3e..ff779b2 100644
--- a/src/test/java/a/pkg/A.java
+++ b/src/test/java/a/pkg/A.java
@@ -10,6 +10,7 @@ public class A extends AParent implements AInterface {
}
public void aMethod() {
+ aInterfaceMethod();
}
public void aOverloaded() {
diff --git a/src/test/java/b/pkg/B.java b/src/test/java/b/pkg/B.java
index 3c71aae..6ed26c1 100644
--- a/src/test/java/b/pkg/B.java
+++ b/src/test/java/b/pkg/B.java
@@ -10,6 +10,7 @@ public class B extends BParent implements BInterface {
}
public void bMethod() {
+ bInterfaceMethod();
}
public void bOverloaded() {
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 3f8d55f..f01a832 100644
--- a/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt
+++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/TestMixinInjections.kt
@@ -137,4 +137,46 @@ class TestMixinInjections {
}
""".trimIndent()
}
+
+ @Test
+ fun `remaps @At target`() {
+ TestData.remap("""
+ import org.spongepowered.asm.mixin.injection.At;
+ import org.spongepowered.asm.mixin.injection.Inject;
+ @org.spongepowered.asm.mixin.Mixin(a.pkg.A.class)
+ class MixinA {
+ @Inject(method = "aMethod", at = @At(target = "La/pkg/A;aInterfaceMethod()V"))
+ private void test() {}
+ }
+ """.trimIndent()) shouldBe """
+ import org.spongepowered.asm.mixin.injection.At;
+ import org.spongepowered.asm.mixin.injection.Inject;
+ @org.spongepowered.asm.mixin.Mixin(b.pkg.B.class)
+ class MixinA {
+ @Inject(method = "bMethod", at = @At(target = "Lb/pkg/B;bInterfaceMethod()V"))
+ private void test() {}
+ }
+ """.trimIndent()
+ }
+
+ @Test
+ fun `remaps @At target without mappings for target`() {
+ TestData.remap("""
+ import org.spongepowered.asm.mixin.injection.At;
+ import org.spongepowered.asm.mixin.injection.Inject;
+ @org.spongepowered.asm.mixin.Mixin(a.pkg.A.class)
+ class MixinA {
+ @Inject(method = "aMethod", at = @At(target = "La/pkg/A;unmappedOverloaded(La/pkg/A;)V"))
+ private void test() {}
+ }
+ """.trimIndent()) shouldBe """
+ import org.spongepowered.asm.mixin.injection.At;
+ import org.spongepowered.asm.mixin.injection.Inject;
+ @org.spongepowered.asm.mixin.Mixin(b.pkg.B.class)
+ class MixinA {
+ @Inject(method = "bMethod", at = @At(target = "Lb/pkg/B;unmappedOverloaded(Lb/pkg/B;)V"))
+ private void test() {}
+ }
+ """.trimIndent()
+ }
} \ No newline at end of file