[PATCH] D136594: [clangd] Add support for semantic token type "operator"

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 20 19:10:45 PST 2022


nridge added a comment.

A couple of high-level thoughts on this:

1. Based on the discussion in https://github.com/clangd/clangd/issues/1115, I believe highlighting of **built-in** operators should be out of scope for semantic highlighting, at least in the default mode; client-side highlighting should be sufficient for these, similar to strings and literals.
2. An alternative to assigning (user-provided) operators a new token kind would be to assign them the same token kind as the entity they invoke (i.e. function or method). Both approaches have their advantages:
  - If we use the function/method kinds, then uses of user-provided operators will be highlighted differently from built-in operators even when using a default / standard theme that doesn't know about clangd-specific token types.
  - If we use a dedicated operator kind, users can configure different styles for operators vs. function/methods (and they may want different styles given that syntactically the two look quite different).

    One way to get the best of both worlds could be to use the function/method kinds in combination with an `operator` **modifier**. That would color overloaded operators out of the box while also allowing users to customize the style based on the presence of the modifier. What do you think about this approach?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136594



More information about the cfe-commits mailing list