aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-02-23 23:20:00 +0000
committerKirill Bulatov <[email protected]>2021-03-08 21:58:48 +0000
commit309421c117fc20e58b9f30fb28a01a89f50b0086 (patch)
tree77ab1a1a1dd426a5ffa2f817e0df49c4b804782e /crates/ide_completion
parentc395c3311dc2ac59251e86eaa6b86b597358d31f (diff)
Draft the qualifier import resolution
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/completions/flyimport.rs84
1 files changed, 81 insertions, 3 deletions
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() {
775 } 775 }
776 776
777 #[test] 777 #[test]
778 fn unresolved_qualifiers() { 778 fn unresolved_qualifier() {
779 check_edit(
780 "Item",
781 r#"
782mod foo {
783 pub mod bar {
784 pub mod baz {
785 pub struct Item;
786 }
787 }
788}
789
790fn main() {
791 bar::baz::Ite$0
792}
793"#,
794 r#"
795use foo::bar;
796
797mod foo {
798 pub mod bar {
799 pub mod baz {
800 pub struct Item;
801 }
802 }
803}
804
805fn main() {
806 bar::baz::Item
807}
808"#,
809 );
810 }
811
812 #[test]
813 fn unresolved_assoc_item_container() {
814 check_edit(
815 "Item",
816 r#"
817mod foo {
818 pub struct Item;
819
820 impl Item {
821 pub const TEST_ASSOC: usize = 3;
822 }
823}
824
825fn main() {
826 Item::TEST_A$0;
827}
828"#,
829 r#"
830use foo::Item;
831
832mod foo {
833 pub struct Item;
834
835 impl Item {
836 pub const TEST_ASSOC: usize = 3;
837 }
838}
839
840fn main() {
841 Item::TEST_ASSOC
842}
843"#,
844 );
845 }
846
847 #[test]
848 fn unresolved_assoc_item_container_with_path() {
779 check_edit( 849 check_edit(
780 "Item", 850 "Item",
781 r#" 851 r#"
782mod foo { 852mod foo {
783 pub mod bar { 853 pub mod bar {
784 pub struct Item; 854 pub struct Item;
855
856 impl Item {
857 pub const TEST_ASSOC: usize = 3;
858 }
785 } 859 }
786} 860}
787 861
788fn main() { 862fn main() {
789 bar::Ite$0 863 bar::Item::TEST_A$0;
790} 864}
791"#, 865"#,
792 r#" 866 r#"
@@ -795,11 +869,15 @@ use foo::bar;
795mod foo { 869mod foo {
796 pub mod bar { 870 pub mod bar {
797 pub struct Item; 871 pub struct Item;
872
873 impl Item {
874 pub const TEST_ASSOC: usize = 3;
875 }
798 } 876 }
799} 877}
800 878
801fn main() { 879fn main() {
802 bar::Item 880 bar::Item::TEST_ASSOC
803} 881}
804"#, 882"#,
805 ); 883 );