1 # RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
2 # RUN: FileCheck --check-prefix=ERR --input-file=%t %s
3 # UNSUPPORTED: windows-gnu,windows-msvc
4 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
6 {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "foo.c"]}}}}}
8 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","text":"int main() { int i; return i; }"}}}
9 # CHECK: "method": "textDocument/publishDiagnostics",
10 # CHECK-NEXT: "params": {
11 # CHECK-NEXT: "diagnostics": [],
12 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
13 # CHECK-NEXT: "version": 0
16 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///bar.c","languageId":"c","text":"int main() { int i; return i; }"}}}
17 # CHECK: "method": "textDocument/publishDiagnostics",
18 # CHECK-NEXT: "params": {
19 # CHECK-NEXT: "diagnostics": [],
20 # CHECK-NEXT: "uri": "file://{{.*}}/bar.c",
21 # CHECK-NEXT: "version": 0
24 {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test2", "compilationCommand": ["clang", "-c", "foo.c", "-Wall", "-Werror"]}}}}}
25 # CHECK: "method": "textDocument/publishDiagnostics",
26 # CHECK-NEXT: "params": {
27 # CHECK-NEXT: "diagnostics": [
29 # CHECK-NEXT: "code": "-Wuninitialized",
30 # CHECK-NEXT: "message": "Variable 'i' is uninitialized when used here (fix available)",
31 # CHECK-NEXT: "range": {
32 # CHECK-NEXT: "end": {
33 # CHECK-NEXT: "character": 28,
34 # CHECK-NEXT: "line": 0
36 # CHECK-NEXT: "start": {
37 # CHECK-NEXT: "character": 27,
38 # CHECK-NEXT: "line": 0
41 # CHECK-NEXT: "severity": 1,
42 # CHECK-NEXT: "source": "clang"
45 # CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
46 # CHECK-NEXT: "version": 0
49 # ERR: ASTWorker building file {{.*}}foo.c version 0 with command
50 # ERR: [{{.*}}clangd-test2]
51 # ERR: clang -c -Wall -Werror {{.*}} -- {{.*}}foo.c
53 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
55 {"jsonrpc":"2.0","method":"exit"}