mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Handle ast::MacroCall in classify_name and impl FromSource for MacroDef
Fixes #2260
This commit is contained in:
parent
920848940a
commit
60fd260e7f
2 changed files with 32 additions and 5 deletions
|
@ -21,7 +21,6 @@ pub(crate) fn classify_name(
|
|||
let parent = name.syntax().parent()?;
|
||||
let file_id = file_id.into();
|
||||
|
||||
// FIXME: add ast::MacroCall(it)
|
||||
match_ast! {
|
||||
match parent {
|
||||
ast::BindPat(it) => {
|
||||
|
@ -104,6 +103,19 @@ pub(crate) fn classify_name(
|
|||
Some(from_module_def(db, def.into(), None))
|
||||
}
|
||||
},
|
||||
ast::MacroCall(it) => {
|
||||
let src = hir::Source { file_id, ast: it};
|
||||
let def = hir::MacroDef::from_source(db, src.clone())?;
|
||||
|
||||
let module_src = ModuleSource::from_child_node(db, src.as_ref().map(|it| it.syntax()));
|
||||
let module = Module::from_definition(db, Source::new(file_id, module_src))?;
|
||||
|
||||
Some(NameDefinition {
|
||||
visibility: None,
|
||||
container: module,
|
||||
kind: NameKind::Macro(def),
|
||||
})
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue