Introduce owned ast nodes

ast::FooNode is an owned 'static counterpart to ast::Foo<'a>
This commit is contained in:
Aleksey Kladov 2018-10-31 10:27:53 +03:00
parent 032d15c392
commit 3068af79ff
2 changed files with 1303 additions and 2 deletions

File diff suppressed because it is too large Load diff

View file

@ -7,11 +7,25 @@ the below applies to the result of this template
use crate::{
ast,
SyntaxNodeRef, AstNode,
SyntaxNode, SyntaxNodeRef, AstNode,
SyntaxKind::*,
};
{% for node, methods in ast %}
// {{ node }}
#[derive(Debug, Clone)]
pub struct {{ node }}Node(SyntaxNode);
impl {{ node }}Node {
pub fn new(&self, ast: {{ node }}) -> {{ node }}Node {
let syntax = ast.syntax().owned();
{{ node }}Node(syntax)
}
pub fn ast(&self) -> {{ node }} {
{{ node }}::cast(self.0.borrowed()).unwrap()
}
}
{%- if methods.enum %}
#[derive(Debug, Clone, Copy)]
pub enum {{ node }}<'a> {