[PATCH] D64922: [clangd] Added option to enable semantic highlighting via an experimental capability

Johan Vikström via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 30 02:34:27 PDT 2019


jvikstrom abandoned this revision.
jvikstrom added a comment.

In D64922#1603759 <https://reviews.llvm.org/D64922#1603759>, @nridge wrote:

> I believe this is not necessary. You can add text document capabilities in the vscode client extension like this:
>
>   class SemanticHighlightingFeature implements vscodelc.StaticFeature {
>     fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
>       const textDocumentCapabilities:
>           vscodelc.TextDocumentClientCapabilities & { semanticHighlightingCapabilities?: { semanticHighlighting: boolean } }
>           = capabilities.textDocument;
>       textDocumentCapabilities.semanticHighlightingCapabilities = { semanticHighlighting: true };
>     }
>   }
>  
>   ...
>  
>   clangdClient.registerFeature(new SemanticHighlightingFeature());
>
>
> What this is doing is creating a new type on the fly which extends `vscodelc.TextDocumentCapabilities` with a new optional field `semanticHighlightingCapabilities`, and then casts `capabilities.textDocument` to that type.


That definitely works, I had no idea that was a feature you could use in typescript. Thanks

Abandoning in favor of using type intersection in typescript instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64922





More information about the cfe-commits mailing list