aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/assists/auto_import.rs4
-rw-r--r--crates/ra_assists/src/doc_tests.rs10
-rw-r--r--crates/ra_assists/src/doc_tests/generated.rs4
3 files changed, 8 insertions, 10 deletions
diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs
index 219051063..f16b08c43 100644
--- a/crates/ra_assists/src/assists/auto_import.rs
+++ b/crates/ra_assists/src/assists/auto_import.rs
@@ -18,14 +18,16 @@ use ra_ide_db::imports_locator::ImportsLocatorIde;
18// fn main() { 18// fn main() {
19// let map = HashMap<|>::new(); 19// let map = HashMap<|>::new();
20// } 20// }
21// # pub mod std { pub mod collections { pub struct HashMap { } } }
21// ``` 22// ```
22// -> 23// ->
23// ``` 24// ```
24// use std::collections::HashMap; 25// use std::collections::HashMap;
25// 26//
26// fn main() { 27// fn main() {
27// let map = HashMap<|>::new(); 28// let map = HashMap::new();
28// } 29// }
30// # pub mod std { pub mod collections { pub struct HashMap { } } }
29// ``` 31// ```
30pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> { 32pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
31 let path_to_import: ast::Path = ctx.find_node_at_offset()?; 33 let path_to_import: ast::Path = ctx.find_node_at_offset()?;
diff --git a/crates/ra_assists/src/doc_tests.rs b/crates/ra_assists/src/doc_tests.rs
index 370b64225..56020028c 100644
--- a/crates/ra_assists/src/doc_tests.rs
+++ b/crates/ra_assists/src/doc_tests.rs
@@ -5,18 +5,12 @@
5 5
6mod generated; 6mod generated;
7 7
8use ra_db::{fixture::WithFixture, FileRange}; 8use ra_db::FileRange;
9use test_utils::{assert_eq_text, extract_range_or_offset}; 9use test_utils::{assert_eq_text, extract_range_or_offset};
10 10
11use ra_ide_db::RootDatabase;
12
13fn check(assist_id: &str, before: &str, after: &str) { 11fn check(assist_id: &str, before: &str, after: &str) {
14 // FIXME we cannot get the imports search functionality here yet, but still need to generate a test and a doc for an assist
15 if assist_id == "auto_import" {
16 return;
17 }
18 let (selection, before) = extract_range_or_offset(before); 12 let (selection, before) = extract_range_or_offset(before);
19 let (db, file_id) = RootDatabase::with_single_file(&before); 13 let (db, file_id) = crate::helpers::with_single_file(&before);
20 let frange = FileRange { file_id, range: selection.into() }; 14 let frange = FileRange { file_id, range: selection.into() };
21 15
22 let assist = crate::assists(&db, frange) 16 let assist = crate::assists(&db, frange)
diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs
index ec4587ce7..0d95b957b 100644
--- a/crates/ra_assists/src/doc_tests/generated.rs
+++ b/crates/ra_assists/src/doc_tests/generated.rs
@@ -222,13 +222,15 @@ fn doctest_auto_import() {
222fn main() { 222fn main() {
223 let map = HashMap<|>::new(); 223 let map = HashMap<|>::new();
224} 224}
225pub mod std { pub mod collections { pub struct HashMap { } } }
225"#####, 226"#####,
226 r#####" 227 r#####"
227use std::collections::HashMap; 228use std::collections::HashMap;
228 229
229fn main() { 230fn main() {
230 let map = HashMap<|>::new(); 231 let map = HashMap::new();
231} 232}
233pub mod std { pub mod collections { pub struct HashMap { } } }
232"#####, 234"#####,
233 ) 235 )
234} 236}