diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index 1321f0def..6e28575b2 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -8,27 +8,12 @@ the below applies to the result of this template | |||
8 | use crate::{ | 8 | use crate::{ |
9 | ast, | 9 | ast, |
10 | SyntaxNode, SyntaxNodeRef, AstNode, | 10 | SyntaxNode, SyntaxNodeRef, AstNode, |
11 | yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, | ||
11 | SyntaxKind::*, | 12 | SyntaxKind::*, |
12 | }; | 13 | }; |
13 | {% for node, methods in ast %} | 14 | {% for node, methods in ast %} |
14 | // {{ node }} | 15 | // {{ node }} |
15 | 16 | ||
16 | #[derive(Debug, Clone)] | ||
17 | pub struct {{ node }}Node(SyntaxNode); | ||
18 | |||
19 | impl {{ node }}Node { | ||
20 | pub fn ast(&self) -> {{ node }} { | ||
21 | {{ node }}::cast(self.0.borrowed()).unwrap() | ||
22 | } | ||
23 | } | ||
24 | |||
25 | impl<'a> From<{{ node }}<'a>> for {{ node }}Node { | ||
26 | fn from(ast: {{ node}}<'a>) -> {{ node }}Node { | ||
27 | let syntax = ast.syntax().owned(); | ||
28 | {{ node }}Node(syntax) | ||
29 | } | ||
30 | } | ||
31 | |||
32 | {%- if methods.enum %} | 17 | {%- if methods.enum %} |
33 | #[derive(Debug, Clone, Copy)] | 18 | #[derive(Debug, Clone, Copy)] |
34 | pub enum {{ node }}<'a> { | 19 | pub enum {{ node }}<'a> { |
@@ -56,9 +41,10 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
56 | } | 41 | } |
57 | {% else %} | 42 | {% else %} |
58 | #[derive(Debug, Clone, Copy)] | 43 | #[derive(Debug, Clone, Copy)] |
59 | pub struct {{ node }}<'a> { | 44 | pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> { |
60 | syntax: SyntaxNodeRef<'a>, | 45 | syntax: SyntaxNode<R>, |
61 | } | 46 | } |
47 | pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>; | ||
62 | 48 | ||
63 | impl<'a> AstNode<'a> for {{ node }}<'a> { | 49 | impl<'a> AstNode<'a> for {{ node }}<'a> { |
64 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 50 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -69,6 +55,16 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
69 | } | 55 | } |
70 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 56 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
71 | } | 57 | } |
58 | |||
59 | impl<R: TreeRoot<RaTypes>> {{ node }}Node<R> { | ||
60 | pub fn borrowed(&self) -> {{ node }} { | ||
61 | {{ node }}Node { syntax: self.syntax.borrowed() } | ||
62 | } | ||
63 | pub fn owned(&self) -> {{ node }}Node { | ||
64 | {{ node }}Node { syntax: self.syntax.owned() } | ||
65 | } | ||
66 | } | ||
67 | |||
72 | {% endif %} | 68 | {% endif %} |
73 | {% if methods.traits -%} | 69 | {% if methods.traits -%} |
74 | {%- for t in methods.traits -%} | 70 | {%- for t in methods.traits -%} |