diff options
author | Aleksey Kladov <[email protected]> | 2020-07-18 13:48:28 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-18 13:48:28 +0100 |
commit | a28aa175d43d9f2db3e18cc83005601cf8a26c8d (patch) | |
tree | f4b3545ea041829809e65b026ac034d726d0783f /crates/ra_assists/src/handlers | |
parent | 2777f8c2950f3d204b7ecbf40785fe8fc3523fc1 (diff) |
Add turbo-fish works after `()`
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r-- | crates/ra_assists/src/handlers/add_turbo_fish.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/crates/ra_assists/src/handlers/add_turbo_fish.rs b/crates/ra_assists/src/handlers/add_turbo_fish.rs index f7e1a7b05..0c565e89a 100644 --- a/crates/ra_assists/src/handlers/add_turbo_fish.rs +++ b/crates/ra_assists/src/handlers/add_turbo_fish.rs | |||
@@ -25,7 +25,14 @@ use crate::{ | |||
25 | // } | 25 | // } |
26 | // ``` | 26 | // ``` |
27 | pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 27 | pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
28 | let ident = ctx.find_token_at_offset(SyntaxKind::IDENT)?; | 28 | let ident = ctx.find_token_at_offset(SyntaxKind::IDENT).or_else(|| { |
29 | let arg_list = ctx.find_node_at_offset::<ast::ArgList>()?; | ||
30 | if arg_list.args().count() > 0 { | ||
31 | return None; | ||
32 | } | ||
33 | mark::hit!(add_turbo_fish_after_call); | ||
34 | arg_list.l_paren_token()?.prev_token().filter(|it| it.kind() == SyntaxKind::IDENT) | ||
35 | })?; | ||
29 | let next_token = ident.next_token()?; | 36 | let next_token = ident.next_token()?; |
30 | if next_token.kind() == T![::] { | 37 | if next_token.kind() == T![::] { |
31 | mark::hit!(add_turbo_fish_one_fish_is_enough); | 38 | mark::hit!(add_turbo_fish_one_fish_is_enough); |
@@ -83,6 +90,26 @@ fn main() { | |||
83 | } | 90 | } |
84 | 91 | ||
85 | #[test] | 92 | #[test] |
93 | fn add_turbo_fish_after_call() { | ||
94 | mark::check!(add_turbo_fish_after_call); | ||
95 | check_assist( | ||
96 | add_turbo_fish, | ||
97 | r#" | ||
98 | fn make<T>() -> T {} | ||
99 | fn main() { | ||
100 | make()<|>; | ||
101 | } | ||
102 | "#, | ||
103 | r#" | ||
104 | fn make<T>() -> T {} | ||
105 | fn main() { | ||
106 | make::<${0:_}>(); | ||
107 | } | ||
108 | "#, | ||
109 | ); | ||
110 | } | ||
111 | |||
112 | #[test] | ||
86 | fn add_turbo_fish_method() { | 113 | fn add_turbo_fish_method() { |
87 | check_assist( | 114 | check_assist( |
88 | add_turbo_fish, | 115 | add_turbo_fish, |