aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast/generated.rs.tera
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs.tera')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs.tera31
1 files changed, 15 insertions, 16 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera
index f83da0326..0572cceaa 100644
--- a/crates/libsyntax2/src/ast/generated.rs.tera
+++ b/crates/libsyntax2/src/ast/generated.rs.tera
@@ -1,21 +1,20 @@
1use std::sync::Arc;
2use { 1use {
3 ast, 2 ast,
4 SyntaxNode, SyntaxRoot, TreeRoot, AstNode, 3 SyntaxNodeRef, AstNode,
5 SyntaxKind::*, 4 SyntaxKind::*,
6}; 5};
7{% for node, methods in ast %} 6{% for node, methods in ast %}
8// {{ node }} 7// {{ node }}
9{%- if methods.enum %} 8{%- if methods.enum %}
10#[derive(Debug, Clone, Copy)] 9#[derive(Debug, Clone, Copy)]
11pub enum {{ node }}<R: TreeRoot = Arc<SyntaxRoot>> { 10pub enum {{ node }}<'a> {
12{%- for kind in methods.enum %} 11{%- for kind in methods.enum %}
13 {{ kind }}({{ kind }}<R>), 12 {{ kind }}({{ kind }}<'a>),
14{%- endfor %} 13{%- endfor %}
15} 14}
16 15
17impl<R: TreeRoot> AstNode<R> for {{ node }}<R> { 16impl<'a> AstNode<'a> for {{ node }}<'a> {
18 fn cast(syntax: SyntaxNode<R>) -> Option<Self> { 17 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
19 match syntax.kind() { 18 match syntax.kind() {
20{%- for kind in methods.enum %} 19{%- for kind in methods.enum %}
21 {{ kind | SCREAM }} => Some({{ node }}::{{ kind }}({{ kind }} { syntax })), 20 {{ kind | SCREAM }} => Some({{ node }}::{{ kind }}({{ kind }} { syntax })),
@@ -23,7 +22,7 @@ impl<R: TreeRoot> AstNode<R> for {{ node }}<R> {
23 _ => None, 22 _ => None,
24 } 23 }
25 } 24 }
26 fn syntax(&self) -> &SyntaxNode<R> { 25 fn syntax(self) -> SyntaxNodeRef<'a> {
27 match self { 26 match self {
28{%- for kind in methods.enum %} 27{%- for kind in methods.enum %}
29 {{ node }}::{{ kind }}(inner) => inner.syntax(), 28 {{ node }}::{{ kind }}(inner) => inner.syntax(),
@@ -33,32 +32,32 @@ impl<R: TreeRoot> AstNode<R> for {{ node }}<R> {
33} 32}
34{% else %} 33{% else %}
35#[derive(Debug, Clone, Copy)] 34#[derive(Debug, Clone, Copy)]
36pub struct {{ node }}<R: TreeRoot = Arc<SyntaxRoot>> { 35pub struct {{ node }}<'a> {
37 syntax: SyntaxNode<R>, 36 syntax: SyntaxNodeRef<'a>,
38} 37}
39 38
40impl<R: TreeRoot> AstNode<R> for {{ node }}<R> { 39impl<'a> AstNode<'a> for {{ node }}<'a> {
41 fn cast(syntax: SyntaxNode<R>) -> Option<Self> { 40 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
42 match syntax.kind() { 41 match syntax.kind() {
43 {{ node | SCREAM }} => Some({{ node }} { syntax }), 42 {{ node | SCREAM }} => Some({{ node }} { syntax }),
44 _ => None, 43 _ => None,
45 } 44 }
46 } 45 }
47 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } 46 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
48} 47}
49{% endif %} 48{% endif %}
50{% if methods.traits -%} 49{% if methods.traits -%}
51{%- for t in methods.traits -%} 50{%- for t in methods.traits -%}
52impl<R: TreeRoot> ast::{{ t }}<R> for {{ node }}<R> {} 51impl<'a> ast::{{ t }}<'a> for {{ node }}<'a> {}
53{% endfor -%} 52{% endfor -%}
54{%- endif -%} 53{%- endif -%}
55 54
56impl<R: TreeRoot> {{ node }}<R> { 55impl<'a> {{ node }}<'a> {
57{%- if methods.collections -%} 56{%- if methods.collections -%}
58{%- for m in methods.collections -%} 57{%- for m in methods.collections -%}
59{%- set method_name = m.0 -%} 58{%- set method_name = m.0 -%}
60{%- set ChildName = m.1 %} 59{%- set ChildName = m.1 %}
61 pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator<Item = {{ ChildName }}<R>> + 'a { 60 pub fn {{ method_name }}(self) -> impl Iterator<Item = {{ ChildName }}<'a>> + 'a {
62 self.syntax() 61 self.syntax()
63 .children() 62 .children()
64 .filter_map({{ ChildName }}::cast) 63 .filter_map({{ ChildName }}::cast)
@@ -70,7 +69,7 @@ impl<R: TreeRoot> {{ node }}<R> {
70{%- for m in methods.options -%} 69{%- for m in methods.options -%}
71{%- set method_name = m.0 -%} 70{%- set method_name = m.0 -%}
72{%- set ChildName = m.1 %} 71{%- set ChildName = m.1 %}
73 pub fn {{ method_name }}(&self) -> Option<{{ ChildName }}<R>> { 72 pub fn {{ method_name }}(self) -> Option<{{ ChildName }}<'a>> {
74 self.syntax() 73 self.syntax()
75 .children() 74 .children()
76 .filter_map({{ ChildName }}::cast) 75 .filter_map({{ ChildName }}::cast)