diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera index 2428378017..afce068c86 100644 --- a/crates/libsyntax2/src/ast/generated.rs.tera +++ b/crates/libsyntax2/src/ast/generated.rs.tera @@ -19,4 +19,15 @@ impl AstNode for {{ Name }} { } fn syntax(&self) -> &SyntaxNode { &self.syntax } } + +impl {{ Name }} { +{% for (method_name, kind) in node.opts %} +{% set ChildName = kind | camel %} + pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator> + 'a { + self.syntax() + .children() + .filter_map({{ ChildKind }}::cast) + } +{% endfor %} +} {% endfor %} diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index bcc79843aa..9ad2c2ec1a 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -215,10 +215,16 @@ Grammar( ], ast: [ ( - kind: "FILE" + kind: "FILE", + collections: [ + ("functions", "FUNCTION") + ] ), ( - kind: "FUNCTION" + kind: "FUNCTION", + options: [ + ("name", "NAME") + ] ), ( kind: "NAME" diff --git a/crates/tools/Cargo.toml b/crates/tools/Cargo.toml index f9fee16f9a..856f7d8cbd 100644 --- a/crates/tools/Cargo.toml +++ b/crates/tools/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Aleksey Kladov "] publish = false [dependencies] -ron = "0.1.7" +ron = "0.3.0" walkdir = "2.1.3" itertools = "0.7.8" tera = "0.11"