Add support for macro in symbo_index
This commit is contained in:
parent
6fe956420f
commit
bb22a4e386
@ -453,7 +453,7 @@ fn collect_expr(&mut self, expr: ast::Expr) -> ExprId {
|
||||
}
|
||||
}
|
||||
ast::Expr::MacroCall(e) => {
|
||||
if let Some(name) = is_macro_rules(&e) {
|
||||
if let Some(name) = e.is_macro_rules().map(|it| it.as_name()) {
|
||||
let mac = MacroDefId {
|
||||
krate: Some(self.expander.module.krate),
|
||||
ast_id: Some(self.expander.ast_id(&e)),
|
||||
@ -697,16 +697,6 @@ fn collect_pat_opt(&mut self, pat: Option<ast::Pat>) -> PatId {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_macro_rules(m: &ast::MacroCall) -> Option<Name> {
|
||||
let name = m.path()?.segment()?.name_ref()?.as_name();
|
||||
|
||||
if name == name![macro_rules] {
|
||||
Some(m.name()?.as_name())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ast::BinOp> for BinaryOp {
|
||||
fn from(ast_op: ast::BinOp) -> Self {
|
||||
match ast_op {
|
||||
|
@ -362,6 +362,13 @@ fn decl<N: NameOwner>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> {
|
||||
ast::TypeAliasDef(it) => { decl(it) },
|
||||
ast::ConstDef(it) => { decl(it) },
|
||||
ast::StaticDef(it) => { decl(it) },
|
||||
ast::MacroCall(it) => {
|
||||
if it.is_macro_rules().is_some() {
|
||||
decl(it)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ fn is_pub_super(&self) -> bool {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user