diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-27 14:38:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-27 14:38:28 +0000 |
commit | cf309b6a5f2d51e9509568ab82446cc3eae29f94 (patch) | |
tree | 54c4a26d7a6688a89515cdc97ec02c1a9f9103bf /crates/ra_assists/src/assists/flip_binexpr.rs | |
parent | ad950830d0902aaacfb5a76355a203626eb93b5f (diff) | |
parent | cda6355de23825c201d02e6062cb2dd414e98bf9 (diff) |
Merge #2094
2094: simplify AssistCtx API r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists/flip_binexpr.rs')
-rw-r--r-- | crates/ra_assists/src/assists/flip_binexpr.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/flip_binexpr.rs b/crates/ra_assists/src/assists/flip_binexpr.rs index 9765d5ddd..386045eb0 100644 --- a/crates/ra_assists/src/assists/flip_binexpr.rs +++ b/crates/ra_assists/src/assists/flip_binexpr.rs | |||
@@ -18,7 +18,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
18 | // let _ = 2 + 90; | 18 | // let _ = 2 + 90; |
19 | // } | 19 | // } |
20 | // ``` | 20 | // ``` |
21 | pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 21 | pub(crate) fn flip_binexpr(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
22 | let expr = ctx.find_node_at_offset::<BinExpr>()?; | 22 | let expr = ctx.find_node_at_offset::<BinExpr>()?; |
23 | let lhs = expr.lhs()?.syntax().clone(); | 23 | let lhs = expr.lhs()?.syntax().clone(); |
24 | let rhs = expr.rhs()?.syntax().clone(); | 24 | let rhs = expr.rhs()?.syntax().clone(); |
@@ -34,16 +34,14 @@ pub(crate) fn flip_binexpr(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assis | |||
34 | return None; | 34 | return None; |
35 | } | 35 | } |
36 | 36 | ||
37 | ctx.add_action(AssistId("flip_binexpr"), "flip binary expression", |edit| { | 37 | ctx.add_assist(AssistId("flip_binexpr"), "flip binary expression", |edit| { |
38 | edit.target(op_range); | 38 | edit.target(op_range); |
39 | if let FlipAction::FlipAndReplaceOp(new_op) = action { | 39 | if let FlipAction::FlipAndReplaceOp(new_op) = action { |
40 | edit.replace(op_range, new_op); | 40 | edit.replace(op_range, new_op); |
41 | } | 41 | } |
42 | edit.replace(lhs.text_range(), rhs.text()); | 42 | edit.replace(lhs.text_range(), rhs.text()); |
43 | edit.replace(rhs.text_range(), lhs.text()); | 43 | edit.replace(rhs.text_range(), lhs.text()); |
44 | }); | 44 | }) |
45 | |||
46 | ctx.build() | ||
47 | } | 45 | } |
48 | 46 | ||
49 | enum FlipAction { | 47 | enum FlipAction { |