eclipse-jdtls / eclipse.jdt.ls

Java language server
1.75k stars 391 forks source link

question: semantic highlighting, assign each parameter or variable its own color #2132

Open ssh352 opened 2 years ago

ssh352 commented 2 years ago

can jdtls do semantic highlighting assign each parameter or variable its own color?

Thanks!

jdneo commented 2 years ago

I think it's not supported yet. Is that true? @Eskibear

Eskibear commented 2 years ago

Semantic highlighting is already supported, and jdtls will report tokens and corresponding modifiers to clients. Color themes will recognize and colorize them.

Not sure what do you mean by "its own color", but if you want to override color theme and customize color of tokens/modifiers by your own, you can use setting editor.semanticTokenColorCustomizations. See https://code.visualstudio.com/docs/getstarted/themes#_editor-semantic-highlighting

ssh352 commented 2 years ago
Screen Shot 2022-06-20 at 11 07 21

@Eskibear Hi Please see the example, it colors each parameter in a different color.

Eskibear commented 2 years ago

Like I mentioned above, LS is responsible for reporting correct token type and modifier information, and theme authors are responsible for colorization based on the information. For example, they are able to differentiate field members and local variables using styling.

In your screenshot, is the color corresponding to type of the variable, or its position of the parameter list? What if I have tens of parameters defined in a method, will they all be colorized differently? Anyway, personally, this feature request doesn't make much sense to me, more like a noise to me.

ssh352 commented 2 years ago

In your screenshot, is the color corresponding to type of the variable, or its position of the parameter list? What if I have tens of parameters defined in a method, will they all be colorized differently?

yes, 10 parameters will be colored differently. It's the behavior of semantic highlighting in IntelliJ.