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 29a7ce166..fae371509 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -1771,6 +1771,72 @@ impl MacroCall {
1771 } 1771 }
1772} 1772}
1773 1773
1774// MacroItems
1775#[derive(Debug, PartialEq, Eq, Hash)]
1776#[repr(transparent)]
1777pub struct MacroItems {
1778 pub(crate) syntax: SyntaxNode,
1779}
1780unsafe impl TransparentNewType for MacroItems {
1781 type Repr = rowan::SyntaxNode;
1782}
1783
1784impl AstNode for MacroItems {
1785 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1786 match syntax.kind() {
1787 MACRO_ITEMS => Some(MacroItems::from_repr(syntax.into_repr())),
1788 _ => None,
1789 }
1790 }
1791 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1792}
1793
1794impl ToOwned for MacroItems {
1795 type Owned = TreeArc<MacroItems>;
1796 fn to_owned(&self) -> TreeArc<MacroItems> { TreeArc::cast(self.syntax.to_owned()) }
1797}
1798
1799
1800impl ast::ModuleItemOwner for MacroItems {}
1801impl ast::FnDefOwner for MacroItems {}
1802impl MacroItems {}
1803
1804// MacroStmts
1805#[derive(Debug, PartialEq, Eq, Hash)]
1806#[repr(transparent)]
1807pub struct MacroStmts {
1808 pub(crate) syntax: SyntaxNode,
1809}
1810unsafe impl TransparentNewType for MacroStmts {
1811 type Repr = rowan::SyntaxNode;
1812}
1813
1814impl AstNode for MacroStmts {
1815 fn cast(syntax: &SyntaxNode) -> Option<&Self> {
1816 match syntax.kind() {
1817 MACRO_STMTS => Some(MacroStmts::from_repr(syntax.into_repr())),
1818 _ => None,
1819 }
1820 }
1821 fn syntax(&self) -> &SyntaxNode { &self.syntax }
1822}
1823
1824impl ToOwned for MacroStmts {
1825 type Owned = TreeArc<MacroStmts>;
1826 fn to_owned(&self) -> TreeArc<MacroStmts> { TreeArc::cast(self.syntax.to_owned()) }
1827}
1828
1829
1830impl MacroStmts {
1831 pub fn statements(&self) -> impl Iterator<Item = &Stmt> {
1832 super::children(self)
1833 }
1834
1835 pub fn expr(&self) -> Option<&Expr> {
1836 super::child_opt(self)
1837 }
1838}
1839
1774// MatchArm 1840// MatchArm
1775#[derive(Debug, PartialEq, Eq, Hash)] 1841#[derive(Debug, PartialEq, Eq, Hash)]
1776#[repr(transparent)] 1842#[repr(transparent)]
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index 41fe35f08..5bdcf9c84 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)