about summary refs log tree commit diff
path: root/crates/rust-analyzer/src
diff options
context:
space:
mode:
authorJonas Schievink <jonas.schievink@ferrous-systems.com>2022-04-19 18:37:18 +0200
committerJonas Schievink <jonas.schievink@ferrous-systems.com>2022-04-19 18:45:48 +0200
commitc6ffffccbdfdcf084d5e280d4f47ed6d970bee56 (patch)
tree3ef6394b82f3f856346c39c1d4bdcdaaa35ec95d /crates/rust-analyzer/src
parente3ec87730aaabccff4200b218528bd5f7fa57ff9 (diff)
downloadrust-c6ffffccbdfdcf084d5e280d4f47ed6d970bee56.tar.gz
rust-c6ffffccbdfdcf084d5e280d4f47ed6d970bee56.zip
Allows triggering commands after an assist edit
Diffstat (limited to 'crates/rust-analyzer/src')
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt1
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt1
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt1
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt1
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt1
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs1
-rw-r--r--crates/rust-analyzer/src/handlers.rs5
-rw-r--r--crates/rust-analyzer/src/lsp_ext.rs5
-rw-r--r--crates/rust-analyzer/src/to_proto.rs6
9 files changed, 17 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt
index 4610984acb9..41c509452a9 100644
--- a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt
+++ b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt
@@ -318,6 +318,7 @@
                             "quickfix",
                         ),
                     ),
+                    command: None,
                     edit: Some(
                         SnippetWorkspaceEdit {
                             changes: Some(
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt
index 46d44192c5c..1c5c3362234 100644
--- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt
+++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable.txt
@@ -165,6 +165,7 @@
                             "quickfix",
                         ),
                     ),
+                    command: None,
                     edit: Some(
                         SnippetWorkspaceEdit {
                             changes: Some(
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt
index b595487e8f3..3ab3412d971 100644
--- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt
+++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_hint.txt
@@ -165,6 +165,7 @@
                             "quickfix",
                         ),
                     ),
+                    command: None,
                     edit: Some(
                         SnippetWorkspaceEdit {
                             changes: Some(
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt
index 3ee50392a7f..0702420aa5f 100644
--- a/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt
+++ b/crates/rust-analyzer/src/diagnostics/test_data/rustc_unused_variable_as_info.txt
@@ -165,6 +165,7 @@
                             "quickfix",
                         ),
                     ),
+                    command: None,
                     edit: Some(
                         SnippetWorkspaceEdit {
                             changes: Some(
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt
index d7987f65eda..4365e450df1 100644
--- a/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt
+++ b/crates/rust-analyzer/src/diagnostics/test_data/snap_multi_line_fix.txt
@@ -328,6 +328,7 @@
                             "quickfix",
                         ),
                     ),
+                    command: None,
                     edit: Some(
                         SnippetWorkspaceEdit {
                             changes: Some(
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs
index 45e46c1a06b..e9a192cdfb0 100644
--- a/crates/rust-analyzer/src/diagnostics/to_proto.rs
+++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs
@@ -204,6 +204,7 @@ fn map_rust_child_diagnostic(
                     }),
                     is_preferred: Some(true),
                     data: None,
+                    command: None,
                 },
             }),
         })
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index fb64eeea4f6..a1b71ab1437 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1160,8 +1160,9 @@ pub(crate) fn handle_code_action_resolve(
         ))
         .into());
     }
-    let edit = to_proto::code_action(&snap, assist.clone(), None)?.edit;
-    code_action.edit = edit;
+    let ca = to_proto::code_action(&snap, assist.clone(), None)?;
+    code_action.edit = ca.edit;
+    code_action.command = ca.command;
     Ok(code_action)
 }
 
diff --git a/crates/rust-analyzer/src/lsp_ext.rs b/crates/rust-analyzer/src/lsp_ext.rs
index 489a233a0a4..1cfaa133274 100644
--- a/crates/rust-analyzer/src/lsp_ext.rs
+++ b/crates/rust-analyzer/src/lsp_ext.rs
@@ -311,9 +311,8 @@ pub struct CodeAction {
     pub group: Option<String>,
     #[serde(skip_serializing_if = "Option::is_none")]
     pub kind: Option<CodeActionKind>,
-    // We don't handle commands on the client-side
-    // #[serde(skip_serializing_if = "Option::is_none")]
-    // pub command: Option<lsp_types::Command>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub command: Option<lsp_types::Command>,
     #[serde(skip_serializing_if = "Option::is_none")]
     pub edit: Option<SnippetWorkspaceEdit>,
     #[serde(skip_serializing_if = "Option::is_none")]
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs
index deea54cf7d5..57b0e93765e 100644
--- a/crates/rust-analyzer/src/to_proto.rs
+++ b/crates/rust-analyzer/src/to_proto.rs
@@ -1018,7 +1018,13 @@ pub(crate) fn code_action(
         edit: None,
         is_preferred: None,
         data: None,
+        command: None,
     };
+
+    if assist.trigger_signature_help && snap.config.client_commands().trigger_parameter_hints {
+        res.command = Some(command::trigger_parameter_hints());
+    }
+
     match (assist.source_change, resolve_data) {
         (Some(it), _) => res.edit = Some(snippet_workspace_edit(snap, it)?),
         (None, Some((index, code_action_params))) => {