Auto merge of #14633 - Veykril:assoc-collect, r=Veykril
internal: Don't reparse files when trying to expand assoc item macro calls
This commit is contained in:
commit
6f43a56201
@ -14,6 +14,7 @@
|
|||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
expander::{Expander, Mark},
|
expander::{Expander, Mark},
|
||||||
item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, ModItem, Param, TreeId},
|
item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, ModItem, Param, TreeId},
|
||||||
|
macro_call_as_call_id, macro_id_to_def_id,
|
||||||
nameres::{
|
nameres::{
|
||||||
attr_resolution::ResolvedAttr,
|
attr_resolution::ResolvedAttr,
|
||||||
diagnostics::DefDiagnostic,
|
diagnostics::DefDiagnostic,
|
||||||
@ -639,18 +640,15 @@ fn collect(&mut self, item_tree: &ItemTree, tree_id: TreeId, assoc_items: &[Asso
|
|||||||
}
|
}
|
||||||
AssocItem::MacroCall(call) => {
|
AssocItem::MacroCall(call) => {
|
||||||
let file_id = self.expander.current_file_id();
|
let file_id = self.expander.current_file_id();
|
||||||
let root = self.db.parse_or_expand(file_id);
|
|
||||||
let call = &item_tree[call];
|
let call = &item_tree[call];
|
||||||
|
|
||||||
let ast_id_map = self.db.ast_id_map(file_id);
|
|
||||||
let macro_call = ast_id_map.get(call.ast_id).to_node(&root);
|
|
||||||
let _cx = stdx::panic_context::enter(format!(
|
|
||||||
"collect_items MacroCall: {macro_call}"
|
|
||||||
));
|
|
||||||
let module = self.expander.module.local_id;
|
let module = self.expander.module.local_id;
|
||||||
|
|
||||||
if let Ok(res) =
|
if let Ok(Some(call_id)) = macro_call_as_call_id(
|
||||||
self.expander.enter_expand::<ast::MacroItems>(self.db, macro_call, |path| {
|
self.db.upcast(),
|
||||||
|
&AstIdWithPath::new(file_id, call.ast_id, Clone::clone(&call.path)),
|
||||||
|
call.expand_to,
|
||||||
|
self.expander.module.krate(),
|
||||||
|
|path| {
|
||||||
self.def_map
|
self.def_map
|
||||||
.resolve_path(
|
.resolve_path(
|
||||||
self.db,
|
self.db,
|
||||||
@ -660,8 +658,11 @@ fn collect(&mut self, item_tree: &ItemTree, tree_id: TreeId, assoc_items: &[Asso
|
|||||||
)
|
)
|
||||||
.0
|
.0
|
||||||
.take_macros()
|
.take_macros()
|
||||||
})
|
.map(|it| macro_id_to_def_id(self.db, it))
|
||||||
{
|
},
|
||||||
|
) {
|
||||||
|
let res =
|
||||||
|
self.expander.enter_expand_id::<ast::MacroItems>(self.db, call_id);
|
||||||
self.collect_macro_items(res, &|| hir_expand::MacroCallKind::FnLike {
|
self.collect_macro_items(res, &|| hir_expand::MacroCallKind::FnLike {
|
||||||
ast_id: InFile::new(file_id, call.ast_id),
|
ast_id: InFile::new(file_id, call.ast_id),
|
||||||
expand_to: hir_expand::ExpandTo::Items,
|
expand_to: hir_expand::ExpandTo::Items,
|
||||||
|
Loading…
Reference in New Issue
Block a user