From 309421c117fc20e58b9f30fb28a01a89f50b0086 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 24 Feb 2021 01:20:00 +0200 Subject: Draft the qualifier import resolution --- crates/ide_completion/src/completions/flyimport.rs | 84 +++++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index 16384551c..64b60bbdd 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -775,18 +775,92 @@ fn main() { } #[test] - fn unresolved_qualifiers() { + fn unresolved_qualifier() { + check_edit( + "Item", + r#" +mod foo { + pub mod bar { + pub mod baz { + pub struct Item; + } + } +} + +fn main() { + bar::baz::Ite$0 +} +"#, + r#" +use foo::bar; + +mod foo { + pub mod bar { + pub mod baz { + pub struct Item; + } + } +} + +fn main() { + bar::baz::Item +} +"#, + ); + } + + #[test] + fn unresolved_assoc_item_container() { + check_edit( + "Item", + r#" +mod foo { + pub struct Item; + + impl Item { + pub const TEST_ASSOC: usize = 3; + } +} + +fn main() { + Item::TEST_A$0; +} +"#, + r#" +use foo::Item; + +mod foo { + pub struct Item; + + impl Item { + pub const TEST_ASSOC: usize = 3; + } +} + +fn main() { + Item::TEST_ASSOC +} +"#, + ); + } + + #[test] + fn unresolved_assoc_item_container_with_path() { check_edit( "Item", r#" mod foo { pub mod bar { pub struct Item; + + impl Item { + pub const TEST_ASSOC: usize = 3; + } } } fn main() { - bar::Ite$0 + bar::Item::TEST_A$0; } "#, r#" @@ -795,11 +869,15 @@ use foo::bar; mod foo { pub mod bar { pub struct Item; + + impl Item { + pub const TEST_ASSOC: usize = 3; + } } } fn main() { - bar::Item + bar::Item::TEST_ASSOC } "#, ); -- cgit v1.2.3