Change in Token color when entering newline and having lexical states
I think have found out, what the problem could be. The comment at the end, which should be grayed, is in another lexer state. Obviously, the Netbeans platform does not restart the Lexer when I enter a character in between the comment and the previously defined tokens who are responsible for setting the correct lexer state. The first time, the lexer produces all tokens from the beginning to the end, i.e. it always has the correct lexer state because it correctly applies the rules responsible for switching from one lexical state to another. If I enter the text afterwards, the lexer seems to start its lexical scanning from the position of my cartet, which seems to be a logical action in respect to performance issues. Can someone please give me a hint in which class I should start adapting my code. In the org.netbeans.spi.lexer.Lexer class, there is indeed a method called state. I suppose that I have to return the lexical state here. My problem is that I am of the opinion, that !
the lexer only knows about its lexical state if it has been started from the beginning, becuase rules must be fullfilled to enter a lexical state or leave it.
In general, I think that I understand the JavaCC lexer bevahiour, but there is something missing in my Netbeans code.