aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/move_guard.rs
diff options
context:
space:
mode:
authorvsrs <[email protected]>2020-05-08 17:34:34 +0100
committervsrs <[email protected]>2020-05-08 17:34:34 +0100
commit0ef17ef1ee9fb0ce7149176d12f4d225f6d01401 (patch)
treefa2f168120f36f8dbef5dc1e85fea0c0071639c2 /crates/ra_assists/src/handlers/move_guard.rs
parent1be6320ea6cf7830195f80681fa0f43cc340da7e (diff)
parentd3eb9d8eafbebca7da95fa8a4813b92eb5080500 (diff)
Merge remote-tracking branch 'upstream/master' into uniformed_debug_lens
# Conflicts: # editors/code/src/commands/runnables.ts
Diffstat (limited to 'crates/ra_assists/src/handlers/move_guard.rs')
-rw-r--r--crates/ra_assists/src/handlers/move_guard.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/handlers/move_guard.rs b/crates/ra_assists/src/handlers/move_guard.rs
index 29bc9a9ff..fc0335b57 100644
--- a/crates/ra_assists/src/handlers/move_guard.rs
+++ b/crates/ra_assists/src/handlers/move_guard.rs
@@ -4,7 +4,7 @@ use ra_syntax::{
4 TextSize, 4 TextSize,
5}; 5};
6 6
7use crate::{Assist, AssistCtx, AssistId}; 7use crate::{AssistContext, AssistId, Assists};
8 8
9// Assist: move_guard_to_arm_body 9// Assist: move_guard_to_arm_body
10// 10//
@@ -31,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId};
31// } 31// }
32// } 32// }
33// ``` 33// ```
34pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option<Assist> { 34pub(crate) fn move_guard_to_arm_body(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
35 let match_arm = ctx.find_node_at_offset::<MatchArm>()?; 35 let match_arm = ctx.find_node_at_offset::<MatchArm>()?;
36 let guard = match_arm.guard()?; 36 let guard = match_arm.guard()?;
37 let space_before_guard = guard.syntax().prev_sibling_or_token(); 37 let space_before_guard = guard.syntax().prev_sibling_or_token();
@@ -41,7 +41,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option<Assist> {
41 let buf = format!("if {} {{ {} }}", guard_conditions.syntax().text(), arm_expr.syntax().text()); 41 let buf = format!("if {} {{ {} }}", guard_conditions.syntax().text(), arm_expr.syntax().text());
42 42
43 let target = guard.syntax().text_range(); 43 let target = guard.syntax().text_range();
44 ctx.add_assist(AssistId("move_guard_to_arm_body"), "Move guard to arm body", target, |edit| { 44 acc.add(AssistId("move_guard_to_arm_body"), "Move guard to arm body", target, |edit| {
45 let offseting_amount = match space_before_guard.and_then(|it| it.into_token()) { 45 let offseting_amount = match space_before_guard.and_then(|it| it.into_token()) {
46 Some(tok) => { 46 Some(tok) => {
47 if ast::Whitespace::cast(tok.clone()).is_some() { 47 if ast::Whitespace::cast(tok.clone()).is_some() {
@@ -88,7 +88,7 @@ pub(crate) fn move_guard_to_arm_body(ctx: AssistCtx) -> Option<Assist> {
88// } 88// }
89// } 89// }
90// ``` 90// ```
91pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx) -> Option<Assist> { 91pub(crate) fn move_arm_cond_to_match_guard(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
92 let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?; 92 let match_arm: MatchArm = ctx.find_node_at_offset::<MatchArm>()?;
93 let match_pat = match_arm.pat()?; 93 let match_pat = match_arm.pat()?;
94 94
@@ -109,7 +109,7 @@ pub(crate) fn move_arm_cond_to_match_guard(ctx: AssistCtx) -> Option<Assist> {
109 let buf = format!(" if {}", cond.syntax().text()); 109 let buf = format!(" if {}", cond.syntax().text());
110 110
111 let target = if_expr.syntax().text_range(); 111 let target = if_expr.syntax().text_range();
112 ctx.add_assist( 112 acc.add(
113 AssistId("move_arm_cond_to_match_guard"), 113 AssistId("move_arm_cond_to_match_guard"),
114 "Move condition to match guard", 114 "Move condition to match guard",
115 target, 115 target,