Expand derive macros under cursor in Expand Macro Recursively

This commit is contained in:
Lukas Wirth 2021-08-24 16:33:52 +02:00
parent 6287d388c0
commit d99b81f839
7 changed files with 90 additions and 2 deletions

View file

@ -6,6 +6,7 @@
use either::Either;
use hir_expand::HirFileId;
use syntax::ast::AttrsOwner;
use crate::{
db::DefDatabase,
@ -108,6 +109,12 @@ impl ChildBySource for ItemScope {
let item = ast_id.with_value(ast_id.to_node(db.upcast()));
res[keys::ATTR_MACRO].insert(item, call_id);
});
self.derive_macro_invocs().for_each(|(ast_id, (attr_id, call_id))| {
let item = ast_id.to_node(db.upcast());
if let Some(attr) = item.attrs().nth(attr_id.ast_index as usize) {
res[keys::DERIVE_MACRO].insert(ast_id.with_value(attr), call_id);
}
});
fn add_module_def(
db: &dyn DefDatabase,