diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index 0767df334e..12e5a1c3e2 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -4,7 +4,6 @@ use { SyntaxKind::*, }; - #[derive(Debug, Clone, Copy)] pub struct File> { syntax: SyntaxNode, @@ -28,7 +27,6 @@ impl File { } } - #[derive(Debug, Clone, Copy)] pub struct Function> { syntax: SyntaxNode, @@ -53,7 +51,6 @@ impl Function { } } - #[derive(Debug, Clone, Copy)] pub struct Name> { syntax: SyntaxNode, diff --git a/crates/libsyntax2/src/ast/generated.rs.tera b/crates/libsyntax2/src/ast/generated.rs.tera index 86de7bce87..09630e427a 100644 --- a/crates/libsyntax2/src/ast/generated.rs.tera +++ b/crates/libsyntax2/src/ast/generated.rs.tera @@ -3,28 +3,27 @@ use { SyntaxNode, SyntaxRoot, TreeRoot, AstNode, SyntaxKind::*, }; -{% for node in ast %} -{% set Name = node.kind | camel %} +{% for node, methods in ast %} #[derive(Debug, Clone, Copy)] -pub struct {{ Name }}> { +pub struct {{ node }}> { syntax: SyntaxNode, } -impl AstNode for {{ Name }} { +impl AstNode for {{ node }} { fn cast(syntax: SyntaxNode) -> Option { match syntax.kind() { - {{ node.kind }} => Some({{ Name }} { syntax }), + {{ node | upper }} => Some({{ node }} { syntax }), _ => None, } } fn syntax(&self) -> &SyntaxNode { &self.syntax } } -impl {{ Name }} { -{%- if node.collections -%} -{%- for m in node.collections -%} +impl {{ node }} { +{%- if methods.collections -%} +{%- for m in methods.collections -%} {%- set method_name = m.0 -%} -{%- set ChildName = m.1 | camel %} +{%- set ChildName = m.1 %} pub fn {{ method_name }}<'a>(&'a self) -> impl Iterator> + 'a { self.syntax() .children() @@ -33,10 +32,10 @@ impl {{ Name }} { {% endfor -%} {%- endif -%} -{%- if node.options -%} -{%- for m in node.options -%} +{%- if methods.options -%} +{%- for m in methods.options -%} {%- set method_name = m.0 -%} -{%- set ChildName = m.1 | camel %} +{%- set ChildName = m.1 %} pub fn {{ method_name }}(&self) -> Option<{{ ChildName }}> { self.syntax() .children() diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 06a4eb6a7e..650f722127 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -213,21 +213,17 @@ Grammar( "SELF_PARAM", "ARG_LIST", ], - ast: [ - ( - kind: "FILE", + ast: { + "File": ( collections: [ - ["functions", "FUNCTION"] + ["functions", "Function"] ] ), - ( - kind: "FUNCTION", + "Function": ( options: [ - ["name", "NAME"] + ["name", "Name"] ] ), - ( - kind: "NAME" - ), - ] + "Name": (), + }, )