mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +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::{
|
use crate::{
|
||||||
ast,
|
ast,
|
||||||
SyntaxNodeRef, AstNode,
|
SyntaxNode, SyntaxNodeRef, AstNode,
|
||||||
SyntaxKind::*,
|
SyntaxKind::*,
|
||||||
};
|
};
|
||||||
{% for node, methods in ast %}
|
{% for node, methods in ast %}
|
||||||
// {{ node }}
|
// {{ 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 %}
|
{%- if methods.enum %}
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum {{ node }}<'a> {
|
pub enum {{ node }}<'a> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue