Semantic highlighting for OT/J scoped keywords [message #1847899] |
Thu, 11 November 2021 21:28 |
Stephan Herrmann Messages: 1853 Registered: July 2009 |
Senior Member |
|
|
From the outset, we have been carefully avoiding conflicts between OT/J-specific keywords and their use as regular identifiers in Java.
In OTJLD, the key concept to this end is Scoped Keywords. Later Java introduced similarly conditional keywords (restricted keywords, and restricted identifiers -- similar indeed in intention, just I still think, the way how 'restricted keywords' are defined in Java is a mess).
One thing was still annoying all those years: the OT/J editor (actually the Java Editor with OTDT tweaks applied :) ) would unconditionally highlight our scoped keywords as keywords, even out of scope, i.e., when they were regular identifiers. For common names like 'result', 'get', 'set' etc. this could cause some itch in the eye. This is of course caused by the fact, that pure "syntax highlighting" cannot cope with scoping / conditional highlighting.
Earlier this year JDT exposed an option to separately configure highlighting for Java's restricted identifiers ('var', 'record' etc.).
That's when I thought: let's jump on the bandwagon! So I implemented semantic highlighting for OT/J scoped keywords (also including the unconditional keyword 'team').
The screenshot shows (most of) the code doing this and also serves as example for the effect :)
The benefit is twofold:
- out-off scope use of these words is not highlighted
- we can visually distinguish scoped keywords from standard keywords
To achieve the second, OTDT simply changes the default styling for 'restricted identifiers'. Change it back to the regular keyword style, and all will look alike, whichever way you like.
enjoy
Stephan
|
|
|
Powered by
FUDForum. Page generated in 0.02167 seconds