diff options
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs.tera')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs.tera | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera index 86de7bce8..09630e427 100644 --- a/crates/libsyntax2/src/ast/generated.rs.tera +++ b/crates/libsyntax2/src/ast/generated.rs.tera | |||
@@ -3,28 +3,27 @@ use { | |||
3 | SyntaxNode, SyntaxRoot, TreeRoot, AstNode, | 3 | SyntaxNode, SyntaxRoot, TreeRoot, AstNode, |
4 | SyntaxKind::*, | 4 | SyntaxKind::*, |
5 | }; | 5 | }; |
6 | {% for node in ast %} | 6 | {% for node, methods in ast %} |
7 | {% set Name = node.kind | camel %} | ||
8 | #[derive(Debug, Clone, Copy)] | 7 | #[derive(Debug, Clone, Copy)] |
9 | pub struct {{ Name }}<R: TreeRoot = Arc<SyntaxRoot>> { | 8 | pub struct {{ node }}<R: TreeRoot = Arc<SyntaxRoot>> { |
10 | syntax: SyntaxNode<R>, | 9 | syntax: SyntaxNode<R>, |
11 | } | 10 | } |
12 | 11 | ||
13 | impl<R: TreeRoot> AstNode<R> for {{ Name }}<R> { | 12 | impl<R: TreeRoot> AstNode<R> for {{ node }}<R> { |
14 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | 13 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { |
15 | match syntax.kind() { | 14 | match syntax.kind() { |
16 | {{ node.kind }} => Some({{ Name }} { syntax }), | 15 | {{ node | upper }} => Some({{ node }} { syntax }), |
17 | _ => None, | 16 | _ => None, |
18 | } | 17 | } |
19 | } | 18 | } |
20 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | 19 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } |
21 | } | 20 | } |
22 | 21 | ||
23 | impl<R: TreeRoot> {{ Name }}<R> { | 22 | impl<R: TreeRoot> {{ node }}<R> { |
24 | {%- if node.collections -%} | 23 | {%- if methods.collections -%} |
25 | {%- for m in node.collections -%} | 24 | {%- for m in methods.collections -%} |
26 | {%- set method_name = m.0 -%} | 25 | {%- set method_name = m.0 -%} |
27 | {%- set ChildName = m.1 | camel %} | 26 | {%- set ChildName = m.1 %} |
28 | pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator<Item = {{ ChildName }}<R>> + 'a { | 27 | pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator<Item = {{ ChildName }}<R>> + 'a { |
29 | self.syntax() | 28 | self.syntax() |
30 | .children() | 29 | .children() |
@@ -33,10 +32,10 @@ impl<R: TreeRoot> {{ Name }}<R> { | |||
33 | {% endfor -%} | 32 | {% endfor -%} |
34 | {%- endif -%} | 33 | {%- endif -%} |
35 | 34 | ||
36 | {%- if node.options -%} | 35 | {%- if methods.options -%} |
37 | {%- for m in node.options -%} | 36 | {%- for m in methods.options -%} |
38 | {%- set method_name = m.0 -%} | 37 | {%- set method_name = m.0 -%} |
39 | {%- set ChildName = m.1 | camel %} | 38 | {%- set ChildName = m.1 %} |
40 | pub fn {{ method_name }}(&self) -> Option<{{ ChildName }}<R>> { | 39 | pub fn {{ method_name }}(&self) -> Option<{{ ChildName }}<R>> { |
41 | self.syntax() | 40 | self.syntax() |
42 | .children() | 41 | .children() |