-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicit token highlighting #383
base: master
Are you sure you want to change the base?
Conversation
Replace some value-matched explicit tokens with their names to better show the difference between implicit and explicit name-matched tokens
…oText's return type so IDEA highlights the string literal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this!
@@ -27,7 +27,8 @@ class BnfSyntaxHighlighter extends SyntaxHighlighterBase { | |||
public static final TextAttributesKey PATTERN = createTextAttributesKey("BNF_PATTERN", DefaultLanguageHighlighterColors.INSTANCE_FIELD); | |||
public static final TextAttributesKey NUMBER = createTextAttributesKey("BNF_NUMBER", DefaultLanguageHighlighterColors.NUMBER); | |||
public static final TextAttributesKey KEYWORD = createTextAttributesKey("BNF_KEYWORD", DefaultLanguageHighlighterColors.MARKUP_ATTRIBUTE); | |||
public static final TextAttributesKey TOKEN = createTextAttributesKey("BNF_TOKEN", DefaultLanguageHighlighterColors.STRING); | |||
public static final TextAttributesKey EXPLICIT_TOKEN = createTextAttributesKey("BNF_EXPLICIT_TOKEN", DefaultLanguageHighlighterColors.STRING); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the identifier will break any customizations users already have, please keep "BNF_TOKEN"
as ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
e065303
to
491ddbf
Compare
Motivation
Currently both implicit and explicit tokens (terminology from here) share a common highlighting key:
BNF_TOKEN
, which makes it impossible to assign different highlighting styles to them and spot issues in the grammar, when e.g. because of a typo implicit token is used instead of the name of an explicit one.E.g. this grammar
Is highlighted like this
This PR makes it to be highlighted like this (by default, may be overridden on the color settings page)
which lets developer notice that something's off, and overall distinguish explicit tokens, matched by name and implicitly defined tokens, the same way we already distinguish explicit tokens, matched by value and toekns, matched by text (called "patterns" in the code base)
Additional changes
There are 2 sets of commits:
fix:
prefix):instanceof
pattern matching syntax where I already started using itTOKEN
toEXPLICIT_TOKEN
to make it symmetric withIMPLICIT_TOKEN
Please advice which of them are desired and which I must drop