From 072028e67996162f5a9da14cfd59ed64de5e8729 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Dec 2018 13:27:30 +0300 Subject: add macro-call node --- crates/ra_syntax/src/ast/generated.rs | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'crates/ra_syntax/src/ast') diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index c22e026cf..b0d2c3e20 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs @@ -1838,6 +1838,47 @@ impl> LoopExprNode { impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} impl<'a> LoopExpr<'a> {} +// MacroCall +#[derive(Debug, Clone, Copy,)] +pub struct MacroCallNode = OwnedRoot> { + pub(crate) syntax: SyntaxNode, +} +pub type MacroCall<'a> = MacroCallNode>; + +impl, R2: TreeRoot> PartialEq> for MacroCallNode { + fn eq(&self, other: &MacroCallNode) -> bool { self.syntax == other.syntax } +} +impl> Eq for MacroCallNode {} +impl> Hash for MacroCallNode { + fn hash(&self, state: &mut H) { self.syntax.hash(state) } +} + +impl<'a> AstNode<'a> for MacroCall<'a> { + fn cast(syntax: SyntaxNodeRef<'a>) -> Option { + match syntax.kind() { + MACRO_CALL => Some(MacroCall { syntax }), + _ => None, + } + } + fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } +} + +impl> MacroCallNode { + pub fn borrowed(&self) -> MacroCall { + MacroCallNode { syntax: self.syntax.borrowed() } + } + pub fn owned(&self) -> MacroCallNode { + MacroCallNode { syntax: self.syntax.owned() } + } +} + + +impl<'a> MacroCall<'a> { + pub fn token_tree(self) -> Option> { + super::child_opt(self) + } +} + // MatchArm #[derive(Debug, Clone, Copy,)] pub struct MatchArmNode = OwnedRoot> { -- cgit v1.2.3