aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers/flip_binexpr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/handlers/flip_binexpr.rs')
-rw-r--r--crates/ra_assists/src/handlers/flip_binexpr.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/crates/ra_assists/src/handlers/flip_binexpr.rs b/crates/ra_assists/src/handlers/flip_binexpr.rs
index 573196576..aee55762f 100644
--- a/crates/ra_assists/src/handlers/flip_binexpr.rs
+++ b/crates/ra_assists/src/handlers/flip_binexpr.rs
@@ -1,6 +1,6 @@
1use ra_syntax::ast::{AstNode, BinExpr, BinOp}; 1use ra_syntax::ast::{AstNode, BinExpr, BinOp};
2 2
3use crate::{AssistContext, AssistId, Assists}; 3use crate::{AssistContext, AssistId, AssistKind, Assists};
4 4
5// Assist: flip_binexpr 5// Assist: flip_binexpr
6// 6//
@@ -33,13 +33,19 @@ pub(crate) fn flip_binexpr(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
33 return None; 33 return None;
34 } 34 }
35 35
36 acc.add(AssistId("flip_binexpr"), "Flip binary expression", op_range, |edit| { 36 acc.add(
37 if let FlipAction::FlipAndReplaceOp(new_op) = action { 37 AssistId("flip_binexpr"),
38 edit.replace(op_range, new_op); 38 AssistKind::RefactorRewrite,
39 } 39 "Flip binary expression",
40 edit.replace(lhs.text_range(), rhs.text()); 40 op_range,
41 edit.replace(rhs.text_range(), lhs.text()); 41 |edit| {
42 }) 42 if let FlipAction::FlipAndReplaceOp(new_op) = action {
43 edit.replace(op_range, new_op);
44 }
45 edit.replace(lhs.text_range(), rhs.text());
46 edit.replace(rhs.text_range(), lhs.text());
47 },
48 )
43} 49}
44 50
45enum FlipAction { 51enum FlipAction {