2018-08-04 03:40:19 +08:00
|
|
|
# Test that we can set choose a configuration/build directly in the initialize
|
|
|
|
# request.
|
|
|
|
|
|
|
|
# RUN: rm -rf %t.dir/* && mkdir -p %t.dir
|
|
|
|
# RUN: mkdir %t.dir/build-1
|
|
|
|
# RUN: echo '[{"directory": "%/t.dir", "command": "c++ the-file.cpp", "file": "the-file.cpp"}]' > %t.dir/compile_commands.json
|
|
|
|
# RUN: echo '[{"directory": "%/t.dir/build-1", "command": "c++ -DMACRO=1 the-file.cpp", "file": "../the-file.cpp"}]' > %t.dir/build-1/compile_commands.json
|
|
|
|
|
|
|
|
# RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
|
|
|
|
|
|
|
|
# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
|
|
|
|
# (with the extra slash in the front), so we add it here.
|
2019-10-14 11:44:47 +08:00
|
|
|
# RUN: sed -E -e "s|file://([A-Z]):/|file:///\1:/|g" %t.test.1 > %t.test
|
2018-08-04 03:40:19 +08:00
|
|
|
|
|
|
|
# RUN: clangd -lit-test < %t.test | FileCheck -strict-whitespace %t.test
|
|
|
|
|
|
|
|
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"initializationOptions":{"compilationDatabasePath":"INPUT_DIR/build-1"}}}
|
|
|
|
---
|
2018-10-16 23:55:03 +08:00
|
|
|
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file://INPUT_DIR/the-file.cpp","languageId":"cpp","version":1,"text":"#if !defined(MACRO)\n#pragma message (\"MACRO is not defined\")\n#elif MACRO == 1\n#pragma message (\"MACRO is one\")\n#else\n#pragma message (\"woops\")\n#endif\nint main() {}\n"}}}
|
2018-08-04 03:40:19 +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": "-W#pragma-messages",
|
2018-08-04 03:40:19 +08:00
|
|
|
# CHECK-NEXT: "message": "MACRO is one",
|
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","id":10000,"method":"shutdown"}
|
[clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. (re-land r344620)
Summary:
This paves the way for alternative transports (mac XPC, maybe messagepack?),
and also generally improves layering: testing ClangdLSPServer becomes less of
a pipe dream, we split up the JSONOutput monolith, etc.
This isn't a final state, much of what remains in JSONRPCDispatcher can go away,
handlers can call reply() on the transport directly, JSONOutput can be renamed
to StreamLogger and removed, etc. But this patch is sprawling already.
The main observable change (see tests) is that hitting EOF on input is now an
error: the client should send the 'exit' notification.
This is defensible: the protocol doesn't spell this case out. Reproducing the
current behavior for all combinations of shutdown/exit/EOF clutters interfaces.
We can iterate on this if desired.
Reviewers: jkorous, ioeric, hokein
Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits
Differential Revision: https://reviews.llvm.org/D53286
llvm-svn: 344672
2018-10-17 15:32:05 +08:00
|
|
|
---
|
|
|
|
{"jsonrpc":"2.0","method":"exit"}
|