mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
make macro parsing a query
This commit is contained in:
parent
e4646ce0d5
commit
e231277ab2
3 changed files with 8 additions and 5 deletions
|
@ -101,7 +101,7 @@ fn parse_macro(db: &impl DefDatabase, macro_call_id: MacroCallId) -> Option<Tree
|
|||
let macro_call = ast::MacroCall::cast(&syntax).unwrap();
|
||||
let (macro_arg, _) = macro_call.token_tree().and_then(mbe::ast_to_token_tree)?;
|
||||
|
||||
let macro_rules = macro_def_query(db, loc.def)?;
|
||||
let macro_rules = db.macro_def(loc.def)?;
|
||||
let tt = macro_rules.expand(¯o_arg).ok()?;
|
||||
Some(mbe::token_tree_to_ast_item_list(&tt))
|
||||
}
|
||||
|
@ -125,11 +125,11 @@ impl From<MacroCallId> for HirFileId {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub(crate) enum MacroDefId {
|
||||
pub enum MacroDefId {
|
||||
MacroByExample { source_item_id: SourceItemId },
|
||||
}
|
||||
|
||||
fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
|
||||
pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<Arc<MacroRules>> {
|
||||
let syntax_node = match id {
|
||||
MacroDefId::MacroByExample { source_item_id } => db.file_item(source_item_id),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue