2020-04-01 18:02:28 +08:00
|
|
|
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s -implicit-check-not=semanticHighlight
|
|
|
|
# Send capabilities for both Theia semanticHighlight & standard semanticTokens.
|
|
|
|
# clangd should not use/acknowledge the Theia protocol in this case.
|
|
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"capabilities":{"textDocument":{
|
|
|
|
"semanticHighlightingCapabilities":{"semanticHighlighting":true},
|
|
|
|
"semanticTokens":{"dynamicRegistration":true}
|
|
|
|
}}}}
|
2020-03-24 09:24:47 +08:00
|
|
|
---
|
[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
2020-04-01 22:21:44 +08:00
|
|
|
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{
|
|
|
|
"uri": "test:///foo.cpp",
|
|
|
|
"languageId": "cpp",
|
|
|
|
"text": "int x = 2;"
|
|
|
|
}}}
|
2020-03-24 09:24:47 +08:00
|
|
|
---
|
[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
2020-04-01 22:21:44 +08:00
|
|
|
# Non-incremental token request.
|
2020-03-24 09:24:47 +08:00
|
|
|
{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
|
|
|
|
# CHECK: "id": 1,
|
|
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
|
|
# CHECK-NEXT: "result": {
|
|
|
|
# CHECK-NEXT: "data": [
|
|
|
|
# First line, char 5, variable, no modifiers.
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 4,
|
|
|
|
# CHECK-NEXT: 1,
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 0
|
[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
2020-04-01 22:21:44 +08:00
|
|
|
# CHECK-NEXT: ],
|
|
|
|
# CHECK-NEXT: "resultId": "1"
|
2020-03-24 09:24:47 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
[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
2020-04-01 22:21:44 +08:00
|
|
|
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{
|
|
|
|
"textDocument": {"uri":"test:///foo.cpp","version":2},
|
|
|
|
"contentChanges":[{"text":"int x = 2;\nint y = 3;"}]
|
|
|
|
}}
|
|
|
|
---
|
|
|
|
# Incremental token request, based on previous response.
|
|
|
|
{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{
|
|
|
|
"textDocument": {"uri":"test:///foo.cpp"},
|
|
|
|
"previousResultId": "1"
|
|
|
|
}}
|
|
|
|
# CHECK: "id": 2,
|
|
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
|
|
# CHECK-NEXT: "result": {
|
|
|
|
# CHECK-NEXT: "edits": [
|
|
|
|
# CHECK-NEXT: {
|
|
|
|
# CHECK-NEXT: "data": [
|
|
|
|
# Next line, char 5, variable, no modifiers
|
|
|
|
# CHECK-NEXT: 1,
|
|
|
|
# CHECK-NEXT: 4,
|
|
|
|
# CHECK-NEXT: 1,
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 0
|
|
|
|
# CHECK-NEXT: ],
|
|
|
|
# Inserted at position 1
|
|
|
|
# CHECK-NEXT: "deleteCount": 0,
|
|
|
|
# CHECK-NEXT: "start": 5
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ],
|
|
|
|
# CHECK-NEXT: "resultId": "2"
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
|
|
|
# Incremental token request with incorrect baseline => full tokens list.
|
|
|
|
{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{
|
|
|
|
"textDocument": {"uri":"test:///foo.cpp"},
|
|
|
|
"previousResultId": "bogus"
|
|
|
|
}}
|
|
|
|
# CHECK: "id": 2,
|
|
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
|
|
# CHECK-NEXT: "result": {
|
|
|
|
# CHECK-NEXT: "data": [
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 4,
|
|
|
|
# CHECK-NEXT: 1,
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 1,
|
|
|
|
# CHECK-NEXT: 4,
|
|
|
|
# CHECK-NEXT: 1,
|
|
|
|
# CHECK-NEXT: 0,
|
|
|
|
# CHECK-NEXT: 0
|
|
|
|
# CHECK-NEXT: ],
|
|
|
|
# CHECK-NEXT: "resultId": "3"
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
|
2020-03-24 09:24:47 +08:00
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","method":"exit"}
|