[clangd] Return Command objects from onCodeAction, rather than ad-hoc JSON. NFC
llvm-svn: 344363
This commit is contained in:
parent
359544acc7
commit
cbf497f452
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue