Skip to content

Commit

Permalink
Move non-private static error to the access modifier (when there is one)
Browse files Browse the repository at this point in the history
  • Loading branch information
O7410 committed Jan 8, 2025
1 parent 75c524e commit f0be6da
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.INVOKER
import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.OVERWRITE
import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.SHADOW
import com.demonwav.mcdev.platform.mixin.util.isMixin
import com.demonwav.mcdev.util.findKeyword
import com.intellij.codeInsight.intention.QuickFixFactory
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.psi.JavaElementVisitor
Expand All @@ -33,6 +34,7 @@ import com.intellij.psi.PsiField
import com.intellij.psi.PsiMember
import com.intellij.psi.PsiMethod
import com.intellij.psi.PsiModifier
import org.jetbrains.kotlin.j2k.accessModifier

class StaticMemberInspection : MixinInspection() {

Expand All @@ -55,7 +57,7 @@ class StaticMemberInspection : MixinInspection() {
private fun visitMember(member: PsiMember) {
if (isProblematic(member)) {
holder.registerProblem(
member,
member.modifierList?.findKeyword(member.accessModifier()) ?: member,
"Non-private static members are not allowed in Mixin classes",
QuickFixFactory.getInstance().createModifierListFix(member, PsiModifier.PRIVATE, true, false),
)
Expand Down

0 comments on commit f0be6da

Please sign in to comment.