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

Christian Kandeler via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 01:49:14 PST 2023


ckandeler added a comment.

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

> In D139926#4032473 <https://reviews.llvm.org/D139926#4032473>, @ckandeler wrote:
>
>> 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.
>
> To clarify, I'm not suggesting that any client-side logic use this heuristic, only that it's probably good enough for a human reader to disambiguate without needing to assign angle brackets and comparison operators different colors.

Note that we use this information to *animate* the matching tokens, i.e. when the cursor is on one of them, both it and its counterpart get a special highlighting. That's why it's so important that the language server guarantees they always come in pairs.


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