diff --git a/crates/els/code_action.rs b/crates/els/code_action.rs index 8a243d85..fc450a58 100644 --- a/crates/els/code_action.rs +++ b/crates/els/code_action.rs @@ -16,7 +16,7 @@ use crate::server::{ELSResult, Server}; use crate::util; impl Server { - fn perform_eliminate_unused_vars_action( + fn send_eliminate_unused_vars_action( &self, _msg: &Value, uri: &Url, @@ -70,7 +70,7 @@ impl Server { } } - pub(crate) fn perform_code_action(&self, msg: &Value) -> ELSResult<()> { + pub(crate) fn send_code_action(&self, msg: &Value) -> ELSResult<()> { Self::send_log(format!("code action requested: {msg}"))?; let params = CodeActionParams::deserialize(&msg["params"])?; let result = match params @@ -79,7 +79,8 @@ impl Server { .as_ref() .and_then(|kinds| kinds.first().map(|s| s.as_str())) { - Some("quickfix") | None => self.perform_quick_fix(msg, params)?, + Some("quickfix") => self.send_quick_fix(msg, params)?, + None => self.send_normal_action(msg, params)?, Some(other) => { Self::send_log(&format!("Unknown code action requested: {other}"))?; vec![] @@ -90,17 +91,21 @@ impl Server { ) } - fn perform_quick_fix( + fn send_normal_action( &self, msg: &Value, params: CodeActionParams, ) -> ELSResult> { + self.send_quick_fix(msg, params) + } + + fn send_quick_fix(&self, msg: &Value, params: CodeActionParams) -> ELSResult> { let mut result: Vec = vec![]; let uri = util::normalize_url(params.text_document.uri); for diag in params.context.diagnostics.into_iter() { match &diag.message { unused if unused.ends_with("is not used") => { - result.extend(self.perform_eliminate_unused_vars_action(msg, &uri, diag)?); + result.extend(self.send_eliminate_unused_vars_action(msg, &uri, diag)?); } _ => { Self::send_log(&format!("Unknown diagnostic for action: {}", diag.message))?; diff --git a/crates/els/server.rs b/crates/els/server.rs index 5e9a2b3e..b6901e0e 100644 --- a/crates/els/server.rs +++ b/crates/els/server.rs @@ -338,7 +338,7 @@ impl Server { "textDocument/references" => self.show_references(msg), "textDocument/semanticTokens/full" => self.get_semantic_tokens_full(msg), "textDocument/inlayHint" => self.get_inlay_hint(msg), - "textDocument/codeAction" => self.perform_code_action(msg), + "textDocument/codeAction" => self.send_code_action(msg), other => Self::send_error(Some(id), -32600, format!("{other} is not supported")), } }