diff options
author | Andrea Pretto <[email protected]> | 2019-02-11 17:07:21 +0000 |
---|---|---|
committer | Andrea Pretto <[email protected]> | 2019-02-11 17:07:21 +0000 |
commit | 5c9c0d3ae2735b4b32a44742bac800ca616fdde8 (patch) | |
tree | 8ad5dc9a548915729bcc87085a1a145d4ba2a00a /crates/ra_assists/src/introduce_variable.rs | |
parent | af62fde57fe58f4aa06608568dc26535731800a0 (diff) |
ra_assists: assist "providers" can produce multiple assists
Diffstat (limited to 'crates/ra_assists/src/introduce_variable.rs')
-rw-r--r-- | crates/ra_assists/src/introduce_variable.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_assists/src/introduce_variable.rs b/crates/ra_assists/src/introduce_variable.rs index 954b97b05..f0e012105 100644 --- a/crates/ra_assists/src/introduce_variable.rs +++ b/crates/ra_assists/src/introduce_variable.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::{ | |||
8 | 8 | ||
9 | use crate::{AssistCtx, Assist}; | 9 | use crate::{AssistCtx, Assist}; |
10 | 10 | ||
11 | pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 11 | pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
12 | let node = ctx.covering_node(); | 12 | let node = ctx.covering_node(); |
13 | if !valid_covering_node(node) { | 13 | if !valid_covering_node(node) { |
14 | return None; | 14 | return None; |
@@ -19,7 +19,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Ass | |||
19 | if indent.kind() != WHITESPACE { | 19 | if indent.kind() != WHITESPACE { |
20 | return None; | 20 | return None; |
21 | } | 21 | } |
22 | ctx.build("introduce variable", move |edit| { | 22 | ctx.add_action("introduce variable", move |edit| { |
23 | let mut buf = String::new(); | 23 | let mut buf = String::new(); |
24 | 24 | ||
25 | let cursor_offset = if wrap_in_block { | 25 | let cursor_offset = if wrap_in_block { |
@@ -68,7 +68,9 @@ pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Ass | |||
68 | } | 68 | } |
69 | } | 69 | } |
70 | edit.set_cursor(anchor_stmt.range().start() + cursor_offset); | 70 | edit.set_cursor(anchor_stmt.range().start() + cursor_offset); |
71 | }) | 71 | }); |
72 | |||
73 | ctx.build() | ||
72 | } | 74 | } |
73 | 75 | ||
74 | fn valid_covering_node(node: &SyntaxNode) -> bool { | 76 | fn valid_covering_node(node: &SyntaxNode) -> bool { |