From 316795e074dff8f627f8c70c85d236420ecfb3a6 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 24 Dec 2019 02:19:09 +0200 Subject: Initial auto import action implementation --- crates/ra_assists/src/doc_tests/generated.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/ra_assists/src/doc_tests') diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs index 7d84dc8fb..ec4587ce7 100644 --- a/crates/ra_assists/src/doc_tests/generated.rs +++ b/crates/ra_assists/src/doc_tests/generated.rs @@ -214,6 +214,25 @@ fn main() { ) } +#[test] +fn doctest_auto_import() { + check( + "auto_import", + r#####" +fn main() { + let map = HashMap<|>::new(); +} +"#####, + r#####" +use std::collections::HashMap; + +fn main() { + let map = HashMap<|>::new(); +} +"#####, + ) +} + #[test] fn doctest_change_visibility() { check( -- cgit v1.2.3 From 755077e3720bd97e1e506bf8fbe0a2534389f282 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Feb 2020 18:10:25 +0100 Subject: Doctest autoimport --- crates/ra_assists/src/doc_tests/generated.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_assists/src/doc_tests') 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() { fn main() { let map = HashMap<|>::new(); } +pub mod std { pub mod collections { pub struct HashMap { } } } "#####, r#####" use std::collections::HashMap; fn main() { - let map = HashMap<|>::new(); + let map = HashMap::new(); } +pub mod std { pub mod collections { pub struct HashMap { } } } "#####, ) } -- cgit v1.2.3 From 740a26b7d26a68cc46becda3cca39091e8da67fc Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 7 Feb 2020 23:35:34 +0200 Subject: Rename add import assist --- crates/ra_assists/src/doc_tests/generated.rs | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'crates/ra_assists/src/doc_tests') diff --git a/crates/ra_assists/src/doc_tests/generated.rs b/crates/ra_assists/src/doc_tests/generated.rs index 0d95b957b..4ab09b167 100644 --- a/crates/ra_assists/src/doc_tests/generated.rs +++ b/crates/ra_assists/src/doc_tests/generated.rs @@ -1,4 +1,4 @@ -//! Generated file, do not edit by hand, see `crate/ra_tools/src/codegen` +//! Generated file, do not edit by hand, see `xtask/src/codegen` use super::check; @@ -160,21 +160,6 @@ impl Trait for () { ) } -#[test] -fn doctest_add_import() { - check( - "add_import", - r#####" -fn process(map: std::collections::<|>HashMap) {} -"#####, - r#####" -use std::collections::HashMap; - -fn process(map: HashMap) {} -"#####, - ) -} - #[test] fn doctest_add_new() { check( @@ -591,6 +576,21 @@ fn handle(action: Action) { ) } +#[test] +fn doctest_replace_qualified_name_with_use() { + check( + "replace_qualified_name_with_use", + r#####" +fn process(map: std::collections::<|>HashMap) {} +"#####, + r#####" +use std::collections::HashMap; + +fn process(map: HashMap) {} +"#####, + ) +} + #[test] fn doctest_split_import() { check( -- cgit v1.2.3