This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Simplify common JSON-parsing patterns in Protocol.
ClosedPublic

Authored by sammccall on Nov 28 2017, 8:49 AM.

Details

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.

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Nov 28 2017, 8:49 AM
ioeric accepted this revision.Nov 29 2017, 3:02 AM

lgtm

clangd/Protocol.cpp
56 ↗(On Diff #124585)

nit: no braces around one liners.

101 ↗(On Diff #124585)

Should we set Out to None in this case?

This revision is now accepted and ready to land.Nov 29 2017, 3:02 AM
This revision was automatically updated to reflect the committed changes.