@@ -339,20 +339,21 @@ void ClangdLSPServer::onCodeAction(CodeActionParams &Params) {
339
339
return replyError (ErrorCode::InvalidParams,
340
340
" onCodeAction called for non-added file" );
341
341
342
- json::Array Commands;
342
+ std::vector<Command> Commands;
343
343
for (Diagnostic &D : Params.context .diagnostics ) {
344
344
for (auto &F : getFixes (Params.textDocument .uri .file (), D)) {
345
345
WorkspaceEdit WE;
346
346
std::vector<TextEdit> Edits (F.Edits .begin (), F.Edits .end ());
347
- WE.changes = {{Params.textDocument .uri .uri (), std::move (Edits)}};
348
- Commands.push_back (json::Object{
349
- {" title" , llvm::formatv (" Apply fix: {0}" , F.Message )},
350
- {" command" , ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND},
351
- {" arguments" , {WE}},
352
- });
347
+ Commands.emplace_back ();
348
+ Commands.back ().title = llvm::formatv (" Apply fix: {0}" , F.Message );
349
+ Commands.back ().command = ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND;
350
+ Commands.back ().workspaceEdit .emplace ();
351
+ Commands.back ().workspaceEdit ->changes = {
352
+ {Params.textDocument .uri .uri (), std::move (Edits)},
353
+ };
353
354
}
354
355
}
355
- reply (std::move (Commands));
356
+ reply (json::Array (Commands));
356
357
}
357
358
358
359
void ClangdLSPServer::onCompletion (TextDocumentPositionParams &Params) {
0 commit comments