summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2018-02-22 18:40:39 +0000
committerEric Liu <ioeric@google.com>2018-02-22 18:40:39 +0000
commit51fed1834258abffb165af9c5252f1e121366586 (patch)
tree6fdad8465dec2ba7753afd7077958f7a34d8e8b9
parent7ef47a67a5ced2e7aa5a9b9f77eaeeb376e0583e (diff)
downloadbcm5719-llvm-51fed1834258abffb165af9c5252f1e121366586.tar.gz
bcm5719-llvm-51fed1834258abffb165af9c5252f1e121366586.zip
[clangd] Extend textDocument/didChange to specify whether diagnostics should be generated.
Summary: This would allow us to disable diagnostics when didChange is called but diagnostics are not wanted (e.g. code completion). Reviewers: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43634 llvm-svn: 325813
-rw-r--r--clang-tools-extra/clangd/ClangdLSPServer.cpp6
-rw-r--r--clang-tools-extra/clangd/Protocol.cpp3
-rw-r--r--clang-tools-extra/clangd/Protocol.h6
3 files changed, 13 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 587aee73ae0..f2c46dc8d3d 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -149,9 +149,13 @@ void ClangdLSPServer::onDocumentDidChange(DidChangeTextDocumentParams &Params) {
if (Params.contentChanges.size() != 1)
return replyError(ErrorCode::InvalidParams,
"can only apply one change at a time");
+ auto WantDiags = WantDiagnostics::Auto;
+ if (Params.wantDiagnostics.hasValue())
+ WantDiags = Params.wantDiagnostics.getValue() ? WantDiagnostics::Yes
+ : WantDiagnostics::No;
// We only support full syncing right now.
Server.addDocument(Params.textDocument.uri.file(),
- Params.contentChanges[0].text, WantDiagnostics::Auto);
+ Params.contentChanges[0].text, WantDiags);
}
void ClangdLSPServer::onFileEvent(DidChangeWatchedFilesParams &Params) {
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 89925992579..799b2a116aa 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -221,7 +221,8 @@ bool fromJSON(const json::Expr &Params, DidCloseTextDocumentParams &R) {
bool fromJSON(const json::Expr &Params, DidChangeTextDocumentParams &R) {
json::ObjectMapper O(Params);
return O && O.map("textDocument", R.textDocument) &&
- O.map("contentChanges", R.contentChanges);
+ O.map("contentChanges", R.contentChanges) &&
+ O.map("wantDiagnostics", R.wantDiagnostics);
}
bool fromJSON(const json::Expr &E, FileChangeType &Out) {
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 40ccfaf49cb..2db30e74db9 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -297,6 +297,12 @@ struct DidChangeTextDocumentParams {
/// The actual content changes.
std::vector<TextDocumentContentChangeEvent> contentChanges;
+
+ /// Forces diagnostics to be generated, or to not be generated, for this
+ /// version of the file. If not set, diagnostics are eventually consistent:
+ /// either they will be provided for this version or some subsequent one.
+ /// This is a clangd extension.
+ llvm::Optional<bool> wantDiagnostics;
};
bool fromJSON(const json::Expr &, DidChangeTextDocumentParams &);
OpenPOWER on IntegriCloud