Skip to content

Commit

Permalink
[clangd] Make version in PublishDiagnosticsParams optional
Browse files Browse the repository at this point in the history
Summary: We were serializing it no matter what, which was against the spec

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79692
  • Loading branch information
kadircet committed May 11, 2020
1 parent 3f07cab commit cc9fefe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 4 additions & 2 deletions clang-tools-extra/clangd/Protocol.cpp
Expand Up @@ -560,11 +560,13 @@ bool fromJSON(const llvm::json::Value &Params, Diagnostic &R) {
}

llvm::json::Value toJSON(const PublishDiagnosticsParams &PDP) {
return llvm::json::Object{
llvm::json::Object Result{
{"uri", PDP.uri},
{"diagnostics", PDP.diagnostics},
{"version", PDP.version},
};
if (PDP.version)
Result["version"] = PDP.version;
return std::move(Result);
}

bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clangd/test/diagnostics-no-tidy.test
Expand Up @@ -32,8 +32,7 @@
# CHECK: "method": "textDocument/publishDiagnostics",
# CHECK-NEXT: "params": {
# CHECK-NEXT: "diagnostics": [],
# CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
# CHECK-NEXT: "version": null
# CHECK-NEXT: "uri": "file://{{.*}}/foo.c"
# CHECK-NEXT: }
---
{"jsonrpc":"2.0","id":5,"method":"shutdown"}
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/clangd/test/diagnostics.test
Expand Up @@ -48,8 +48,7 @@
# CHECK: "method": "textDocument/publishDiagnostics",
# CHECK-NEXT: "params": {
# CHECK-NEXT: "diagnostics": [],
# CHECK-NEXT: "uri": "file://{{.*}}/foo.c",
# CHECK-NEXT: "version": null
# CHECK-NEXT: "uri": "file://{{.*}}/foo.c"
# CHECK-NEXT: }
---
{"jsonrpc":"2.0","id":5,"method":"shutdown"}
Expand Down

0 comments on commit cc9fefe

Please sign in to comment.