aboutsummaryrefslogtreecommitdiff
path: root/crates/assists/src/handlers/remove_mut.rs
diff options
context:
space:
mode:
authorChetan Khilosiya <[email protected]>2021-02-22 18:47:48 +0000
committerChetan Khilosiya <[email protected]>2021-02-22 19:29:16 +0000
commite4756cb4f6e66097638b9d101589358976be2ba8 (patch)
treeb6ca0ae6b45b57834476ae0f9985cec3a6bd9090 /crates/assists/src/handlers/remove_mut.rs
parent8687053b118f47ce1a4962d0baa19b22d40d2758 (diff)
7526: Rename crate assists to ide_assists.
Diffstat (limited to 'crates/assists/src/handlers/remove_mut.rs')
-rw-r--r--crates/assists/src/handlers/remove_mut.rs37
1 files changed, 0 insertions, 37 deletions
diff --git a/crates/assists/src/handlers/remove_mut.rs b/crates/assists/src/handlers/remove_mut.rs
deleted file mode 100644
index 30d36dacd..000000000
--- a/crates/assists/src/handlers/remove_mut.rs
+++ /dev/null
@@ -1,37 +0,0 @@
1use syntax::{SyntaxKind, TextRange, T};
2
3use crate::{AssistContext, AssistId, AssistKind, Assists};
4
5// Assist: remove_mut
6//
7// Removes the `mut` keyword.
8//
9// ```
10// impl Walrus {
11// fn feed(&mut$0 self, amount: u32) {}
12// }
13// ```
14// ->
15// ```
16// impl Walrus {
17// fn feed(&self, amount: u32) {}
18// }
19// ```
20pub(crate) fn remove_mut(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
21 let mut_token = ctx.find_token_syntax_at_offset(T![mut])?;
22 let delete_from = mut_token.text_range().start();
23 let delete_to = match mut_token.next_token() {
24 Some(it) if it.kind() == SyntaxKind::WHITESPACE => it.text_range().end(),
25 _ => mut_token.text_range().end(),
26 };
27
28 let target = mut_token.text_range();
29 acc.add(
30 AssistId("remove_mut", AssistKind::Refactor),
31 "Remove `mut` keyword",
32 target,
33 |builder| {
34 builder.delete(TextRange::new(delete_from, delete_to));
35 },
36 )
37}