aboutsummaryrefslogtreecommitdiff
path: root/crates/assists
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-11-17 13:07:13 +0000
committerAleksey Kladov <[email protected]>2020-11-17 13:33:30 +0000
commit10fa9c595ab6cae7420eb879cabadc30db4d6d7e (patch)
tree6e68e2c7390cc319c72cd430859f325feb644e4e /crates/assists
parent8dd0b7d2b59cffda0aa788c5d3016fe75d31a2ff (diff)
Simplify
Diffstat (limited to 'crates/assists')
-rw-r--r--crates/assists/src/handlers/unwrap_block.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/crates/assists/src/handlers/unwrap_block.rs b/crates/assists/src/handlers/unwrap_block.rs
index a82399aa8..a3ef33520 100644
--- a/crates/assists/src/handlers/unwrap_block.rs
+++ b/crates/assists/src/handlers/unwrap_block.rs
@@ -31,6 +31,7 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
31 31
32 let l_curly_token = ctx.find_token_syntax_at_offset(T!['{'])?; 32 let l_curly_token = ctx.find_token_syntax_at_offset(T!['{'])?;
33 let mut block = ast::BlockExpr::cast(l_curly_token.parent())?; 33 let mut block = ast::BlockExpr::cast(l_curly_token.parent())?;
34 let target = block.syntax().text_range();
34 let mut parent = block.syntax().parent()?; 35 let mut parent = block.syntax().parent()?;
35 if ast::MatchArm::can_cast(parent.kind()) { 36 if ast::MatchArm::can_cast(parent.kind()) {
36 parent = parent.ancestors().find(|it| ast::MatchExpr::can_cast(it.kind()))? 37 parent = parent.ancestors().find(|it| ast::MatchExpr::can_cast(it.kind()))?
@@ -48,7 +49,6 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
48 // For `else if` blocks 49 // For `else if` blocks
49 let ancestor_then_branch = ancestor.then_branch()?; 50 let ancestor_then_branch = ancestor.then_branch()?;
50 51
51 let target = then_branch.syntax().text_range();
52 return acc.add(assist_id, assist_label, target, |edit| { 52 return acc.add(assist_id, assist_label, target, |edit| {
53 let range_to_del_else_if = TextRange::new( 53 let range_to_del_else_if = TextRange::new(
54 ancestor_then_branch.syntax().text_range().end(), 54 ancestor_then_branch.syntax().text_range().end(),
@@ -68,7 +68,6 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
68 }); 68 });
69 } 69 }
70 } else { 70 } else {
71 let target = block.syntax().text_range();
72 return acc.add(assist_id, assist_label, target, |edit| { 71 return acc.add(assist_id, assist_label, target, |edit| {
73 let range_to_del = TextRange::new( 72 let range_to_del = TextRange::new(
74 then_branch.syntax().text_range().end(), 73 then_branch.syntax().text_range().end(),
@@ -83,7 +82,6 @@ pub(crate) fn unwrap_block(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
83 _ => return None, 82 _ => return None,
84 }; 83 };
85 84
86 let target = block.syntax().text_range();
87 let unwrapped = unwrap_trivial_block(block); 85 let unwrapped = unwrap_trivial_block(block);
88 acc.add(assist_id, assist_label, target, |builder| { 86 acc.add(assist_id, assist_label, target, |builder| {
89 builder.replace( 87 builder.replace(