mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-10 04:08:47 +00:00
23 lines
557 B
Text
23 lines
557 B
Text
|
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 %}
|