Error during syntax highlighting

So, I have implemented a lexer and parser for my language, and a SyntaxHighlighter, and with existing documents everything works fine. But when I try to write a new document in my language, two things happen:

  1. Syntax Highlighting doesn't activate while/after typing. It seems that what to highlight is determined by the *first* scan of the tokenizer (while typing) and doesn't update properly when the tokens change once I've finished typing. I'm guessing that's an error on my part, but I have no idea what to adapt.
  2. I get an IDE Fatal Error: com.intellij.openapi.editor.ex.util.LexerEditorHighlighter$InvalidStateException: com.intellij.openapi.editor.ex.util.LexerEditorHighlighter(<My LexerAdapter>): Error updating after DocumentEventImpl[myOffset=56, myOldLength=0, myNewLength=1, myOldString='', myNewString='M'].

    The latter seems to be related to my autocompletion method, which I slightly abuse to mimic jEdit-style abbreviations. In fact, the latter seems to always occur if at the end of the document, I type "jM" which makes the auto completion window pop up, and I "autocomplete" jMD to a unicode-character. (I use autocompletion to be able to type unicode characters such as mathematical symbols).

    Can I do anything to solve this error? Or is there some better way to introduce abbreviations for unicode characters other than abusing the autocompletion method?
0
1 comment

For anyone else comming across this issue while trying to figure out why their language plugin throws this error then in my case it was due to speciel EOF handling. In certain states, the lexer would consume characters for a token, but return null as part of the EOF handler. Be sure that all characters in the file gets assigned to a token. TokenType.BAD_CHARACTER worked for me, if I was EOF and in a state the collected characters and then change to a state that would return null on eof after.

0

Please sign in to leave a comment.