aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/ast/generated.rs.tera
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-14 10:38:20 +0100
committerAleksey Kladov <[email protected]>2018-08-14 10:38:20 +0100
commit5953a348bd6102a868f303d3f732a6ec7d465833 (patch)
tree8f4ca16180f850465d871d9b2959d4ae065dcfeb /crates/libsyntax2/src/ast/generated.rs.tera
parentde02d2891ec7f7b295e33887d49de954f677387a (diff)
Less hackish impl structure
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs.tera')
-rw-r--r--crates/libsyntax2/src/ast/generated.rs.tera28
1 files changed, 27 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera
index 3d79b5543..f83da0326 100644
--- a/crates/libsyntax2/src/ast/generated.rs.tera
+++ b/crates/libsyntax2/src/ast/generated.rs.tera
@@ -6,6 +6,32 @@ use {
6}; 6};
7{% for node, methods in ast %} 7{% for node, methods in ast %}
8// {{ node }} 8// {{ node }}
9{%- if methods.enum %}
10#[derive(Debug, Clone, Copy)]
11pub enum {{ node }}<R: TreeRoot = Arc<SyntaxRoot>> {
12{%- for kind in methods.enum %}
13 {{ kind }}({{ kind }}<R>),
14{%- endfor %}
15}
16
17impl<R: TreeRoot> AstNode<R> for {{ node }}<R> {
18 fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
19 match syntax.kind() {
20{%- for kind in methods.enum %}
21 {{ kind | SCREAM }} => Some({{ node }}::{{ kind }}({{ kind }} { syntax })),
22{%- endfor %}
23 _ => None,
24 }
25 }
26 fn syntax(&self) -> &SyntaxNode<R> {
27 match self {
28{%- for kind in methods.enum %}
29 {{ node }}::{{ kind }}(inner) => inner.syntax(),
30{%- endfor %}
31 }
32 }
33}
34{% else %}
9#[derive(Debug, Clone, Copy)] 35#[derive(Debug, Clone, Copy)]
10pub struct {{ node }}<R: TreeRoot = Arc<SyntaxRoot>> { 36pub struct {{ node }}<R: TreeRoot = Arc<SyntaxRoot>> {
11 syntax: SyntaxNode<R>, 37 syntax: SyntaxNode<R>,
@@ -20,7 +46,7 @@ impl<R: TreeRoot> AstNode<R> for {{ node }}<R> {
20 } 46 }
21 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } 47 fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
22} 48}
23 49{% endif %}
24{% if methods.traits -%} 50{% if methods.traits -%}
25{%- for t in methods.traits -%} 51{%- for t in methods.traits -%}
26impl<R: TreeRoot> ast::{{ t }}<R> for {{ node }}<R> {} 52impl<R: TreeRoot> ast::{{ t }}<R> for {{ node }}<R> {}