1+ package de.halirutan.mathematica.codeinsight.inspections.symbol
2+
3+ import com.intellij.codeHighlighting.HighlightDisplayLevel
4+ import com.intellij.codeInspection.LocalInspectionToolSession
5+ import com.intellij.codeInspection.ProblemHighlightType
6+ import com.intellij.codeInspection.ProblemsHolder
7+ import com.intellij.openapi.util.TextRange
8+ import com.intellij.psi.PsiElementVisitor
9+ import de.halirutan.mathematica.codeinsight.inspections.AbstractInspection
10+ import de.halirutan.mathematica.codeinsight.inspections.InspectionBundle
11+ import de.halirutan.mathematica.lang.psi.MathematicaVisitor
12+ import de.halirutan.mathematica.lang.psi.api.Symbol
13+ import de.halirutan.mathematica.lang.psi.impl.LightUndefinedSymbol
14+
15+ /* *
16+ *
17+ * @author patrick (13.09.17).
18+ */
19+ class UnresolvedSymbolInspection : AbstractInspection () {
20+
21+
22+ override fun getDisplayName (): String {
23+ return InspectionBundle .message(" symbol.unresolved.name" )
24+ }
25+
26+ override fun getStaticDescription (): String? {
27+ return InspectionBundle .message(" symbol.unresolved.description" )
28+ }
29+
30+ override fun getGroupDisplayName (): String {
31+ return InspectionBundle .message(" group.symbol" )
32+ }
33+
34+ override fun getDefaultLevel (): HighlightDisplayLevel {
35+ return HighlightDisplayLevel .ERROR
36+ }
37+
38+ override fun buildVisitor (holder : ProblemsHolder , isOnTheFly : Boolean , session : LocalInspectionToolSession ): PsiElementVisitor {
39+ return object : MathematicaVisitor (){
40+ override fun visitSymbol (symbol : Symbol ? ) {
41+ symbol?.let {
42+ val resolve = symbol.resolve()
43+ if (resolve is LightUndefinedSymbol ) {
44+ holder.registerProblem(symbol, InspectionBundle .message(" symbol.unresolved.message" ), ProblemHighlightType .LIKE_UNKNOWN_SYMBOL , TextRange .create(0 ,symbol.textLength))
45+ }
46+
47+ }
48+ }
49+ }
50+
51+ }
52+ }
0 commit comments