Is there any way to start syntax highlighting lexer for the whole file instead of starting it for the part that have changed?

Hi,

I`m writing a simple plugin for custom language. Its very basic version and i have big problem with syntax highlighting lexer, when its called only for the part of file.

0
3 comments
Avatar
Permanently deleted user

Have you read this document carefully? Especially this part:

A lexer that can be used incrementally may need to return its state, which means the context corresponding to each position in a file. For example, a Java lexer could have separate states for top level context, comment context and string literal context. An important requirement for a syntax highlighting lexer is that its state must be represented by a single integer number returned from Lexer.getState(). That state will be passed to the Lexer.start() method, along with the start offset of the fragment to process, when lexing is resumed from the middle of a file. Lexers used in other contexts can always return 0 from the getState() method.

Except for this, it's impossible to give further advice as your question doesn't even contain a question but only a statement that you have problems.

0

The highlighting lexer is only restarted at points where it returned 0 from getState. So an easy fix would be to only return 0 at the beginning of the text. However, this would mean that whole file will be relexed on each typing, which might be noticeably slow as files get larger.

1
Avatar
Permanently deleted user

Thanks. Thats what i wanted.

0

Please sign in to leave a comment.