diff options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs | 46 | ||||
-rw-r--r-- | crates/ra_assists/src/tests/generated.rs | 25 |
2 files changed, 48 insertions, 23 deletions
diff --git a/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs b/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs index 8d8f7833f..7101d9aaf 100644 --- a/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs +++ b/crates/ra_assists/src/handlers/change_lifetime_anon_to_named.rs | |||
@@ -2,29 +2,29 @@ use crate::{AssistContext, AssistId, Assists}; | |||
2 | use ra_syntax::{ast, ast::TypeParamsOwner, AstNode, SyntaxKind}; | 2 | use ra_syntax::{ast, ast::TypeParamsOwner, AstNode, SyntaxKind}; |
3 | use std::collections::HashSet; | 3 | use std::collections::HashSet; |
4 | 4 | ||
5 | /// Assist: change_lifetime_anon_to_named | 5 | // Assist: change_lifetime_anon_to_named |
6 | /// | 6 | // |
7 | /// Change an anonymous lifetime to a named lifetime. | 7 | // Change an anonymous lifetime to a named lifetime. |
8 | /// | 8 | // |
9 | /// ``` | 9 | // ``` |
10 | /// impl Cursor<'_<|>> { | 10 | // impl Cursor<'_<|>> { |
11 | /// fn node(self) -> &SyntaxNode { | 11 | // fn node(self) -> &SyntaxNode { |
12 | /// match self { | 12 | // match self { |
13 | /// Cursor::Replace(node) | Cursor::Before(node) => node, | 13 | // Cursor::Replace(node) | Cursor::Before(node) => node, |
14 | /// } | 14 | // } |
15 | /// } | 15 | // } |
16 | /// } | 16 | // } |
17 | /// ``` | 17 | // ``` |
18 | /// -> | 18 | // -> |
19 | /// ``` | 19 | // ``` |
20 | /// impl<'a> Cursor<'a> { | 20 | // impl<'a> Cursor<'a> { |
21 | /// fn node(self) -> &SyntaxNode { | 21 | // fn node(self) -> &SyntaxNode { |
22 | /// match self { | 22 | // match self { |
23 | /// Cursor::Replace(node) | Cursor::Before(node) => node, | 23 | // Cursor::Replace(node) | Cursor::Before(node) => node, |
24 | /// } | 24 | // } |
25 | /// } | 25 | // } |
26 | /// } | 26 | // } |
27 | /// ``` | 27 | // ``` |
28 | // FIXME: How can we handle renaming any one of multiple anonymous lifetimes? | 28 | // FIXME: How can we handle renaming any one of multiple anonymous lifetimes? |
29 | pub(crate) fn change_lifetime_anon_to_named(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 29 | pub(crate) fn change_lifetime_anon_to_named(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
30 | let lifetime_token = ctx.find_token_at_offset(SyntaxKind::LIFETIME)?; | 30 | let lifetime_token = ctx.find_token_at_offset(SyntaxKind::LIFETIME)?; |
diff --git a/crates/ra_assists/src/tests/generated.rs b/crates/ra_assists/src/tests/generated.rs index 250e56a69..abffbf97c 100644 --- a/crates/ra_assists/src/tests/generated.rs +++ b/crates/ra_assists/src/tests/generated.rs | |||
@@ -269,6 +269,31 @@ pub mod std { pub mod collections { pub struct HashMap { } } } | |||
269 | } | 269 | } |
270 | 270 | ||
271 | #[test] | 271 | #[test] |
272 | fn doctest_change_lifetime_anon_to_named() { | ||
273 | check_doc_test( | ||
274 | "change_lifetime_anon_to_named", | ||
275 | r#####" | ||
276 | impl Cursor<'_<|>> { | ||
277 | fn node(self) -> &SyntaxNode { | ||
278 | match self { | ||
279 | Cursor::Replace(node) | Cursor::Before(node) => node, | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | "#####, | ||
284 | r#####" | ||
285 | impl<'a> Cursor<'a> { | ||
286 | fn node(self) -> &SyntaxNode { | ||
287 | match self { | ||
288 | Cursor::Replace(node) | Cursor::Before(node) => node, | ||
289 | } | ||
290 | } | ||
291 | } | ||
292 | "#####, | ||
293 | ) | ||
294 | } | ||
295 | |||
296 | #[test] | ||
272 | fn doctest_change_return_type_to_result() { | 297 | fn doctest_change_return_type_to_result() { |
273 | check_doc_test( | 298 | check_doc_test( |
274 | "change_return_type_to_result", | 299 | "change_return_type_to_result", |