Adds option to enable semantic highlighting as an experimental capability. The reason for this is that it is not possible to add textDocument capabilities in the vscode extension as it is a strongly typed argument. The experimental capability is a normal JS like object and we can therefore send the capability there. However we can't remove the textDocument capability as theia relies on the capability to be in textDocument. (The same reasoning is why the server sends the TM scopes in the experimental capability if it got the capability as experimental).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 35254 Build 35253: arc lint + arc unit
Event Timeline
clang-tools-extra/clangd/ClangdLSPServer.cpp | ||
---|---|---|
428 | these comments (and also the one in Protocol.h) lack context: it's easy to understand what they're saying when looking at this patch, but hard when just looking at the code. Maybe something like "There are two slightly different versions of the semantic highlighting capabilities: one in the 'main' namespace (supported by Theia), and one in the 'experimental' namespace (supported by VSCode)" |
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.
these comments (and also the one in Protocol.h) lack context: it's easy to understand what they're saying when looking at this patch, but hard when just looking at the code.
Maybe something like "There are two slightly different versions of the semantic highlighting capabilities: one in the 'main' namespace (supported by Theia), and one in the 'experimental' namespace (supported by VSCode)"