aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r--crates/ra_hir_expand/src/ast_id_map.rs2
-rw-r--r--crates/ra_hir_expand/src/proc_macro.rs29
2 files changed, 14 insertions, 17 deletions
diff --git a/crates/ra_hir_expand/src/ast_id_map.rs b/crates/ra_hir_expand/src/ast_id_map.rs
index a6644d55f..5643ecdce 100644
--- a/crates/ra_hir_expand/src/ast_id_map.rs
+++ b/crates/ra_hir_expand/src/ast_id_map.rs
@@ -68,8 +68,6 @@ impl AstIdMap {
68 bfs(node, |it| { 68 bfs(node, |it| {
69 if let Some(module_item) = ast::ModuleItem::cast(it.clone()) { 69 if let Some(module_item) = ast::ModuleItem::cast(it.clone()) {
70 res.alloc(module_item.syntax()); 70 res.alloc(module_item.syntax());
71 } else if let Some(macro_call) = ast::MacroCall::cast(it) {
72 res.alloc(macro_call.syntax());
73 } 71 }
74 }); 72 });
75 res 73 res
diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs
index a8dee2052..4d270e0de 100644
--- a/crates/ra_hir_expand/src/proc_macro.rs
+++ b/crates/ra_hir_expand/src/proc_macro.rs
@@ -1,33 +1,32 @@
1//! Proc Macro Expander stub 1//! Proc Macro Expander stub
2 2
3use crate::{db::AstDatabase, LazyMacroId, MacroCallKind, MacroCallLoc}; 3use crate::{db::AstDatabase, LazyMacroId};
4use ra_db::CrateId; 4use ra_db::{CrateId, ProcMacroId};
5 5
6#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] 6#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
7pub struct ProcMacroExpander { 7pub struct ProcMacroExpander {
8 krate: CrateId, 8 krate: CrateId,
9 proc_macro_id: ProcMacroId,
9} 10}
10 11
11impl ProcMacroExpander { 12impl ProcMacroExpander {
12 pub fn new(krate: CrateId) -> ProcMacroExpander { 13 pub fn new(krate: CrateId, proc_macro_id: ProcMacroId) -> ProcMacroExpander {
13 ProcMacroExpander { krate } 14 ProcMacroExpander { krate, proc_macro_id }
14 } 15 }
15 16
16 pub fn expand( 17 pub fn expand(
17 &self, 18 &self,
18 db: &dyn AstDatabase, 19 db: &dyn AstDatabase,
19 id: LazyMacroId, 20 _id: LazyMacroId,
20 _tt: &tt::Subtree, 21 tt: &tt::Subtree,
21 ) -> Result<tt::Subtree, mbe::ExpandError> { 22 ) -> Result<tt::Subtree, mbe::ExpandError> {
22 let loc: MacroCallLoc = db.lookup_intern_macro(id); 23 let krate_graph = db.crate_graph();
23 let name = match loc.kind { 24 let proc_macro = krate_graph[self.krate]
24 MacroCallKind::FnLike(_) => return Err(mbe::ExpandError::ConversionError), 25 .proc_macro
25 MacroCallKind::Attr(_, name) => name, 26 .get(self.proc_macro_id.0 as usize)
26 }; 27 .clone()
28 .ok_or_else(|| mbe::ExpandError::ConversionError)?;
27 29
28 log::debug!("Proc-macro-expanding name = {}", name); 30 proc_macro.expander.expand(&tt, None).map_err(mbe::ExpandError::from)
29
30 // Return nothing for now
31 return Ok(tt::Subtree::default());
32 } 31 }
33} 32}