diff options
author | Aleksey Kladov <[email protected]> | 2019-10-27 14:35:37 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-27 14:35:37 +0000 |
commit | cda6355de23825c201d02e6062cb2dd414e98bf9 (patch) | |
tree | 54c4a26d7a6688a89515cdc97ec02c1a9f9103bf /crates/ra_assists/src/assists/replace_if_let_with_match.rs | |
parent | 9e638c9f3ee68784cd93ec0458b0c92c18776f06 (diff) |
simplify AssistCtx API
We never actually use ability to create multiple actions out of a
single context
Diffstat (limited to 'crates/ra_assists/src/assists/replace_if_let_with_match.rs')
-rw-r--r-- | crates/ra_assists/src/assists/replace_if_let_with_match.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/replace_if_let_with_match.rs b/crates/ra_assists/src/assists/replace_if_let_with_match.rs index 58ef2ff20..dff84d865 100644 --- a/crates/ra_assists/src/assists/replace_if_let_with_match.rs +++ b/crates/ra_assists/src/assists/replace_if_let_with_match.rs | |||
@@ -31,7 +31,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
31 | // } | 31 | // } |
32 | // } | 32 | // } |
33 | // ``` | 33 | // ``` |
34 | pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 34 | pub(crate) fn replace_if_let_with_match(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
35 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; | 35 | let if_expr: ast::IfExpr = ctx.find_node_at_offset()?; |
36 | let cond = if_expr.condition()?; | 36 | let cond = if_expr.condition()?; |
37 | let pat = cond.pat()?; | 37 | let pat = cond.pat()?; |
@@ -42,14 +42,12 @@ pub(crate) fn replace_if_let_with_match(mut ctx: AssistCtx<impl HirDatabase>) -> | |||
42 | ast::ElseBranch::IfExpr(_) => return None, | 42 | ast::ElseBranch::IfExpr(_) => return None, |
43 | }; | 43 | }; |
44 | 44 | ||
45 | ctx.add_action(AssistId("replace_if_let_with_match"), "replace with match", |edit| { | 45 | ctx.add_assist(AssistId("replace_if_let_with_match"), "replace with match", |edit| { |
46 | let match_expr = build_match_expr(expr, pat, then_block, else_block); | 46 | let match_expr = build_match_expr(expr, pat, then_block, else_block); |
47 | edit.target(if_expr.syntax().text_range()); | 47 | edit.target(if_expr.syntax().text_range()); |
48 | edit.replace_node_and_indent(if_expr.syntax(), match_expr); | 48 | edit.replace_node_and_indent(if_expr.syntax(), match_expr); |
49 | edit.set_cursor(if_expr.syntax().text_range().start()) | 49 | edit.set_cursor(if_expr.syntax().text_range().start()) |
50 | }); | 50 | }) |
51 | |||
52 | ctx.build() | ||
53 | } | 51 | } |
54 | 52 | ||
55 | fn build_match_expr( | 53 | fn build_match_expr( |