aboutsummaryrefslogtreecommitdiff
path: root/src/ast/generated.rs.tera
blob: f2559383a2d4d8b2ac3a221178e9965b52ca4dd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::sync::Arc;
use {
    SyntaxNode, SyntaxRoot, TreeRoot, AstNode,
    SyntaxKind::*,
};
{% for node in ast %}
{% set Name = node.kind | camel  %}
#[derive(Debug)]
pub struct {{ Name }}<R: TreeRoot = Arc<SyntaxRoot>> {
    syntax: SyntaxNode<R>,
}

impl<R: TreeRoot> AstNode<R> for {{ Name }}<R> {
    fn cast(syntax: SyntaxNode<R>) -> Option<Self> {
        match syntax.kind() {
            {{ node.kind }} => Some({{ Name }} { syntax }),
            _ => None,
        }
    }
    fn syntax(&self) -> &SyntaxNode<R> { &self.syntax }
}
{% endfor %}