aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/unqualified_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/unqualified_path.rs')
-rw-r--r--crates/ide_completion/src/completions/unqualified_path.rs31
1 files changed, 27 insertions, 4 deletions
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs
index cbac88240..c901b358b 100644
--- a/crates/ide_completion/src/completions/unqualified_path.rs
+++ b/crates/ide_completion/src/completions/unqualified_path.rs
@@ -9,14 +9,17 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
9 if !ctx.is_trivial_path { 9 if !ctx.is_trivial_path {
10 return; 10 return;
11 } 11 }
12 if ctx.is_path_disallowed() { 12 if ctx.is_path_disallowed() || ctx.expects_item() {
13 return; 13 return;
14 } 14 }
15 if ctx.expects_item() || ctx.expects_assoc_item() { 15 if ctx.expects_assoc_item() {
16 ctx.scope.process_all_names(&mut |name, def| { 16 ctx.scope.process_all_names(&mut |name, def| {
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,19 +675,39 @@ 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 )
689 } 694 }
695
696 // FIXME: The completions here currently come from `macro_in_item_position`, but they shouldn't
697 #[test]
698 fn completes_in_item_list() {
699 check(
700 r#"
701struct MyStruct {}
702macro_rules! foo {}
703mod bar {}
704
705$0
706"#,
707 expect![[r#"
708 md bar
709 ma foo!(…) macro_rules! foo
710 "#]],
711 )
712 }
690} 713}