[clangd] Support textDocument/semanticTokens/edits
authorSam McCall <sam.mccall@gmail.com>
Wed, 1 Apr 2020 14:21:44 +0000 (16:21 +0200)
committerSam McCall <sam.mccall@gmail.com>
Thu, 2 Apr 2020 15:38:29 +0000 (17:38 +0200)
commit9e3063eaceec5054684a77acf5281772df2a7f73
treea14677c53525d8cc98e4a8ea4c2797df74044c35
parentfc830106e15553fcca3fc80066fe5a988e16dfec
[clangd] Support textDocument/semanticTokens/edits

Summary:
This returns incremental highlights as a set of edits against the
previous highlights.

Server-side, we compute the full set of highlights, this just saves
wire-format size.

For now, the diff used is trivial: everything from the first change to
the last change is sent as a single edit.

The wire format is grungy - the replacement offset/length refer to
positions in the encoded array instead of the logical list of tokens.
We use token-oriented structs and translating to LSP forms when serializing.
This departs from LSP (but is consistent with semanticTokens today).

Tested in VSCode insiders (with a patched client to enable experimental
features).

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77225
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp