aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-05-27 19:53:38 +0100
committerLukas Wirth <[email protected]>2021-05-27 19:53:38 +0100
commit7ad378fec06dae4ba2417f2a109e4759bbcf75db (patch)
tree3dd623966b3aaed5b1036fa4c40d91a9ee013843 /crates/ide_completion/src/completions
parent3a16950fd919f46fd879c36423810a40105b2c10 (diff)
Complete modules in assoc item lists
Diffstat (limited to 'crates/ide_completion/src/completions')
-rw-r--r--crates/ide_completion/src/completions/qualified_path.rs8
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs9
2 files changed, 13 insertions, 4 deletions
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs
index c16bb215f..4aa37df91 100644
--- a/crates/ide_completion/src/completions/qualified_path.rs
+++ b/crates/ide_completion/src/completions/qualified_path.rs
@@ -27,6 +27,9 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
27 if let ScopeDef::MacroDef(macro_def) = def { 27 if let ScopeDef::MacroDef(macro_def) = def {
28 acc.add_macro(ctx, Some(name.to_string()), macro_def); 28 acc.add_macro(ctx, Some(name.to_string()), macro_def);
29 } 29 }
30 if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = def {
31 acc.add_resolution(ctx, name.to_string(), &def);
32 }
30 } 33 }
31 } 34 }
32 return; 35 return;
@@ -614,19 +617,20 @@ fn main() { let _ = crate::$0 }
614 } 617 }
615 618
616 #[test] 619 #[test]
617 fn completes_qualified_macros_in_impl() { 620 fn completes_in_assoc_item_list() {
618 check( 621 check(
619 r#" 622 r#"
620#[macro_export] 623#[macro_export]
621macro_rules! foo { () => {} } 624macro_rules! foo { () => {} }
625mod bar {}
622 626
623struct MyStruct {} 627struct MyStruct {}
624
625impl MyStruct { 628impl MyStruct {
626 crate::$0 629 crate::$0
627} 630}
628"#, 631"#,
629 expect![[r##" 632 expect![[r##"
633 md bar
630 ma foo! #[macro_export] macro_rules! foo 634 ma foo! #[macro_export] macro_rules! foo
631 "##]], 635 "##]],
632 ); 636 );
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index cbac88240..dc93e368d 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -17,6 +17,9 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
17 if let ScopeDef::MacroDef(macro_def) = def { 17 if let ScopeDef::MacroDef(macro_def) = def {
18 acc.add_macro(ctx, Some(name.to_string()), macro_def); 18 acc.add_macro(ctx, Some(name.to_string()), macro_def);
19 } 19 }
20 if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = def {
21 acc.add_resolution(ctx, name.to_string(), &def);
22 }
20 }); 23 });
21 return; 24 return;
22 } 25 }
@@ -672,17 +675,19 @@ impl My$0
672 } 675 }
673 676
674 #[test] 677 #[test]
675 fn only_completes_macros_in_assoc_item_list() { 678 fn completes_in_assoc_item_list() {
676 check( 679 check(
677 r#" 680 r#"
678struct MyStruct {}
679macro_rules! foo {} 681macro_rules! foo {}
682mod bar {}
680 683
684struct MyStruct {}
681impl MyStruct { 685impl MyStruct {
682 $0 686 $0
683} 687}
684"#, 688"#,
685 expect![[r#" 689 expect![[r#"
690 md bar
686 ma foo! macro_rules! foo 691 ma foo! macro_rules! foo
687 "#]], 692 "#]],
688 ) 693 )