[PATCH] D87669: [clangd] Rainbow Semantic Highlighting

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 18 08:23:43 PDT 2020


sammccall added a comment.

This is cool! We've had a couple of looks at attributes, but haven't really gotten around to polishing it.
(For a submittable version, I think we should avoid introducing more modifiers at the same time, just to avoid getting bogged down in exactly which ones)

I like the idea of using modifiers to encode the rainbow variants - this avoids the need for a protocol extension. On the other hand, it's ugly to have the server rather than themes decide how many variants there should be. What do you think of having modifiers for each bit of the hash, rather than specific hash values?

i.e.
1 = bool(symbolid & 1)
2 = bool(symbolid & 2)
4 = bool(symbolid & 4)
etc.

Then the client can decide how many variants to style, as long as it's a power of 2: e.g. providing styles for variable, variable.1, variable.2, variable.1.2 should yield 4 uniform colors. With 8 attributes we can support 256 colors, which ought to be enough for anyone :-)

One catch here is that some tokens may not have a symbol id and can't be distinguished from all-bits-zero, we could provide a marker modifier like "0" so you can style variable.0, variable.1, variable.2, variable.1.2.

(Not sure whether it's more intuitive to name the attributes 0, 1, 2, 3... or 1, 2, 4, 8...)

>From your description I'm not sure whether you're interested in upstreaming this yourself (revising through code review, writing tests, etc) or looking to hand the patch over to someone else - let me know!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87669/new/

https://reviews.llvm.org/D87669



More information about the cfe-commits mailing list