diff options
Diffstat (limited to 'crates/ide_assists/src/handlers')
-rw-r--r-- | crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs (renamed from crates/ide_assists/src/handlers/convert_for_to_iter_for_each.rs) | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ide_assists/src/handlers/convert_for_to_iter_for_each.rs b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs index 011df1c18..27da28bc0 100644 --- a/crates/ide_assists/src/handlers/convert_for_to_iter_for_each.rs +++ b/crates/ide_assists/src/handlers/replace_for_loop_with_for_each.rs | |||
@@ -7,7 +7,7 @@ use test_utils::mark; | |||
7 | 7 | ||
8 | use crate::{AssistContext, AssistId, AssistKind, Assists}; | 8 | use crate::{AssistContext, AssistId, AssistKind, Assists}; |
9 | 9 | ||
10 | // Assist: convert_for_to_iter_for_each | 10 | // Assist: replace_for_loop_with_for_each |
11 | // | 11 | // |
12 | // Converts a for loop into a for_each loop on the Iterator. | 12 | // Converts a for loop into a for_each loop on the Iterator. |
13 | // | 13 | // |
@@ -28,7 +28,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; | |||
28 | // }); | 28 | // }); |
29 | // } | 29 | // } |
30 | // ``` | 30 | // ``` |
31 | pub(crate) fn convert_for_to_iter_for_each(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 31 | pub(crate) fn replace_for_loop_with_for_each(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
32 | let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?; | 32 | let for_loop = ctx.find_node_at_offset::<ast::ForExpr>()?; |
33 | let iterable = for_loop.iterable()?; | 33 | let iterable = for_loop.iterable()?; |
34 | let pat = for_loop.pat()?; | 34 | let pat = for_loop.pat()?; |
@@ -39,8 +39,8 @@ pub(crate) fn convert_for_to_iter_for_each(acc: &mut Assists, ctx: &AssistContex | |||
39 | } | 39 | } |
40 | 40 | ||
41 | acc.add( | 41 | acc.add( |
42 | AssistId("convert_for_to_iter_for_each", AssistKind::RefactorRewrite), | 42 | AssistId("replace_for_loop_with_for_each", AssistKind::RefactorRewrite), |
43 | "Convert a for loop into an Iterator::for_each", | 43 | "Replace this for loop with `Iterator::for_each`", |
44 | for_loop.syntax().text_range(), | 44 | for_loop.syntax().text_range(), |
45 | |builder| { | 45 | |builder| { |
46 | let mut buf = String::new(); | 46 | let mut buf = String::new(); |
@@ -150,13 +150,13 @@ pub struct NoIterMethod; | |||
150 | FamousDefs::FIXTURE, | 150 | FamousDefs::FIXTURE, |
151 | EMPTY_ITER_FIXTURE | 151 | EMPTY_ITER_FIXTURE |
152 | ); | 152 | ); |
153 | check_assist(convert_for_to_iter_for_each, before, after); | 153 | check_assist(replace_for_loop_with_for_each, before, after); |
154 | } | 154 | } |
155 | 155 | ||
156 | #[test] | 156 | #[test] |
157 | fn test_not_for() { | 157 | fn test_not_for() { |
158 | check_assist_not_applicable( | 158 | check_assist_not_applicable( |
159 | convert_for_to_iter_for_each, | 159 | replace_for_loop_with_for_each, |
160 | r" | 160 | r" |
161 | let mut x = vec![1, 2, 3]; | 161 | let mut x = vec![1, 2, 3]; |
162 | x.iter_mut().$0for_each(|v| *v *= 2); | 162 | x.iter_mut().$0for_each(|v| *v *= 2); |
@@ -167,7 +167,7 @@ x.iter_mut().$0for_each(|v| *v *= 2); | |||
167 | #[test] | 167 | #[test] |
168 | fn test_simple_for() { | 168 | fn test_simple_for() { |
169 | check_assist( | 169 | check_assist( |
170 | convert_for_to_iter_for_each, | 170 | replace_for_loop_with_for_each, |
171 | r" | 171 | r" |
172 | fn main() { | 172 | fn main() { |
173 | let x = vec![1, 2, 3]; | 173 | let x = vec![1, 2, 3]; |
@@ -189,7 +189,7 @@ fn main() { | |||
189 | fn not_available_in_body() { | 189 | fn not_available_in_body() { |
190 | mark::check!(not_available_in_body); | 190 | mark::check!(not_available_in_body); |
191 | check_assist_not_applicable( | 191 | check_assist_not_applicable( |
192 | convert_for_to_iter_for_each, | 192 | replace_for_loop_with_for_each, |
193 | r" | 193 | r" |
194 | fn main() { | 194 | fn main() { |
195 | let x = vec![1, 2, 3]; | 195 | let x = vec![1, 2, 3]; |
@@ -275,7 +275,7 @@ fn main() { | |||
275 | #[test] | 275 | #[test] |
276 | fn test_for_borrowed_mut_behind_var() { | 276 | fn test_for_borrowed_mut_behind_var() { |
277 | check_assist( | 277 | check_assist( |
278 | convert_for_to_iter_for_each, | 278 | replace_for_loop_with_for_each, |
279 | r" | 279 | r" |
280 | fn main() { | 280 | fn main() { |
281 | let x = vec![1, 2, 3]; | 281 | let x = vec![1, 2, 3]; |