aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/generated.rs.tera
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-16 10:54:24 +0100
committerAleksey Kladov <[email protected]>2018-09-16 11:07:39 +0100
commitb5021411a84822cb3f1e3aeffad9550dd15bdeb6 (patch)
tree9dca564f8e51b298dced01c4ce669c756dce3142 /crates/ra_syntax/src/ast/generated.rs.tera
parentba0bfeee12e19da40b5eabc8d0408639af10e96f (diff)
rename all things
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs.tera83
1 files changed, 83 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera
new file mode 100644
index 000000000..a72e9b732
--- /dev/null
+++ b/crates/ra_syntax/src/ast/generated.rs.tera
@@ -0,0 +1,83 @@
1use {
2 ast,
3 SyntaxNodeRef, AstNode,
4 SyntaxKind::*,
5};
6{% for node, methods in ast %}
7// {{ node }}
8{%- if methods.enum %}
9#[derive(Debug, Clone, Copy)]
10pub enum {{ node }}<'a> {
11{%- for kind in methods.enum %}
12 {{ kind }}({{ kind }}<'a>),
13{%- endfor %}
14}
15
16impl<'a> AstNode<'a> for {{ node }}<'a> {
17 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
18 match syntax.kind() {
19{%- for kind in methods.enum %}
20 {{ kind | SCREAM }} => Some({{ node }}::{{ kind }}({{ kind }} { syntax })),
21{%- endfor %}
22 _ => None,
23 }
24 }
25 fn syntax(self) -> SyntaxNodeRef<'a> {
26 match self {
27{%- for kind in methods.enum %}
28 {{ node }}::{{ kind }}(inner) => inner.syntax(),
29{%- endfor %}
30 }
31 }
32}
33{% else %}
34#[derive(Debug, Clone, Copy)]
35pub struct {{ node }}<'a> {
36 syntax: SyntaxNodeRef<'a>,
37}
38
39impl<'a> AstNode<'a> for {{ node }}<'a> {
40 fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> {
41 match syntax.kind() {
42 {{ node | SCREAM }} => Some({{ node }} { syntax }),
43 _ => None,
44 }
45 }
46 fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax }
47}
48{% endif %}
49{% if methods.traits -%}
50{%- for t in methods.traits -%}
51impl<'a> ast::{{ t }}<'a> for {{ node }}<'a> {}
52{% endfor -%}
53{%- endif -%}
54
55impl<'a> {{ node }}<'a> {
56{%- if methods.collections -%}
57{%- for m in methods.collections -%}
58{%- set method_name = m.0 -%}
59{%- set ChildName = m.1 %}
60 pub fn {{ method_name }}(self) -> impl Iterator<Item = {{ ChildName }}<'a>> + 'a {
61 super::children(self)
62 }
63{% endfor -%}
64{%- endif -%}
65
66{%- if methods.options -%}
67{%- for m in methods.options -%}
68
69{%- if m is string -%}
70{%- set method_name = m | snake -%}
71{%- set ChildName = m %}
72{%- else -%}
73{%- set method_name = m.0 -%}
74{%- set ChildName = m.1 %}
75{%- endif -%}
76
77 pub fn {{ method_name }}(self) -> Option<{{ ChildName }}<'a>> {
78 super::child_opt(self)
79 }
80{% endfor -%}
81{%- endif -%}
82}
83{% endfor %}