[clangd] Simplify common JSON-parsing patterns in Protocol.
authorSam McCall <sam.mccall@gmail.com>
Wed, 29 Nov 2017 11:36:46 +0000 (11:36 +0000)
committerSam McCall <sam.mccall@gmail.com>
Wed, 29 Nov 2017 11:36:46 +0000 (11:36 +0000)
commit38a0491c6885cb14176520b0328d6e3723d5d345
treee96ca4ea3bf76a7cc11bb6dd78b8cb6fb31be5e6
parentda95772230c2925c34583a5ab251065d99efbf89
[clangd] Simplify common JSON-parsing patterns in Protocol.

Summary:
This makes the parse() functions about as short as they can be given the
current signature, and moves all array-traversal etc code to a
central location.

We keep the ability to distinguish between optional and required fields:
and we don't propagate parse errors for optional fields.

I've made most fields required per the LSP spec - the looseness we had
here was mostly a historical accident I think.

Reviewers: ioeric

Subscribers: klimek, cfe-commits, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D40564

llvm-svn: 319309
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/test/clangd/initialize-params-invalid.test