Custom error reporting while parsing

Hi!

I've been developing a plugin for language support in IDEA. I used Grammar Kit for grammar specification and parser generation.

However, the language is indent-structured, so I have implemented ParserUtils method for checking the correct indentation of a token

like this:

@JvmStatic
fun indNone(builder_: PsiBuilder, level: Int): Boolean {
val state = getParserState(builder_)
return state!!.getTokenIndent() == - 1
}

so these methods are called during parsing. My problem is whether there is a convenient way to report about custom errors (e,g, wrong indentation level), since generated parser reports something like this in many places, where errors are caused by implemented methodds returning false:

 

and PsiTree is following:

 

1 comment
Comment actions Permalink

Did using com.intellij.lang.PsiBuilder#error not work for you?

1

Please sign in to leave a comment.