[PATCH] D79692: [clangd] Make version in PublishDiagnosticsParams optional
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun May 10 14:54:39 PDT 2020
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
We were serializing it no matter what, which was against the spec
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79692
Files:
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/test/diagnostics-no-tidy.test
clang-tools-extra/clangd/test/diagnostics.test
Index: clang-tools-extra/clangd/test/diagnostics.test
===================================================================
--- clang-tools-extra/clangd/test/diagnostics.test
+++ 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"}
Index: clang-tools-extra/clangd/test/diagnostics-no-tidy.test
===================================================================
--- clang-tools-extra/clangd/test/diagnostics-no-tidy.test
+++ 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"}
Index: clang-tools-extra/clangd/Protocol.cpp
===================================================================
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -560,11 +560,14 @@
}
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;
+ // FIXME: workaround for older gcc/clang
+ return std::move(Result);
}
bool fromJSON(const llvm::json::Value &Params, CodeActionContext &R) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79692.263084.patch
Type: text/x-patch
Size: 1818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200510/0114bc56/attachment-0001.bin>
More information about the cfe-commits
mailing list