2020-01-07 18:28:05 +08:00
|
|
|
# Copy over the server file into test workspace
|
|
|
|
# RUN: rm -rf %t
|
|
|
|
# RUN: cp -r %S/Inputs/path-mappings %t
|
|
|
|
#
|
|
|
|
# RUN: clangd --path-mappings 'C:\client=%t/server' -lit-test < %s | FileCheck -strict-whitespace %s
|
|
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
|
|
|
|
---
|
|
|
|
{
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
"method": "textDocument/didOpen",
|
|
|
|
"params": {
|
|
|
|
"textDocument": {
|
|
|
|
"uri": "file:///C:/client/bar.cpp",
|
|
|
|
"languageId": "cpp",
|
|
|
|
"text": "#include \"foo.h\"\nint main(){\nreturn foo();\n}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# Ensure that the client gets back the same client path (clangd thinks it edited %t/server/bar.cpp)
|
|
|
|
# CHECK: "method": "textDocument/publishDiagnostics",
|
|
|
|
# CHECK-NEXT: "params": {
|
|
|
|
# CHECK-NEXT: "diagnostics": [],
|
[clangd] Track document versions, include them with diags, enhance logs
Summary:
This ties to an LSP feature (diagnostic versioning) but really a lot
of the value is in being able to log what's happening with file versions
and queues more descriptively and clearly.
As such it's fairly invasive, for a logging patch :-\
Key decisions:
- at the LSP layer, we don't reqire the client to provide versions (LSP
makes it mandatory but we never enforced it). If not provided,
versions start at 0 and increment. DraftStore handles this.
- don't propagate magically using contexts, but rather manually:
addDocument -> ParseInputs -> (ParsedAST, Preamble, various callbacks)
Context-propagation would hide the versions from ClangdServer, which
would make producing good log messages hard
- within ClangdServer, treat versions as opaque and unordered.
std::string is a convenient type for this, and allows richer versions
for embedders. They're "mandatory" but "null" is a reasonable default.
Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75582
2020-03-04 07:33:29 +08:00
|
|
|
# CHECK-NEXT: "uri": "file:///C:/client/bar.cpp",
|
|
|
|
# CHECK-NEXT: "version": 0
|
2020-01-07 18:28:05 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
|
|
|
# We're editing bar.cpp, which includes foo.h, where foo.h "exists" at a server location
|
|
|
|
# With path mappings, when we go to definition on foo(), we get back a client file uri
|
|
|
|
{
|
|
|
|
"jsonrpc": "2.0",
|
|
|
|
"id": 1,
|
|
|
|
"method": "textDocument/definition",
|
|
|
|
"params": {
|
|
|
|
"textDocument": {
|
|
|
|
"uri": "file:///C:/client/bar.cpp"
|
|
|
|
},
|
|
|
|
"position": {
|
|
|
|
"line": 2,
|
|
|
|
"character": 8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# CHECK: "id": 1,
|
|
|
|
# CHECK-NEXT: "jsonrpc": "2.0",
|
|
|
|
# CHECK-NEXT: "result": [
|
|
|
|
# CHECK-NEXT: {
|
|
|
|
# CHECK-NEXT: "range": {
|
|
|
|
# CHECK-NEXT: "end": {
|
|
|
|
# CHECK-NEXT: "character": {{[0-9]+}},
|
[clangd] Track document versions, include them with diags, enhance logs
Summary:
This ties to an LSP feature (diagnostic versioning) but really a lot
of the value is in being able to log what's happening with file versions
and queues more descriptively and clearly.
As such it's fairly invasive, for a logging patch :-\
Key decisions:
- at the LSP layer, we don't reqire the client to provide versions (LSP
makes it mandatory but we never enforced it). If not provided,
versions start at 0 and increment. DraftStore handles this.
- don't propagate magically using contexts, but rather manually:
addDocument -> ParseInputs -> (ParsedAST, Preamble, various callbacks)
Context-propagation would hide the versions from ClangdServer, which
would make producing good log messages hard
- within ClangdServer, treat versions as opaque and unordered.
std::string is a convenient type for this, and allows richer versions
for embedders. They're "mandatory" but "null" is a reasonable default.
Subscribers: ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75582
2020-03-04 07:33:29 +08:00
|
|
|
# CHECK-NEXT: "line": {{[0-9]+}}
|
2020-01-07 18:28:05 +08:00
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "start": {
|
|
|
|
# CHECK-NEXT: "character": {{[0-9]+}},
|
|
|
|
# CHECK-NEXT: "line": {{[0-9]+}}
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "uri": "file:///C:/client/foo.h"
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ]
|
|
|
|
#
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","id":2,"method":"shutdown"}
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","method":"exit"}
|