Remove dead apply_code_actions_on_save code (#8488)

I think this was a left-over from when Conrad and I worked on this but
then it was changed to work with `format`.

Release Notes:

- N/A
This commit is contained in:
Thorsten Ball 2024-02-27 17:38:15 +01:00 committed by GitHub
parent 83bc24b480
commit 3036c0cab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5279,103 +5279,6 @@ impl Project {
self.code_actions_impl(buffer_handle, range, cx)
}
pub fn apply_code_actions_on_save(
&self,
buffers: HashSet<Model<Buffer>>,
cx: &mut ModelContext<Self>,
) -> Task<Result<ProjectTransaction>> {
if !self.is_local() {
return Task::ready(Ok(Default::default()));
}
let buffers_with_adapters_and_servers = buffers
.into_iter()
.filter_map(|buffer_handle| {
let buffer = buffer_handle.read(cx);
self.primary_language_server_for_buffer(buffer, cx)
.map(|(a, s)| (buffer_handle, a.clone(), s.clone()))
})
.collect::<Vec<_>>();
cx.spawn(move |this, mut cx| async move {
for (buffer_handle, lsp_adapter, lang_server) in buffers_with_adapters_and_servers {
let actions = this
.update(&mut cx, |this, cx| {
let buffer = buffer_handle.read(cx);
let kinds: Vec<lsp::CodeActionKind> =
language_settings(buffer.language(), buffer.file(), cx)
.code_actions_on_format
.iter()
.flat_map(|(kind, enabled)| {
if *enabled {
Some(kind.clone().into())
} else {
None
}
})
.collect();
if kinds.is_empty() {
return Task::ready(Ok(vec![]));
}
this.request_lsp(
buffer_handle.clone(),
LanguageServerToQuery::Other(lang_server.server_id()),
GetCodeActions {
range: text::Anchor::MIN..text::Anchor::MAX,
kinds: Some(kinds),
},
cx,
)
})?
.await?;
for action in actions {
if let Some(edit) = action.lsp_action.edit {
if edit.changes.is_some() || edit.document_changes.is_some() {
return Self::deserialize_workspace_edit(
this.upgrade().ok_or_else(|| anyhow!("no app present"))?,
edit,
true,
lsp_adapter.clone(),
lang_server.clone(),
&mut cx,
)
.await;
}
}
if let Some(command) = action.lsp_action.command {
this.update(&mut cx, |this, _| {
this.last_workspace_edits_by_language_server
.remove(&lang_server.server_id());
})?;
let result = lang_server
.request::<lsp::request::ExecuteCommand>(lsp::ExecuteCommandParams {
command: command.command,
arguments: command.arguments.unwrap_or_default(),
..Default::default()
})
.await;
if let Err(err) = result {
// TODO: LSP ERROR
return Err(err);
}
return Ok(this.update(&mut cx, |this, _| {
this.last_workspace_edits_by_language_server
.remove(&lang_server.server_id())
.unwrap_or_default()
})?);
}
}
}
Ok(ProjectTransaction::default())
})
}
pub fn apply_code_action(
&self,
buffer_handle: Model<Buffer>,