aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index ec3c0a557..d76639474 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -3,6 +3,7 @@
3 3
4use std::{fmt::Write as _, io::Write as _}; 4use std::{fmt::Write as _, io::Write as _};
5 5
6use itertools::Either;
6use lsp_server::ErrorCode; 7use lsp_server::ErrorCode;
7use lsp_types::{ 8use lsp_types::{
8 CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem, 9 CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem,
@@ -698,18 +699,25 @@ pub fn handle_code_action(
698 699
699 for assist in world.analysis().assists(FileRange { file_id, range })?.into_iter() { 700 for assist in world.analysis().assists(FileRange { file_id, range })?.into_iter() {
700 let title = assist.label.clone(); 701 let title = assist.label.clone();
701 let edit = assist.change.try_conv_with(&world)?;
702 let alternative_edits = assist
703 .alternative_changes
704 .into_iter()
705 .map(|change| change.try_conv_with(&world))
706 .collect::<Result<Vec<_>>>()?;
707 702
708 let command = Command { 703 let command = match assist.change_data {
709 title, 704 Either::Left(change) => Command {
710 command: "rust-analyzer.applySourceChange".to_string(), 705 title,
711 arguments: Some(vec![to_value(edit).unwrap(), to_value(alternative_edits).unwrap()]), 706 command: "rust-analyzer.applySourceChange".to_string(),
707 arguments: Some(vec![to_value(change.try_conv_with(&world)?)?]),
708 },
709 Either::Right(changes) => Command {
710 title,
711 command: "rust-analyzer.selectAndApplySourceChange".to_string(),
712 arguments: Some(vec![to_value(
713 changes
714 .into_iter()
715 .map(|change| change.try_conv_with(&world))
716 .collect::<Result<Vec<_>>>()?,
717 )?]),
718 },
712 }; 719 };
720
713 let action = CodeAction { 721 let action = CodeAction {
714 title: command.title.clone(), 722 title: command.title.clone(),
715 kind: match assist.id { 723 kind: match assist.id {