rust-analyzer/crates/ra_hir_expand/src/proc_macro.rs

34 lines
907 B
Rust
Raw Normal View History

2020-03-18 09:47:59 +00:00
//! 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,
};
2020-03-23 19:31:53 +00:00
log::debug!("Proc-macro-expanding name = {}", name);
2020-03-18 09:47:59 +00:00
2020-03-23 19:31:53 +00:00
// Return nothing for now
return Ok(tt::Subtree::default());
2020-03-18 09:47:59 +00:00
}
}