aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src/proc_macro.rs
blob: a8dee20526074a6e99df660cecb9642efbf2011d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Proc Macro Expander stub

use crate::{db::AstDatabase, LazyMacroId, MacroCallKind, MacroCallLoc};
use ra_db::CrateId;

#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
pub struct ProcMacroExpander {
    krate: CrateId,
}

impl ProcMacroExpander {
    pub fn new(krate: CrateId) -> ProcMacroExpander {
        ProcMacroExpander { krate }
    }

    pub fn expand(
        &self,
        db: &dyn AstDatabase,
        id: LazyMacroId,
        _tt: &tt::Subtree,
    ) -> Result<tt::Subtree, mbe::ExpandError> {
        let loc: MacroCallLoc = db.lookup_intern_macro(id);
        let name = match loc.kind {
            MacroCallKind::FnLike(_) => return Err(mbe::ExpandError::ConversionError),
            MacroCallKind::Attr(_, name) => name,
        };

        log::debug!("Proc-macro-expanding name = {}", name);

        // Return nothing for now
        return Ok(tt::Subtree::default());
    }
}