On to Syntax Coloring!

Made great progress today :-D A Clojure plugin is much closer!

I wrote a JFlex Lexer and got Syntax Coloring working... almost.

If I scroll to the top of a file then everything is perfect. The sample
code in my ColorAndFont page also works fine. The Lexer seems to work fine.

However, if I scroll down a bit, or edit the code, or even just click on
test somewhere, the syntax coloring goes away. If I scroll back to
the top it comes back. There are no runtime errors.

I suspected that I had not implemented Lexer.reset() properly, but this
is not the case. reset() is only called once when the file is first loaded.

Can anyone give me some knowledge about what happens when I do the above
operations. What happens when an editor is scrolled, or text is
changed? Why does coloring not work except when I scroll to the very
top? How should I debug this?

Thanks again
Peter

2 comments
Comment actions Permalink

Hello Peter,
again myself


It seems like idea calls your lexer with only a part of the file when you scroll or edit. Your lexer should parse the chunk normally given just the state of the lexer.
However, if it's working like i think it is then it's strange that syntax coloring disappears for the whole file.

0
Comment actions Permalink

Hello Peter,

there is no need to implement reset() yourself. Just use the JFlex skeleton that is supplied with
the IDEA Plugin DevKit (IDEA_HOME/tools/jflex/idea-flex.skeleton). This is the Ant-Task that should
be used:

]]>

HTH,
Sascha

Peter Wolf wrote:

Made great progress today :-D A Clojure plugin is much closer!

I wrote a JFlex Lexer and got Syntax Coloring working... almost.

If I scroll to the top of a file then everything is perfect. The sample
code in my ColorAndFont page also works fine. The Lexer seems to work
fine.

However, if I scroll down a bit, or edit the code, or even just click on
test somewhere, the syntax coloring goes away. If I scroll back to the
top it comes back. There are no runtime errors.

I suspected that I had not implemented Lexer.reset() properly, but this
is not the case. reset() is only called once when the file is first
loaded.

Can anyone give me some knowledge about what happens when I do the above
operations. What happens when an editor is scrolled, or text is
changed? Why does coloring not work except when I scroll to the very
top? How should I debug this?

Thanks again
Peter

0

Please sign in to leave a comment.