aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists/introduce_variable.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-10-27 14:35:37 +0000
committerAleksey Kladov <[email protected]>2019-10-27 14:35:37 +0000
commitcda6355de23825c201d02e6062cb2dd414e98bf9 (patch)
tree54c4a26d7a6688a89515cdc97ec02c1a9f9103bf /crates/ra_assists/src/assists/introduce_variable.rs
parent9e638c9f3ee68784cd93ec0458b0c92c18776f06 (diff)
simplify AssistCtx API
We never actually use ability to create multiple actions out of a single context
Diffstat (limited to 'crates/ra_assists/src/assists/introduce_variable.rs')
-rw-r--r--crates/ra_assists/src/assists/introduce_variable.rs8
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// ```
31pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 31pub(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.