if let ScopeDef::MacroDef(macro_def) = def {
acc.add_macro(ctx, Some(name.to_string()), macro_def);
}
+ if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = def {
+ acc.add_resolution(ctx, name.to_string(), &def);
+ }
}
}
return;
}
#[test]
- fn completes_qualified_macros_in_impl() {
+ fn completes_in_assoc_item_list() {
check(
r#"
#[macro_export]
macro_rules! foo { () => {} }
+mod bar {}
struct MyStruct {}
-
impl MyStruct {
crate::$0
}
"#,
expect![[r##"
+ md bar
ma foo! #[macro_export] macro_rules! foo
"##]],
);
if let ScopeDef::MacroDef(macro_def) = def {
acc.add_macro(ctx, Some(name.to_string()), macro_def);
}
+ if let ScopeDef::ModuleDef(hir::ModuleDef::Module(_)) = def {
+ acc.add_resolution(ctx, name.to_string(), &def);
+ }
});
return;
}
}
#[test]
- fn only_completes_macros_in_assoc_item_list() {
+ fn completes_in_assoc_item_list() {
check(
r#"
-struct MyStruct {}
macro_rules! foo {}
+mod bar {}
+struct MyStruct {}
impl MyStruct {
$0
}
"#,
expect![[r#"
+ md bar
ma foo! macro_rules! foo
"#]],
)
ast::SourceFile(_it) => ImmediateLocation::ItemList,
ast::ItemList(_it) => ImmediateLocation::ItemList,
ast::RefExpr(_it) => ImmediateLocation::RefExpr,
- ast::RefPat(_it) => ImmediateLocation::RefExpr,
ast::RecordField(_it) => ImmediateLocation::RecordField,
ast::AssocItemList(it) => match it.syntax().parent().map(|it| it.kind()) {
Some(IMPL) => ImmediateLocation::Impl,