aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-18 19:47:29 +0100
committerEdwin Cheng <[email protected]>2019-04-18 19:47:29 +0100
commit3ff5440a503f090032136c37c3d44375d6107db1 (patch)
tree6da9635a94f8fe11c74eb06ceec89cf215dbe78c /crates/ra_syntax/src/ast
parent403cd78baee7e9c2410d04ca0304575e7bbab16d (diff)
Add MacroItems and MacroStmts in grammer.ron
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index 774d9bcc8..17de4f058 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1770,6 +1770,72 @@ impl MacroCall {
1770 } 1770 }
1771} 1771}
1772 1772
1773// MacroItems
1774#[derive(Debug, PartialEq, Eq, Hash)]
1775#[repr(transparent)]
1776pub struct MacroItems {
1777 pub(crate) syntax: SyntaxNode,
1778}
1779unsafe impl TransparentNewType for MacroItems {
1780 type Repr = rowan::SyntaxNode;
1781}
1782
1783impl AstNode for MacroItems {
1784 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1785 match syntax.kind() {
1786 MACRO_ITEMS => Some(MacroItems::from_repr(syntax.into_repr())),
1787 _ => None,
1788 }
1789 }
1790 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1791}
1792
1793impl ToOwned for MacroItems {
1794 type Owned = TreeArc<MacroItems>;
1795 fn to_owned(&self) -> TreeArc<MacroItems> { TreeArc::cast(self.syntax.to_owned()) }
1796}
1797
1798
1799impl ast::ModuleItemOwner for MacroItems {}
1800impl ast::FnDefOwner for MacroItems {}
1801impl MacroItems {}
1802
1803// MacroStmts
1804#[derive(Debug, PartialEq, Eq, Hash)]
1805#[repr(transparent)]
1806pub struct MacroStmts {
1807 pub(crate) syntax: SyntaxNode,
1808}
1809unsafe impl TransparentNewType for MacroStmts {
1810 type Repr = rowan::SyntaxNode;
1811}
1812
1813impl AstNode for MacroStmts {
1814 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1815 match syntax.kind() {
1816 MACRO_STMTS => Some(MacroStmts::from_repr(syntax.into_repr())),
1817 _ => None,
1818 }
1819 }
1820 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1821}
1822
1823impl ToOwned for MacroStmts {
1824 type Owned = TreeArc<MacroStmts>;
1825 fn to_owned(&self) -> TreeArc<MacroStmts> { TreeArc::cast(self.syntax.to_owned()) }
1826}
1827
1828
1829impl MacroStmts {
1830 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
1831 super::children(self)
1832 }
1833
1834 pub fn expr(&self) -> Option<&Expr> {
1835 super::child_opt(self)
1836 }
1837}
1838
1773// MatchArm 1839// MatchArm
1774#[derive(Debug, PartialEq, Eq, Hash)] 1840#[derive(Debug, PartialEq, Eq, Hash)]
1775#[repr(transparent)] 1841#[repr(transparent)]