aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs66
-rw-r--r--crates/ra_syntax/src/grammar.ron15
2 files changed, 81 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)]
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index b41241287..663e3a2f9 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -247,6 +247,10 @@ Grammar(
247 "ARG_LIST", 247 "ARG_LIST",
248 "TYPE_BOUND", 248 "TYPE_BOUND",
249 "TYPE_BOUND_LIST", 249 "TYPE_BOUND_LIST",
250
251 // macro related
252 "MACRO_ITEMS",
253 "MACRO_STMTS",
250 ], 254 ],
251 ast: { 255 ast: {
252 "SourceFile": ( 256 "SourceFile": (
@@ -668,5 +672,16 @@ Grammar(
668 "TypeArg": (options: ["TypeRef"]), 672 "TypeArg": (options: ["TypeRef"]),
669 "AssocTypeArg": (options: ["NameRef", "TypeRef"]), 673 "AssocTypeArg": (options: ["NameRef", "TypeRef"]),
670 "LifetimeArg": (), 674 "LifetimeArg": (),
675
676 "MacroItems": (
677 traits: [ "ModuleItemOwner", "FnDefOwner" ],
678 ),
679
680 "MacroStmts" : (
681 options: [ "Expr" ],
682 collections: [
683 ["statements", "Stmt"],
684 ],
685 )
671 }, 686 },
672) 687)