From ce05cfe9e5f9e63ec7b68c454774fe7fd98c2749 Mon Sep 17 00:00:00 2001 From: LlamaLad7 Date: Thu, 16 Oct 2025 22:15:06 +0100 Subject: [PATCH] Fix: Check all annotations for targets in LocalArgsOnlyInspection. Currently, only the first one is checked, which is particularly noticeable with Expressions since those normally involve other annotations preceding the injector. --- .../inspection/mixinextras/LocalArgsOnlyInspection.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/platform/mixin/inspection/mixinextras/LocalArgsOnlyInspection.kt b/src/main/kotlin/platform/mixin/inspection/mixinextras/LocalArgsOnlyInspection.kt index 0d1caca24..1dc388278 100644 --- a/src/main/kotlin/platform/mixin/inspection/mixinextras/LocalArgsOnlyInspection.kt +++ b/src/main/kotlin/platform/mixin/inspection/mixinextras/LocalArgsOnlyInspection.kt @@ -29,7 +29,7 @@ import com.demonwav.mcdev.platform.mixin.util.MixinConstants import com.demonwav.mcdev.platform.mixin.util.MixinConstants.MixinExtras.unwrapLocalRef import com.demonwav.mcdev.util.constantValue import com.demonwav.mcdev.util.findContainingMethod -import com.demonwav.mcdev.util.mapFirstNotNull +import com.demonwav.mcdev.util.ifEmpty import com.intellij.codeInspection.ProblemsHolder import com.intellij.psi.JavaElementVisitor import com.intellij.psi.PsiAnnotation @@ -52,15 +52,15 @@ class LocalArgsOnlyInspection : MixinInspection() { val parameter = localAnnotation.parentOfType() ?: return val method = parameter.findContainingMethod() ?: return - val targets = method.annotations.mapFirstNotNull { annotation -> + val targets = method.annotations.flatMap { annotation -> MixinAnnotationHandler.resolveTarget(annotation).asSequence() .filterIsInstance() .map { it.classAndMethod } - } ?: return + }.ifEmpty { return } val localType = parameter.type.unwrapLocalRef() - if (ModifyVariableArgsOnlyInspection.shouldReport(localAnnotation, localType, targets)) { + if (ModifyVariableArgsOnlyInspection.shouldReport(localAnnotation, localType, targets.asSequence())) { holder.registerProblem( localAnnotation.nameReferenceElement ?: localAnnotation, "@Local may be argsOnly = true",