⁠
joe: 2025
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2024 minecraft-dev
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, version 3.0 only.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- package com.demonwav.mcdev.platform.mixin.inspection.implements
- import com.demonwav.mcdev.platform.mixin.inspection.MixinInspection
- import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.IMPLEMENTS
- import com.demonwav.mcdev.util.findAnnotations
- import com.intellij.codeInspection.ProblemsHolder
- import com.intellij.codeInspection.RemoveAnnotationQuickFix
- import com.intellij.psi.JavaElementVisitor
- import com.intellij.psi.PsiAnnotation
- import com.intellij.psi.PsiElementVisitor
- class EmptyImplementsInspection : MixinInspection() {
- override fun getStaticDescription() = "Reports empty @Implements annotations (without an @Interface)"
- override fun buildVisitor(holder: ProblemsHolder): PsiElementVisitor = Visitor(holder)
- private class Visitor(private val holder: ProblemsHolder) : JavaElementVisitor() {
- override fun visitAnnotation(annotation: PsiAnnotation) {
- if (annotation.qualifiedName != IMPLEMENTS) {
- return
- }
- val interfaces = annotation.findDeclaredAttributeValue(null)?.findAnnotations()
- if (interfaces.isNullOrEmpty()) {
- holder.registerProblem(
- annotation,
- "@Implements is redundant",
- RemoveAnnotationQuickFix(annotation, null),
- )
- }
- }
- }
- }
- /*
- * Minecraft Development for IntelliJ
- *
- * https://mcdev.io/
- *
- * Copyright (C) 2025 minecraft-dev
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, version 3.0 only.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- package com.demonwav.mcdev.platform.mixin.inspection.implements
- import com.demonwav.mcdev.platform.mixin.inspection.MixinInspection
- import com.demonwav.mcdev.platform.mixin.util.MixinConstants.Annotations.IMPLEMENTS
- import com.demonwav.mcdev.util.findAnnotations
- import com.intellij.codeInspection.ProblemsHolder
- import com.intellij.codeInspection.RemoveAnnotationQuickFix
- import com.intellij.psi.JavaElementVisitor
- import com.intellij.psi.PsiAnnotation
- import com.intellij.psi.PsiElementVisitor
- class EmptyImplementsInspection : MixinInspection() {
- override fun getStaticDescription() = "Reports empty @Implements annotations (without an @Interface)"
- override fun buildVisitor(holder: ProblemsHolder): PsiElementVisitor = Visitor(holder)
- private class Visitor(private val holder: ProblemsHolder) : JavaElementVisitor() {
- override fun visitAnnotation(annotation: PsiAnnotation) {
- if (annotation.qualifiedName != IMPLEMENTS) {
- return
- }
- val interfaces = annotation.findDeclaredAttributeValue(null)?.findAnnotations()
- if (interfaces.isNullOrEmpty()) {
- holder.registerProblem(
- annotation,
- "@Implements is redundant",
- RemoveAnnotationQuickFix(annotation, null),
- )
- }
- }
- }
- }