aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod/gradle/remap
diff options
context:
space:
mode:
authorJonas Herzig <jonas@spark-squared.com>2021-11-11 20:37:10 +0100
committerJonas Herzig <jonas@spark-squared.com>2021-11-12 15:23:25 +0100
commit1aa8b425982a6d30a177bc25a70a325652209ee0 (patch)
treed2566206ab2fd4580608d0b2a00a1929ab2e34b2 /src/main/kotlin/com/replaymod/gradle/remap
parent42abaaa0994ee5d0cc900e1f819605b88185f64f (diff)
downloadRemap-1aa8b425982a6d30a177bc25a70a325652209ee0.tar.gz
Remap-1aa8b425982a6d30a177bc25a70a325652209ee0.tar.bz2
Remap-1aa8b425982a6d30a177bc25a70a325652209ee0.zip
Fix methods in mixin being remapped when they should not be
Diffstat (limited to 'src/main/kotlin/com/replaymod/gradle/remap')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index 7e8162f..a8d9f2a 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -169,7 +169,15 @@ internal class PsiMapper(
var name = declaringClass!!.qualifiedName
if (name != null) {
+ // If this method is declared in a mixin class, we want to consider the hierarchy of the target as well
mapping = mixinMappings[name]
+ // but only if the method conceptually belongs to the target class
+ val isShadow = method.getAnnotation(CLASS_SHADOW) != null
+ val isOverwrite = method.getAnnotation(CLASS_OVERWRITE) != null
+ val isOverride = method.getAnnotation(CLASS_OVERRIDE) != null
+ if (mapping != null && !isShadow && !isOverwrite && !isOverride) {
+ return null // otherwise, it belongs to the mixin and never gets remapped
+ }
}
while (true) {
if (mapping != null) {
@@ -592,6 +600,8 @@ internal class PsiMapper(
companion object {
private const val CLASS_MIXIN = "org.spongepowered.asm.mixin.Mixin"
+ private const val CLASS_SHADOW = "org.spongepowered.asm.mixin.Shadow"
+ private const val CLASS_OVERWRITE = "org.spongepowered.asm.mixin.Overwrite"
private const val CLASS_ACCESSOR = "org.spongepowered.asm.mixin.gen.Accessor"
private const val CLASS_INVOKER = "org.spongepowered.asm.mixin.gen.Invoker"
private const val CLASS_AT = "org.spongepowered.asm.mixin.injection.At"
@@ -601,6 +611,7 @@ internal class PsiMapper(
private const val CLASS_MODIFY_CONSTANT = "org.spongepowered.asm.mixin.injection.ModifyConstant"
private const val CLASS_MODIFY_VARIABLE = "org.spongepowered.asm.mixin.injection.ModifyVariable"
private const val CLASS_REDIRECT = "org.spongepowered.asm.mixin.injection.Redirect"
+ private const val CLASS_OVERRIDE = "java.lang.Override"
private fun isSwitchCase(e: PsiElement): Boolean {
if (e is PsiSwitchLabelStatement) {