mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 09:27:27 +00:00
Introduce owned ast nodes
ast::FooNode is an owned 'static counterpart to ast::Foo<'a>
This commit is contained in:
parent
032d15c392
commit
3068af79ff
2 changed files with 1303 additions and 2 deletions
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> {
|
||||
|
|
Loading…
Reference in a new issue