diff options
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r-- | crates/ide_completion/src/completions/qualified_path.rs | 8 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/unqualified_path.rs | 9 | ||||
-rw-r--r-- | crates/ide_completion/src/patterns.rs | 1 |
3 files changed, 13 insertions, 5 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] |
621 | macro_rules! foo { () => {} } | 624 | macro_rules! foo { () => {} } |
625 | mod bar {} | ||
622 | 626 | ||
623 | struct MyStruct {} | 627 | struct MyStruct {} |
624 | |||
625 | impl MyStruct { | 628 | impl 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#" |
678 | struct MyStruct {} | ||
679 | macro_rules! foo {} | 681 | macro_rules! foo {} |
682 | mod bar {} | ||
680 | 683 | ||
684 | struct MyStruct {} | ||
681 | impl MyStruct { | 685 | impl 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 | ) |
diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index ed289d561..19e42ba43 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs | |||
@@ -62,7 +62,6 @@ pub(crate) fn determine_location(tok: SyntaxToken) -> Option<ImmediateLocation> | |||
62 | ast::SourceFile(_it) => ImmediateLocation::ItemList, | 62 | ast::SourceFile(_it) => ImmediateLocation::ItemList, |
63 | ast::ItemList(_it) => ImmediateLocation::ItemList, | 63 | ast::ItemList(_it) => ImmediateLocation::ItemList, |
64 | ast::RefExpr(_it) => ImmediateLocation::RefExpr, | 64 | ast::RefExpr(_it) => ImmediateLocation::RefExpr, |
65 | ast::RefPat(_it) => ImmediateLocation::RefExpr, | ||
66 | ast::RecordField(_it) => ImmediateLocation::RecordField, | 65 | ast::RecordField(_it) => ImmediateLocation::RecordField, |
67 | ast::AssocItemList(it) => match it.syntax().parent().map(|it| it.kind()) { | 66 | ast::AssocItemList(it) => match it.syntax().parent().map(|it| it.kind()) { |
68 | Some(IMPL) => ImmediateLocation::Impl, | 67 | Some(IMPL) => ImmediateLocation::Impl, |