diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-27 14:38:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-27 14:38:28 +0000 |
commit | cf309b6a5f2d51e9509568ab82446cc3eae29f94 (patch) | |
tree | 54c4a26d7a6688a89515cdc97ec02c1a9f9103bf /crates/ra_assists/src/assists/introduce_variable.rs | |
parent | ad950830d0902aaacfb5a76355a203626eb93b5f (diff) | |
parent | cda6355de23825c201d02e6062cb2dd414e98bf9 (diff) |
Merge #2094
2094: simplify AssistCtx API r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists/introduce_variable.rs')
-rw-r--r-- | crates/ra_assists/src/assists/introduce_variable.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/introduce_variable.rs b/crates/ra_assists/src/assists/introduce_variable.rs index 8245dc99f..0623d4475 100644 --- a/crates/ra_assists/src/assists/introduce_variable.rs +++ b/crates/ra_assists/src/assists/introduce_variable.rs | |||
@@ -28,7 +28,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
28 | // var_name * 4; | 28 | // var_name * 4; |
29 | // } | 29 | // } |
30 | // ``` | 30 | // ``` |
31 | pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 31 | pub(crate) fn introduce_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
32 | if ctx.frange.range.is_empty() { | 32 | if ctx.frange.range.is_empty() { |
33 | return None; | 33 | return None; |
34 | } | 34 | } |
@@ -43,7 +43,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option | |||
43 | if indent.kind() != WHITESPACE { | 43 | if indent.kind() != WHITESPACE { |
44 | return None; | 44 | return None; |
45 | } | 45 | } |
46 | ctx.add_action(AssistId("introduce_variable"), "introduce variable", move |edit| { | 46 | ctx.add_assist(AssistId("introduce_variable"), "introduce variable", move |edit| { |
47 | let mut buf = String::new(); | 47 | let mut buf = String::new(); |
48 | 48 | ||
49 | let cursor_offset = if wrap_in_block { | 49 | let cursor_offset = if wrap_in_block { |
@@ -88,9 +88,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option | |||
88 | } | 88 | } |
89 | } | 89 | } |
90 | edit.set_cursor(anchor_stmt.text_range().start() + cursor_offset); | 90 | edit.set_cursor(anchor_stmt.text_range().start() + cursor_offset); |
91 | }); | 91 | }) |
92 | |||
93 | ctx.build() | ||
94 | } | 92 | } |
95 | 93 | ||
96 | /// Check whether the node is a valid expression which can be extracted to a variable. | 94 | /// Check whether the node is a valid expression which can be extracted to a variable. |