diff options
author | Jeremy Kolb <[email protected]> | 2020-06-28 23:36:05 +0100 |
---|---|---|
committer | kjeremy <[email protected]> | 2020-07-02 22:13:02 +0100 |
commit | b98c16a034620913f3dbc67bd3f48ad2686face7 (patch) | |
tree | 10f90c96791cfd82bb160a1a5c7474ccc17d5b8b /crates/ra_assists/src/handlers/apply_demorgan.rs | |
parent | 4cb8bf03c588dcf244d25785de3878b6ef3f7958 (diff) |
Categorize assists
Diffstat (limited to 'crates/ra_assists/src/handlers/apply_demorgan.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/apply_demorgan.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/crates/ra_assists/src/handlers/apply_demorgan.rs b/crates/ra_assists/src/handlers/apply_demorgan.rs index 233e8fb8e..a1fd6e112 100644 --- a/crates/ra_assists/src/handlers/apply_demorgan.rs +++ b/crates/ra_assists/src/handlers/apply_demorgan.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_syntax::ast::{self, AstNode}; | 1 | use ra_syntax::ast::{self, AstNode}; |
2 | 2 | ||
3 | use crate::{utils::invert_boolean_expression, AssistContext, AssistId, Assists}; | 3 | use crate::{utils::invert_boolean_expression, AssistContext, AssistId, AssistKind, Assists}; |
4 | 4 | ||
5 | // Assist: apply_demorgan | 5 | // Assist: apply_demorgan |
6 | // | 6 | // |
@@ -39,11 +39,17 @@ pub(crate) fn apply_demorgan(acc: &mut Assists, ctx: &AssistContext) -> Option<( | |||
39 | let rhs_range = rhs.syntax().text_range(); | 39 | let rhs_range = rhs.syntax().text_range(); |
40 | let not_rhs = invert_boolean_expression(rhs); | 40 | let not_rhs = invert_boolean_expression(rhs); |
41 | 41 | ||
42 | acc.add(AssistId("apply_demorgan"), "Apply De Morgan's law", op_range, |edit| { | 42 | acc.add( |
43 | edit.replace(op_range, opposite_op); | 43 | AssistId("apply_demorgan"), |
44 | edit.replace(lhs_range, format!("!({}", not_lhs.syntax().text())); | 44 | AssistKind::RefactorRewrite, |
45 | edit.replace(rhs_range, format!("{})", not_rhs.syntax().text())); | 45 | "Apply De Morgan's law", |
46 | }) | 46 | op_range, |
47 | |edit| { | ||
48 | edit.replace(op_range, opposite_op); | ||
49 | edit.replace(lhs_range, format!("!({}", not_lhs.syntax().text())); | ||
50 | edit.replace(rhs_range, format!("{})", not_rhs.syntax().text())); | ||
51 | }, | ||
52 | ) | ||
47 | } | 53 | } |
48 | 54 | ||
49 | // Return the opposite text for a given logical operator, if it makes sense | 55 | // Return the opposite text for a given logical operator, if it makes sense |