summaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clangd
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2018-08-01 17:39:29 +0000
committerAlex Lorenz <arphaman@gmail.com>2018-08-01 17:39:29 +0000
commit25133a4c7c9e2df74718cab0f8e17b0672cc0458 (patch)
tree4c5cde1ff3658dcf4b678dd4b356a5c38fd95f23 /clang-tools-extra/test/clangd
parenta85182bc0f8e0326fa37f85efd032ba43404de54 (diff)
[clangd] allow clients to control the compilation database by passing in
compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request This commit allows clangd to use an in-memory compilation database that's controlled from the LSP client (-compile_args_from=lsp). It extends the 'workspace/didChangeConfiguration' request to allow the client to pass in a compilation database subset that needs to be updated in the workspace. Differential Revision: https://reviews.llvm.org/D49758
Diffstat (limited to 'clang-tools-extra/test/clangd')
-rw-r--r--clang-tools-extra/test/clangd/did-change-configuration-params.test52
1 files changed, 52 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clangd/did-change-configuration-params.test b/clang-tools-extra/test/clangd/did-change-configuration-params.test
new file mode 100644
index 00000000000..d46c043da2b
--- /dev/null
+++ b/clang-tools-extra/test/clangd/did-change-configuration-params.test
@@ -0,0 +1,52 @@
+# RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
+# RUN: cat %t | FileCheck --check-prefix=ERR %s
+# UNSUPPORTED: mingw32,win32
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "foo.c"]}}}}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main() { int i; return i; }"}}}
+# CHECK: "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT: "params": {
+# CHECK-NEXT: "diagnostics": [],
+# CHECK-NEXT: "uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT: }
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///bar.c","languageId":"c","version":1,"text":"int main() { int i; return i; }"}}}
+# CHECK: "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT: "params": {
+# CHECK-NEXT: "diagnostics": [],
+# CHECK-NEXT: "uri": "file://{{.*}}/bar.c"
+# CHECK-NEXT: }
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test2", "compilationCommand": ["clang", "-c", "foo.c", "-Wall", "-Werror"]}}}}}
+# CHECK: "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT: "params": {
+# CHECK-NEXT: "diagnostics": [
+# CHECK-NEXT: {
+# CHECK-NEXT: "message": "variable 'i' is uninitialized when used here",
+# CHECK-NEXT: "range": {
+# CHECK-NEXT: "end": {
+# CHECK-NEXT: "character": 28,
+# CHECK-NEXT: "line": 0
+# CHECK-NEXT: },
+# CHECK-NEXT: "start": {
+# CHECK-NEXT: "character": 27,
+# CHECK-NEXT: "line": 0
+# CHECK-NEXT: }
+# CHECK-NEXT: },
+# CHECK-NEXT: "severity": 1
+# CHECK-NEXT: }
+# CHECK-NEXT: ],
+# CHECK-NEXT: "uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT: }
+#
+# ERR: Updating file {{.*}}foo.c with command [{{.*}}clangd-test2] clang -c foo.c -Wall -Werror
+# Don't reparse the second file:
+# ERR: Skipping rebuild of the AST for {{.*}}bar.c
+---
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
+
+