mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Add MacroDefKind
This commit is contained in:
parent
c4aa8b63bc
commit
4f7df2aac1
6 changed files with 31 additions and 53 deletions
|
@ -78,15 +78,9 @@ impl HirFileId {
|
|||
HirFileIdRepr::MacroFile(macro_file) => {
|
||||
let loc: MacroCallLoc = db.lookup_intern_macro(macro_file.macro_call_id);
|
||||
|
||||
// FIXME: Do we support expansion information in builtin macro?
|
||||
let macro_decl = match loc.def {
|
||||
MacroDefId::DeclarativeMacro(it) => (it),
|
||||
MacroDefId::BuiltinMacro(_) => return None,
|
||||
};
|
||||
|
||||
let arg_start = loc.ast_id.to_node(db).token_tree()?.syntax().text_range().start();
|
||||
let def_start =
|
||||
macro_decl.ast_id.to_node(db).token_tree()?.syntax().text_range().start();
|
||||
loc.def.ast_id.to_node(db).token_tree()?.syntax().text_range().start();
|
||||
|
||||
let macro_def = db.macro_def(loc.def)?;
|
||||
let shift = macro_def.0.shift();
|
||||
|
@ -94,7 +88,7 @@ impl HirFileId {
|
|||
let macro_arg = db.macro_arg(macro_file.macro_call_id)?;
|
||||
|
||||
let arg_start = (loc.ast_id.file_id, arg_start);
|
||||
let def_start = (macro_decl.ast_id.file_id, def_start);
|
||||
let def_start = (loc.def.ast_id.file_id, def_start);
|
||||
|
||||
Some(ExpansionInfo { arg_start, def_start, macro_arg, macro_def, exp_map, shift })
|
||||
}
|
||||
|
@ -128,22 +122,16 @@ impl salsa::InternKey for MacroCallId {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum MacroDefId {
|
||||
DeclarativeMacro(DeclarativeMacro),
|
||||
BuiltinMacro(BuiltinMacro),
|
||||
pub struct MacroDefId {
|
||||
pub krate: CrateId,
|
||||
pub ast_id: AstId<ast::MacroCall>,
|
||||
pub kind: MacroDefKind,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct DeclarativeMacro {
|
||||
pub krate: CrateId,
|
||||
pub ast_id: AstId<ast::MacroCall>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct BuiltinMacro {
|
||||
pub krate: CrateId,
|
||||
pub ast_id: AstId<ast::MacroCall>,
|
||||
pub expander: BuiltinExpander,
|
||||
pub enum MacroDefKind {
|
||||
Declarative,
|
||||
BuiltIn(BuiltinExpander),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue