aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index b0e9b1f9a..24c5f412b 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -86,11 +86,7 @@ fn parse_macro(
86 macro_call_id: MacroCallId, 86 macro_call_id: MacroCallId,
87) -> Result<TreeArc<SourceFile>, String> { 87) -> Result<TreeArc<SourceFile>, String> {
88 let loc = macro_call_id.loc(db); 88 let loc = macro_call_id.loc(db);
89 let macro_call = loc.ast_id.to_node(db); 89 let macro_arg = db.macro_arg(macro_call_id).ok_or("Fail to args in to tt::TokenTree")?;
90 let (macro_arg, _) = macro_call
91 .token_tree()
92 .and_then(mbe::ast_to_token_tree)
93 .ok_or("Fail to args in to tt::TokenTree")?;
94 90
95 let macro_rules = db.macro_def(loc.def).ok_or("Fail to find macro definition")?; 91 let macro_rules = db.macro_def(loc.def).ok_or("Fail to find macro definition")?;
96 let tt = macro_rules.expand(&macro_arg).map_err(|err| format!("{:?}", err))?; 92 let tt = macro_rules.expand(&macro_arg).map_err(|err| format!("{:?}", err))?;
@@ -139,6 +135,14 @@ pub(crate) fn macro_def_query(db: &impl DefDatabase, id: MacroDefId) -> Option<A
139 Some(Arc::new(rules)) 135 Some(Arc::new(rules))
140} 136}
141 137
138pub(crate) fn macro_arg_query(db: &impl DefDatabase, id: MacroCallId) -> Option<Arc<tt::Subtree>> {
139 let loc = id.loc(db);
140 let macro_call = loc.ast_id.to_node(db);
141 let arg = macro_call.token_tree()?;
142 let (tt, _) = mbe::ast_to_token_tree(arg)?;
143 Some(Arc::new(tt))
144}
145
142macro_rules! impl_intern_key { 146macro_rules! impl_intern_key {
143 ($name:ident) => { 147 ($name:ident) => {
144 impl salsa::InternKey for $name { 148 impl salsa::InternKey for $name {