Add support for macro in symbo_index

This commit is contained in:
Edwin Cheng 2020-03-22 15:00:44 +08:00
parent 6fe956420f
commit bb22a4e386
3 changed files with 20 additions and 12 deletions

View file

@ -4,7 +4,7 @@
use itertools::Itertools;
use crate::{
ast::{self, child_opt, children, AstNode, AttrInput, SyntaxNode},
ast::{self, child_opt, children, AstNode, AttrInput, NameOwner, SyntaxNode},
SmolStr, SyntaxElement,
SyntaxKind::*,
SyntaxToken, T,
@ -514,3 +514,14 @@ impl ast::Visibility {
self.syntax().children_with_tokens().any(|it| it.kind() == T![super])
}
}
impl ast::MacroCall {
pub fn is_macro_rules(&self) -> Option<ast::Name> {
let name_ref = self.path()?.segment()?.name_ref()?;
if name_ref.text() == "macro_rules" {
self.name()
} else {
None
}
}
}