[PATCH] D44272: [clangd] Support incremental document syncing
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 16 04:41:23 PDT 2018
ilya-biryukov added inline comments.
================
Comment at: clangd/ClangdLSPServer.cpp:101
json::obj{
- {"textDocumentSync", 1},
+ {"textDocumentSync", 2},
{"documentFormattingProvider", true},
----------------
simark wrote:
> ilya-biryukov wrote:
> > A comment mentioning that 2 means incremental document sync from LSP would be useful here.
> I opted to add a TextDocumentSyncKind enum to Protocol.h and use that. Though instead of an enum, I did a class with static const fields:
>
> ```
> struct TextDocumentSyncKind {
> /// Documents should not be synced at all.
> static const int None = 0;
>
> /// Documents are synced by always sending the full content of the document.
> static const int Full = 1;
>
> /// Documents are synced by sending the full content on open. After that
> /// only incremental updates to the document are send.
> static const int Incremental = 2;
> };
> ```
>
> otherwise it would've required an (int) cast when using it to generate JSON:
>
> {"textDocumentSync", TextDocumentSyncKind::Incremental},
I'd opt for a real enum. Having some extra type-safety and compiler warnings (i.e. non-covered enum value in switch) is much more valuable than a small inconvenience when converting the value back to json and back.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D44272
More information about the cfe-commits
mailing list