diff options
Diffstat (limited to 'crates/ide_completion/src/completions/qualified_path.rs')
-rw-r--r-- | crates/ide_completion/src/completions/qualified_path.rs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index ed48f61af..c16bb215f 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs | |||
@@ -20,6 +20,17 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon | |||
20 | None => return, | 20 | None => return, |
21 | }; | 21 | }; |
22 | let context_module = ctx.scope.module(); | 22 | let context_module = ctx.scope.module(); |
23 | if ctx.expects_item() || ctx.expects_assoc_item() { | ||
24 | if let PathResolution::Def(hir::ModuleDef::Module(module)) = resolution { | ||
25 | let module_scope = module.scope(ctx.db, context_module); | ||
26 | for (name, def) in module_scope { | ||
27 | if let ScopeDef::MacroDef(macro_def) = def { | ||
28 | acc.add_macro(ctx, Some(name.to_string()), macro_def); | ||
29 | } | ||
30 | } | ||
31 | } | ||
32 | return; | ||
33 | } | ||
23 | 34 | ||
24 | // Add associated types on type parameters and `Self`. | 35 | // Add associated types on type parameters and `Self`. |
25 | resolution.assoc_type_shorthand_candidates(ctx.db, |_, alias| { | 36 | resolution.assoc_type_shorthand_candidates(ctx.db, |_, alias| { |
@@ -594,7 +605,7 @@ fn main() { T::$0; } | |||
594 | macro_rules! foo { () => {} } | 605 | macro_rules! foo { () => {} } |
595 | 606 | ||
596 | fn main() { let _ = crate::$0 } | 607 | fn main() { let _ = crate::$0 } |
597 | "#, | 608 | "#, |
598 | expect![[r##" | 609 | expect![[r##" |
599 | fn main() fn() | 610 | fn main() fn() |
600 | ma foo!(…) #[macro_export] macro_rules! foo | 611 | ma foo!(…) #[macro_export] macro_rules! foo |
@@ -603,6 +614,25 @@ fn main() { let _ = crate::$0 } | |||
603 | } | 614 | } |
604 | 615 | ||
605 | #[test] | 616 | #[test] |
617 | fn completes_qualified_macros_in_impl() { | ||
618 | check( | ||
619 | r#" | ||
620 | #[macro_export] | ||
621 | macro_rules! foo { () => {} } | ||
622 | |||
623 | struct MyStruct {} | ||
624 | |||
625 | impl MyStruct { | ||
626 | crate::$0 | ||
627 | } | ||
628 | "#, | ||
629 | expect![[r##" | ||
630 | ma foo! #[macro_export] macro_rules! foo | ||
631 | "##]], | ||
632 | ); | ||
633 | } | ||
634 | |||
635 | #[test] | ||
606 | fn test_super_super_completion() { | 636 | fn test_super_super_completion() { |
607 | check( | 637 | check( |
608 | r#" | 638 | r#" |