return Reply(std::move(Err));
WorkspaceEdit WE;
- WE.changes.emplace();
for (const auto &It : R->ApplyEdits) {
- (*WE.changes)[URI::createFile(It.first()).toString()] =
+ WE.changes[URI::createFile(It.first()).toString()] =
It.second.asTextEdits();
}
// ApplyEdit will take care of calling Reply().
if (!Server->getDraft(File))
return Reply(llvm::make_error<LSPError>(
"onRename called for non-added file", ErrorCode::InvalidParams));
- Server->rename(
- File, Params.position, Params.newName, Opts.Rename,
- [File, Params, Reply = std::move(Reply),
- this](llvm::Expected<RenameResult> R) mutable {
- if (!R)
- return Reply(R.takeError());
- if (auto Err = validateEdits(*Server, R->GlobalChanges))
- return Reply(std::move(Err));
- WorkspaceEdit Result;
- Result.changes.emplace();
- for (const auto &Rep : R->GlobalChanges) {
- (*Result.changes)[URI::createFile(Rep.first()).toString()] =
- Rep.second.asTextEdits();
- }
- Reply(Result);
- });
+ Server->rename(File, Params.position, Params.newName, Opts.Rename,
+ [File, Params, Reply = std::move(Reply),
+ this](llvm::Expected<RenameResult> R) mutable {
+ if (!R)
+ return Reply(R.takeError());
+ if (auto Err = validateEdits(*Server, R->GlobalChanges))
+ return Reply(std::move(Err));
+ WorkspaceEdit Result;
+ for (const auto &Rep : R->GlobalChanges) {
+ Result.changes[URI::createFile(Rep.first()).toString()] =
+ Rep.second.asTextEdits();
+ }
+ Reply(Result);
+ });
}
void ClangdLSPServer::onDocumentDidClose(
}
llvm::json::Value toJSON(const WorkspaceEdit &WE) {
- if (!WE.changes)
- return llvm::json::Object{};
llvm::json::Object FileChanges;
- for (auto &Change : *WE.changes)
+ for (auto &Change : WE.changes)
FileChanges[Change.first] = llvm::json::Array(Change.second);
return llvm::json::Object{{"changes", std::move(FileChanges)}};
}