diff options
Diffstat (limited to 'crates/ra_assists/src/handlers')
38 files changed, 72 insertions, 118 deletions
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index e86b01dbb..acb07e36a 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -52,7 +52,7 @@ pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
52 | format!("Add custom impl `{}` for `{}`", trait_token.text().as_str(), annotated_name); | 52 | format!("Add custom impl `{}` for `{}`", trait_token.text().as_str(), annotated_name); |
53 | 53 | ||
54 | let target = attr.syntax().text_range(); | 54 | let target = attr.syntax().text_range(); |
55 | acc.add(AssistId("add_custom_impl"), AssistKind::Refactor, label, target, |builder| { | 55 | acc.add(AssistId("add_custom_impl", AssistKind::Refactor), label, target, |builder| { |
56 | let new_attr_input = input | 56 | let new_attr_input = input |
57 | .syntax() | 57 | .syntax() |
58 | .descendants_with_tokens() | 58 | .descendants_with_tokens() |
diff --git a/crates/ra_assists/src/handlers/add_derive.rs b/crates/ra_assists/src/handlers/add_derive.rs index 3b7a570b0..12acfbbe4 100644 --- a/crates/ra_assists/src/handlers/add_derive.rs +++ b/crates/ra_assists/src/handlers/add_derive.rs | |||
@@ -29,7 +29,7 @@ pub(crate) fn add_derive(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
29 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; | 29 | let nominal = ctx.find_node_at_offset::<ast::NominalDef>()?; |
30 | let node_start = derive_insertion_offset(&nominal)?; | 30 | let node_start = derive_insertion_offset(&nominal)?; |
31 | let target = nominal.syntax().text_range(); | 31 | let target = nominal.syntax().text_range(); |
32 | acc.add(AssistId("add_derive"), AssistKind::Refactor, "Add `#[derive]`", target, |builder| { | 32 | acc.add(AssistId("add_derive", AssistKind::Refactor), "Add `#[derive]`", target, |builder| { |
33 | let derive_attr = nominal | 33 | let derive_attr = nominal |
34 | .attrs() | 34 | .attrs() |
35 | .filter_map(|x| x.as_simple_call()) | 35 | .filter_map(|x| x.as_simple_call()) |
diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index 653137d43..39a5321d1 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs | |||
@@ -59,8 +59,7 @@ pub(crate) fn add_explicit_type(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
59 | 59 | ||
60 | let inferred_type = ty.display_source_code(ctx.db(), module.into()).ok()?; | 60 | let inferred_type = ty.display_source_code(ctx.db(), module.into()).ok()?; |
61 | acc.add( | 61 | acc.add( |
62 | AssistId("add_explicit_type"), | 62 | AssistId("add_explicit_type", AssistKind::RefactorRewrite), |
63 | AssistKind::RefactorRewrite, | ||
64 | format!("Insert explicit type `{}`", inferred_type), | 63 | format!("Insert explicit type `{}`", inferred_type), |
65 | pat_range, | 64 | pat_range, |
66 | |builder| match ascribed_ty { | 65 | |builder| match ascribed_ty { |
diff --git a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs index 505085c54..a324670ed 100644 --- a/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs +++ b/crates/ra_assists/src/handlers/add_from_impl_for_enum.rs | |||
@@ -45,8 +45,7 @@ pub(crate) fn add_from_impl_for_enum(acc: &mut Assists, ctx: &AssistContext) -> | |||
45 | 45 | ||
46 | let target = variant.syntax().text_range(); | 46 | let target = variant.syntax().text_range(); |
47 | acc.add( | 47 | acc.add( |
48 | AssistId("add_from_impl_for_enum"), | 48 | AssistId("add_from_impl_for_enum", AssistKind::Refactor), |
49 | AssistKind::Refactor, | ||
50 | "Add From impl for this enum variant", | 49 | "Add From impl for this enum variant", |
51 | target, | 50 | target, |
52 | |edit| { | 51 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/add_function.rs b/crates/ra_assists/src/handlers/add_function.rs index a11bc2551..6f2950daf 100644 --- a/crates/ra_assists/src/handlers/add_function.rs +++ b/crates/ra_assists/src/handlers/add_function.rs | |||
@@ -63,8 +63,7 @@ pub(crate) fn add_function(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
63 | 63 | ||
64 | let target = call.syntax().text_range(); | 64 | let target = call.syntax().text_range(); |
65 | acc.add( | 65 | acc.add( |
66 | AssistId("add_function"), | 66 | AssistId("add_function", AssistKind::RefactorExtract), |
67 | AssistKind::RefactorExtract, | ||
68 | "Add function", | 67 | "Add function", |
69 | target, | 68 | target, |
70 | |builder| { | 69 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs index 405e3c568..2f603ef9c 100644 --- a/crates/ra_assists/src/handlers/add_impl.rs +++ b/crates/ra_assists/src/handlers/add_impl.rs | |||
@@ -27,8 +27,7 @@ pub(crate) fn add_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
27 | let name = nominal.name()?; | 27 | let name = nominal.name()?; |
28 | let target = nominal.syntax().text_range(); | 28 | let target = nominal.syntax().text_range(); |
29 | acc.add( | 29 | acc.add( |
30 | AssistId("add_impl"), | 30 | AssistId("add_impl", AssistKind::Refactor), |
31 | AssistKind::Refactor, | ||
32 | format!("Implement {}", name.text().as_str()), | 31 | format!("Implement {}", name.text().as_str()), |
33 | target, | 32 | target, |
34 | |edit| { | 33 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 13b441a29..d6aaf53f1 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -147,7 +147,7 @@ fn add_missing_impl_members_inner( | |||
147 | } | 147 | } |
148 | 148 | ||
149 | let target = impl_def.syntax().text_range(); | 149 | let target = impl_def.syntax().text_range(); |
150 | acc.add(AssistId(assist_id), AssistKind::QuickFix, label, target, |builder| { | 150 | acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| { |
151 | let n_existing_items = impl_item_list.assoc_items().count(); | 151 | let n_existing_items = impl_item_list.assoc_items().count(); |
152 | let source_scope = ctx.sema.scope_for_def(trait_); | 152 | let source_scope = ctx.sema.scope_for_def(trait_); |
153 | let target_scope = ctx.sema.scope(impl_item_list.syntax()); | 153 | let target_scope = ctx.sema.scope(impl_item_list.syntax()); |
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 4cd3ca264..84eda5486 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -43,8 +43,7 @@ pub(crate) fn add_new(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
43 | 43 | ||
44 | let target = strukt.syntax().text_range(); | 44 | let target = strukt.syntax().text_range(); |
45 | acc.add( | 45 | acc.add( |
46 | AssistId("add_new"), | 46 | AssistId("add_new", AssistKind::Refactor), |
47 | AssistKind::Refactor, | ||
48 | "Add default constructor", | 47 | "Add default constructor", |
49 | target, | 48 | target, |
50 | |builder| { | 49 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/ra_assists/src/handlers/add_turbo_fish.rs index 7a807fbde..f7e1a7b05 100644 --- a/crates/ra_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ra_assists/src/handlers/add_turbo_fish.rs | |||
@@ -46,8 +46,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<( | |||
46 | return None; | 46 | return None; |
47 | } | 47 | } |
48 | acc.add( | 48 | acc.add( |
49 | AssistId("add_turbo_fish"), | 49 | AssistId("add_turbo_fish", AssistKind::RefactorRewrite), |
50 | AssistKind::RefactorRewrite, | ||
51 | "Add `::<>`", | 50 | "Add `::<>`", |
52 | ident.text_range(), | 51 | ident.text_range(), |
53 | |builder| match ctx.config.snippet_cap { | 52 | |builder| match ctx.config.snippet_cap { |
diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/ra_assists/src/handlers/apply_demorgan.rs index a1fd6e112..de701f8b8 100644 --- a/crates/ra_assists/src/handlers/apply_demorgan.rs +++ b/crates/ra_assists/src/handlers/apply_demorgan.rs | |||
@@ -40,8 +40,7 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( | |||
40 | let not_rhs = invert_boolean_expression(rhs); | 40 | let not_rhs = invert_boolean_expression(rhs); |
41 | 41 | ||
42 | acc.add( | 42 | acc.add( |
43 | AssistId("apply_demorgan"), | 43 | AssistId("apply_demorgan", AssistKind::RefactorRewrite), |
44 | AssistKind::RefactorRewrite, | ||
45 | "Apply De Morgan's law", | 44 | "Apply De Morgan's law", |
46 | op_range, | 45 | op_range, |
47 | |edit| { | 46 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 4d97ed101..947be3b9b 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs | |||
@@ -48,8 +48,7 @@ pub(crate) fn auto_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
48 | for import in proposed_imports { | 48 | for import in proposed_imports { |
49 | acc.add_group( | 49 | acc.add_group( |
50 | &group, | 50 | &group, |
51 | AssistId("auto_import"), | 51 | AssistId("auto_import", AssistKind::QuickFix), |
52 | AssistKind::QuickFix, | ||
53 | format!("Import `{}`", &import), | 52 | format!("Import `{}`", &import), |
54 | range, | 53 | range, |
55 | |builder| { | 54 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index 2be6d5e49..24e5f6963 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs | |||
@@ -35,8 +35,7 @@ pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContex | |||
35 | let block_expr = &fn_def.body()?; | 35 | let block_expr = &fn_def.body()?; |
36 | 36 | ||
37 | acc.add( | 37 | acc.add( |
38 | AssistId("change_return_type_to_result"), | 38 | AssistId("change_return_type_to_result", AssistKind::RefactorRewrite), |
39 | AssistKind::RefactorRewrite, | ||
40 | "Change return type to Result", | 39 | "Change return type to Result", |
41 | type_ref.syntax().text_range(), | 40 | type_ref.syntax().text_range(), |
42 | |builder| { | 41 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 34c7e481d..703ee2143 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs | |||
@@ -63,8 +63,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
63 | }; | 63 | }; |
64 | 64 | ||
65 | acc.add( | 65 | acc.add( |
66 | AssistId("change_visibility"), | 66 | AssistId("change_visibility", AssistKind::RefactorRewrite), |
67 | AssistKind::RefactorRewrite, | ||
68 | "Change visibility to pub(crate)", | 67 | "Change visibility to pub(crate)", |
69 | target, | 68 | target, |
70 | |edit| { | 69 | |edit| { |
@@ -77,8 +76,7 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { | |||
77 | if vis.syntax().text() == "pub" { | 76 | if vis.syntax().text() == "pub" { |
78 | let target = vis.syntax().text_range(); | 77 | let target = vis.syntax().text_range(); |
79 | return acc.add( | 78 | return acc.add( |
80 | AssistId("change_visibility"), | 79 | AssistId("change_visibility", AssistKind::RefactorRewrite), |
81 | AssistKind::RefactorRewrite, | ||
82 | "Change Visibility to pub(crate)", | 80 | "Change Visibility to pub(crate)", |
83 | target, | 81 | target, |
84 | |edit| { | 82 | |edit| { |
@@ -89,8 +87,7 @@ fn change_vis(acc: &mut Assists, vis: ast::Visibility) -> Option<()> { | |||
89 | if vis.syntax().text() == "pub(crate)" { | 87 | if vis.syntax().text() == "pub(crate)" { |
90 | let target = vis.syntax().text_range(); | 88 | let target = vis.syntax().text_range(); |
91 | return acc.add( | 89 | return acc.add( |
92 | AssistId("change_visibility"), | 90 | AssistId("change_visibility", AssistKind::RefactorRewrite), |
93 | AssistKind::RefactorRewrite, | ||
94 | "Change visibility to pub", | 91 | "Change visibility to pub", |
95 | target, | 92 | target, |
96 | |edit| { | 93 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 9ccd42cd7..330459f3c 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs | |||
@@ -100,8 +100,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) | |||
100 | 100 | ||
101 | let target = if_expr.syntax().text_range(); | 101 | let target = if_expr.syntax().text_range(); |
102 | acc.add( | 102 | acc.add( |
103 | AssistId("convert_to_guarded_return"), | 103 | AssistId("convert_to_guarded_return", AssistKind::RefactorRewrite), |
104 | AssistKind::RefactorRewrite, | ||
105 | "Convert to guarded return", | 104 | "Convert to guarded return", |
106 | target, | 105 | target, |
107 | |edit| { | 106 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index e1ae485c9..2b8e273b3 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -49,8 +49,7 @@ pub(crate) fn extract_struct_from_enum_variant( | |||
49 | let current_module = enum_hir.module(ctx.db()); | 49 | let current_module = enum_hir.module(ctx.db()); |
50 | let target = variant.syntax().text_range(); | 50 | let target = variant.syntax().text_range(); |
51 | acc.add( | 51 | acc.add( |
52 | AssistId("extract_struct_from_enum_variant"), | 52 | AssistId("extract_struct_from_enum_variant", AssistKind::RefactorRewrite), |
53 | AssistKind::RefactorRewrite, | ||
54 | "Extract struct from enum variant", | 53 | "Extract struct from enum variant", |
55 | target, | 54 | target, |
56 | |builder| { | 55 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/extract_variable.rs b/crates/ra_assists/src/handlers/extract_variable.rs index 8f7ffdaff..481baf1a4 100644 --- a/crates/ra_assists/src/handlers/extract_variable.rs +++ b/crates/ra_assists/src/handlers/extract_variable.rs | |||
@@ -44,8 +44,7 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
44 | } | 44 | } |
45 | let target = expr.syntax().text_range(); | 45 | let target = expr.syntax().text_range(); |
46 | acc.add( | 46 | acc.add( |
47 | AssistId("extract_variable"), | 47 | AssistId("extract_variable", AssistKind::RefactorExtract), |
48 | AssistKind::RefactorExtract, | ||
49 | "Extract into variable", | 48 | "Extract into variable", |
50 | target, | 49 | target, |
51 | move |edit| { | 50 | move |edit| { |
diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index c779e749b..511355e07 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs | |||
@@ -104,8 +104,7 @@ pub(crate) fn fill_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
104 | 104 | ||
105 | let target = match_expr.syntax().text_range(); | 105 | let target = match_expr.syntax().text_range(); |
106 | acc.add( | 106 | acc.add( |
107 | AssistId("fill_match_arms"), | 107 | AssistId("fill_match_arms", AssistKind::QuickFix), |
108 | AssistKind::QuickFix, | ||
109 | "Fill match arms", | 108 | "Fill match arms", |
110 | target, | 109 | target, |
111 | |builder| { | 110 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/fix_visibility.rs b/crates/ra_assists/src/handlers/fix_visibility.rs index 9c6f9efc2..e212557c8 100644 --- a/crates/ra_assists/src/handlers/fix_visibility.rs +++ b/crates/ra_assists/src/handlers/fix_visibility.rs | |||
@@ -58,7 +58,7 @@ fn add_vis_to_referenced_module_def(acc: &mut Assists, ctx: &AssistContext) -> O | |||
58 | Some(name) => format!("Change visibility of {} to {}", name, missing_visibility), | 58 | Some(name) => format!("Change visibility of {} to {}", name, missing_visibility), |
59 | }; | 59 | }; |
60 | 60 | ||
61 | acc.add(AssistId("fix_visibility"), AssistKind::QuickFix, assist_label, target, |builder| { | 61 | acc.add(AssistId("fix_visibility", AssistKind::QuickFix), assist_label, target, |builder| { |
62 | builder.edit_file(target_file); | 62 | builder.edit_file(target_file); |
63 | match ctx.config.snippet_cap { | 63 | match ctx.config.snippet_cap { |
64 | Some(cap) => builder.insert_snippet(cap, offset, format!("$0{} ", missing_visibility)), | 64 | Some(cap) => builder.insert_snippet(cap, offset, format!("$0{} ", missing_visibility)), |
@@ -101,7 +101,7 @@ fn add_vis_to_referenced_record_field(acc: &mut Assists, ctx: &AssistContext) -> | |||
101 | let assist_label = | 101 | let assist_label = |
102 | format!("Change visibility of {}.{} to {}", parent_name, target_name, missing_visibility); | 102 | format!("Change visibility of {}.{} to {}", parent_name, target_name, missing_visibility); |
103 | 103 | ||
104 | acc.add(AssistId("fix_visibility"), AssistKind::QuickFix, assist_label, target, |builder| { | 104 | acc.add(AssistId("fix_visibility", AssistKind::QuickFix), assist_label, target, |builder| { |
105 | builder.edit_file(target_file); | 105 | builder.edit_file(target_file); |
106 | match ctx.config.snippet_cap { | 106 | match ctx.config.snippet_cap { |
107 | Some(cap) => builder.insert_snippet(cap, offset, format!("$0{} ", missing_visibility)), | 107 | Some(cap) => builder.insert_snippet(cap, offset, format!("$0{} ", missing_visibility)), |
diff --git a/crates/ra_assists/src/handlers/flip_binexpr.rs b/crates/ra_assists/src/handlers/flip_binexpr.rs index aee55762f..3cd532650 100644 --- a/crates/ra_assists/src/handlers/flip_binexpr.rs +++ b/crates/ra_assists/src/handlers/flip_binexpr.rs | |||
@@ -34,8 +34,7 @@ pub(crate) fn flip_binexpr(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
34 | } | 34 | } |
35 | 35 | ||
36 | acc.add( | 36 | acc.add( |
37 | AssistId("flip_binexpr"), | 37 | AssistId("flip_binexpr", AssistKind::RefactorRewrite), |
38 | AssistKind::RefactorRewrite, | ||
39 | "Flip binary expression", | 38 | "Flip binary expression", |
40 | op_range, | 39 | op_range, |
41 | |edit| { | 40 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/flip_comma.rs b/crates/ra_assists/src/handlers/flip_comma.rs index 9971ffa71..55a971dc7 100644 --- a/crates/ra_assists/src/handlers/flip_comma.rs +++ b/crates/ra_assists/src/handlers/flip_comma.rs | |||
@@ -29,8 +29,7 @@ pub(crate) fn flip_comma(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | acc.add( | 31 | acc.add( |
32 | AssistId("flip_comma"), | 32 | AssistId("flip_comma", AssistKind::RefactorRewrite), |
33 | AssistKind::RefactorRewrite, | ||
34 | "Flip comma", | 33 | "Flip comma", |
35 | comma.text_range(), | 34 | comma.text_range(), |
36 | |edit| { | 35 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/flip_trait_bound.rs b/crates/ra_assists/src/handlers/flip_trait_bound.rs index 192f70ccb..1234f4d29 100644 --- a/crates/ra_assists/src/handlers/flip_trait_bound.rs +++ b/crates/ra_assists/src/handlers/flip_trait_bound.rs | |||
@@ -34,8 +34,7 @@ pub(crate) fn flip_trait_bound(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
34 | 34 | ||
35 | let target = plus.text_range(); | 35 | let target = plus.text_range(); |
36 | acc.add( | 36 | acc.add( |
37 | AssistId("flip_trait_bound"), | 37 | AssistId("flip_trait_bound", AssistKind::RefactorRewrite), |
38 | AssistKind::RefactorRewrite, | ||
39 | "Flip trait bounds", | 38 | "Flip trait bounds", |
40 | target, | 39 | target, |
41 | |edit| { | 40 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/inline_local_variable.rs b/crates/ra_assists/src/handlers/inline_local_variable.rs index f1bd8b46d..2fdfabaf5 100644 --- a/crates/ra_assists/src/handlers/inline_local_variable.rs +++ b/crates/ra_assists/src/handlers/inline_local_variable.rs | |||
@@ -111,8 +111,7 @@ pub(crate) fn inline_local_variable(acc: &mut Assists, ctx: &AssistContext) -> O | |||
111 | 111 | ||
112 | let target = bind_pat.syntax().text_range(); | 112 | let target = bind_pat.syntax().text_range(); |
113 | acc.add( | 113 | acc.add( |
114 | AssistId("inline_local_variable"), | 114 | AssistId("inline_local_variable", AssistKind::RefactorInline), |
115 | AssistKind::RefactorInline, | ||
116 | "Inline variable", | 115 | "Inline variable", |
117 | target, | 116 | target, |
118 | move |builder| { | 117 | move |builder| { |
diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index 374274824..967593031 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs | |||
@@ -83,7 +83,7 @@ fn generate_fn_def_assist( | |||
83 | _ => return None, | 83 | _ => return None, |
84 | } | 84 | } |
85 | }; | 85 | }; |
86 | acc.add(AssistId(ASSIST_NAME), AssistKind::Refactor, ASSIST_LABEL, lifetime_loc, |builder| { | 86 | acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { |
87 | add_lifetime_param(fn_def, builder, end_of_fn_ident, new_lifetime_param); | 87 | add_lifetime_param(fn_def, builder, end_of_fn_ident, new_lifetime_param); |
88 | builder.replace(lifetime_loc, format!("'{}", new_lifetime_param)); | 88 | builder.replace(lifetime_loc, format!("'{}", new_lifetime_param)); |
89 | loc_needing_lifetime.map(|loc| builder.insert(loc, format!("'{} ", new_lifetime_param))); | 89 | loc_needing_lifetime.map(|loc| builder.insert(loc, format!("'{} ", new_lifetime_param))); |
@@ -98,7 +98,7 @@ fn generate_impl_def_assist( | |||
98 | ) -> Option<()> { | 98 | ) -> Option<()> { |
99 | let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; | 99 | let new_lifetime_param = generate_unique_lifetime_param_name(&impl_def.type_param_list())?; |
100 | let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); | 100 | let end_of_impl_kw = impl_def.impl_token()?.text_range().end(); |
101 | acc.add(AssistId(ASSIST_NAME), AssistKind::Refactor, ASSIST_LABEL, lifetime_loc, |builder| { | 101 | acc.add(AssistId(ASSIST_NAME, AssistKind::Refactor), ASSIST_LABEL, lifetime_loc, |builder| { |
102 | add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); | 102 | add_lifetime_param(impl_def, builder, end_of_impl_kw, new_lifetime_param); |
103 | builder.replace(lifetime_loc, format!("'{}", new_lifetime_param)); | 103 | builder.replace(lifetime_loc, format!("'{}", new_lifetime_param)); |
104 | }) | 104 | }) |
diff --git a/crates/ra_assists/src/handlers/invert_if.rs b/crates/ra_assists/src/handlers/invert_if.rs index eebb2364d..bbe3f3643 100644 --- a/crates/ra_assists/src/handlers/invert_if.rs +++ b/crates/ra_assists/src/handlers/invert_if.rs | |||
@@ -54,7 +54,7 @@ pub(crate) fn invert_if(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
54 | let else_node = else_block.syntax(); | 54 | let else_node = else_block.syntax(); |
55 | let else_range = else_node.text_range(); | 55 | let else_range = else_node.text_range(); |
56 | let then_range = then_node.text_range(); | 56 | let then_range = then_node.text_range(); |
57 | acc.add(AssistId("invert_if"), AssistKind::RefactorRewrite, "Invert if", if_range, |edit| { | 57 | acc.add(AssistId("invert_if", AssistKind::RefactorRewrite), "Invert if", if_range, |edit| { |
58 | edit.replace(cond_range, flip_cond.syntax().text()); | 58 | edit.replace(cond_range, flip_cond.syntax().text()); |
59 | edit.replace(else_range, then_node.text()); | 59 | edit.replace(else_range, then_node.text()); |
60 | edit.replace(then_range, else_node.text()); | 60 | edit.replace(then_range, else_node.text()); |
diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index b0458e17f..1beccb61c 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs | |||
@@ -57,8 +57,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<() | |||
57 | 57 | ||
58 | let target = tree.syntax().text_range(); | 58 | let target = tree.syntax().text_range(); |
59 | acc.add( | 59 | acc.add( |
60 | AssistId("merge_imports"), | 60 | AssistId("merge_imports", AssistKind::RefactorRewrite), |
61 | AssistKind::RefactorRewrite, | ||
62 | "Merge imports", | 61 | "Merge imports", |
63 | target, | 62 | target, |
64 | |builder| { | 63 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/merge_match_arms.rs b/crates/ra_assists/src/handlers/merge_match_arms.rs index f0f11a046..186a1f618 100644 --- a/crates/ra_assists/src/handlers/merge_match_arms.rs +++ b/crates/ra_assists/src/handlers/merge_match_arms.rs | |||
@@ -60,8 +60,7 @@ pub(crate) fn merge_match_arms(acc: &mut Assists, ctx: &AssistContext) -> Option | |||
60 | } | 60 | } |
61 | 61 | ||
62 | acc.add( | 62 | acc.add( |
63 | AssistId("merge_match_arms"), | 63 | AssistId("merge_match_arms", AssistKind::RefactorRewrite), |
64 | AssistKind::RefactorRewrite, | ||
65 | "Merge match arms", | 64 | "Merge match arms", |
66 | current_text_range, | 65 | current_text_range, |
67 | |edit| { | 66 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index bcedd39a8..ba3dafb99 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs | |||
@@ -51,8 +51,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext | |||
51 | 51 | ||
52 | let target = type_param_list.syntax().text_range(); | 52 | let target = type_param_list.syntax().text_range(); |
53 | acc.add( | 53 | acc.add( |
54 | AssistId("move_bounds_to_where_clause"), | 54 | AssistId("move_bounds_to_where_clause", AssistKind::RefactorRewrite), |
55 | AssistKind::RefactorRewrite, | ||
56 | "Move to where clause", | 55 | "Move to where clause", |
57 | target, | 56 | target, |
58 | |edit| { | 57 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/ra_assists/src/handlers/move_guard.rs index 77c1b66be..4060d34c6 100644 --- a/crates/ra_assists/src/handlers/move_guard.rs +++ b/crates/ra_assists/src/handlers/move_guard.rs | |||
@@ -41,8 +41,7 @@ pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> | |||
41 | 41 | ||
42 | let target = guard.syntax().text_range(); | 42 | let target = guard.syntax().text_range(); |
43 | acc.add( | 43 | acc.add( |
44 | AssistId("move_guard_to_arm_body"), | 44 | AssistId("move_guard_to_arm_body", AssistKind::RefactorRewrite), |
45 | AssistKind::RefactorRewrite, | ||
46 | "Move guard to arm body", | 45 | "Move guard to arm body", |
47 | target, | 46 | target, |
48 | |edit| { | 47 | |edit| { |
@@ -106,8 +105,7 @@ pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContex | |||
106 | 105 | ||
107 | let target = if_expr.syntax().text_range(); | 106 | let target = if_expr.syntax().text_range(); |
108 | acc.add( | 107 | acc.add( |
109 | AssistId("move_arm_cond_to_match_guard"), | 108 | AssistId("move_arm_cond_to_match_guard", AssistKind::RefactorRewrite), |
110 | AssistKind::RefactorRewrite, | ||
111 | "Move condition to match guard", | 109 | "Move condition to match guard", |
112 | target, | 110 | target, |
113 | |edit| { | 111 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/raw_string.rs b/crates/ra_assists/src/handlers/raw_string.rs index 8d0dac528..96679e160 100644 --- a/crates/ra_assists/src/handlers/raw_string.rs +++ b/crates/ra_assists/src/handlers/raw_string.rs | |||
@@ -27,8 +27,7 @@ pub(crate) fn make_raw_string(acc: &mut Assists, ctx: &AssistContext) -> Option< | |||
27 | let value = token.value()?; | 27 | let value = token.value()?; |
28 | let target = token.syntax().text_range(); | 28 | let target = token.syntax().text_range(); |
29 | acc.add( | 29 | acc.add( |
30 | AssistId("make_raw_string"), | 30 | AssistId("make_raw_string", AssistKind::RefactorRewrite), |
31 | AssistKind::RefactorRewrite, | ||
32 | "Rewrite as raw string", | 31 | "Rewrite as raw string", |
33 | target, | 32 | target, |
34 | |edit| { | 33 | |edit| { |
@@ -65,8 +64,7 @@ pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
65 | let value = token.value()?; | 64 | let value = token.value()?; |
66 | let target = token.syntax().text_range(); | 65 | let target = token.syntax().text_range(); |
67 | acc.add( | 66 | acc.add( |
68 | AssistId("make_usual_string"), | 67 | AssistId("make_usual_string", AssistKind::RefactorRewrite), |
69 | AssistKind::RefactorRewrite, | ||
70 | "Rewrite as regular string", | 68 | "Rewrite as regular string", |
71 | target, | 69 | target, |
72 | |edit| { | 70 | |edit| { |
@@ -95,7 +93,7 @@ pub(crate) fn make_usual_string(acc: &mut Assists, ctx: &AssistContext) -> Optio | |||
95 | pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 93 | pub(crate) fn add_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
96 | let token = ctx.find_token_at_offset(RAW_STRING)?; | 94 | let token = ctx.find_token_at_offset(RAW_STRING)?; |
97 | let target = token.text_range(); | 95 | let target = token.text_range(); |
98 | acc.add(AssistId("add_hash"), AssistKind::Refactor, "Add # to raw string", target, |edit| { | 96 | acc.add(AssistId("add_hash", AssistKind::Refactor), "Add # to raw string", target, |edit| { |
99 | edit.insert(token.text_range().start() + TextSize::of('r'), "#"); | 97 | edit.insert(token.text_range().start() + TextSize::of('r'), "#"); |
100 | edit.insert(token.text_range().end(), "#"); | 98 | edit.insert(token.text_range().end(), "#"); |
101 | }) | 99 | }) |
@@ -125,8 +123,7 @@ pub(crate) fn remove_hash(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
125 | } | 123 | } |
126 | let target = token.text_range(); | 124 | let target = token.text_range(); |
127 | acc.add( | 125 | acc.add( |
128 | AssistId("remove_hash"), | 126 | AssistId("remove_hash", AssistKind::RefactorRewrite), |
129 | AssistKind::RefactorRewrite, | ||
130 | "Remove hash from raw string", | 127 | "Remove hash from raw string", |
131 | target, | 128 | target, |
132 | |edit| { | 129 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/remove_dbg.rs b/crates/ra_assists/src/handlers/remove_dbg.rs index e5571676f..a616cca57 100644 --- a/crates/ra_assists/src/handlers/remove_dbg.rs +++ b/crates/ra_assists/src/handlers/remove_dbg.rs | |||
@@ -38,7 +38,7 @@ pub(crate) fn remove_dbg(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
38 | }; | 38 | }; |
39 | 39 | ||
40 | let target = macro_call.syntax().text_range(); | 40 | let target = macro_call.syntax().text_range(); |
41 | acc.add(AssistId("remove_dbg"), AssistKind::Refactor, "Remove dbg!()", target, |builder| { | 41 | acc.add(AssistId("remove_dbg", AssistKind::Refactor), "Remove dbg!()", target, |builder| { |
42 | builder.replace(macro_range, macro_content); | 42 | builder.replace(macro_range, macro_content); |
43 | }) | 43 | }) |
44 | } | 44 | } |
diff --git a/crates/ra_assists/src/handlers/remove_mut.rs b/crates/ra_assists/src/handlers/remove_mut.rs index a8173694a..ef55c354e 100644 --- a/crates/ra_assists/src/handlers/remove_mut.rs +++ b/crates/ra_assists/src/handlers/remove_mut.rs | |||
@@ -27,8 +27,7 @@ pub(crate) fn remove_mut(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
27 | 27 | ||
28 | let target = mut_token.text_range(); | 28 | let target = mut_token.text_range(); |
29 | acc.add( | 29 | acc.add( |
30 | AssistId("remove_mut"), | 30 | AssistId("remove_mut", AssistKind::Refactor), |
31 | AssistKind::Refactor, | ||
32 | "Remove `mut` keyword", | 31 | "Remove `mut` keyword", |
33 | target, | 32 | target, |
34 | |builder| { | 33 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/reorder_fields.rs b/crates/ra_assists/src/handlers/reorder_fields.rs index 4a542a5d7..2ac1c56cf 100644 --- a/crates/ra_assists/src/handlers/reorder_fields.rs +++ b/crates/ra_assists/src/handlers/reorder_fields.rs | |||
@@ -43,8 +43,7 @@ fn reorder<R: AstNode>(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
43 | 43 | ||
44 | let target = record.syntax().text_range(); | 44 | let target = record.syntax().text_range(); |
45 | acc.add( | 45 | acc.add( |
46 | AssistId("reorder_fields"), | 46 | AssistId("reorder_fields", AssistKind::RefactorRewrite), |
47 | AssistKind::RefactorRewrite, | ||
48 | "Reorder record fields", | 47 | "Reorder record fields", |
49 | target, | 48 | target, |
50 | |edit| { | 49 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs index 9ef121a4c..b7e30a7f2 100644 --- a/crates/ra_assists/src/handlers/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_if_let_with_match.rs | |||
@@ -49,8 +49,7 @@ pub(crate) fn replace_if_let_with_match(acc: &mut Assists, ctx: &AssistContext) | |||
49 | 49 | ||
50 | let target = if_expr.syntax().text_range(); | 50 | let target = if_expr.syntax().text_range(); |
51 | acc.add( | 51 | acc.add( |
52 | AssistId("replace_if_let_with_match"), | 52 | AssistId("replace_if_let_with_match", AssistKind::RefactorRewrite), |
53 | AssistKind::RefactorRewrite, | ||
54 | "Replace with match", | 53 | "Replace with match", |
55 | target, | 54 | target, |
56 | move |edit| { | 55 | move |edit| { |
diff --git a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs index 174ff1fb4..a49292c97 100644 --- a/crates/ra_assists/src/handlers/replace_let_with_if_let.rs +++ b/crates/ra_assists/src/handlers/replace_let_with_if_let.rs | |||
@@ -45,8 +45,7 @@ pub(crate) fn replace_let_with_if_let(acc: &mut Assists, ctx: &AssistContext) -> | |||
45 | 45 | ||
46 | let target = let_kw.text_range(); | 46 | let target = let_kw.text_range(); |
47 | acc.add( | 47 | acc.add( |
48 | AssistId("replace_let_with_if_let"), | 48 | AssistId("replace_let_with_if_let", AssistKind::RefactorRewrite), |
49 | AssistKind::RefactorRewrite, | ||
50 | "Replace with if-let", | 49 | "Replace with if-let", |
51 | target, | 50 | target, |
52 | |edit| { | 51 | |edit| { |
diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index 5e06f7f0e..dfd314abf 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs | |||
@@ -37,8 +37,7 @@ pub(crate) fn replace_qualified_name_with_use( | |||
37 | 37 | ||
38 | let target = path.syntax().text_range(); | 38 | let target = path.syntax().text_range(); |
39 | acc.add( | 39 | acc.add( |
40 | AssistId("replace_qualified_name_with_use"), | 40 | AssistId("replace_qualified_name_with_use", AssistKind::RefactorRewrite), |
41 | AssistKind::RefactorRewrite, | ||
42 | "Replace qualified path with use", | 41 | "Replace qualified path with use", |
43 | target, | 42 | target, |
44 | |builder| { | 43 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs index 5f9705be1..e5a4bb23c 100644 --- a/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs +++ b/crates/ra_assists/src/handlers/replace_unwrap_with_match.rs | |||
@@ -47,8 +47,7 @@ pub(crate) fn replace_unwrap_with_match(acc: &mut Assists, ctx: &AssistContext) | |||
47 | let happy_variant = TryEnum::from_ty(&ctx.sema, &ty)?.happy_case(); | 47 | let happy_variant = TryEnum::from_ty(&ctx.sema, &ty)?.happy_case(); |
48 | let target = method_call.syntax().text_range(); | 48 | let target = method_call.syntax().text_range(); |
49 | acc.add( | 49 | acc.add( |
50 | AssistId("replace_unwrap_with_match"), | 50 | AssistId("replace_unwrap_with_match", AssistKind::RefactorRewrite), |
51 | AssistKind::RefactorRewrite, | ||
52 | "Replace unwrap with match", | 51 | "Replace unwrap with match", |
53 | target, | 52 | target, |
54 | |builder| { | 53 | |builder| { |
diff --git a/crates/ra_assists/src/handlers/split_import.rs b/crates/ra_assists/src/handlers/split_import.rs index a27b6230a..4ca5c3ca1 100644 --- a/crates/ra_assists/src/handlers/split_import.rs +++ b/crates/ra_assists/src/handlers/split_import.rs | |||
@@ -28,7 +28,7 @@ pub(crate) fn split_import(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
28 | } | 28 | } |
29 | 29 | ||
30 | let target = colon_colon.text_range(); | 30 | let target = colon_colon.text_range(); |
31 | acc.add(AssistId("split_import"), AssistKind::RefactorRewrite, "Split import", target, |edit| { | 31 | acc.add(AssistId("split_import", AssistKind::RefactorRewrite), "Split import", target, |edit| { |
32 | edit.replace_ast(use_tree, new_tree); | 32 | edit.replace_ast(use_tree, new_tree); |
33 | }) | 33 | }) |
34 | } | 34 | } |
diff --git a/crates/ra_assists/src/handlers/unwrap_block.rs b/crates/ra_assists/src/handlers/unwrap_block.rs index a66fba7c3..8b38695a9 100644 --- a/crates/ra_assists/src/handlers/unwrap_block.rs +++ b/crates/ra_assists/src/handlers/unwrap_block.rs | |||
@@ -27,7 +27,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
27 | // } | 27 | // } |
28 | // ``` | 28 | // ``` |
29 | pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 29 | pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
30 | let assist_id = AssistId("unwrap_block"); | 30 | let assist_id = AssistId("unwrap_block", AssistKind::RefactorRewrite); |
31 | let assist_label = "Unwrap block"; | 31 | let assist_label = "Unwrap block"; |
32 | 32 | ||
33 | let l_curly_token = ctx.find_token_at_offset(T!['{'])?; | 33 | let l_curly_token = ctx.find_token_at_offset(T!['{'])?; |
@@ -50,47 +50,35 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
50 | let ancestor_then_branch = ancestor.then_branch()?; | 50 | let ancestor_then_branch = ancestor.then_branch()?; |
51 | 51 | ||
52 | let target = then_branch.syntax().text_range(); | 52 | let target = then_branch.syntax().text_range(); |
53 | return acc.add( | 53 | return acc.add(assist_id, assist_label, target, |edit| { |
54 | assist_id, | 54 | let range_to_del_else_if = TextRange::new( |
55 | AssistKind::Refactor, | 55 | ancestor_then_branch.syntax().text_range().end(), |
56 | assist_label, | 56 | l_curly_token.text_range().start(), |
57 | target, | 57 | ); |
58 | |edit| { | 58 | let range_to_del_rest = TextRange::new( |
59 | let range_to_del_else_if = TextRange::new( | 59 | then_branch.syntax().text_range().end(), |
60 | ancestor_then_branch.syntax().text_range().end(), | 60 | if_expr.syntax().text_range().end(), |
61 | l_curly_token.text_range().start(), | 61 | ); |
62 | ); | 62 | |
63 | let range_to_del_rest = TextRange::new( | 63 | edit.delete(range_to_del_rest); |
64 | then_branch.syntax().text_range().end(), | 64 | edit.delete(range_to_del_else_if); |
65 | if_expr.syntax().text_range().end(), | 65 | edit.replace( |
66 | ); | 66 | target, |
67 | 67 | update_expr_string(then_branch.to_string(), &[' ', '{']), | |
68 | edit.delete(range_to_del_rest); | 68 | ); |
69 | edit.delete(range_to_del_else_if); | 69 | }); |
70 | edit.replace( | ||
71 | target, | ||
72 | update_expr_string(then_branch.to_string(), &[' ', '{']), | ||
73 | ); | ||
74 | }, | ||
75 | ); | ||
76 | } | 70 | } |
77 | } else { | 71 | } else { |
78 | let target = block.syntax().text_range(); | 72 | let target = block.syntax().text_range(); |
79 | return acc.add( | 73 | return acc.add(assist_id, assist_label, target, |edit| { |
80 | assist_id, | 74 | let range_to_del = TextRange::new( |
81 | AssistKind::RefactorRewrite, | 75 | then_branch.syntax().text_range().end(), |
82 | assist_label, | 76 | l_curly_token.text_range().start(), |
83 | target, | 77 | ); |
84 | |edit| { | ||
85 | let range_to_del = TextRange::new( | ||
86 | then_branch.syntax().text_range().end(), | ||
87 | l_curly_token.text_range().start(), | ||
88 | ); | ||
89 | 78 | ||
90 | edit.delete(range_to_del); | 79 | edit.delete(range_to_del); |
91 | edit.replace(target, update_expr_string(block.to_string(), &[' ', '{'])); | 80 | edit.replace(target, update_expr_string(block.to_string(), &[' ', '{'])); |
92 | }, | 81 | }); |
93 | ); | ||
94 | } | 82 | } |
95 | } | 83 | } |
96 | _ => return None, | 84 | _ => return None, |
@@ -98,7 +86,7 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()> | |||
98 | 86 | ||
99 | let unwrapped = unwrap_trivial_block(block); | 87 | let unwrapped = unwrap_trivial_block(block); |
100 | let target = unwrapped.syntax().text_range(); | 88 | let target = unwrapped.syntax().text_range(); |
101 | acc.add(assist_id, AssistKind::RefactorRewrite, assist_label, target, |builder| { | 89 | acc.add(assist_id, assist_label, target, |builder| { |
102 | builder.replace( | 90 | builder.replace( |
103 | parent.syntax().text_range(), | 91 | parent.syntax().text_range(), |
104 | update_expr_string(unwrapped.to_string(), &[' ', '{', '\n']), | 92 | update_expr_string(unwrapped.to_string(), &[' ', '{', '\n']), |