[clang-tools-extra] cc9fefe - [clangd] Make version in PublishDiagnosticsParams optional

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon May 11 01:31:19 PDT 2020


Author: Kadir Cetinkaya
Date: 2020-05-11T10:31:10+02:00
New Revision: cc9fefec4368efb64e78dee1109e342b37d21bca

URL: https://github.com/llvm/llvm-project/commit/cc9fefec4368efb64e78dee1109e342b37d21bca
DIFF: https://github.com/llvm/llvm-project/commit/cc9fefec4368efb64e78dee1109e342b37d21bca.diff

LOG: [clangd] Make version in PublishDiagnosticsParams optional

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

Added: 
    

Modified: 
    clang-tools-extra/clangd/Protocol.cpp
    clang-tools-extra/clangd/test/diagnostics-no-tidy.test
    clang-tools-extra/clangd/test/diagnostics.test

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index 675ba18e80ce..ecae65336e5b 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -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) {

diff  --git a/clang-tools-extra/clangd/test/diagnostics-no-tidy.test b/clang-tools-extra/clangd/test/diagnostics-no-tidy.test
index 1a1068dafd5b..9341275b6c21 100644
--- a/clang-tools-extra/clangd/test/diagnostics-no-tidy.test
+++ b/clang-tools-extra/clangd/test/diagnostics-no-tidy.test
@@ -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"}

diff  --git a/clang-tools-extra/clangd/test/diagnostics.test b/clang-tools-extra/clangd/test/diagnostics.test
index 6f54e2cf115a..588fefdbf2e0 100644
--- a/clang-tools-extra/clangd/test/diagnostics.test
+++ b/clang-tools-extra/clangd/test/diagnostics.test
@@ -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"}


        


More information about the cfe-commits mailing list