diff options
author | LlamaLad7 <l3gomindstorms@gmail.com> | 2022-04-30 19:55:27 +0100 |
---|---|---|
committer | Jonas Herzig <me@johni0702.de> | 2022-05-03 10:14:48 +0200 |
commit | c7eaf63caad15b8e1935be5acc9b85fd3765faa9 (patch) | |
tree | 5ff8fe751345e167577f99afd389df2ccad5f0a1 /src/main/kotlin/com/replaymod | |
parent | f9fe968c431766ab0937f1b717700d2afa39c9bb (diff) | |
download | Remap-c7eaf63caad15b8e1935be5acc9b85fd3765faa9.tar.gz Remap-c7eaf63caad15b8e1935be5acc9b85fd3765faa9.tar.bz2 Remap-c7eaf63caad15b8e1935be5acc9b85fd3765faa9.zip |
Don't hardcode injector annotations in `PsiMapper`.
Any annotation in a mixin class that has a `method` will do.
This will mean it doesn't need updating for future stock injectors, and doesn't break with custom injectors.
Diffstat (limited to 'src/main/kotlin/com/replaymod')
-rw-r--r-- | src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt index 210e2d4..dbd3f2e 100644 --- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt +++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt @@ -475,15 +475,7 @@ internal class PsiMapper( private fun remapMixinInjections(targetClass: PsiClass, mapping: ClassMapping<*, *>) { file.accept(object : JavaRecursiveElementVisitor() { override fun visitMethod(method: PsiMethod) { - val annotation = method.getAnnotation(CLASS_INJECT) - ?: method.getAnnotation(CLASS_MODIFY_ARG) - ?: method.getAnnotation(CLASS_MODIFY_ARGS) - ?: method.getAnnotation(CLASS_MODIFY_CONSTANT) - ?: method.getAnnotation(CLASS_MODIFY_VARIABLE) - ?: method.getAnnotation(CLASS_REDIRECT) - ?: return - - val methodAttrib = annotation.findDeclaredAttributeValue("method") + val methodAttrib = method.annotations.firstNotNullOfOrNull { it.findDeclaredAttributeValue("method") } for ((literalExpr, literalValue) in methodAttrib?.resolvedLiteralValues ?: emptyList()) { val (targetName, targetDesc) = if ('(' in literalValue) { MethodSignature.of(literalValue).let { it.name to it.descriptor.toString() } @@ -762,12 +754,6 @@ internal class PsiMapper( 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" - private const val CLASS_INJECT = "org.spongepowered.asm.mixin.injection.Inject" - private const val CLASS_MODIFY_ARG = "org.spongepowered.asm.mixin.injection.ModifyArg" - private const val CLASS_MODIFY_ARGS = "org.spongepowered.asm.mixin.injection.ModifyArgs" - 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 { |