Why TypeOfText enum has a few types only?

hi,

I’m working on a custom plugin and implementing syntax highlighting.

It works, but I’m wondering why TypeOfText enum has 8 types only? I have created a vscode extension for the same language earlier and there is a much wider choice for token types there (in the current standard, there are 23 token types and 10 modifiers).

Is this a design decision to keep the list of types this short? I would be happy to see some more, escpecially those that are used in many languages (for example, data types or functions). Without knowing anything about Sonarqube’s web component I still guess this would be relatively easy to add some more highlighting items.

br,
Miki

Hi Miki,

This is a deliberate design decision. The goal of SonarQube’s syntax highlighting is not to provide a superset of all possible token types across all existing languages, nor is this enum used in the rule implementation of our language analyzers. Its only goal is to improve human readability when viewing source code in the SonarQube web interface.

We want developers to have a comfortable reading experience that mirrors their IDE, but it helps to look at the difference between underlying token types and actual visual colors:

  • IntelliJ IDEA (Darcula/Light): Standard themes typically rely on only 6 to 8 distinct colors for core syntax (e.g., one color for keywords, one for strings, one for numbers, one for comments, etc.).

  • VS Code (Default Dark+): Generally uses around 8 to 10 primary colors for syntax highlighting.

While an IDE’s language server might identify 23 different token types and 10 modifiers under the hood, the UI theme ultimately buckets them into a much smaller color palette. If an interface actually used 20+ different colors, the code would suffer from a “rainbow effect,” creating visual noise and making it harder to read.

Because those wide-ranging token types eventually map down to roughly 8 colors in standard development environments, SonarQube keeps the TypeOfText enum limited to those foundational categories. Adding more types is technically easy, but it would mostly result in redundant colors without genuinely improving the reading experience.

Hope this context helps clear up the design philosophy.

Best of luck with the rest of your custom plugin,

Alban