From 16e7070e3e7640f0f081a84ec72b2a8d81f2a668 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Wed, 24 Oct 2018 07:59:38 +0000 Subject: [clangd] Embed fixes as CodeAction, instead of clangd_fixes. Clean up serialization. Summary: CodeAction provides us with a standard way of representing fixes inline, so use it, replacing our existing ad-hoc extension. After this, it's easy to serialize diagnostics using the structured toJSON/Protocol.h mechanism rather than assembling JSON ad-hoc. Reviewers: hokein, arphaman Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53391 llvm-svn: 345119 --- clang-tools-extra/clangd/Protocol.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'clang-tools-extra/clangd/Protocol.cpp') diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index 3622a43c18e..d4892682db9 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -210,8 +210,8 @@ bool fromJSON(const json::Value &Params, ClientCapabilities &R) { if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) { if (auto CategorySupport = Diagnostics->getBoolean("categorySupport")) R.DiagnosticCategory = *CategorySupport; - if (auto ClangdFixSupport = Diagnostics->getBoolean("clangdFixSupport")) - R.DiagnosticFixes = *ClangdFixSupport; + if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) + R.DiagnosticFixes = *CodeActions; } if (auto *Completion = TextDocument->getObject("completion")) { if (auto *Item = Completion->getObject("completionItem")) { @@ -348,8 +348,10 @@ json::Value toJSON(const Diagnostic &D) { {"severity", D.severity}, {"message", D.message}, }; - // FIXME: this should be used for publishDiagnostics. - // FIXME: send category and fixes when appropriate. + if (D.category) + Diag["category"] = *D.category; + if (D.codeActions) + Diag["codeActions"] = D.codeActions; return std::move(Diag); } @@ -358,6 +360,7 @@ bool fromJSON(const json::Value &Params, Diagnostic &R) { if (!O || !O.map("range", R.range) || !O.map("message", R.message)) return false; O.map("severity", R.severity); + O.map("category", R.category); return true; } -- cgit v1.2.3