Expand attributes recursively in expand_macro

This commit is contained in:
Lukas Wirth 2021-08-21 23:24:12 +02:00
parent 9e3517f8f3
commit 2f179adc41
2 changed files with 29 additions and 8 deletions

View file

@ -278,6 +278,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
self.imp.resolve_macro_call(macro_call)
}
pub fn resolve_attr_macro_call(&self, item: &ast::Item) -> Option<MacroDef> {
self.imp.resolve_attr_macro_call(item)
}
pub fn resolve_path(&self, path: &ast::Path) -> Option<PathResolution> {
self.imp.resolve_path(path)
}
@ -634,6 +638,12 @@ impl<'db> SemanticsImpl<'db> {
sa.resolve_macro_call(self.db, macro_call)
}
fn resolve_attr_macro_call(&self, item: &ast::Item) -> Option<MacroDef> {
let item_in_file = self.find_file(item.syntax().clone()).with_value(item.clone());
let macro_call_id = self.with_ctx(|ctx| ctx.item_to_macro_call(item_in_file))?;
Some(MacroDef { id: self.db.lookup_intern_macro(macro_call_id).def })
}
fn resolve_path(&self, path: &ast::Path) -> Option<PathResolution> {
self.analyze(path.syntax()).resolve_path(self.db, path)
}