2019-04-17 20:35:16 +08:00
|
|
|
# RUN: clangd -lit-test -clang-tidy-checks=bugprone-sizeof-expression < %s | FileCheck -strict-whitespace %s
|
2018-02-06 18:47:30 +08:00
|
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
|
|
|
|
---
|
[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
|
|
|
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","text":"void main() {\n(void)sizeof(42);\n}"}}}
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK: "method": "textDocument/publishDiagnostics",
|
|
|
|
# CHECK-NEXT: "params": {
|
|
|
|
# CHECK-NEXT: "diagnostics": [
|
|
|
|
# CHECK-NEXT: {
|
2019-04-18 04:12:03 +08:00
|
|
|
# CHECK-NEXT: "code": "-Wmain-return-type",
|
2019-02-01 00:09:25 +08:00
|
|
|
# CHECK-NEXT: "message": "Return type of 'main' is not 'int' (fix available)",
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: "range": {
|
|
|
|
# CHECK-NEXT: "end": {
|
|
|
|
# CHECK-NEXT: "character": 4,
|
|
|
|
# CHECK-NEXT: "line": 0
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "start": {
|
|
|
|
# CHECK-NEXT: "character": 0,
|
|
|
|
# CHECK-NEXT: "line": 0
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: },
|
2019-04-17 20:35:16 +08:00
|
|
|
# CHECK-NEXT: "severity": 2,
|
|
|
|
# CHECK-NEXT: "source": "clang"
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: {
|
|
|
|
# CHECK-NEXT: "code": "bugprone-sizeof-expression",
|
2019-04-18 04:15:08 +08:00
|
|
|
# CHECK-NEXT: "message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
|
2019-04-17 20:35:16 +08:00
|
|
|
# CHECK-NEXT: "range": {
|
|
|
|
# CHECK-NEXT: "end": {
|
|
|
|
# CHECK-NEXT: "character": 12,
|
|
|
|
# CHECK-NEXT: "line": 1
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "start": {
|
|
|
|
# CHECK-NEXT: "character": 6,
|
|
|
|
# CHECK-NEXT: "line": 1
|
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: },
|
|
|
|
# CHECK-NEXT: "severity": 2,
|
|
|
|
# CHECK-NEXT: "source": "clang-tidy"
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
# CHECK-NEXT: ],
|
[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://{{.*}}/foo.c",
|
|
|
|
# CHECK-NEXT: "version": 0
|
2018-02-06 18:47:30 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
2019-03-25 18:15:11 +08:00
|
|
|
{"jsonrpc":"2.0","id":2,"method":"sync","params":null}
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"test:///foo.c"}}}
|
|
|
|
# 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://{{.*}}/foo.c",
|
|
|
|
# CHECK-NEXT: "version": null
|
2019-03-25 18:15:11 +08:00
|
|
|
# CHECK-NEXT: }
|
|
|
|
---
|
2018-02-06 18:47:30 +08:00
|
|
|
{"jsonrpc":"2.0","id":5,"method":"shutdown"}
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","method":"exit"}
|