[PATCH] D39098: Add nlohmann-json library to clangd, and use it to write JSON responses.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 09:33:41 PDT 2017
sammccall created this revision.
Herald added subscribers: ilya-biryukov, fedor.sergeev, krytarowski.
(This is a first cut, and pretty rough)
Goals:
- improve protocol compliance (don't accept YAML, escape more consistently)
- make marshalling code easier to read and write
- make contracts clearer: type system knows when we're passing JSON blobs
I've raised the general issue of adding a library on llvm-dev:
https://groups.google.com/d/topic/llvm-dev/5rryBKDY8eY/discussion
and will wait for a conclusion there too before proceeding.
Some callsites have been updated to pass JSON objects instead of
strings. The rest will be too, incrementally rather than in this patch.
This necessarily modifies the format of the output (e.g. reordering fields).
This breaks the tests, to make them more robust to this in the future
and easier to read I've canonicalized and prettyprinted the output.
We may want to put the prettyprinting behind a flag to save some spaces later.
Only a couple of tests have been updated so far, the others fail - I'll
fix them if the approach seems OK.
Things to do in future:
- have JSONRPCDispatcher/'parse' methods in Protocol use the JSON lib
- replace the 'unparse' methods in Protocol with to_json hooks
- see if we can make JSON use llvm types for strings etc
- clean up callsites that are using replyRaw
https://reviews.llvm.org/D39098
Files:
clangd/ClangdLSPServer.cpp
clangd/JSON.h
clangd/JSONRPCDispatcher.cpp
clangd/JSONRPCDispatcher.h
clangd/nlohmann-json/LICENSE.txt
clangd/nlohmann-json/README.LLVM
clangd/nlohmann-json/json.hpp
test/clangd/authority-less-uri.test
test/clangd/initialize-params-invalid.test
test/clangd/initialize-params.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39098.119593.patch
Type: text/x-patch
Size: 541996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171019/bbc3e1b5/attachment-0001.bin>
More information about the cfe-commits
mailing list