aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs
index 12e5a1c3e..c9b587ecb 100644
--- a/crates/libsyntax2/src/ast/generated.rs
+++ b/crates/libsyntax2/src/ast/generated.rs
@@ -5,6 +5,30 @@ use {
5}; 5};
6 6
7#[derive(Debug, Clone, Copy)] 7#[derive(Debug, Clone, Copy)]
8pub struct Enum<R: TreeRoot = Arc<SyntaxRoot>> {
9 syntax: SyntaxNode<R>,
10}
11
12impl<R: TreeRoot> AstNode<R> for Enum<R> {
13 fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
14 match syntax.kind() {
15 ENUM => Some(Enum { syntax }),
16 _ => None,
17 }
18 }
19 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
20}
21
22impl<R: TreeRoot> Enum<R> {
23 pub fn name(&self) -> Option<Name<R>> {
24 self.syntax()
25 .children()
26 .filter_map(Name::cast)
27 .next()
28 }
29}
30
31#[derive(Debug, Clone, Copy)]
8pub struct File<R: TreeRoot = Arc<SyntaxRoot>> { 32pub struct File<R: TreeRoot = Arc<SyntaxRoot>> {
9 syntax: SyntaxNode<R>, 33 syntax: SyntaxNode<R>,
10} 34}
@@ -68,3 +92,27 @@ impl<R: TreeRoot> AstNode<R> for Name<R> {
68 92
69impl<R: TreeRoot> Name<R> {} 93impl<R: TreeRoot> Name<R> {}
70 94
95#[derive(Debug, Clone, Copy)]
96pub struct Struct<R: TreeRoot = Arc<SyntaxRoot>> {
97 syntax: SyntaxNode<R>,
98}
99
100impl<R: TreeRoot> AstNode<R> for Struct<R> {
101 fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
102 match syntax.kind() {
103 STRUCT => Some(Struct { syntax }),
104 _ => None,
105 }
106 }
107 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
108}
109
110impl<R: TreeRoot> Struct<R> {
111 pub fn name(&self) -> Option<Name<R>> {
112 self.syntax()
113 .children()
114 .filter_map(Name::cast)
115 .next()
116 }
117}
118