diff options
author | Aleksey Kladov <[email protected]> | 2018-10-31 07:27:53 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-31 07:29:32 +0000 |
commit | 3068af79ffd23656ff2d46ac92d9192ce6c813fb (patch) | |
tree | bce803cd3f48489eee785c726fb09906f8a5f36a /crates/ra_syntax/src/ast/generated.rs.tera | |
parent | 032d15c392e8de7936c8729e03e6229313f3b054 (diff) |
Introduce owned ast nodes
ast::FooNode is an owned 'static counterpart to ast::Foo<'a>
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index e1404deac..c61c3e80b 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -7,11 +7,25 @@ the below applies to the result of this template | |||
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | ast, | 9 | ast, |
10 | SyntaxNodeRef, AstNode, | 10 | SyntaxNode, SyntaxNodeRef, AstNode, |
11 | SyntaxKind::*, | 11 | SyntaxKind::*, |
12 | }; | 12 | }; |
13 | {% for node, methods in ast %} | 13 | {% for node, methods in ast %} |
14 | // {{ node }} | 14 | // {{ node }} |
15 | |||
16 | #[derive(Debug, Clone)] | ||
17 | pub struct {{ node }}Node(SyntaxNode); | ||
18 | |||
19 | impl {{ node }}Node { | ||
20 | pub fn new(&self, ast: {{ node }}) -> {{ node }}Node { | ||
21 | let syntax = ast.syntax().owned(); | ||
22 | {{ node }}Node(syntax) | ||
23 | } | ||
24 | pub fn ast(&self) -> {{ node }} { | ||
25 | {{ node }}::cast(self.0.borrowed()).unwrap() | ||
26 | } | ||
27 | } | ||
28 | |||
15 | {%- if methods.enum %} | 29 | {%- if methods.enum %} |
16 | #[derive(Debug, Clone, Copy)] | 30 | #[derive(Debug, Clone, Copy)] |
17 | pub enum {{ node }}<'a> { | 31 | pub enum {{ node }}<'a> { |