diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-10-24 07:59:38 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-10-24 07:59:38 +0000 |
| commit | 16e7070e3e7640f0f081a84ec72b2a8d81f2a668 (patch) | |
| tree | bfb763d0f6a6872c9a26ba20ebccf3164a755145 /clang-tools-extra/clangd/Protocol.cpp | |
| parent | 1f54500af04bcdc2a4cd41b154778abf691ed300 (diff) | |
| download | bcm5719-llvm-16e7070e3e7640f0f081a84ec72b2a8d81f2a668.tar.gz bcm5719-llvm-16e7070e3e7640f0f081a84ec72b2a8d81f2a668.zip | |
[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
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/Protocol.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
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; } |

