diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-10-12 16:51:48 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-10-12 16:51:48 +0000 |
commit | cbf497f4528f1a16429ef1d668c77a547923cda6 (patch) | |
tree | 9f638d3421e1fce39bd7a94ac0407e37151ea185 /clang-tools-extra | |
parent | 359544acc7d7b3e64d136642056de5dde6801d18 (diff) | |
download | bcm5719-llvm-cbf497f4528f1a16429ef1d668c77a547923cda6.tar.gz bcm5719-llvm-cbf497f4528f1a16429ef1d668c77a547923cda6.zip |
[clangd] Return Command objects from onCodeAction, rather than ad-hoc JSON. NFC
llvm-svn: 344363
Diffstat (limited to 'clang-tools-extra')
-rw-r--r-- | clang-tools-extra/clangd/ClangdLSPServer.cpp | 17 | ||||
-rw-r--r-- | clang-tools-extra/clangd/Protocol.h | 1 |
2 files changed, 9 insertions, 9 deletions
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index ca898a15353..02496ad4854 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -339,20 +339,21 @@ void ClangdLSPServer::onCodeAction(CodeActionParams &Params) { return replyError(ErrorCode::InvalidParams, "onCodeAction called for non-added file"); - json::Array Commands; + std::vector<Command> Commands; for (Diagnostic &D : Params.context.diagnostics) { for (auto &F : getFixes(Params.textDocument.uri.file(), D)) { WorkspaceEdit WE; std::vector<TextEdit> Edits(F.Edits.begin(), F.Edits.end()); - WE.changes = {{Params.textDocument.uri.uri(), std::move(Edits)}}; - Commands.push_back(json::Object{ - {"title", llvm::formatv("Apply fix: {0}", F.Message)}, - {"command", ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}, - {"arguments", {WE}}, - }); + Commands.emplace_back(); + Commands.back().title = llvm::formatv("Apply fix: {0}", F.Message); + Commands.back().command = ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND; + Commands.back().workspaceEdit.emplace(); + Commands.back().workspaceEdit->changes = { + {Params.textDocument.uri.uri(), std::move(Edits)}, + }; } } - reply(std::move(Commands)); + reply(json::Array(Commands)); } void ClangdLSPServer::onCompletion(TextDocumentPositionParams &Params) { diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index 22da2e3af6d..bd0973f529d 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -673,7 +673,6 @@ bool fromJSON(const llvm::json::Value &, ExecuteCommandParams &); struct Command : public ExecuteCommandParams { std::string title; }; - llvm::json::Value toJSON(const Command &C); /// Represents information about programming constructs like variables, classes, |