[Custom Language Plugin] Highlighter doesn't update colors sometimes (no errors in log)

Answered

Hello, in the language I create plugin for, there are multiline comments that starts with '/*' and end with '*/' - just line in most modern languages. When I remove comment START ('/*') and add it again, highlighter updates colors correctly, but if I try the same thing with the comment END ('*/'), then highlighter updates once, and then when If keep adding/removing it, text colors won't update.

My project is here: https://github.com/Kisioj/byond-intellij
I created short youtube video (29sec.) to demonstrate exacly what the problem is: https://www.youtube.com/watch?v=wFQny2UAvFE&feature=youtu.be

What can I do to make highlighter update the colors when readding multiline comment END ('*/') ?

1 comment
Comment actions Permalink

1. Highlighting in your case being performed by lexer's information. It has nothing to do with psi tree. 

2. On text modification, psi tree always rebuilt completely with some internal optimizations. But it's always consistent with current source state. 

3. Highlighting, however, works incrementally. Basically - after each pass, IDE remembers positions where lexer's state was YYINITIAL (0). And if you are typing something, it relexes from the last 0 position before text change. In your case, 0 position should be before opening marker. And unclosed comment should be treated as comment with possible error or smth.  You are lexing unclosed comment as normal source and there are initials in there. So when you are closing comment, highlighiter does not relexes everything from comment start, just from last YYINITIAL.

2

Please sign in to leave a comment.