eclipse.jdt.ls icon indicating copy to clipboard operation
eclipse.jdt.ls copied to clipboard

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

Open ssh352 opened this issue 2 years ago • 5 comments

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

Thanks!

ssh352 avatar Jun 19 '22 15:06 ssh352

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

jdneo avatar Jun 20 '22 02:06 jdneo

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

Eskibear avatar Jun 20 '22 03:06 Eskibear

Screen Shot 2022-06-20 at 11 07 21

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

ssh352 avatar Jun 20 '22 03:06 ssh352

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.

Eskibear avatar Jun 20 '22 03:06 Eskibear

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.

ssh352 avatar Jun 20 '22 10:06 ssh352