diff options
author | Aleksey Kladov <[email protected]> | 2019-10-27 14:49:39 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-10-27 14:49:39 +0000 |
commit | b6fcacd96d26e7edaf37bda852b8b3ad104d4c90 (patch) | |
tree | 97e3213d449e6237d1a20f99e9e82ede19215b20 /crates | |
parent | cda6355de23825c201d02e6062cb2dd414e98bf9 (diff) |
move all assists to use generated docs
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/assists/add_import.rs | 21 | ||||
-rw-r--r-- | crates/ra_assists/src/doc_tests/generated.rs | 15 |
2 files changed, 31 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/add_import.rs b/crates/ra_assists/src/assists/add_import.rs index c522d6a5a..e87fae1af 100644 --- a/crates/ra_assists/src/assists/add_import.rs +++ b/crates/ra_assists/src/assists/add_import.rs | |||
@@ -1,5 +1,3 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use hir::{self, db::HirDatabase}; | 1 | use hir::{self, db::HirDatabase}; |
4 | use ra_syntax::{ | 2 | use ra_syntax::{ |
5 | ast::{self, NameOwner}, | 3 | ast::{self, NameOwner}, |
@@ -14,9 +12,9 @@ use crate::{ | |||
14 | AssistId, | 12 | AssistId, |
15 | }; | 13 | }; |
16 | 14 | ||
17 | // This function produces sequence of text edits into edit | 15 | /// This function produces sequence of text edits into edit |
18 | // to import the target path in the most appropriate scope given | 16 | /// to import the target path in the most appropriate scope given |
19 | // the cursor position | 17 | /// the cursor position |
20 | pub fn auto_import_text_edit( | 18 | pub fn auto_import_text_edit( |
21 | // Ideally the position of the cursor, used to | 19 | // Ideally the position of the cursor, used to |
22 | position: &SyntaxNode, | 20 | position: &SyntaxNode, |
@@ -39,6 +37,19 @@ pub fn auto_import_text_edit( | |||
39 | } | 37 | } |
40 | } | 38 | } |
41 | 39 | ||
40 | // Assist: add_import | ||
41 | // | ||
42 | // Adds a use statement for a given fully-qualified path. | ||
43 | // | ||
44 | // ``` | ||
45 | // fn process(map: std::collections::<|>HashMap<String, String>) {} | ||
46 | // ``` | ||
47 | // -> | ||
48 | // ``` | ||
49 | // use std::collections::HashMap; | ||
50 | // | ||
51 | // fn process(map: HashMap<String, String>) {} | ||
52 | // ``` | ||
42 | pub(crate) fn add_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 53 | pub(crate) fn add_import(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
43 | let path: ast::Path = ctx.find_node_at_offset()?; | 54 | let path: ast::Path = ctx.find_node_at_offset()?; |
44 | // We don't want to mess with use statements | 55 | // We don't want to mess with use statements |
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs index ebe49aecf..1bee76f59 100644 --- a/crates/ra_assists/src/doc_tests/generated.rs +++ b/crates/ra_assists/src/doc_tests/generated.rs | |||
@@ -142,6 +142,21 @@ impl T for () { | |||
142 | } | 142 | } |
143 | 143 | ||
144 | #[test] | 144 | #[test] |
145 | fn doctest_add_import() { | ||
146 | check( | ||
147 | "add_import", | ||
148 | r#####" | ||
149 | fn process(map: std::collections::<|>HashMap<String, String>) {} | ||
150 | "#####, | ||
151 | r#####" | ||
152 | use std::collections::HashMap; | ||
153 | |||
154 | fn process(map: HashMap<String, String>) {} | ||
155 | "#####, | ||
156 | ) | ||
157 | } | ||
158 | |||
159 | #[test] | ||
145 | fn doctest_apply_demorgan() { | 160 | fn doctest_apply_demorgan() { |
146 | check( | 161 | check( |
147 | "apply_demorgan", | 162 | "apply_demorgan", |