How to make same token type syntax hightlight with different styles?

Answered

I've defind two statements in bnf grammar file. and I want to syntax highlight IDENTIFIER with two different style, but I have no idea how to do this, please help…

more detail here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/16212656744850-How-to-make-syntax-hightlight-with-different-style-

NamespaceDefinition ::= 'namespace' IDENTIFIER
IncludeDefinition ::= 'include' IDENTIFIER
0
2 comments

But how to map each token to distinct TextAttributesKey? As IElementType is returned by the jflex lexer, which means that I have to return different token type in my flex file, the only way I know is to use the lexer states:

<NAMESPACE> {
  {IDENTIFIER} {return TYPE1;}
}

But you told me not to use it if only for highlight purpose?

Sorry I didn't find the way to do so at: https://plugins.jetbrains.com/docs/intellij/syntax-highlighter-and-color-settings-page.html#define-a-syntax-highlighter

0

Please sign in to leave a comment.