Skip to content
Snippets Groups Projects
Commit 49dab591 authored by Johannes Mey's avatar Johannes Mey
Browse files

add error when reference in grammar is undefined

parent f4779cbc
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ import com.intellij.lang.annotation.HighlightSeverity; ...@@ -8,6 +8,7 @@ import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElement;
import org.jastadd.tooling.psi.RelAstGrammarComponent; import org.jastadd.tooling.psi.RelAstGrammarComponent;
import org.jastadd.tooling.psi.RelAstGrammarTypeReference;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class RelAstGrammarAnnotator implements Annotator { public class RelAstGrammarAnnotator implements Annotator {
...@@ -29,6 +30,15 @@ public class RelAstGrammarAnnotator implements Annotator { ...@@ -29,6 +30,15 @@ public class RelAstGrammarAnnotator implements Annotator {
.create(); .create();
} }
} }
} else if (element instanceof RelAstGrammarTypeReference) {
RelAstGrammarTypeReference reference = (RelAstGrammarTypeReference) element;
if (RelAstGrammarUtil.findTypeDecl(element.getProject(), reference.getName()).isEmpty()) {
holder.newAnnotation(HighlightSeverity.ERROR, "Undefined reference")
.range(element.getTextRange())
.highlightType(ProblemHighlightType.ERROR)
.tooltip("Reference to unknown nonterminal type.")
.create();
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment