Store an AstId for procedural macros

This commit is contained in:
Jonas Schievink 2021-03-18 16:11:18 +01:00
parent 3ab9b39dd4
commit c05a1a6e37
11 changed files with 47 additions and 26 deletions

View file

@ -1144,12 +1144,15 @@ impl MacroDef {
/// XXX: this parses the file
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
self.source(db)?.value.name().map(|it| it.as_name())
match self.source(db)?.value {
Either::Left(it) => it.name().map(|it| it.as_name()),
Either::Right(it) => it.name().map(|it| it.as_name()),
}
}
/// Indicate it is a proc-macro
pub fn is_proc_macro(&self) -> bool {
matches!(self.id.kind, MacroDefKind::ProcMacro(_))
matches!(self.id.kind, MacroDefKind::ProcMacro(..))
}
/// Indicate it is a derive macro