aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src/proc_macro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_expand/src/proc_macro.rs')
-rw-r--r--crates/ra_hir_expand/src/proc_macro.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/ra_hir_expand/src/proc_macro.rs b/crates/ra_hir_expand/src/proc_macro.rs
new file mode 100644
index 000000000..a8dee2052
--- /dev/null
+++ b/crates/ra_hir_expand/src/proc_macro.rs
@@ -0,0 +1,33 @@
1//! Proc Macro Expander stub
2
3use crate::{db::AstDatabase, LazyMacroId, MacroCallKind, MacroCallLoc};
4use ra_db::CrateId;
5
6#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
7pub struct ProcMacroExpander {
8 krate: CrateId,
9}
10
11impl ProcMacroExpander {
12 pub fn new(krate: CrateId) -> ProcMacroExpander {
13 ProcMacroExpander { krate }
14 }
15
16 pub fn expand(
17 &self,
18 db: &dyn AstDatabase,
19 id: LazyMacroId,
20 _tt: &tt::Subtree,
21 ) -> Result<tt::Subtree, mbe::ExpandError> {
22 let loc: MacroCallLoc = db.lookup_intern_macro(id);
23 let name = match loc.kind {
24 MacroCallKind::FnLike(_) => return Err(mbe::ExpandError::ConversionError),
25 MacroCallKind::Attr(_, name) => name,
26 };
27
28 log::debug!("Proc-macro-expanding name = {}", name);
29
30 // Return nothing for now
31 return Ok(tt::Subtree::default());
32 }
33}