Skip to content

Commit 03821c6

Browse files
committed
Add AT unresolved inspection
1 parent 665387d commit 03821c6

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Minecraft Development for IntelliJ
3+
*
4+
* https://mcdev.io/
5+
*
6+
* Copyright (C) 2024 minecraft-dev
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published
10+
* by the Free Software Foundation, version 3.0 only.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
package com.demonwav.mcdev.platform.mcp.at
22+
23+
import com.demonwav.mcdev.platform.mcp.at.gen.psi.AtVisitor
24+
import com.intellij.codeInspection.LocalInspectionTool
25+
import com.intellij.codeInspection.ProblemHighlightType
26+
import com.intellij.codeInspection.ProblemsHolder
27+
import com.intellij.psi.PsiElement
28+
import com.intellij.psi.PsiElementVisitor
29+
30+
class AtUnresolvedReferenceInspection : LocalInspectionTool() {
31+
32+
override fun getStaticDescription(): String? = "Unresolved reference"
33+
34+
override fun buildVisitor(
35+
holder: ProblemsHolder,
36+
isOnTheFly: Boolean
37+
): PsiElementVisitor = object : AtVisitor() {
38+
override fun visitElement(element: PsiElement) {
39+
super.visitElement(element)
40+
41+
for (reference in element.references) {
42+
if (reference.resolve() == null) {
43+
holder.registerProblem(reference, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL)
44+
}
45+
}
46+
}
47+
}
48+
}

src/main/resources/META-INF/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,13 @@
10001000
editorAttributes="NOT_USED_ELEMENT_ATTRIBUTES"
10011001
hasStaticDescription="true"
10021002
implementationClass="com.demonwav.mcdev.platform.mcp.at.AtUsageInspection"/>
1003+
<localInspection displayName="Unresolved reference"
1004+
groupName="MCP"
1005+
language="Access Transformers"
1006+
enabledByDefault="true"
1007+
level="ERROR"
1008+
hasStaticDescription="true"
1009+
implementationClass="com.demonwav.mcdev.platform.mcp.at.AtUnresolvedReferenceInspection"/>
10031010
<localInspection displayName="Invalid empty ItemStack comparison with ItemStack.EMPTY"
10041011
groupName="MCP"
10051012
language="JAVA"

0 commit comments

Comments
 (0)