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
70 lines
4.2 KiB
Plaintext
70 lines
4.2 KiB
Plaintext
# RUN: clangd -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":"test:///foo.c","languageId":"c","text":"int main(int i, char **a) { if (i = 2) {}}"}}}
|
|
# CHECK: "method": "textDocument/publishDiagnostics",
|
|
# CHECK-NEXT: "params": {
|
|
# CHECK-NEXT: "diagnostics": [
|
|
# CHECK-NEXT: {
|
|
# CHECK-NEXT: "code": "-Wparentheses",
|
|
# CHECK-NEXT: "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
|
|
# CHECK-NEXT: "range": {
|
|
# CHECK-NEXT: "end": {
|
|
# CHECK-NEXT: "character": 37,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "start": {
|
|
# CHECK-NEXT: "character": 32,
|
|
# CHECK-NEXT: "line": 0
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: },
|
|
# CHECK-NEXT: "severity": 2,
|
|
# CHECK-NEXT: "source": "clang"
|
|
# CHECK-NEXT: }
|
|
# CHECK-NEXT: ],
|
|
# CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
|
|
# CHECK-NEXT: "version": 0
|
|
# CHECK-NEXT: }
|
|
---
|
|
# No command name
|
|
{"jsonrpc":"2.0","id":3,"method":"workspace/executeCommand","params":{}}
|
|
---
|
|
# Invalid, non-scalar command name
|
|
{"jsonrpc":"2.0","id":4,"method":"workspace/executeCommand","params":{"command": {}}}
|
|
---
|
|
{"jsonrpc":"2.0","id":5,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","custom":"foo", "arguments":[{"changes":{"test:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":{"start":{"line":0,"character":37},"end":{"line":0,"character":37}},"newText":")"}]}}]}}
|
|
---
|
|
# Arguments not a sequence.
|
|
{"jsonrpc":"2.0","id":6,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":"foo"}}
|
|
---
|
|
# Unknown command.
|
|
{"jsonrpc":"2.0","id":7,"method":"workspace/executeCommand","params":{"command":"mycommand"}}
|
|
---
|
|
# ApplyFix argument not a mapping node.
|
|
{"jsonrpc":"2.0","id":8,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","custom":"foo", "arguments":[""]}}
|
|
---
|
|
# Custom field in WorkspaceEdit
|
|
{"jsonrpc":"2.0","id":9,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"custom":"foo", "changes":{"test:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":{"start":{"line":0,"character":37},"end":{"line":0,"character":37}},"newText":")"}]}}]}}
|
|
---
|
|
# changes in WorkspaceEdit with no mapping node
|
|
{"jsonrpc":"2.0","id":10,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":"foo"}]}}
|
|
---
|
|
# Custom field in WorkspaceEditChange
|
|
{"jsonrpc":"2.0","id":11,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":{"start":{"line":0,"character":37},"end":{"line":0,"character":37}},"newText":")"}], "custom":"foo"}}]}}
|
|
---
|
|
# No sequence node for TextEdits
|
|
{"jsonrpc":"2.0","id":12,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":"bar"}}]}}
|
|
---
|
|
# No mapping node for TextEdit
|
|
{"jsonrpc":"2.0","id":13,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":[""]}}]}}
|
|
---
|
|
# TextEdit not decoded
|
|
{"jsonrpc":"2.0","id":14,"method":"workspace/executeCommand","params":{"command":"clangd.applyFix","arguments":[{"changes":{"test:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":"","newText":")"}]}}]}}
|
|
---
|
|
# Command name after arguments
|
|
{"jsonrpc":"2.0","id":9,"method":"workspace/executeCommand","params":{"arguments":[{"custom":"foo", "changes":{"test:///foo.c":[{"range":{"start":{"line":0,"character":32},"end":{"line":0,"character":32}},"newText":"("},{"range":{"start":{"line":0,"character":37},"end":{"line":0,"character":37}},"newText":")"}]}}],"command":"clangd.applyFix"}}
|
|
---
|
|
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
|
|
---
|
|
{"jsonrpc":"2.0","method":"exit"}
|