diff options
author | Aleksey Kladov <[email protected]> | 2019-10-26 17:58:18 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-26 18:57:23 +0100 |
commit | 4a83aae09849123dbbbc5726b07c2601a14397a8 (patch) | |
tree | b8944447b98e8b0b25ac95d0465210312bf4cd57 /crates/ra_assists/src/assists | |
parent | 733fd64260793a0f7335e4f75ba9197d5fa98b70 (diff) |
support range selection in assist docs
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r-- | crates/ra_assists/src/assists/introduce_variable.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_assists/src/assists/introduce_variable.rs b/crates/ra_assists/src/assists/introduce_variable.rs index 43378c4b0..8245dc99f 100644 --- a/crates/ra_assists/src/assists/introduce_variable.rs +++ b/crates/ra_assists/src/assists/introduce_variable.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use format_buf::format; | 1 | use format_buf::format; |
4 | use hir::db::HirDatabase; | 2 | use hir::db::HirDatabase; |
5 | use ra_syntax::{ | 3 | use ra_syntax::{ |
@@ -14,6 +12,22 @@ use test_utils::tested_by; | |||
14 | 12 | ||
15 | use crate::{Assist, AssistCtx, AssistId}; | 13 | use crate::{Assist, AssistCtx, AssistId}; |
16 | 14 | ||
15 | // Assist: introduce_variable | ||
16 | // | ||
17 | // Extracts subexpression into a variable. | ||
18 | // | ||
19 | // ``` | ||
20 | // fn main() { | ||
21 | // <|>(1 + 2)<|> * 4; | ||
22 | // } | ||
23 | // ``` | ||
24 | // -> | ||
25 | // ``` | ||
26 | // fn main() { | ||
27 | // let var_name = (1 + 2); | ||
28 | // var_name * 4; | ||
29 | // } | ||
30 | // ``` | ||
17 | pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 31 | pub(crate) fn introduce_variable(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
18 | if ctx.frange.range.is_empty() { | 32 | if ctx.frange.range.is_empty() { |
19 | return None; | 33 | return None; |