diff options
author | Aleksey Kladov <[email protected]> | 2018-08-11 07:55:32 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-11 07:55:32 +0100 |
commit | b18d2882f4f05078abfcf0595d08c226860de6c3 (patch) | |
tree | 247e87f3f8e03cec063d29dd6223e7727dadadb4 /crates/libsyntax2/src/ast/generated.rs.tera | |
parent | 7581984601b35c113c4bcdf0f8b402b2635be0dc (diff) |
Generate accessors
Diffstat (limited to 'crates/libsyntax2/src/ast/generated.rs.tera')
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs.tera | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera index afce068c8..86de7bce8 100644 --- a/crates/libsyntax2/src/ast/generated.rs.tera +++ b/crates/libsyntax2/src/ast/generated.rs.tera | |||
@@ -21,13 +21,29 @@ impl<R: TreeRoot> AstNode<R> for {{ Name }}<R> { | |||
21 | } | 21 | } |
22 | 22 | ||
23 | impl<R: TreeRoot> {{ Name }}<R> { | 23 | impl<R: TreeRoot> {{ Name }}<R> { |
24 | {% for (method_name, kind) in node.opts %} | 24 | {%- if node.collections -%} |
25 | {% set ChildName = kind | camel %} | 25 | {%- for m in node.collections -%} |
26 | pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator<Item = {{ ChildKind }}<R>> + 'a { | 26 | {%- set method_name = m.0 -%} |
27 | {%- set ChildName = m.1 | camel %} | ||
28 | pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator<Item = {{ ChildName }}<R>> + 'a { | ||
27 | self.syntax() | 29 | self.syntax() |
28 | .children() | 30 | .children() |
29 | .filter_map({{ ChildKind }}::cast) | 31 | .filter_map({{ ChildName }}::cast) |
30 | } | 32 | } |
31 | {% endfor %} | 33 | {% endfor -%} |
34 | {%- endif -%} | ||
35 | |||
36 | {%- if node.options -%} | ||
37 | {%- for m in node.options -%} | ||
38 | {%- set method_name = m.0 -%} | ||
39 | {%- set ChildName = m.1 | camel %} | ||
40 | pub fn {{ method_name }}(&self) -> Option<{{ ChildName }}<R>> { | ||
41 | self.syntax() | ||
42 | .children() | ||
43 | .filter_map({{ ChildName }}::cast) | ||
44 | .next() | ||
45 | } | ||
46 | {% endfor -%} | ||
47 | {%- endif -%} | ||
32 | } | 48 | } |
33 | {% endfor %} | 49 | {% endfor %} |