[PATCH] D139926: [clangd] Add semantic tokens for angle brackets

Christian Kandeler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 6 13:38:09 PST 2023


ckandeler added a comment.

In D139926#4030782 <https://reviews.llvm.org/D139926#4030782>, @nridge wrote:

> It's true that there is an ambiguity between `<` and `>` as operators, vs. template arg/param list delimiters, but, at least in terms of user understanding of code, my sense is that the highlighting of the **preceding** token should be sufficient to disambiguate -- i.e. it would be some sort of type name in the template case, vs. a variable / literal / punctuation ending an expression in the operator case.

We used to do this sort of heuristic in our old libclang-based implementation, and it turned out to be rather messy, with a surprising amount of exceptions having to be added.

>> This is needed for clients that would like to visualize matching opening and closing angle brackets, which can be valuable in non-trivial template declarations or instantiations.
>
> For this use case, could an editor make use of the recently added operator tokens (https://reviews.llvm.org/D136594) instead, inferring that a `<` token which does not have an `operator` semantic token is a template delimiter?

I have a suspicion that this will lead to false positives for invalid code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139926



More information about the cfe-commits mailing list