From 7581984601b35c113c4bcdf0f8b402b2635be0dc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 11 Aug 2018 09:38:27 +0300 Subject: bump ron --- crates/libsyntax2/src/ast/generated.rs.tera | 11 +++++++++++ crates/libsyntax2/src/grammar.ron | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'crates/libsyntax2/src') diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera index 242837801..afce068c8 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 bcc79843a..9ad2c2ec1 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" -- cgit v1.2.3