Introduce owned ast nodes
ast::FooNode is an owned 'static counterpart to ast::Foo<'a>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user