mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Complete modules in assoc item lists
This commit is contained in:
parent
3a16950fd9
commit
7ad378fec0
3 changed files with 13 additions and 5 deletions
|
@ -27,6 +27,9 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon
|
|||
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;
|
||||
|
@ -614,19 +617,20 @@ fn main() { let _ = crate::$0 }
|
|||
}
|
||||
|
||||
#[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
|
||||
"##]],
|
||||
);
|
||||
|
|
|
@ -17,6 +17,9 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
|
|||
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;
|
||||
}
|
||||
|
@ -672,17 +675,19 @@ impl My$0
|
|||
}
|
||||
|
||||
#[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
|
||||
"#]],
|
||||
)
|
||||
|
|
|
@ -62,7 +62,6 @@ pub(crate) fn determine_location(tok: SyntaxToken) -> Option<ImmediateLocation>
|
|||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue