diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-06 19:08:00 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-06 19:08:00 +0000 |
commit | 3928255b6f919ca0a0a93393ab7fa3d0ce6df681 (patch) | |
tree | fd67f18d5a631a1cbcb84cbe3455713943253fb8 /crates/ra_syntax/src/ast/generated.rs | |
parent | 21797bf0efdeafde4148fe02ba4bd11171737872 (diff) | |
parent | 7f88fe8790014f4c879ec49de4bfdb823043e16a (diff) |
Merge #209
209: Owned nodes r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 3017 |
1 files changed, 1229 insertions, 1788 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 75769a4e9..420d9090c 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1,35 +1,27 @@ | |||
1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run | 1 | // This file is automatically generated based on the file `./generated.rs.tera` when `cargo gen-syntax` is run |
2 | // Do not edit manually | 2 | // Do not edit manually |
3 | 3 | ||
4 | //! This module contains auto-generated Rust AST. Like `SyntaxNode`s, AST nodes | ||
5 | //! are generic over ownership: `X<'a>` things are `Copy` references, `XNode` | ||
6 | //! are Arc-based. You can switch between the two variants using `.owned` and | ||
7 | //! `.borrowed` functions. Most of the code works with borowed mode, and only | ||
8 | //! this mode has all AST accessors. | ||
9 | |||
4 | #![cfg_attr(rustfmt, rustfmt_skip)] | 10 | #![cfg_attr(rustfmt, rustfmt_skip)] |
5 | 11 | ||
6 | use crate::{ | 12 | use crate::{ |
7 | ast, | 13 | ast, |
8 | SyntaxNode, SyntaxNodeRef, AstNode, | 14 | SyntaxNode, SyntaxNodeRef, AstNode, |
15 | yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, | ||
9 | SyntaxKind::*, | 16 | SyntaxKind::*, |
10 | }; | 17 | }; |
11 | 18 | ||
12 | // ArgList | 19 | // ArgList |
13 | |||
14 | #[derive(Debug, Clone)] | ||
15 | pub struct ArgListNode(SyntaxNode); | ||
16 | |||
17 | impl ArgListNode { | ||
18 | pub fn ast(&self) -> ArgList { | ||
19 | ArgList::cast(self.0.borrowed()).unwrap() | ||
20 | } | ||
21 | } | ||
22 | |||
23 | impl<'a> From<ArgList<'a>> for ArgListNode { | ||
24 | fn from(ast: ArgList<'a>) -> ArgListNode { | ||
25 | let syntax = ast.syntax().owned(); | ||
26 | ArgListNode(syntax) | ||
27 | } | ||
28 | } | ||
29 | #[derive(Debug, Clone, Copy)] | 20 | #[derive(Debug, Clone, Copy)] |
30 | pub struct ArgList<'a> { | 21 | pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
31 | syntax: SyntaxNodeRef<'a>, | 22 | syntax: SyntaxNode<R>, |
32 | } | 23 | } |
24 | pub type ArgList<'a> = ArgListNode<RefRoot<'a>>; | ||
33 | 25 | ||
34 | impl<'a> AstNode<'a> for ArgList<'a> { | 26 | impl<'a> AstNode<'a> for ArgList<'a> { |
35 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 27 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -41,33 +33,28 @@ impl<'a> AstNode<'a> for ArgList<'a> { | |||
41 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 33 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
42 | } | 34 | } |
43 | 35 | ||
44 | impl<'a> ArgList<'a> { | 36 | impl<R: TreeRoot<RaTypes>> ArgListNode<R> { |
45 | pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { | 37 | pub fn borrowed(&self) -> ArgList { |
46 | super::children(self) | 38 | ArgListNode { syntax: self.syntax.borrowed() } |
39 | } | ||
40 | pub fn owned(&self) -> ArgListNode { | ||
41 | ArgListNode { syntax: self.syntax.owned() } | ||
47 | } | 42 | } |
48 | } | 43 | } |
49 | 44 | ||
50 | // ArrayExpr | ||
51 | 45 | ||
52 | #[derive(Debug, Clone)] | 46 | impl<'a> ArgList<'a> { |
53 | pub struct ArrayExprNode(SyntaxNode); | 47 | pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { |
54 | 48 | super::children(self) | |
55 | impl ArrayExprNode { | ||
56 | pub fn ast(&self) -> ArrayExpr { | ||
57 | ArrayExpr::cast(self.0.borrowed()).unwrap() | ||
58 | } | 49 | } |
59 | } | 50 | } |
60 | 51 | ||
61 | impl<'a> From<ArrayExpr<'a>> for ArrayExprNode { | 52 | // ArrayExpr |
62 | fn from(ast: ArrayExpr<'a>) -> ArrayExprNode { | ||
63 | let syntax = ast.syntax().owned(); | ||
64 | ArrayExprNode(syntax) | ||
65 | } | ||
66 | } | ||
67 | #[derive(Debug, Clone, Copy)] | 53 | #[derive(Debug, Clone, Copy)] |
68 | pub struct ArrayExpr<'a> { | 54 | pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
69 | syntax: SyntaxNodeRef<'a>, | 55 | syntax: SyntaxNode<R>, |
70 | } | 56 | } |
57 | pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>; | ||
71 | 58 | ||
72 | impl<'a> AstNode<'a> for ArrayExpr<'a> { | 59 | impl<'a> AstNode<'a> for ArrayExpr<'a> { |
73 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 60 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -79,29 +66,24 @@ impl<'a> AstNode<'a> for ArrayExpr<'a> { | |||
79 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 66 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
80 | } | 67 | } |
81 | 68 | ||
82 | impl<'a> ArrayExpr<'a> {} | 69 | impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> { |
83 | 70 | pub fn borrowed(&self) -> ArrayExpr { | |
84 | // ArrayType | 71 | ArrayExprNode { syntax: self.syntax.borrowed() } |
85 | |||
86 | #[derive(Debug, Clone)] | ||
87 | pub struct ArrayTypeNode(SyntaxNode); | ||
88 | |||
89 | impl ArrayTypeNode { | ||
90 | pub fn ast(&self) -> ArrayType { | ||
91 | ArrayType::cast(self.0.borrowed()).unwrap() | ||
92 | } | 72 | } |
93 | } | 73 | pub fn owned(&self) -> ArrayExprNode { |
94 | 74 | ArrayExprNode { syntax: self.syntax.owned() } | |
95 | impl<'a> From<ArrayType<'a>> for ArrayTypeNode { | ||
96 | fn from(ast: ArrayType<'a>) -> ArrayTypeNode { | ||
97 | let syntax = ast.syntax().owned(); | ||
98 | ArrayTypeNode(syntax) | ||
99 | } | 75 | } |
100 | } | 76 | } |
77 | |||
78 | |||
79 | impl<'a> ArrayExpr<'a> {} | ||
80 | |||
81 | // ArrayType | ||
101 | #[derive(Debug, Clone, Copy)] | 82 | #[derive(Debug, Clone, Copy)] |
102 | pub struct ArrayType<'a> { | 83 | pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
103 | syntax: SyntaxNodeRef<'a>, | 84 | syntax: SyntaxNode<R>, |
104 | } | 85 | } |
86 | pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>; | ||
105 | 87 | ||
106 | impl<'a> AstNode<'a> for ArrayType<'a> { | 88 | impl<'a> AstNode<'a> for ArrayType<'a> { |
107 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 89 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -113,29 +95,24 @@ impl<'a> AstNode<'a> for ArrayType<'a> { | |||
113 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 95 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
114 | } | 96 | } |
115 | 97 | ||
116 | impl<'a> ArrayType<'a> {} | 98 | impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> { |
117 | 99 | pub fn borrowed(&self) -> ArrayType { | |
118 | // Attr | 100 | ArrayTypeNode { syntax: self.syntax.borrowed() } |
119 | |||
120 | #[derive(Debug, Clone)] | ||
121 | pub struct AttrNode(SyntaxNode); | ||
122 | |||
123 | impl AttrNode { | ||
124 | pub fn ast(&self) -> Attr { | ||
125 | Attr::cast(self.0.borrowed()).unwrap() | ||
126 | } | 101 | } |
127 | } | 102 | pub fn owned(&self) -> ArrayTypeNode { |
128 | 103 | ArrayTypeNode { syntax: self.syntax.owned() } | |
129 | impl<'a> From<Attr<'a>> for AttrNode { | ||
130 | fn from(ast: Attr<'a>) -> AttrNode { | ||
131 | let syntax = ast.syntax().owned(); | ||
132 | AttrNode(syntax) | ||
133 | } | 104 | } |
134 | } | 105 | } |
106 | |||
107 | |||
108 | impl<'a> ArrayType<'a> {} | ||
109 | |||
110 | // Attr | ||
135 | #[derive(Debug, Clone, Copy)] | 111 | #[derive(Debug, Clone, Copy)] |
136 | pub struct Attr<'a> { | 112 | pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
137 | syntax: SyntaxNodeRef<'a>, | 113 | syntax: SyntaxNode<R>, |
138 | } | 114 | } |
115 | pub type Attr<'a> = AttrNode<RefRoot<'a>>; | ||
139 | 116 | ||
140 | impl<'a> AstNode<'a> for Attr<'a> { | 117 | impl<'a> AstNode<'a> for Attr<'a> { |
141 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 118 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -147,33 +124,28 @@ impl<'a> AstNode<'a> for Attr<'a> { | |||
147 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 124 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
148 | } | 125 | } |
149 | 126 | ||
150 | impl<'a> Attr<'a> { | 127 | impl<R: TreeRoot<RaTypes>> AttrNode<R> { |
151 | pub fn value(self) -> Option<TokenTree<'a>> { | 128 | pub fn borrowed(&self) -> Attr { |
152 | super::child_opt(self) | 129 | AttrNode { syntax: self.syntax.borrowed() } |
130 | } | ||
131 | pub fn owned(&self) -> AttrNode { | ||
132 | AttrNode { syntax: self.syntax.owned() } | ||
153 | } | 133 | } |
154 | } | 134 | } |
155 | 135 | ||
156 | // BinExpr | ||
157 | |||
158 | #[derive(Debug, Clone)] | ||
159 | pub struct BinExprNode(SyntaxNode); | ||
160 | 136 | ||
161 | impl BinExprNode { | 137 | impl<'a> Attr<'a> { |
162 | pub fn ast(&self) -> BinExpr { | 138 | pub fn value(self) -> Option<TokenTree<'a>> { |
163 | BinExpr::cast(self.0.borrowed()).unwrap() | 139 | super::child_opt(self) |
164 | } | 140 | } |
165 | } | 141 | } |
166 | 142 | ||
167 | impl<'a> From<BinExpr<'a>> for BinExprNode { | 143 | // BinExpr |
168 | fn from(ast: BinExpr<'a>) -> BinExprNode { | ||
169 | let syntax = ast.syntax().owned(); | ||
170 | BinExprNode(syntax) | ||
171 | } | ||
172 | } | ||
173 | #[derive(Debug, Clone, Copy)] | 144 | #[derive(Debug, Clone, Copy)] |
174 | pub struct BinExpr<'a> { | 145 | pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
175 | syntax: SyntaxNodeRef<'a>, | 146 | syntax: SyntaxNode<R>, |
176 | } | 147 | } |
148 | pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>; | ||
177 | 149 | ||
178 | impl<'a> AstNode<'a> for BinExpr<'a> { | 150 | impl<'a> AstNode<'a> for BinExpr<'a> { |
179 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 151 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -185,29 +157,24 @@ impl<'a> AstNode<'a> for BinExpr<'a> { | |||
185 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 157 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
186 | } | 158 | } |
187 | 159 | ||
188 | impl<'a> BinExpr<'a> {} | 160 | impl<R: TreeRoot<RaTypes>> BinExprNode<R> { |
189 | 161 | pub fn borrowed(&self) -> BinExpr { | |
190 | // BindPat | 162 | BinExprNode { syntax: self.syntax.borrowed() } |
191 | |||
192 | #[derive(Debug, Clone)] | ||
193 | pub struct BindPatNode(SyntaxNode); | ||
194 | |||
195 | impl BindPatNode { | ||
196 | pub fn ast(&self) -> BindPat { | ||
197 | BindPat::cast(self.0.borrowed()).unwrap() | ||
198 | } | 163 | } |
199 | } | 164 | pub fn owned(&self) -> BinExprNode { |
200 | 165 | BinExprNode { syntax: self.syntax.owned() } | |
201 | impl<'a> From<BindPat<'a>> for BindPatNode { | ||
202 | fn from(ast: BindPat<'a>) -> BindPatNode { | ||
203 | let syntax = ast.syntax().owned(); | ||
204 | BindPatNode(syntax) | ||
205 | } | 166 | } |
206 | } | 167 | } |
168 | |||
169 | |||
170 | impl<'a> BinExpr<'a> {} | ||
171 | |||
172 | // BindPat | ||
207 | #[derive(Debug, Clone, Copy)] | 173 | #[derive(Debug, Clone, Copy)] |
208 | pub struct BindPat<'a> { | 174 | pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
209 | syntax: SyntaxNodeRef<'a>, | 175 | syntax: SyntaxNode<R>, |
210 | } | 176 | } |
177 | pub type BindPat<'a> = BindPatNode<RefRoot<'a>>; | ||
211 | 178 | ||
212 | impl<'a> AstNode<'a> for BindPat<'a> { | 179 | impl<'a> AstNode<'a> for BindPat<'a> { |
213 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 180 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -219,30 +186,25 @@ impl<'a> AstNode<'a> for BindPat<'a> { | |||
219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 186 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
220 | } | 187 | } |
221 | 188 | ||
189 | impl<R: TreeRoot<RaTypes>> BindPatNode<R> { | ||
190 | pub fn borrowed(&self) -> BindPat { | ||
191 | BindPatNode { syntax: self.syntax.borrowed() } | ||
192 | } | ||
193 | pub fn owned(&self) -> BindPatNode { | ||
194 | BindPatNode { syntax: self.syntax.owned() } | ||
195 | } | ||
196 | } | ||
197 | |||
198 | |||
222 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} | 199 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} |
223 | impl<'a> BindPat<'a> {} | 200 | impl<'a> BindPat<'a> {} |
224 | 201 | ||
225 | // Block | 202 | // Block |
226 | |||
227 | #[derive(Debug, Clone)] | ||
228 | pub struct BlockNode(SyntaxNode); | ||
229 | |||
230 | impl BlockNode { | ||
231 | pub fn ast(&self) -> Block { | ||
232 | Block::cast(self.0.borrowed()).unwrap() | ||
233 | } | ||
234 | } | ||
235 | |||
236 | impl<'a> From<Block<'a>> for BlockNode { | ||
237 | fn from(ast: Block<'a>) -> BlockNode { | ||
238 | let syntax = ast.syntax().owned(); | ||
239 | BlockNode(syntax) | ||
240 | } | ||
241 | } | ||
242 | #[derive(Debug, Clone, Copy)] | 203 | #[derive(Debug, Clone, Copy)] |
243 | pub struct Block<'a> { | 204 | pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
244 | syntax: SyntaxNodeRef<'a>, | 205 | syntax: SyntaxNode<R>, |
245 | } | 206 | } |
207 | pub type Block<'a> = BlockNode<RefRoot<'a>>; | ||
246 | 208 | ||
247 | impl<'a> AstNode<'a> for Block<'a> { | 209 | impl<'a> AstNode<'a> for Block<'a> { |
248 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 210 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -254,6 +216,16 @@ impl<'a> AstNode<'a> for Block<'a> { | |||
254 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 216 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
255 | } | 217 | } |
256 | 218 | ||
219 | impl<R: TreeRoot<RaTypes>> BlockNode<R> { | ||
220 | pub fn borrowed(&self) -> Block { | ||
221 | BlockNode { syntax: self.syntax.borrowed() } | ||
222 | } | ||
223 | pub fn owned(&self) -> BlockNode { | ||
224 | BlockNode { syntax: self.syntax.owned() } | ||
225 | } | ||
226 | } | ||
227 | |||
228 | |||
257 | impl<'a> Block<'a> { | 229 | impl<'a> Block<'a> { |
258 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { | 230 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { |
259 | super::children(self) | 231 | super::children(self) |
@@ -265,26 +237,11 @@ impl<'a> Block<'a> { | |||
265 | } | 237 | } |
266 | 238 | ||
267 | // BlockExpr | 239 | // BlockExpr |
268 | |||
269 | #[derive(Debug, Clone)] | ||
270 | pub struct BlockExprNode(SyntaxNode); | ||
271 | |||
272 | impl BlockExprNode { | ||
273 | pub fn ast(&self) -> BlockExpr { | ||
274 | BlockExpr::cast(self.0.borrowed()).unwrap() | ||
275 | } | ||
276 | } | ||
277 | |||
278 | impl<'a> From<BlockExpr<'a>> for BlockExprNode { | ||
279 | fn from(ast: BlockExpr<'a>) -> BlockExprNode { | ||
280 | let syntax = ast.syntax().owned(); | ||
281 | BlockExprNode(syntax) | ||
282 | } | ||
283 | } | ||
284 | #[derive(Debug, Clone, Copy)] | 240 | #[derive(Debug, Clone, Copy)] |
285 | pub struct BlockExpr<'a> { | 241 | pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
286 | syntax: SyntaxNodeRef<'a>, | 242 | syntax: SyntaxNode<R>, |
287 | } | 243 | } |
244 | pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>; | ||
288 | 245 | ||
289 | impl<'a> AstNode<'a> for BlockExpr<'a> { | 246 | impl<'a> AstNode<'a> for BlockExpr<'a> { |
290 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 247 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -296,33 +253,28 @@ impl<'a> AstNode<'a> for BlockExpr<'a> { | |||
296 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 253 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
297 | } | 254 | } |
298 | 255 | ||
299 | impl<'a> BlockExpr<'a> { | 256 | impl<R: TreeRoot<RaTypes>> BlockExprNode<R> { |
300 | pub fn block(self) -> Option<Block<'a>> { | 257 | pub fn borrowed(&self) -> BlockExpr { |
301 | super::child_opt(self) | 258 | BlockExprNode { syntax: self.syntax.borrowed() } |
259 | } | ||
260 | pub fn owned(&self) -> BlockExprNode { | ||
261 | BlockExprNode { syntax: self.syntax.owned() } | ||
302 | } | 262 | } |
303 | } | 263 | } |
304 | 264 | ||
305 | // BreakExpr | ||
306 | |||
307 | #[derive(Debug, Clone)] | ||
308 | pub struct BreakExprNode(SyntaxNode); | ||
309 | 265 | ||
310 | impl BreakExprNode { | 266 | impl<'a> BlockExpr<'a> { |
311 | pub fn ast(&self) -> BreakExpr { | 267 | pub fn block(self) -> Option<Block<'a>> { |
312 | BreakExpr::cast(self.0.borrowed()).unwrap() | 268 | super::child_opt(self) |
313 | } | 269 | } |
314 | } | 270 | } |
315 | 271 | ||
316 | impl<'a> From<BreakExpr<'a>> for BreakExprNode { | 272 | // BreakExpr |
317 | fn from(ast: BreakExpr<'a>) -> BreakExprNode { | ||
318 | let syntax = ast.syntax().owned(); | ||
319 | BreakExprNode(syntax) | ||
320 | } | ||
321 | } | ||
322 | #[derive(Debug, Clone, Copy)] | 273 | #[derive(Debug, Clone, Copy)] |
323 | pub struct BreakExpr<'a> { | 274 | pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
324 | syntax: SyntaxNodeRef<'a>, | 275 | syntax: SyntaxNode<R>, |
325 | } | 276 | } |
277 | pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>; | ||
326 | 278 | ||
327 | impl<'a> AstNode<'a> for BreakExpr<'a> { | 279 | impl<'a> AstNode<'a> for BreakExpr<'a> { |
328 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 280 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -334,29 +286,24 @@ impl<'a> AstNode<'a> for BreakExpr<'a> { | |||
334 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 286 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
335 | } | 287 | } |
336 | 288 | ||
337 | impl<'a> BreakExpr<'a> {} | 289 | impl<R: TreeRoot<RaTypes>> BreakExprNode<R> { |
338 | 290 | pub fn borrowed(&self) -> BreakExpr { | |
339 | // CallExpr | 291 | BreakExprNode { syntax: self.syntax.borrowed() } |
340 | |||
341 | #[derive(Debug, Clone)] | ||
342 | pub struct CallExprNode(SyntaxNode); | ||
343 | |||
344 | impl CallExprNode { | ||
345 | pub fn ast(&self) -> CallExpr { | ||
346 | CallExpr::cast(self.0.borrowed()).unwrap() | ||
347 | } | 292 | } |
348 | } | 293 | pub fn owned(&self) -> BreakExprNode { |
349 | 294 | BreakExprNode { syntax: self.syntax.owned() } | |
350 | impl<'a> From<CallExpr<'a>> for CallExprNode { | ||
351 | fn from(ast: CallExpr<'a>) -> CallExprNode { | ||
352 | let syntax = ast.syntax().owned(); | ||
353 | CallExprNode(syntax) | ||
354 | } | 295 | } |
355 | } | 296 | } |
297 | |||
298 | |||
299 | impl<'a> BreakExpr<'a> {} | ||
300 | |||
301 | // CallExpr | ||
356 | #[derive(Debug, Clone, Copy)] | 302 | #[derive(Debug, Clone, Copy)] |
357 | pub struct CallExpr<'a> { | 303 | pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
358 | syntax: SyntaxNodeRef<'a>, | 304 | syntax: SyntaxNode<R>, |
359 | } | 305 | } |
306 | pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>; | ||
360 | 307 | ||
361 | impl<'a> AstNode<'a> for CallExpr<'a> { | 308 | impl<'a> AstNode<'a> for CallExpr<'a> { |
362 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 309 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -368,6 +315,16 @@ impl<'a> AstNode<'a> for CallExpr<'a> { | |||
368 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 315 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
369 | } | 316 | } |
370 | 317 | ||
318 | impl<R: TreeRoot<RaTypes>> CallExprNode<R> { | ||
319 | pub fn borrowed(&self) -> CallExpr { | ||
320 | CallExprNode { syntax: self.syntax.borrowed() } | ||
321 | } | ||
322 | pub fn owned(&self) -> CallExprNode { | ||
323 | CallExprNode { syntax: self.syntax.owned() } | ||
324 | } | ||
325 | } | ||
326 | |||
327 | |||
371 | impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} | 328 | impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} |
372 | impl<'a> CallExpr<'a> { | 329 | impl<'a> CallExpr<'a> { |
373 | pub fn expr(self) -> Option<Expr<'a>> { | 330 | pub fn expr(self) -> Option<Expr<'a>> { |
@@ -376,26 +333,11 @@ impl<'a> CallExpr<'a> { | |||
376 | } | 333 | } |
377 | 334 | ||
378 | // CastExpr | 335 | // CastExpr |
379 | |||
380 | #[derive(Debug, Clone)] | ||
381 | pub struct CastExprNode(SyntaxNode); | ||
382 | |||
383 | impl CastExprNode { | ||
384 | pub fn ast(&self) -> CastExpr { | ||
385 | CastExpr::cast(self.0.borrowed()).unwrap() | ||
386 | } | ||
387 | } | ||
388 | |||
389 | impl<'a> From<CastExpr<'a>> for CastExprNode { | ||
390 | fn from(ast: CastExpr<'a>) -> CastExprNode { | ||
391 | let syntax = ast.syntax().owned(); | ||
392 | CastExprNode(syntax) | ||
393 | } | ||
394 | } | ||
395 | #[derive(Debug, Clone, Copy)] | 336 | #[derive(Debug, Clone, Copy)] |
396 | pub struct CastExpr<'a> { | 337 | pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
397 | syntax: SyntaxNodeRef<'a>, | 338 | syntax: SyntaxNode<R>, |
398 | } | 339 | } |
340 | pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>; | ||
399 | 341 | ||
400 | impl<'a> AstNode<'a> for CastExpr<'a> { | 342 | impl<'a> AstNode<'a> for CastExpr<'a> { |
401 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 343 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -407,29 +349,24 @@ impl<'a> AstNode<'a> for CastExpr<'a> { | |||
407 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 349 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
408 | } | 350 | } |
409 | 351 | ||
410 | impl<'a> CastExpr<'a> {} | 352 | impl<R: TreeRoot<RaTypes>> CastExprNode<R> { |
411 | 353 | pub fn borrowed(&self) -> CastExpr { | |
412 | // Char | 354 | CastExprNode { syntax: self.syntax.borrowed() } |
413 | |||
414 | #[derive(Debug, Clone)] | ||
415 | pub struct CharNode(SyntaxNode); | ||
416 | |||
417 | impl CharNode { | ||
418 | pub fn ast(&self) -> Char { | ||
419 | Char::cast(self.0.borrowed()).unwrap() | ||
420 | } | 355 | } |
421 | } | 356 | pub fn owned(&self) -> CastExprNode { |
422 | 357 | CastExprNode { syntax: self.syntax.owned() } | |
423 | impl<'a> From<Char<'a>> for CharNode { | ||
424 | fn from(ast: Char<'a>) -> CharNode { | ||
425 | let syntax = ast.syntax().owned(); | ||
426 | CharNode(syntax) | ||
427 | } | 358 | } |
428 | } | 359 | } |
360 | |||
361 | |||
362 | impl<'a> CastExpr<'a> {} | ||
363 | |||
364 | // Char | ||
429 | #[derive(Debug, Clone, Copy)] | 365 | #[derive(Debug, Clone, Copy)] |
430 | pub struct Char<'a> { | 366 | pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
431 | syntax: SyntaxNodeRef<'a>, | 367 | syntax: SyntaxNode<R>, |
432 | } | 368 | } |
369 | pub type Char<'a> = CharNode<RefRoot<'a>>; | ||
433 | 370 | ||
434 | impl<'a> AstNode<'a> for Char<'a> { | 371 | impl<'a> AstNode<'a> for Char<'a> { |
435 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 372 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -441,29 +378,24 @@ impl<'a> AstNode<'a> for Char<'a> { | |||
441 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 378 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
442 | } | 379 | } |
443 | 380 | ||
444 | impl<'a> Char<'a> {} | 381 | impl<R: TreeRoot<RaTypes>> CharNode<R> { |
445 | 382 | pub fn borrowed(&self) -> Char { | |
446 | // Comment | 383 | CharNode { syntax: self.syntax.borrowed() } |
447 | |||
448 | #[derive(Debug, Clone)] | ||
449 | pub struct CommentNode(SyntaxNode); | ||
450 | |||
451 | impl CommentNode { | ||
452 | pub fn ast(&self) -> Comment { | ||
453 | Comment::cast(self.0.borrowed()).unwrap() | ||
454 | } | 384 | } |
455 | } | 385 | pub fn owned(&self) -> CharNode { |
456 | 386 | CharNode { syntax: self.syntax.owned() } | |
457 | impl<'a> From<Comment<'a>> for CommentNode { | ||
458 | fn from(ast: Comment<'a>) -> CommentNode { | ||
459 | let syntax = ast.syntax().owned(); | ||
460 | CommentNode(syntax) | ||
461 | } | 387 | } |
462 | } | 388 | } |
389 | |||
390 | |||
391 | impl<'a> Char<'a> {} | ||
392 | |||
393 | // Comment | ||
463 | #[derive(Debug, Clone, Copy)] | 394 | #[derive(Debug, Clone, Copy)] |
464 | pub struct Comment<'a> { | 395 | pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
465 | syntax: SyntaxNodeRef<'a>, | 396 | syntax: SyntaxNode<R>, |
466 | } | 397 | } |
398 | pub type Comment<'a> = CommentNode<RefRoot<'a>>; | ||
467 | 399 | ||
468 | impl<'a> AstNode<'a> for Comment<'a> { | 400 | impl<'a> AstNode<'a> for Comment<'a> { |
469 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 401 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -475,29 +407,24 @@ impl<'a> AstNode<'a> for Comment<'a> { | |||
475 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 407 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
476 | } | 408 | } |
477 | 409 | ||
478 | impl<'a> Comment<'a> {} | 410 | impl<R: TreeRoot<RaTypes>> CommentNode<R> { |
479 | 411 | pub fn borrowed(&self) -> Comment { | |
480 | // Condition | 412 | CommentNode { syntax: self.syntax.borrowed() } |
481 | |||
482 | #[derive(Debug, Clone)] | ||
483 | pub struct ConditionNode(SyntaxNode); | ||
484 | |||
485 | impl ConditionNode { | ||
486 | pub fn ast(&self) -> Condition { | ||
487 | Condition::cast(self.0.borrowed()).unwrap() | ||
488 | } | 413 | } |
489 | } | 414 | pub fn owned(&self) -> CommentNode { |
490 | 415 | CommentNode { syntax: self.syntax.owned() } | |
491 | impl<'a> From<Condition<'a>> for ConditionNode { | ||
492 | fn from(ast: Condition<'a>) -> ConditionNode { | ||
493 | let syntax = ast.syntax().owned(); | ||
494 | ConditionNode(syntax) | ||
495 | } | 416 | } |
496 | } | 417 | } |
418 | |||
419 | |||
420 | impl<'a> Comment<'a> {} | ||
421 | |||
422 | // Condition | ||
497 | #[derive(Debug, Clone, Copy)] | 423 | #[derive(Debug, Clone, Copy)] |
498 | pub struct Condition<'a> { | 424 | pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
499 | syntax: SyntaxNodeRef<'a>, | 425 | syntax: SyntaxNode<R>, |
500 | } | 426 | } |
427 | pub type Condition<'a> = ConditionNode<RefRoot<'a>>; | ||
501 | 428 | ||
502 | impl<'a> AstNode<'a> for Condition<'a> { | 429 | impl<'a> AstNode<'a> for Condition<'a> { |
503 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 430 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -509,6 +436,16 @@ impl<'a> AstNode<'a> for Condition<'a> { | |||
509 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 436 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
510 | } | 437 | } |
511 | 438 | ||
439 | impl<R: TreeRoot<RaTypes>> ConditionNode<R> { | ||
440 | pub fn borrowed(&self) -> Condition { | ||
441 | ConditionNode { syntax: self.syntax.borrowed() } | ||
442 | } | ||
443 | pub fn owned(&self) -> ConditionNode { | ||
444 | ConditionNode { syntax: self.syntax.owned() } | ||
445 | } | ||
446 | } | ||
447 | |||
448 | |||
512 | impl<'a> Condition<'a> { | 449 | impl<'a> Condition<'a> { |
513 | pub fn pat(self) -> Option<Pat<'a>> { | 450 | pub fn pat(self) -> Option<Pat<'a>> { |
514 | super::child_opt(self) | 451 | super::child_opt(self) |
@@ -520,26 +457,11 @@ impl<'a> Condition<'a> { | |||
520 | } | 457 | } |
521 | 458 | ||
522 | // ConstDef | 459 | // ConstDef |
523 | |||
524 | #[derive(Debug, Clone)] | ||
525 | pub struct ConstDefNode(SyntaxNode); | ||
526 | |||
527 | impl ConstDefNode { | ||
528 | pub fn ast(&self) -> ConstDef { | ||
529 | ConstDef::cast(self.0.borrowed()).unwrap() | ||
530 | } | ||
531 | } | ||
532 | |||
533 | impl<'a> From<ConstDef<'a>> for ConstDefNode { | ||
534 | fn from(ast: ConstDef<'a>) -> ConstDefNode { | ||
535 | let syntax = ast.syntax().owned(); | ||
536 | ConstDefNode(syntax) | ||
537 | } | ||
538 | } | ||
539 | #[derive(Debug, Clone, Copy)] | 460 | #[derive(Debug, Clone, Copy)] |
540 | pub struct ConstDef<'a> { | 461 | pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
541 | syntax: SyntaxNodeRef<'a>, | 462 | syntax: SyntaxNode<R>, |
542 | } | 463 | } |
464 | pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>; | ||
543 | 465 | ||
544 | impl<'a> AstNode<'a> for ConstDef<'a> { | 466 | impl<'a> AstNode<'a> for ConstDef<'a> { |
545 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 467 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -551,32 +473,27 @@ impl<'a> AstNode<'a> for ConstDef<'a> { | |||
551 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 473 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
552 | } | 474 | } |
553 | 475 | ||
476 | impl<R: TreeRoot<RaTypes>> ConstDefNode<R> { | ||
477 | pub fn borrowed(&self) -> ConstDef { | ||
478 | ConstDefNode { syntax: self.syntax.borrowed() } | ||
479 | } | ||
480 | pub fn owned(&self) -> ConstDefNode { | ||
481 | ConstDefNode { syntax: self.syntax.owned() } | ||
482 | } | ||
483 | } | ||
484 | |||
485 | |||
554 | impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} | 486 | impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} |
555 | impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} | 487 | impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} |
556 | impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} | 488 | impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} |
557 | impl<'a> ConstDef<'a> {} | 489 | impl<'a> ConstDef<'a> {} |
558 | 490 | ||
559 | // ContinueExpr | 491 | // ContinueExpr |
560 | |||
561 | #[derive(Debug, Clone)] | ||
562 | pub struct ContinueExprNode(SyntaxNode); | ||
563 | |||
564 | impl ContinueExprNode { | ||
565 | pub fn ast(&self) -> ContinueExpr { | ||
566 | ContinueExpr::cast(self.0.borrowed()).unwrap() | ||
567 | } | ||
568 | } | ||
569 | |||
570 | impl<'a> From<ContinueExpr<'a>> for ContinueExprNode { | ||
571 | fn from(ast: ContinueExpr<'a>) -> ContinueExprNode { | ||
572 | let syntax = ast.syntax().owned(); | ||
573 | ContinueExprNode(syntax) | ||
574 | } | ||
575 | } | ||
576 | #[derive(Debug, Clone, Copy)] | 492 | #[derive(Debug, Clone, Copy)] |
577 | pub struct ContinueExpr<'a> { | 493 | pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
578 | syntax: SyntaxNodeRef<'a>, | 494 | syntax: SyntaxNode<R>, |
579 | } | 495 | } |
496 | pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>; | ||
580 | 497 | ||
581 | impl<'a> AstNode<'a> for ContinueExpr<'a> { | 498 | impl<'a> AstNode<'a> for ContinueExpr<'a> { |
582 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 499 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -588,29 +505,24 @@ impl<'a> AstNode<'a> for ContinueExpr<'a> { | |||
588 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 505 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
589 | } | 506 | } |
590 | 507 | ||
591 | impl<'a> ContinueExpr<'a> {} | 508 | impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> { |
592 | 509 | pub fn borrowed(&self) -> ContinueExpr { | |
593 | // DynTraitType | 510 | ContinueExprNode { syntax: self.syntax.borrowed() } |
594 | |||
595 | #[derive(Debug, Clone)] | ||
596 | pub struct DynTraitTypeNode(SyntaxNode); | ||
597 | |||
598 | impl DynTraitTypeNode { | ||
599 | pub fn ast(&self) -> DynTraitType { | ||
600 | DynTraitType::cast(self.0.borrowed()).unwrap() | ||
601 | } | 511 | } |
602 | } | 512 | pub fn owned(&self) -> ContinueExprNode { |
603 | 513 | ContinueExprNode { syntax: self.syntax.owned() } | |
604 | impl<'a> From<DynTraitType<'a>> for DynTraitTypeNode { | ||
605 | fn from(ast: DynTraitType<'a>) -> DynTraitTypeNode { | ||
606 | let syntax = ast.syntax().owned(); | ||
607 | DynTraitTypeNode(syntax) | ||
608 | } | 514 | } |
609 | } | 515 | } |
516 | |||
517 | |||
518 | impl<'a> ContinueExpr<'a> {} | ||
519 | |||
520 | // DynTraitType | ||
610 | #[derive(Debug, Clone, Copy)] | 521 | #[derive(Debug, Clone, Copy)] |
611 | pub struct DynTraitType<'a> { | 522 | pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
612 | syntax: SyntaxNodeRef<'a>, | 523 | syntax: SyntaxNode<R>, |
613 | } | 524 | } |
525 | pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>; | ||
614 | 526 | ||
615 | impl<'a> AstNode<'a> for DynTraitType<'a> { | 527 | impl<'a> AstNode<'a> for DynTraitType<'a> { |
616 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 528 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -622,29 +534,24 @@ impl<'a> AstNode<'a> for DynTraitType<'a> { | |||
622 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 534 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
623 | } | 535 | } |
624 | 536 | ||
625 | impl<'a> DynTraitType<'a> {} | 537 | impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> { |
626 | 538 | pub fn borrowed(&self) -> DynTraitType { | |
627 | // EnumDef | 539 | DynTraitTypeNode { syntax: self.syntax.borrowed() } |
628 | |||
629 | #[derive(Debug, Clone)] | ||
630 | pub struct EnumDefNode(SyntaxNode); | ||
631 | |||
632 | impl EnumDefNode { | ||
633 | pub fn ast(&self) -> EnumDef { | ||
634 | EnumDef::cast(self.0.borrowed()).unwrap() | ||
635 | } | 540 | } |
636 | } | 541 | pub fn owned(&self) -> DynTraitTypeNode { |
637 | 542 | DynTraitTypeNode { syntax: self.syntax.owned() } | |
638 | impl<'a> From<EnumDef<'a>> for EnumDefNode { | ||
639 | fn from(ast: EnumDef<'a>) -> EnumDefNode { | ||
640 | let syntax = ast.syntax().owned(); | ||
641 | EnumDefNode(syntax) | ||
642 | } | 543 | } |
643 | } | 544 | } |
545 | |||
546 | |||
547 | impl<'a> DynTraitType<'a> {} | ||
548 | |||
549 | // EnumDef | ||
644 | #[derive(Debug, Clone, Copy)] | 550 | #[derive(Debug, Clone, Copy)] |
645 | pub struct EnumDef<'a> { | 551 | pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
646 | syntax: SyntaxNodeRef<'a>, | 552 | syntax: SyntaxNode<R>, |
647 | } | 553 | } |
554 | pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>; | ||
648 | 555 | ||
649 | impl<'a> AstNode<'a> for EnumDef<'a> { | 556 | impl<'a> AstNode<'a> for EnumDef<'a> { |
650 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 557 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -656,28 +563,22 @@ impl<'a> AstNode<'a> for EnumDef<'a> { | |||
656 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 563 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
657 | } | 564 | } |
658 | 565 | ||
566 | impl<R: TreeRoot<RaTypes>> EnumDefNode<R> { | ||
567 | pub fn borrowed(&self) -> EnumDef { | ||
568 | EnumDefNode { syntax: self.syntax.borrowed() } | ||
569 | } | ||
570 | pub fn owned(&self) -> EnumDefNode { | ||
571 | EnumDefNode { syntax: self.syntax.owned() } | ||
572 | } | ||
573 | } | ||
574 | |||
575 | |||
659 | impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} | 576 | impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} |
660 | impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} | 577 | impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} |
661 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} | 578 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} |
662 | impl<'a> EnumDef<'a> {} | 579 | impl<'a> EnumDef<'a> {} |
663 | 580 | ||
664 | // Expr | 581 | // Expr |
665 | |||
666 | #[derive(Debug, Clone)] | ||
667 | pub struct ExprNode(SyntaxNode); | ||
668 | |||
669 | impl ExprNode { | ||
670 | pub fn ast(&self) -> Expr { | ||
671 | Expr::cast(self.0.borrowed()).unwrap() | ||
672 | } | ||
673 | } | ||
674 | |||
675 | impl<'a> From<Expr<'a>> for ExprNode { | ||
676 | fn from(ast: Expr<'a>) -> ExprNode { | ||
677 | let syntax = ast.syntax().owned(); | ||
678 | ExprNode(syntax) | ||
679 | } | ||
680 | } | ||
681 | #[derive(Debug, Clone, Copy)] | 582 | #[derive(Debug, Clone, Copy)] |
682 | pub enum Expr<'a> { | 583 | pub enum Expr<'a> { |
683 | TupleExpr(TupleExpr<'a>), | 584 | TupleExpr(TupleExpr<'a>), |
@@ -793,26 +694,11 @@ impl<'a> AstNode<'a> for Expr<'a> { | |||
793 | impl<'a> Expr<'a> {} | 694 | impl<'a> Expr<'a> {} |
794 | 695 | ||
795 | // ExprStmt | 696 | // ExprStmt |
796 | |||
797 | #[derive(Debug, Clone)] | ||
798 | pub struct ExprStmtNode(SyntaxNode); | ||
799 | |||
800 | impl ExprStmtNode { | ||
801 | pub fn ast(&self) -> ExprStmt { | ||
802 | ExprStmt::cast(self.0.borrowed()).unwrap() | ||
803 | } | ||
804 | } | ||
805 | |||
806 | impl<'a> From<ExprStmt<'a>> for ExprStmtNode { | ||
807 | fn from(ast: ExprStmt<'a>) -> ExprStmtNode { | ||
808 | let syntax = ast.syntax().owned(); | ||
809 | ExprStmtNode(syntax) | ||
810 | } | ||
811 | } | ||
812 | #[derive(Debug, Clone, Copy)] | 697 | #[derive(Debug, Clone, Copy)] |
813 | pub struct ExprStmt<'a> { | 698 | pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
814 | syntax: SyntaxNodeRef<'a>, | 699 | syntax: SyntaxNode<R>, |
815 | } | 700 | } |
701 | pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>; | ||
816 | 702 | ||
817 | impl<'a> AstNode<'a> for ExprStmt<'a> { | 703 | impl<'a> AstNode<'a> for ExprStmt<'a> { |
818 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 704 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -824,33 +710,28 @@ impl<'a> AstNode<'a> for ExprStmt<'a> { | |||
824 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 710 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
825 | } | 711 | } |
826 | 712 | ||
827 | impl<'a> ExprStmt<'a> { | 713 | impl<R: TreeRoot<RaTypes>> ExprStmtNode<R> { |
828 | pub fn expr(self) -> Option<Expr<'a>> { | 714 | pub fn borrowed(&self) -> ExprStmt { |
829 | super::child_opt(self) | 715 | ExprStmtNode { syntax: self.syntax.borrowed() } |
716 | } | ||
717 | pub fn owned(&self) -> ExprStmtNode { | ||
718 | ExprStmtNode { syntax: self.syntax.owned() } | ||
830 | } | 719 | } |
831 | } | 720 | } |
832 | 721 | ||
833 | // ExternCrateItem | ||
834 | |||
835 | #[derive(Debug, Clone)] | ||
836 | pub struct ExternCrateItemNode(SyntaxNode); | ||
837 | 722 | ||
838 | impl ExternCrateItemNode { | 723 | impl<'a> ExprStmt<'a> { |
839 | pub fn ast(&self) -> ExternCrateItem { | 724 | pub fn expr(self) -> Option<Expr<'a>> { |
840 | ExternCrateItem::cast(self.0.borrowed()).unwrap() | 725 | super::child_opt(self) |
841 | } | 726 | } |
842 | } | 727 | } |
843 | 728 | ||
844 | impl<'a> From<ExternCrateItem<'a>> for ExternCrateItemNode { | 729 | // ExternCrateItem |
845 | fn from(ast: ExternCrateItem<'a>) -> ExternCrateItemNode { | ||
846 | let syntax = ast.syntax().owned(); | ||
847 | ExternCrateItemNode(syntax) | ||
848 | } | ||
849 | } | ||
850 | #[derive(Debug, Clone, Copy)] | 730 | #[derive(Debug, Clone, Copy)] |
851 | pub struct ExternCrateItem<'a> { | 731 | pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
852 | syntax: SyntaxNodeRef<'a>, | 732 | syntax: SyntaxNode<R>, |
853 | } | 733 | } |
734 | pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>; | ||
854 | 735 | ||
855 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { | 736 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { |
856 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 737 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -862,29 +743,24 @@ impl<'a> AstNode<'a> for ExternCrateItem<'a> { | |||
862 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 743 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
863 | } | 744 | } |
864 | 745 | ||
865 | impl<'a> ExternCrateItem<'a> {} | 746 | impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> { |
866 | 747 | pub fn borrowed(&self) -> ExternCrateItem { | |
867 | // FieldExpr | 748 | ExternCrateItemNode { syntax: self.syntax.borrowed() } |
868 | |||
869 | #[derive(Debug, Clone)] | ||
870 | pub struct FieldExprNode(SyntaxNode); | ||
871 | |||
872 | impl FieldExprNode { | ||
873 | pub fn ast(&self) -> FieldExpr { | ||
874 | FieldExpr::cast(self.0.borrowed()).unwrap() | ||
875 | } | 749 | } |
876 | } | 750 | pub fn owned(&self) -> ExternCrateItemNode { |
877 | 751 | ExternCrateItemNode { syntax: self.syntax.owned() } | |
878 | impl<'a> From<FieldExpr<'a>> for FieldExprNode { | ||
879 | fn from(ast: FieldExpr<'a>) -> FieldExprNode { | ||
880 | let syntax = ast.syntax().owned(); | ||
881 | FieldExprNode(syntax) | ||
882 | } | 752 | } |
883 | } | 753 | } |
754 | |||
755 | |||
756 | impl<'a> ExternCrateItem<'a> {} | ||
757 | |||
758 | // FieldExpr | ||
884 | #[derive(Debug, Clone, Copy)] | 759 | #[derive(Debug, Clone, Copy)] |
885 | pub struct FieldExpr<'a> { | 760 | pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
886 | syntax: SyntaxNodeRef<'a>, | 761 | syntax: SyntaxNode<R>, |
887 | } | 762 | } |
763 | pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>; | ||
888 | 764 | ||
889 | impl<'a> AstNode<'a> for FieldExpr<'a> { | 765 | impl<'a> AstNode<'a> for FieldExpr<'a> { |
890 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 766 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -896,29 +772,24 @@ impl<'a> AstNode<'a> for FieldExpr<'a> { | |||
896 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 772 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
897 | } | 773 | } |
898 | 774 | ||
899 | impl<'a> FieldExpr<'a> {} | 775 | impl<R: TreeRoot<RaTypes>> FieldExprNode<R> { |
900 | 776 | pub fn borrowed(&self) -> FieldExpr { | |
901 | // FieldPatList | 777 | FieldExprNode { syntax: self.syntax.borrowed() } |
902 | |||
903 | #[derive(Debug, Clone)] | ||
904 | pub struct FieldPatListNode(SyntaxNode); | ||
905 | |||
906 | impl FieldPatListNode { | ||
907 | pub fn ast(&self) -> FieldPatList { | ||
908 | FieldPatList::cast(self.0.borrowed()).unwrap() | ||
909 | } | 778 | } |
910 | } | 779 | pub fn owned(&self) -> FieldExprNode { |
911 | 780 | FieldExprNode { syntax: self.syntax.owned() } | |
912 | impl<'a> From<FieldPatList<'a>> for FieldPatListNode { | ||
913 | fn from(ast: FieldPatList<'a>) -> FieldPatListNode { | ||
914 | let syntax = ast.syntax().owned(); | ||
915 | FieldPatListNode(syntax) | ||
916 | } | 781 | } |
917 | } | 782 | } |
783 | |||
784 | |||
785 | impl<'a> FieldExpr<'a> {} | ||
786 | |||
787 | // FieldPatList | ||
918 | #[derive(Debug, Clone, Copy)] | 788 | #[derive(Debug, Clone, Copy)] |
919 | pub struct FieldPatList<'a> { | 789 | pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
920 | syntax: SyntaxNodeRef<'a>, | 790 | syntax: SyntaxNode<R>, |
921 | } | 791 | } |
792 | pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>; | ||
922 | 793 | ||
923 | impl<'a> AstNode<'a> for FieldPatList<'a> { | 794 | impl<'a> AstNode<'a> for FieldPatList<'a> { |
924 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 795 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -930,29 +801,24 @@ impl<'a> AstNode<'a> for FieldPatList<'a> { | |||
930 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 801 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
931 | } | 802 | } |
932 | 803 | ||
933 | impl<'a> FieldPatList<'a> {} | 804 | impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> { |
934 | 805 | pub fn borrowed(&self) -> FieldPatList { | |
935 | // FnDef | 806 | FieldPatListNode { syntax: self.syntax.borrowed() } |
936 | |||
937 | #[derive(Debug, Clone)] | ||
938 | pub struct FnDefNode(SyntaxNode); | ||
939 | |||
940 | impl FnDefNode { | ||
941 | pub fn ast(&self) -> FnDef { | ||
942 | FnDef::cast(self.0.borrowed()).unwrap() | ||
943 | } | 807 | } |
944 | } | 808 | pub fn owned(&self) -> FieldPatListNode { |
945 | 809 | FieldPatListNode { syntax: self.syntax.owned() } | |
946 | impl<'a> From<FnDef<'a>> for FnDefNode { | ||
947 | fn from(ast: FnDef<'a>) -> FnDefNode { | ||
948 | let syntax = ast.syntax().owned(); | ||
949 | FnDefNode(syntax) | ||
950 | } | 810 | } |
951 | } | 811 | } |
812 | |||
813 | |||
814 | impl<'a> FieldPatList<'a> {} | ||
815 | |||
816 | // FnDef | ||
952 | #[derive(Debug, Clone, Copy)] | 817 | #[derive(Debug, Clone, Copy)] |
953 | pub struct FnDef<'a> { | 818 | pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
954 | syntax: SyntaxNodeRef<'a>, | 819 | syntax: SyntaxNode<R>, |
955 | } | 820 | } |
821 | pub type FnDef<'a> = FnDefNode<RefRoot<'a>>; | ||
956 | 822 | ||
957 | impl<'a> AstNode<'a> for FnDef<'a> { | 823 | impl<'a> AstNode<'a> for FnDef<'a> { |
958 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 824 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -964,6 +830,16 @@ impl<'a> AstNode<'a> for FnDef<'a> { | |||
964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 830 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
965 | } | 831 | } |
966 | 832 | ||
833 | impl<R: TreeRoot<RaTypes>> FnDefNode<R> { | ||
834 | pub fn borrowed(&self) -> FnDef { | ||
835 | FnDefNode { syntax: self.syntax.borrowed() } | ||
836 | } | ||
837 | pub fn owned(&self) -> FnDefNode { | ||
838 | FnDefNode { syntax: self.syntax.owned() } | ||
839 | } | ||
840 | } | ||
841 | |||
842 | |||
967 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} | 843 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} |
968 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} | 844 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} |
969 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} | 845 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} |
@@ -983,26 +859,11 @@ impl<'a> FnDef<'a> { | |||
983 | } | 859 | } |
984 | 860 | ||
985 | // FnPointerType | 861 | // FnPointerType |
986 | |||
987 | #[derive(Debug, Clone)] | ||
988 | pub struct FnPointerTypeNode(SyntaxNode); | ||
989 | |||
990 | impl FnPointerTypeNode { | ||
991 | pub fn ast(&self) -> FnPointerType { | ||
992 | FnPointerType::cast(self.0.borrowed()).unwrap() | ||
993 | } | ||
994 | } | ||
995 | |||
996 | impl<'a> From<FnPointerType<'a>> for FnPointerTypeNode { | ||
997 | fn from(ast: FnPointerType<'a>) -> FnPointerTypeNode { | ||
998 | let syntax = ast.syntax().owned(); | ||
999 | FnPointerTypeNode(syntax) | ||
1000 | } | ||
1001 | } | ||
1002 | #[derive(Debug, Clone, Copy)] | 862 | #[derive(Debug, Clone, Copy)] |
1003 | pub struct FnPointerType<'a> { | 863 | pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1004 | syntax: SyntaxNodeRef<'a>, | 864 | syntax: SyntaxNode<R>, |
1005 | } | 865 | } |
866 | pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>; | ||
1006 | 867 | ||
1007 | impl<'a> AstNode<'a> for FnPointerType<'a> { | 868 | impl<'a> AstNode<'a> for FnPointerType<'a> { |
1008 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 869 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1014,29 +875,24 @@ impl<'a> AstNode<'a> for FnPointerType<'a> { | |||
1014 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 875 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1015 | } | 876 | } |
1016 | 877 | ||
1017 | impl<'a> FnPointerType<'a> {} | 878 | impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> { |
1018 | 879 | pub fn borrowed(&self) -> FnPointerType { | |
1019 | // ForExpr | 880 | FnPointerTypeNode { syntax: self.syntax.borrowed() } |
1020 | |||
1021 | #[derive(Debug, Clone)] | ||
1022 | pub struct ForExprNode(SyntaxNode); | ||
1023 | |||
1024 | impl ForExprNode { | ||
1025 | pub fn ast(&self) -> ForExpr { | ||
1026 | ForExpr::cast(self.0.borrowed()).unwrap() | ||
1027 | } | 881 | } |
1028 | } | 882 | pub fn owned(&self) -> FnPointerTypeNode { |
1029 | 883 | FnPointerTypeNode { syntax: self.syntax.owned() } | |
1030 | impl<'a> From<ForExpr<'a>> for ForExprNode { | ||
1031 | fn from(ast: ForExpr<'a>) -> ForExprNode { | ||
1032 | let syntax = ast.syntax().owned(); | ||
1033 | ForExprNode(syntax) | ||
1034 | } | 884 | } |
1035 | } | 885 | } |
886 | |||
887 | |||
888 | impl<'a> FnPointerType<'a> {} | ||
889 | |||
890 | // ForExpr | ||
1036 | #[derive(Debug, Clone, Copy)] | 891 | #[derive(Debug, Clone, Copy)] |
1037 | pub struct ForExpr<'a> { | 892 | pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1038 | syntax: SyntaxNodeRef<'a>, | 893 | syntax: SyntaxNode<R>, |
1039 | } | 894 | } |
895 | pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>; | ||
1040 | 896 | ||
1041 | impl<'a> AstNode<'a> for ForExpr<'a> { | 897 | impl<'a> AstNode<'a> for ForExpr<'a> { |
1042 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 898 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1048,6 +904,16 @@ impl<'a> AstNode<'a> for ForExpr<'a> { | |||
1048 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 904 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1049 | } | 905 | } |
1050 | 906 | ||
907 | impl<R: TreeRoot<RaTypes>> ForExprNode<R> { | ||
908 | pub fn borrowed(&self) -> ForExpr { | ||
909 | ForExprNode { syntax: self.syntax.borrowed() } | ||
910 | } | ||
911 | pub fn owned(&self) -> ForExprNode { | ||
912 | ForExprNode { syntax: self.syntax.owned() } | ||
913 | } | ||
914 | } | ||
915 | |||
916 | |||
1051 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} | 917 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} |
1052 | impl<'a> ForExpr<'a> { | 918 | impl<'a> ForExpr<'a> { |
1053 | pub fn pat(self) -> Option<Pat<'a>> { | 919 | pub fn pat(self) -> Option<Pat<'a>> { |
@@ -1060,26 +926,11 @@ impl<'a> ForExpr<'a> { | |||
1060 | } | 926 | } |
1061 | 927 | ||
1062 | // ForType | 928 | // ForType |
1063 | |||
1064 | #[derive(Debug, Clone)] | ||
1065 | pub struct ForTypeNode(SyntaxNode); | ||
1066 | |||
1067 | impl ForTypeNode { | ||
1068 | pub fn ast(&self) -> ForType { | ||
1069 | ForType::cast(self.0.borrowed()).unwrap() | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | impl<'a> From<ForType<'a>> for ForTypeNode { | ||
1074 | fn from(ast: ForType<'a>) -> ForTypeNode { | ||
1075 | let syntax = ast.syntax().owned(); | ||
1076 | ForTypeNode(syntax) | ||
1077 | } | ||
1078 | } | ||
1079 | #[derive(Debug, Clone, Copy)] | 929 | #[derive(Debug, Clone, Copy)] |
1080 | pub struct ForType<'a> { | 930 | pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1081 | syntax: SyntaxNodeRef<'a>, | 931 | syntax: SyntaxNode<R>, |
1082 | } | 932 | } |
933 | pub type ForType<'a> = ForTypeNode<RefRoot<'a>>; | ||
1083 | 934 | ||
1084 | impl<'a> AstNode<'a> for ForType<'a> { | 935 | impl<'a> AstNode<'a> for ForType<'a> { |
1085 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 936 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1091,29 +942,24 @@ impl<'a> AstNode<'a> for ForType<'a> { | |||
1091 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 942 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1092 | } | 943 | } |
1093 | 944 | ||
1094 | impl<'a> ForType<'a> {} | 945 | impl<R: TreeRoot<RaTypes>> ForTypeNode<R> { |
1095 | 946 | pub fn borrowed(&self) -> ForType { | |
1096 | // IfExpr | 947 | ForTypeNode { syntax: self.syntax.borrowed() } |
1097 | |||
1098 | #[derive(Debug, Clone)] | ||
1099 | pub struct IfExprNode(SyntaxNode); | ||
1100 | |||
1101 | impl IfExprNode { | ||
1102 | pub fn ast(&self) -> IfExpr { | ||
1103 | IfExpr::cast(self.0.borrowed()).unwrap() | ||
1104 | } | 948 | } |
1105 | } | 949 | pub fn owned(&self) -> ForTypeNode { |
1106 | 950 | ForTypeNode { syntax: self.syntax.owned() } | |
1107 | impl<'a> From<IfExpr<'a>> for IfExprNode { | ||
1108 | fn from(ast: IfExpr<'a>) -> IfExprNode { | ||
1109 | let syntax = ast.syntax().owned(); | ||
1110 | IfExprNode(syntax) | ||
1111 | } | 951 | } |
1112 | } | 952 | } |
953 | |||
954 | |||
955 | impl<'a> ForType<'a> {} | ||
956 | |||
957 | // IfExpr | ||
1113 | #[derive(Debug, Clone, Copy)] | 958 | #[derive(Debug, Clone, Copy)] |
1114 | pub struct IfExpr<'a> { | 959 | pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1115 | syntax: SyntaxNodeRef<'a>, | 960 | syntax: SyntaxNode<R>, |
1116 | } | 961 | } |
962 | pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>; | ||
1117 | 963 | ||
1118 | impl<'a> AstNode<'a> for IfExpr<'a> { | 964 | impl<'a> AstNode<'a> for IfExpr<'a> { |
1119 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 965 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1125,33 +971,28 @@ impl<'a> AstNode<'a> for IfExpr<'a> { | |||
1125 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 971 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1126 | } | 972 | } |
1127 | 973 | ||
1128 | impl<'a> IfExpr<'a> { | 974 | impl<R: TreeRoot<RaTypes>> IfExprNode<R> { |
1129 | pub fn condition(self) -> Option<Condition<'a>> { | 975 | pub fn borrowed(&self) -> IfExpr { |
1130 | super::child_opt(self) | 976 | IfExprNode { syntax: self.syntax.borrowed() } |
977 | } | ||
978 | pub fn owned(&self) -> IfExprNode { | ||
979 | IfExprNode { syntax: self.syntax.owned() } | ||
1131 | } | 980 | } |
1132 | } | 981 | } |
1133 | 982 | ||
1134 | // ImplItem | ||
1135 | |||
1136 | #[derive(Debug, Clone)] | ||
1137 | pub struct ImplItemNode(SyntaxNode); | ||
1138 | 983 | ||
1139 | impl ImplItemNode { | 984 | impl<'a> IfExpr<'a> { |
1140 | pub fn ast(&self) -> ImplItem { | 985 | pub fn condition(self) -> Option<Condition<'a>> { |
1141 | ImplItem::cast(self.0.borrowed()).unwrap() | 986 | super::child_opt(self) |
1142 | } | 987 | } |
1143 | } | 988 | } |
1144 | 989 | ||
1145 | impl<'a> From<ImplItem<'a>> for ImplItemNode { | 990 | // ImplItem |
1146 | fn from(ast: ImplItem<'a>) -> ImplItemNode { | ||
1147 | let syntax = ast.syntax().owned(); | ||
1148 | ImplItemNode(syntax) | ||
1149 | } | ||
1150 | } | ||
1151 | #[derive(Debug, Clone, Copy)] | 991 | #[derive(Debug, Clone, Copy)] |
1152 | pub struct ImplItem<'a> { | 992 | pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1153 | syntax: SyntaxNodeRef<'a>, | 993 | syntax: SyntaxNode<R>, |
1154 | } | 994 | } |
995 | pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>; | ||
1155 | 996 | ||
1156 | impl<'a> AstNode<'a> for ImplItem<'a> { | 997 | impl<'a> AstNode<'a> for ImplItem<'a> { |
1157 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 998 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1163,29 +1004,24 @@ impl<'a> AstNode<'a> for ImplItem<'a> { | |||
1163 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1004 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1164 | } | 1005 | } |
1165 | 1006 | ||
1166 | impl<'a> ImplItem<'a> {} | 1007 | impl<R: TreeRoot<RaTypes>> ImplItemNode<R> { |
1167 | 1008 | pub fn borrowed(&self) -> ImplItem { | |
1168 | // ImplTraitType | 1009 | ImplItemNode { syntax: self.syntax.borrowed() } |
1169 | |||
1170 | #[derive(Debug, Clone)] | ||
1171 | pub struct ImplTraitTypeNode(SyntaxNode); | ||
1172 | |||
1173 | impl ImplTraitTypeNode { | ||
1174 | pub fn ast(&self) -> ImplTraitType { | ||
1175 | ImplTraitType::cast(self.0.borrowed()).unwrap() | ||
1176 | } | 1010 | } |
1177 | } | 1011 | pub fn owned(&self) -> ImplItemNode { |
1178 | 1012 | ImplItemNode { syntax: self.syntax.owned() } | |
1179 | impl<'a> From<ImplTraitType<'a>> for ImplTraitTypeNode { | ||
1180 | fn from(ast: ImplTraitType<'a>) -> ImplTraitTypeNode { | ||
1181 | let syntax = ast.syntax().owned(); | ||
1182 | ImplTraitTypeNode(syntax) | ||
1183 | } | 1013 | } |
1184 | } | 1014 | } |
1015 | |||
1016 | |||
1017 | impl<'a> ImplItem<'a> {} | ||
1018 | |||
1019 | // ImplTraitType | ||
1185 | #[derive(Debug, Clone, Copy)] | 1020 | #[derive(Debug, Clone, Copy)] |
1186 | pub struct ImplTraitType<'a> { | 1021 | pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1187 | syntax: SyntaxNodeRef<'a>, | 1022 | syntax: SyntaxNode<R>, |
1188 | } | 1023 | } |
1024 | pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>; | ||
1189 | 1025 | ||
1190 | impl<'a> AstNode<'a> for ImplTraitType<'a> { | 1026 | impl<'a> AstNode<'a> for ImplTraitType<'a> { |
1191 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1027 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1197,29 +1033,24 @@ impl<'a> AstNode<'a> for ImplTraitType<'a> { | |||
1197 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1033 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1198 | } | 1034 | } |
1199 | 1035 | ||
1200 | impl<'a> ImplTraitType<'a> {} | 1036 | impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> { |
1201 | 1037 | pub fn borrowed(&self) -> ImplTraitType { | |
1202 | // IndexExpr | 1038 | ImplTraitTypeNode { syntax: self.syntax.borrowed() } |
1203 | |||
1204 | #[derive(Debug, Clone)] | ||
1205 | pub struct IndexExprNode(SyntaxNode); | ||
1206 | |||
1207 | impl IndexExprNode { | ||
1208 | pub fn ast(&self) -> IndexExpr { | ||
1209 | IndexExpr::cast(self.0.borrowed()).unwrap() | ||
1210 | } | 1039 | } |
1211 | } | 1040 | pub fn owned(&self) -> ImplTraitTypeNode { |
1212 | 1041 | ImplTraitTypeNode { syntax: self.syntax.owned() } | |
1213 | impl<'a> From<IndexExpr<'a>> for IndexExprNode { | ||
1214 | fn from(ast: IndexExpr<'a>) -> IndexExprNode { | ||
1215 | let syntax = ast.syntax().owned(); | ||
1216 | IndexExprNode(syntax) | ||
1217 | } | 1042 | } |
1218 | } | 1043 | } |
1044 | |||
1045 | |||
1046 | impl<'a> ImplTraitType<'a> {} | ||
1047 | |||
1048 | // IndexExpr | ||
1219 | #[derive(Debug, Clone, Copy)] | 1049 | #[derive(Debug, Clone, Copy)] |
1220 | pub struct IndexExpr<'a> { | 1050 | pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1221 | syntax: SyntaxNodeRef<'a>, | 1051 | syntax: SyntaxNode<R>, |
1222 | } | 1052 | } |
1053 | pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>; | ||
1223 | 1054 | ||
1224 | impl<'a> AstNode<'a> for IndexExpr<'a> { | 1055 | impl<'a> AstNode<'a> for IndexExpr<'a> { |
1225 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1056 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1231,29 +1062,24 @@ impl<'a> AstNode<'a> for IndexExpr<'a> { | |||
1231 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1062 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1232 | } | 1063 | } |
1233 | 1064 | ||
1234 | impl<'a> IndexExpr<'a> {} | 1065 | impl<R: TreeRoot<RaTypes>> IndexExprNode<R> { |
1235 | 1066 | pub fn borrowed(&self) -> IndexExpr { | |
1236 | // ItemList | 1067 | IndexExprNode { syntax: self.syntax.borrowed() } |
1237 | |||
1238 | #[derive(Debug, Clone)] | ||
1239 | pub struct ItemListNode(SyntaxNode); | ||
1240 | |||
1241 | impl ItemListNode { | ||
1242 | pub fn ast(&self) -> ItemList { | ||
1243 | ItemList::cast(self.0.borrowed()).unwrap() | ||
1244 | } | 1068 | } |
1245 | } | 1069 | pub fn owned(&self) -> IndexExprNode { |
1246 | 1070 | IndexExprNode { syntax: self.syntax.owned() } | |
1247 | impl<'a> From<ItemList<'a>> for ItemListNode { | ||
1248 | fn from(ast: ItemList<'a>) -> ItemListNode { | ||
1249 | let syntax = ast.syntax().owned(); | ||
1250 | ItemListNode(syntax) | ||
1251 | } | 1071 | } |
1252 | } | 1072 | } |
1073 | |||
1074 | |||
1075 | impl<'a> IndexExpr<'a> {} | ||
1076 | |||
1077 | // ItemList | ||
1253 | #[derive(Debug, Clone, Copy)] | 1078 | #[derive(Debug, Clone, Copy)] |
1254 | pub struct ItemList<'a> { | 1079 | pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1255 | syntax: SyntaxNodeRef<'a>, | 1080 | syntax: SyntaxNode<R>, |
1256 | } | 1081 | } |
1082 | pub type ItemList<'a> = ItemListNode<RefRoot<'a>>; | ||
1257 | 1083 | ||
1258 | impl<'a> AstNode<'a> for ItemList<'a> { | 1084 | impl<'a> AstNode<'a> for ItemList<'a> { |
1259 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1085 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1265,31 +1091,26 @@ impl<'a> AstNode<'a> for ItemList<'a> { | |||
1265 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1091 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1266 | } | 1092 | } |
1267 | 1093 | ||
1094 | impl<R: TreeRoot<RaTypes>> ItemListNode<R> { | ||
1095 | pub fn borrowed(&self) -> ItemList { | ||
1096 | ItemListNode { syntax: self.syntax.borrowed() } | ||
1097 | } | ||
1098 | pub fn owned(&self) -> ItemListNode { | ||
1099 | ItemListNode { syntax: self.syntax.owned() } | ||
1100 | } | ||
1101 | } | ||
1102 | |||
1103 | |||
1268 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} | 1104 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} |
1269 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} | 1105 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} |
1270 | impl<'a> ItemList<'a> {} | 1106 | impl<'a> ItemList<'a> {} |
1271 | 1107 | ||
1272 | // Label | 1108 | // Label |
1273 | |||
1274 | #[derive(Debug, Clone)] | ||
1275 | pub struct LabelNode(SyntaxNode); | ||
1276 | |||
1277 | impl LabelNode { | ||
1278 | pub fn ast(&self) -> Label { | ||
1279 | Label::cast(self.0.borrowed()).unwrap() | ||
1280 | } | ||
1281 | } | ||
1282 | |||
1283 | impl<'a> From<Label<'a>> for LabelNode { | ||
1284 | fn from(ast: Label<'a>) -> LabelNode { | ||
1285 | let syntax = ast.syntax().owned(); | ||
1286 | LabelNode(syntax) | ||
1287 | } | ||
1288 | } | ||
1289 | #[derive(Debug, Clone, Copy)] | 1109 | #[derive(Debug, Clone, Copy)] |
1290 | pub struct Label<'a> { | 1110 | pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1291 | syntax: SyntaxNodeRef<'a>, | 1111 | syntax: SyntaxNode<R>, |
1292 | } | 1112 | } |
1113 | pub type Label<'a> = LabelNode<RefRoot<'a>>; | ||
1293 | 1114 | ||
1294 | impl<'a> AstNode<'a> for Label<'a> { | 1115 | impl<'a> AstNode<'a> for Label<'a> { |
1295 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1116 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1301,29 +1122,24 @@ impl<'a> AstNode<'a> for Label<'a> { | |||
1301 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1122 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1302 | } | 1123 | } |
1303 | 1124 | ||
1304 | impl<'a> Label<'a> {} | 1125 | impl<R: TreeRoot<RaTypes>> LabelNode<R> { |
1305 | 1126 | pub fn borrowed(&self) -> Label { | |
1306 | // LambdaExpr | 1127 | LabelNode { syntax: self.syntax.borrowed() } |
1307 | |||
1308 | #[derive(Debug, Clone)] | ||
1309 | pub struct LambdaExprNode(SyntaxNode); | ||
1310 | |||
1311 | impl LambdaExprNode { | ||
1312 | pub fn ast(&self) -> LambdaExpr { | ||
1313 | LambdaExpr::cast(self.0.borrowed()).unwrap() | ||
1314 | } | 1128 | } |
1315 | } | 1129 | pub fn owned(&self) -> LabelNode { |
1316 | 1130 | LabelNode { syntax: self.syntax.owned() } | |
1317 | impl<'a> From<LambdaExpr<'a>> for LambdaExprNode { | ||
1318 | fn from(ast: LambdaExpr<'a>) -> LambdaExprNode { | ||
1319 | let syntax = ast.syntax().owned(); | ||
1320 | LambdaExprNode(syntax) | ||
1321 | } | 1131 | } |
1322 | } | 1132 | } |
1133 | |||
1134 | |||
1135 | impl<'a> Label<'a> {} | ||
1136 | |||
1137 | // LambdaExpr | ||
1323 | #[derive(Debug, Clone, Copy)] | 1138 | #[derive(Debug, Clone, Copy)] |
1324 | pub struct LambdaExpr<'a> { | 1139 | pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1325 | syntax: SyntaxNodeRef<'a>, | 1140 | syntax: SyntaxNode<R>, |
1326 | } | 1141 | } |
1142 | pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>; | ||
1327 | 1143 | ||
1328 | impl<'a> AstNode<'a> for LambdaExpr<'a> { | 1144 | impl<'a> AstNode<'a> for LambdaExpr<'a> { |
1329 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1145 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1335,6 +1151,16 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> { | |||
1335 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1151 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1336 | } | 1152 | } |
1337 | 1153 | ||
1154 | impl<R: TreeRoot<RaTypes>> LambdaExprNode<R> { | ||
1155 | pub fn borrowed(&self) -> LambdaExpr { | ||
1156 | LambdaExprNode { syntax: self.syntax.borrowed() } | ||
1157 | } | ||
1158 | pub fn owned(&self) -> LambdaExprNode { | ||
1159 | LambdaExprNode { syntax: self.syntax.owned() } | ||
1160 | } | ||
1161 | } | ||
1162 | |||
1163 | |||
1338 | impl<'a> LambdaExpr<'a> { | 1164 | impl<'a> LambdaExpr<'a> { |
1339 | pub fn param_list(self) -> Option<ParamList<'a>> { | 1165 | pub fn param_list(self) -> Option<ParamList<'a>> { |
1340 | super::child_opt(self) | 1166 | super::child_opt(self) |
@@ -1346,26 +1172,11 @@ impl<'a> LambdaExpr<'a> { | |||
1346 | } | 1172 | } |
1347 | 1173 | ||
1348 | // LetStmt | 1174 | // LetStmt |
1349 | |||
1350 | #[derive(Debug, Clone)] | ||
1351 | pub struct LetStmtNode(SyntaxNode); | ||
1352 | |||
1353 | impl LetStmtNode { | ||
1354 | pub fn ast(&self) -> LetStmt { | ||
1355 | LetStmt::cast(self.0.borrowed()).unwrap() | ||
1356 | } | ||
1357 | } | ||
1358 | |||
1359 | impl<'a> From<LetStmt<'a>> for LetStmtNode { | ||
1360 | fn from(ast: LetStmt<'a>) -> LetStmtNode { | ||
1361 | let syntax = ast.syntax().owned(); | ||
1362 | LetStmtNode(syntax) | ||
1363 | } | ||
1364 | } | ||
1365 | #[derive(Debug, Clone, Copy)] | 1175 | #[derive(Debug, Clone, Copy)] |
1366 | pub struct LetStmt<'a> { | 1176 | pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1367 | syntax: SyntaxNodeRef<'a>, | 1177 | syntax: SyntaxNode<R>, |
1368 | } | 1178 | } |
1179 | pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>; | ||
1369 | 1180 | ||
1370 | impl<'a> AstNode<'a> for LetStmt<'a> { | 1181 | impl<'a> AstNode<'a> for LetStmt<'a> { |
1371 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1182 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1377,6 +1188,16 @@ impl<'a> AstNode<'a> for LetStmt<'a> { | |||
1377 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1188 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1378 | } | 1189 | } |
1379 | 1190 | ||
1191 | impl<R: TreeRoot<RaTypes>> LetStmtNode<R> { | ||
1192 | pub fn borrowed(&self) -> LetStmt { | ||
1193 | LetStmtNode { syntax: self.syntax.borrowed() } | ||
1194 | } | ||
1195 | pub fn owned(&self) -> LetStmtNode { | ||
1196 | LetStmtNode { syntax: self.syntax.owned() } | ||
1197 | } | ||
1198 | } | ||
1199 | |||
1200 | |||
1380 | impl<'a> LetStmt<'a> { | 1201 | impl<'a> LetStmt<'a> { |
1381 | pub fn pat(self) -> Option<Pat<'a>> { | 1202 | pub fn pat(self) -> Option<Pat<'a>> { |
1382 | super::child_opt(self) | 1203 | super::child_opt(self) |
@@ -1388,26 +1209,11 @@ impl<'a> LetStmt<'a> { | |||
1388 | } | 1209 | } |
1389 | 1210 | ||
1390 | // Lifetime | 1211 | // Lifetime |
1391 | |||
1392 | #[derive(Debug, Clone)] | ||
1393 | pub struct LifetimeNode(SyntaxNode); | ||
1394 | |||
1395 | impl LifetimeNode { | ||
1396 | pub fn ast(&self) -> Lifetime { | ||
1397 | Lifetime::cast(self.0.borrowed()).unwrap() | ||
1398 | } | ||
1399 | } | ||
1400 | |||
1401 | impl<'a> From<Lifetime<'a>> for LifetimeNode { | ||
1402 | fn from(ast: Lifetime<'a>) -> LifetimeNode { | ||
1403 | let syntax = ast.syntax().owned(); | ||
1404 | LifetimeNode(syntax) | ||
1405 | } | ||
1406 | } | ||
1407 | #[derive(Debug, Clone, Copy)] | 1212 | #[derive(Debug, Clone, Copy)] |
1408 | pub struct Lifetime<'a> { | 1213 | pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1409 | syntax: SyntaxNodeRef<'a>, | 1214 | syntax: SyntaxNode<R>, |
1410 | } | 1215 | } |
1216 | pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>; | ||
1411 | 1217 | ||
1412 | impl<'a> AstNode<'a> for Lifetime<'a> { | 1218 | impl<'a> AstNode<'a> for Lifetime<'a> { |
1413 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1219 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1419,29 +1225,24 @@ impl<'a> AstNode<'a> for Lifetime<'a> { | |||
1419 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1225 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1420 | } | 1226 | } |
1421 | 1227 | ||
1422 | impl<'a> Lifetime<'a> {} | 1228 | impl<R: TreeRoot<RaTypes>> LifetimeNode<R> { |
1423 | 1229 | pub fn borrowed(&self) -> Lifetime { | |
1424 | // LifetimeParam | 1230 | LifetimeNode { syntax: self.syntax.borrowed() } |
1425 | |||
1426 | #[derive(Debug, Clone)] | ||
1427 | pub struct LifetimeParamNode(SyntaxNode); | ||
1428 | |||
1429 | impl LifetimeParamNode { | ||
1430 | pub fn ast(&self) -> LifetimeParam { | ||
1431 | LifetimeParam::cast(self.0.borrowed()).unwrap() | ||
1432 | } | 1231 | } |
1433 | } | 1232 | pub fn owned(&self) -> LifetimeNode { |
1434 | 1233 | LifetimeNode { syntax: self.syntax.owned() } | |
1435 | impl<'a> From<LifetimeParam<'a>> for LifetimeParamNode { | ||
1436 | fn from(ast: LifetimeParam<'a>) -> LifetimeParamNode { | ||
1437 | let syntax = ast.syntax().owned(); | ||
1438 | LifetimeParamNode(syntax) | ||
1439 | } | 1234 | } |
1440 | } | 1235 | } |
1236 | |||
1237 | |||
1238 | impl<'a> Lifetime<'a> {} | ||
1239 | |||
1240 | // LifetimeParam | ||
1441 | #[derive(Debug, Clone, Copy)] | 1241 | #[derive(Debug, Clone, Copy)] |
1442 | pub struct LifetimeParam<'a> { | 1242 | pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1443 | syntax: SyntaxNodeRef<'a>, | 1243 | syntax: SyntaxNode<R>, |
1444 | } | 1244 | } |
1245 | pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>; | ||
1445 | 1246 | ||
1446 | impl<'a> AstNode<'a> for LifetimeParam<'a> { | 1247 | impl<'a> AstNode<'a> for LifetimeParam<'a> { |
1447 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1248 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1453,33 +1254,28 @@ impl<'a> AstNode<'a> for LifetimeParam<'a> { | |||
1453 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1254 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1454 | } | 1255 | } |
1455 | 1256 | ||
1456 | impl<'a> LifetimeParam<'a> { | 1257 | impl<R: TreeRoot<RaTypes>> LifetimeParamNode<R> { |
1457 | pub fn lifetime(self) -> Option<Lifetime<'a>> { | 1258 | pub fn borrowed(&self) -> LifetimeParam { |
1458 | super::child_opt(self) | 1259 | LifetimeParamNode { syntax: self.syntax.borrowed() } |
1260 | } | ||
1261 | pub fn owned(&self) -> LifetimeParamNode { | ||
1262 | LifetimeParamNode { syntax: self.syntax.owned() } | ||
1459 | } | 1263 | } |
1460 | } | 1264 | } |
1461 | 1265 | ||
1462 | // Literal | ||
1463 | 1266 | ||
1464 | #[derive(Debug, Clone)] | 1267 | impl<'a> LifetimeParam<'a> { |
1465 | pub struct LiteralNode(SyntaxNode); | 1268 | pub fn lifetime(self) -> Option<Lifetime<'a>> { |
1466 | 1269 | super::child_opt(self) | |
1467 | impl LiteralNode { | ||
1468 | pub fn ast(&self) -> Literal { | ||
1469 | Literal::cast(self.0.borrowed()).unwrap() | ||
1470 | } | 1270 | } |
1471 | } | 1271 | } |
1472 | 1272 | ||
1473 | impl<'a> From<Literal<'a>> for LiteralNode { | 1273 | // Literal |
1474 | fn from(ast: Literal<'a>) -> LiteralNode { | ||
1475 | let syntax = ast.syntax().owned(); | ||
1476 | LiteralNode(syntax) | ||
1477 | } | ||
1478 | } | ||
1479 | #[derive(Debug, Clone, Copy)] | 1274 | #[derive(Debug, Clone, Copy)] |
1480 | pub struct Literal<'a> { | 1275 | pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1481 | syntax: SyntaxNodeRef<'a>, | 1276 | syntax: SyntaxNode<R>, |
1482 | } | 1277 | } |
1278 | pub type Literal<'a> = LiteralNode<RefRoot<'a>>; | ||
1483 | 1279 | ||
1484 | impl<'a> AstNode<'a> for Literal<'a> { | 1280 | impl<'a> AstNode<'a> for Literal<'a> { |
1485 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1281 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1491,29 +1287,24 @@ impl<'a> AstNode<'a> for Literal<'a> { | |||
1491 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1287 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1492 | } | 1288 | } |
1493 | 1289 | ||
1494 | impl<'a> Literal<'a> {} | 1290 | impl<R: TreeRoot<RaTypes>> LiteralNode<R> { |
1495 | 1291 | pub fn borrowed(&self) -> Literal { | |
1496 | // LoopExpr | 1292 | LiteralNode { syntax: self.syntax.borrowed() } |
1497 | |||
1498 | #[derive(Debug, Clone)] | ||
1499 | pub struct LoopExprNode(SyntaxNode); | ||
1500 | |||
1501 | impl LoopExprNode { | ||
1502 | pub fn ast(&self) -> LoopExpr { | ||
1503 | LoopExpr::cast(self.0.borrowed()).unwrap() | ||
1504 | } | 1293 | } |
1505 | } | 1294 | pub fn owned(&self) -> LiteralNode { |
1506 | 1295 | LiteralNode { syntax: self.syntax.owned() } | |
1507 | impl<'a> From<LoopExpr<'a>> for LoopExprNode { | ||
1508 | fn from(ast: LoopExpr<'a>) -> LoopExprNode { | ||
1509 | let syntax = ast.syntax().owned(); | ||
1510 | LoopExprNode(syntax) | ||
1511 | } | 1296 | } |
1512 | } | 1297 | } |
1298 | |||
1299 | |||
1300 | impl<'a> Literal<'a> {} | ||
1301 | |||
1302 | // LoopExpr | ||
1513 | #[derive(Debug, Clone, Copy)] | 1303 | #[derive(Debug, Clone, Copy)] |
1514 | pub struct LoopExpr<'a> { | 1304 | pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1515 | syntax: SyntaxNodeRef<'a>, | 1305 | syntax: SyntaxNode<R>, |
1516 | } | 1306 | } |
1307 | pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>; | ||
1517 | 1308 | ||
1518 | impl<'a> AstNode<'a> for LoopExpr<'a> { | 1309 | impl<'a> AstNode<'a> for LoopExpr<'a> { |
1519 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1310 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1525,30 +1316,25 @@ impl<'a> AstNode<'a> for LoopExpr<'a> { | |||
1525 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1316 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1526 | } | 1317 | } |
1527 | 1318 | ||
1319 | impl<R: TreeRoot<RaTypes>> LoopExprNode<R> { | ||
1320 | pub fn borrowed(&self) -> LoopExpr { | ||
1321 | LoopExprNode { syntax: self.syntax.borrowed() } | ||
1322 | } | ||
1323 | pub fn owned(&self) -> LoopExprNode { | ||
1324 | LoopExprNode { syntax: self.syntax.owned() } | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | |||
1528 | impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} | 1329 | impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} |
1529 | impl<'a> LoopExpr<'a> {} | 1330 | impl<'a> LoopExpr<'a> {} |
1530 | 1331 | ||
1531 | // MatchArm | 1332 | // MatchArm |
1532 | |||
1533 | #[derive(Debug, Clone)] | ||
1534 | pub struct MatchArmNode(SyntaxNode); | ||
1535 | |||
1536 | impl MatchArmNode { | ||
1537 | pub fn ast(&self) -> MatchArm { | ||
1538 | MatchArm::cast(self.0.borrowed()).unwrap() | ||
1539 | } | ||
1540 | } | ||
1541 | |||
1542 | impl<'a> From<MatchArm<'a>> for MatchArmNode { | ||
1543 | fn from(ast: MatchArm<'a>) -> MatchArmNode { | ||
1544 | let syntax = ast.syntax().owned(); | ||
1545 | MatchArmNode(syntax) | ||
1546 | } | ||
1547 | } | ||
1548 | #[derive(Debug, Clone, Copy)] | 1333 | #[derive(Debug, Clone, Copy)] |
1549 | pub struct MatchArm<'a> { | 1334 | pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1550 | syntax: SyntaxNodeRef<'a>, | 1335 | syntax: SyntaxNode<R>, |
1551 | } | 1336 | } |
1337 | pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>; | ||
1552 | 1338 | ||
1553 | impl<'a> AstNode<'a> for MatchArm<'a> { | 1339 | impl<'a> AstNode<'a> for MatchArm<'a> { |
1554 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1340 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1560,6 +1346,16 @@ impl<'a> AstNode<'a> for MatchArm<'a> { | |||
1560 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1346 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1561 | } | 1347 | } |
1562 | 1348 | ||
1349 | impl<R: TreeRoot<RaTypes>> MatchArmNode<R> { | ||
1350 | pub fn borrowed(&self) -> MatchArm { | ||
1351 | MatchArmNode { syntax: self.syntax.borrowed() } | ||
1352 | } | ||
1353 | pub fn owned(&self) -> MatchArmNode { | ||
1354 | MatchArmNode { syntax: self.syntax.owned() } | ||
1355 | } | ||
1356 | } | ||
1357 | |||
1358 | |||
1563 | impl<'a> MatchArm<'a> { | 1359 | impl<'a> MatchArm<'a> { |
1564 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { | 1360 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { |
1565 | super::children(self) | 1361 | super::children(self) |
@@ -1575,26 +1371,11 @@ impl<'a> MatchArm<'a> { | |||
1575 | } | 1371 | } |
1576 | 1372 | ||
1577 | // MatchArmList | 1373 | // MatchArmList |
1578 | |||
1579 | #[derive(Debug, Clone)] | ||
1580 | pub struct MatchArmListNode(SyntaxNode); | ||
1581 | |||
1582 | impl MatchArmListNode { | ||
1583 | pub fn ast(&self) -> MatchArmList { | ||
1584 | MatchArmList::cast(self.0.borrowed()).unwrap() | ||
1585 | } | ||
1586 | } | ||
1587 | |||
1588 | impl<'a> From<MatchArmList<'a>> for MatchArmListNode { | ||
1589 | fn from(ast: MatchArmList<'a>) -> MatchArmListNode { | ||
1590 | let syntax = ast.syntax().owned(); | ||
1591 | MatchArmListNode(syntax) | ||
1592 | } | ||
1593 | } | ||
1594 | #[derive(Debug, Clone, Copy)] | 1374 | #[derive(Debug, Clone, Copy)] |
1595 | pub struct MatchArmList<'a> { | 1375 | pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1596 | syntax: SyntaxNodeRef<'a>, | 1376 | syntax: SyntaxNode<R>, |
1597 | } | 1377 | } |
1378 | pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>; | ||
1598 | 1379 | ||
1599 | impl<'a> AstNode<'a> for MatchArmList<'a> { | 1380 | impl<'a> AstNode<'a> for MatchArmList<'a> { |
1600 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1381 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1606,33 +1387,28 @@ impl<'a> AstNode<'a> for MatchArmList<'a> { | |||
1606 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1387 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1607 | } | 1388 | } |
1608 | 1389 | ||
1609 | impl<'a> MatchArmList<'a> { | 1390 | impl<R: TreeRoot<RaTypes>> MatchArmListNode<R> { |
1610 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { | 1391 | pub fn borrowed(&self) -> MatchArmList { |
1611 | super::children(self) | 1392 | MatchArmListNode { syntax: self.syntax.borrowed() } |
1393 | } | ||
1394 | pub fn owned(&self) -> MatchArmListNode { | ||
1395 | MatchArmListNode { syntax: self.syntax.owned() } | ||
1612 | } | 1396 | } |
1613 | } | 1397 | } |
1614 | 1398 | ||
1615 | // MatchExpr | ||
1616 | |||
1617 | #[derive(Debug, Clone)] | ||
1618 | pub struct MatchExprNode(SyntaxNode); | ||
1619 | 1399 | ||
1620 | impl MatchExprNode { | 1400 | impl<'a> MatchArmList<'a> { |
1621 | pub fn ast(&self) -> MatchExpr { | 1401 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { |
1622 | MatchExpr::cast(self.0.borrowed()).unwrap() | 1402 | super::children(self) |
1623 | } | 1403 | } |
1624 | } | 1404 | } |
1625 | 1405 | ||
1626 | impl<'a> From<MatchExpr<'a>> for MatchExprNode { | 1406 | // MatchExpr |
1627 | fn from(ast: MatchExpr<'a>) -> MatchExprNode { | ||
1628 | let syntax = ast.syntax().owned(); | ||
1629 | MatchExprNode(syntax) | ||
1630 | } | ||
1631 | } | ||
1632 | #[derive(Debug, Clone, Copy)] | 1407 | #[derive(Debug, Clone, Copy)] |
1633 | pub struct MatchExpr<'a> { | 1408 | pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1634 | syntax: SyntaxNodeRef<'a>, | 1409 | syntax: SyntaxNode<R>, |
1635 | } | 1410 | } |
1411 | pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>; | ||
1636 | 1412 | ||
1637 | impl<'a> AstNode<'a> for MatchExpr<'a> { | 1413 | impl<'a> AstNode<'a> for MatchExpr<'a> { |
1638 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1414 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1644,6 +1420,16 @@ impl<'a> AstNode<'a> for MatchExpr<'a> { | |||
1644 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1420 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1645 | } | 1421 | } |
1646 | 1422 | ||
1423 | impl<R: TreeRoot<RaTypes>> MatchExprNode<R> { | ||
1424 | pub fn borrowed(&self) -> MatchExpr { | ||
1425 | MatchExprNode { syntax: self.syntax.borrowed() } | ||
1426 | } | ||
1427 | pub fn owned(&self) -> MatchExprNode { | ||
1428 | MatchExprNode { syntax: self.syntax.owned() } | ||
1429 | } | ||
1430 | } | ||
1431 | |||
1432 | |||
1647 | impl<'a> MatchExpr<'a> { | 1433 | impl<'a> MatchExpr<'a> { |
1648 | pub fn expr(self) -> Option<Expr<'a>> { | 1434 | pub fn expr(self) -> Option<Expr<'a>> { |
1649 | super::child_opt(self) | 1435 | super::child_opt(self) |
@@ -1655,26 +1441,11 @@ impl<'a> MatchExpr<'a> { | |||
1655 | } | 1441 | } |
1656 | 1442 | ||
1657 | // MatchGuard | 1443 | // MatchGuard |
1658 | |||
1659 | #[derive(Debug, Clone)] | ||
1660 | pub struct MatchGuardNode(SyntaxNode); | ||
1661 | |||
1662 | impl MatchGuardNode { | ||
1663 | pub fn ast(&self) -> MatchGuard { | ||
1664 | MatchGuard::cast(self.0.borrowed()).unwrap() | ||
1665 | } | ||
1666 | } | ||
1667 | |||
1668 | impl<'a> From<MatchGuard<'a>> for MatchGuardNode { | ||
1669 | fn from(ast: MatchGuard<'a>) -> MatchGuardNode { | ||
1670 | let syntax = ast.syntax().owned(); | ||
1671 | MatchGuardNode(syntax) | ||
1672 | } | ||
1673 | } | ||
1674 | #[derive(Debug, Clone, Copy)] | 1444 | #[derive(Debug, Clone, Copy)] |
1675 | pub struct MatchGuard<'a> { | 1445 | pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1676 | syntax: SyntaxNodeRef<'a>, | 1446 | syntax: SyntaxNode<R>, |
1677 | } | 1447 | } |
1448 | pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>; | ||
1678 | 1449 | ||
1679 | impl<'a> AstNode<'a> for MatchGuard<'a> { | 1450 | impl<'a> AstNode<'a> for MatchGuard<'a> { |
1680 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1451 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1686,29 +1457,24 @@ impl<'a> AstNode<'a> for MatchGuard<'a> { | |||
1686 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1457 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1687 | } | 1458 | } |
1688 | 1459 | ||
1689 | impl<'a> MatchGuard<'a> {} | 1460 | impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> { |
1690 | 1461 | pub fn borrowed(&self) -> MatchGuard { | |
1691 | // MethodCallExpr | 1462 | MatchGuardNode { syntax: self.syntax.borrowed() } |
1692 | |||
1693 | #[derive(Debug, Clone)] | ||
1694 | pub struct MethodCallExprNode(SyntaxNode); | ||
1695 | |||
1696 | impl MethodCallExprNode { | ||
1697 | pub fn ast(&self) -> MethodCallExpr { | ||
1698 | MethodCallExpr::cast(self.0.borrowed()).unwrap() | ||
1699 | } | 1463 | } |
1700 | } | 1464 | pub fn owned(&self) -> MatchGuardNode { |
1701 | 1465 | MatchGuardNode { syntax: self.syntax.owned() } | |
1702 | impl<'a> From<MethodCallExpr<'a>> for MethodCallExprNode { | ||
1703 | fn from(ast: MethodCallExpr<'a>) -> MethodCallExprNode { | ||
1704 | let syntax = ast.syntax().owned(); | ||
1705 | MethodCallExprNode(syntax) | ||
1706 | } | 1466 | } |
1707 | } | 1467 | } |
1468 | |||
1469 | |||
1470 | impl<'a> MatchGuard<'a> {} | ||
1471 | |||
1472 | // MethodCallExpr | ||
1708 | #[derive(Debug, Clone, Copy)] | 1473 | #[derive(Debug, Clone, Copy)] |
1709 | pub struct MethodCallExpr<'a> { | 1474 | pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1710 | syntax: SyntaxNodeRef<'a>, | 1475 | syntax: SyntaxNode<R>, |
1711 | } | 1476 | } |
1477 | pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>; | ||
1712 | 1478 | ||
1713 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { | 1479 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { |
1714 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1480 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1720,6 +1486,16 @@ impl<'a> AstNode<'a> for MethodCallExpr<'a> { | |||
1720 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1486 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1721 | } | 1487 | } |
1722 | 1488 | ||
1489 | impl<R: TreeRoot<RaTypes>> MethodCallExprNode<R> { | ||
1490 | pub fn borrowed(&self) -> MethodCallExpr { | ||
1491 | MethodCallExprNode { syntax: self.syntax.borrowed() } | ||
1492 | } | ||
1493 | pub fn owned(&self) -> MethodCallExprNode { | ||
1494 | MethodCallExprNode { syntax: self.syntax.owned() } | ||
1495 | } | ||
1496 | } | ||
1497 | |||
1498 | |||
1723 | impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} | 1499 | impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} |
1724 | impl<'a> MethodCallExpr<'a> { | 1500 | impl<'a> MethodCallExpr<'a> { |
1725 | pub fn expr(self) -> Option<Expr<'a>> { | 1501 | pub fn expr(self) -> Option<Expr<'a>> { |
@@ -1728,26 +1504,11 @@ impl<'a> MethodCallExpr<'a> { | |||
1728 | } | 1504 | } |
1729 | 1505 | ||
1730 | // Module | 1506 | // Module |
1731 | |||
1732 | #[derive(Debug, Clone)] | ||
1733 | pub struct ModuleNode(SyntaxNode); | ||
1734 | |||
1735 | impl ModuleNode { | ||
1736 | pub fn ast(&self) -> Module { | ||
1737 | Module::cast(self.0.borrowed()).unwrap() | ||
1738 | } | ||
1739 | } | ||
1740 | |||
1741 | impl<'a> From<Module<'a>> for ModuleNode { | ||
1742 | fn from(ast: Module<'a>) -> ModuleNode { | ||
1743 | let syntax = ast.syntax().owned(); | ||
1744 | ModuleNode(syntax) | ||
1745 | } | ||
1746 | } | ||
1747 | #[derive(Debug, Clone, Copy)] | 1507 | #[derive(Debug, Clone, Copy)] |
1748 | pub struct Module<'a> { | 1508 | pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1749 | syntax: SyntaxNodeRef<'a>, | 1509 | syntax: SyntaxNode<R>, |
1750 | } | 1510 | } |
1511 | pub type Module<'a> = ModuleNode<RefRoot<'a>>; | ||
1751 | 1512 | ||
1752 | impl<'a> AstNode<'a> for Module<'a> { | 1513 | impl<'a> AstNode<'a> for Module<'a> { |
1753 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1514 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1759,6 +1520,16 @@ impl<'a> AstNode<'a> for Module<'a> { | |||
1759 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1520 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1760 | } | 1521 | } |
1761 | 1522 | ||
1523 | impl<R: TreeRoot<RaTypes>> ModuleNode<R> { | ||
1524 | pub fn borrowed(&self) -> Module { | ||
1525 | ModuleNode { syntax: self.syntax.borrowed() } | ||
1526 | } | ||
1527 | pub fn owned(&self) -> ModuleNode { | ||
1528 | ModuleNode { syntax: self.syntax.owned() } | ||
1529 | } | ||
1530 | } | ||
1531 | |||
1532 | |||
1762 | impl<'a> ast::NameOwner<'a> for Module<'a> {} | 1533 | impl<'a> ast::NameOwner<'a> for Module<'a> {} |
1763 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} | 1534 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} |
1764 | impl<'a> Module<'a> { | 1535 | impl<'a> Module<'a> { |
@@ -1768,22 +1539,6 @@ impl<'a> Module<'a> { | |||
1768 | } | 1539 | } |
1769 | 1540 | ||
1770 | // ModuleItem | 1541 | // ModuleItem |
1771 | |||
1772 | #[derive(Debug, Clone)] | ||
1773 | pub struct ModuleItemNode(SyntaxNode); | ||
1774 | |||
1775 | impl ModuleItemNode { | ||
1776 | pub fn ast(&self) -> ModuleItem { | ||
1777 | ModuleItem::cast(self.0.borrowed()).unwrap() | ||
1778 | } | ||
1779 | } | ||
1780 | |||
1781 | impl<'a> From<ModuleItem<'a>> for ModuleItemNode { | ||
1782 | fn from(ast: ModuleItem<'a>) -> ModuleItemNode { | ||
1783 | let syntax = ast.syntax().owned(); | ||
1784 | ModuleItemNode(syntax) | ||
1785 | } | ||
1786 | } | ||
1787 | #[derive(Debug, Clone, Copy)] | 1542 | #[derive(Debug, Clone, Copy)] |
1788 | pub enum ModuleItem<'a> { | 1543 | pub enum ModuleItem<'a> { |
1789 | StructDef(StructDef<'a>), | 1544 | StructDef(StructDef<'a>), |
@@ -1836,26 +1591,11 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
1836 | impl<'a> ModuleItem<'a> {} | 1591 | impl<'a> ModuleItem<'a> {} |
1837 | 1592 | ||
1838 | // Name | 1593 | // Name |
1839 | |||
1840 | #[derive(Debug, Clone)] | ||
1841 | pub struct NameNode(SyntaxNode); | ||
1842 | |||
1843 | impl NameNode { | ||
1844 | pub fn ast(&self) -> Name { | ||
1845 | Name::cast(self.0.borrowed()).unwrap() | ||
1846 | } | ||
1847 | } | ||
1848 | |||
1849 | impl<'a> From<Name<'a>> for NameNode { | ||
1850 | fn from(ast: Name<'a>) -> NameNode { | ||
1851 | let syntax = ast.syntax().owned(); | ||
1852 | NameNode(syntax) | ||
1853 | } | ||
1854 | } | ||
1855 | #[derive(Debug, Clone, Copy)] | 1594 | #[derive(Debug, Clone, Copy)] |
1856 | pub struct Name<'a> { | 1595 | pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1857 | syntax: SyntaxNodeRef<'a>, | 1596 | syntax: SyntaxNode<R>, |
1858 | } | 1597 | } |
1598 | pub type Name<'a> = NameNode<RefRoot<'a>>; | ||
1859 | 1599 | ||
1860 | impl<'a> AstNode<'a> for Name<'a> { | 1600 | impl<'a> AstNode<'a> for Name<'a> { |
1861 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1601 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1867,29 +1607,24 @@ impl<'a> AstNode<'a> for Name<'a> { | |||
1867 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1607 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1868 | } | 1608 | } |
1869 | 1609 | ||
1870 | impl<'a> Name<'a> {} | 1610 | impl<R: TreeRoot<RaTypes>> NameNode<R> { |
1871 | 1611 | pub fn borrowed(&self) -> Name { | |
1872 | // NameRef | 1612 | NameNode { syntax: self.syntax.borrowed() } |
1873 | |||
1874 | #[derive(Debug, Clone)] | ||
1875 | pub struct NameRefNode(SyntaxNode); | ||
1876 | |||
1877 | impl NameRefNode { | ||
1878 | pub fn ast(&self) -> NameRef { | ||
1879 | NameRef::cast(self.0.borrowed()).unwrap() | ||
1880 | } | 1613 | } |
1881 | } | 1614 | pub fn owned(&self) -> NameNode { |
1882 | 1615 | NameNode { syntax: self.syntax.owned() } | |
1883 | impl<'a> From<NameRef<'a>> for NameRefNode { | ||
1884 | fn from(ast: NameRef<'a>) -> NameRefNode { | ||
1885 | let syntax = ast.syntax().owned(); | ||
1886 | NameRefNode(syntax) | ||
1887 | } | 1616 | } |
1888 | } | 1617 | } |
1618 | |||
1619 | |||
1620 | impl<'a> Name<'a> {} | ||
1621 | |||
1622 | // NameRef | ||
1889 | #[derive(Debug, Clone, Copy)] | 1623 | #[derive(Debug, Clone, Copy)] |
1890 | pub struct NameRef<'a> { | 1624 | pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1891 | syntax: SyntaxNodeRef<'a>, | 1625 | syntax: SyntaxNode<R>, |
1892 | } | 1626 | } |
1627 | pub type NameRef<'a> = NameRefNode<RefRoot<'a>>; | ||
1893 | 1628 | ||
1894 | impl<'a> AstNode<'a> for NameRef<'a> { | 1629 | impl<'a> AstNode<'a> for NameRef<'a> { |
1895 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1630 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1901,29 +1636,24 @@ impl<'a> AstNode<'a> for NameRef<'a> { | |||
1901 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1636 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1902 | } | 1637 | } |
1903 | 1638 | ||
1904 | impl<'a> NameRef<'a> {} | 1639 | impl<R: TreeRoot<RaTypes>> NameRefNode<R> { |
1905 | 1640 | pub fn borrowed(&self) -> NameRef { | |
1906 | // NamedField | 1641 | NameRefNode { syntax: self.syntax.borrowed() } |
1907 | |||
1908 | #[derive(Debug, Clone)] | ||
1909 | pub struct NamedFieldNode(SyntaxNode); | ||
1910 | |||
1911 | impl NamedFieldNode { | ||
1912 | pub fn ast(&self) -> NamedField { | ||
1913 | NamedField::cast(self.0.borrowed()).unwrap() | ||
1914 | } | 1642 | } |
1915 | } | 1643 | pub fn owned(&self) -> NameRefNode { |
1916 | 1644 | NameRefNode { syntax: self.syntax.owned() } | |
1917 | impl<'a> From<NamedField<'a>> for NamedFieldNode { | ||
1918 | fn from(ast: NamedField<'a>) -> NamedFieldNode { | ||
1919 | let syntax = ast.syntax().owned(); | ||
1920 | NamedFieldNode(syntax) | ||
1921 | } | 1645 | } |
1922 | } | 1646 | } |
1647 | |||
1648 | |||
1649 | impl<'a> NameRef<'a> {} | ||
1650 | |||
1651 | // NamedField | ||
1923 | #[derive(Debug, Clone, Copy)] | 1652 | #[derive(Debug, Clone, Copy)] |
1924 | pub struct NamedField<'a> { | 1653 | pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1925 | syntax: SyntaxNodeRef<'a>, | 1654 | syntax: SyntaxNode<R>, |
1926 | } | 1655 | } |
1656 | pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>; | ||
1927 | 1657 | ||
1928 | impl<'a> AstNode<'a> for NamedField<'a> { | 1658 | impl<'a> AstNode<'a> for NamedField<'a> { |
1929 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1659 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1935,29 +1665,24 @@ impl<'a> AstNode<'a> for NamedField<'a> { | |||
1935 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1665 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1936 | } | 1666 | } |
1937 | 1667 | ||
1938 | impl<'a> NamedField<'a> {} | 1668 | impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> { |
1939 | 1669 | pub fn borrowed(&self) -> NamedField { | |
1940 | // NamedFieldDef | 1670 | NamedFieldNode { syntax: self.syntax.borrowed() } |
1941 | |||
1942 | #[derive(Debug, Clone)] | ||
1943 | pub struct NamedFieldDefNode(SyntaxNode); | ||
1944 | |||
1945 | impl NamedFieldDefNode { | ||
1946 | pub fn ast(&self) -> NamedFieldDef { | ||
1947 | NamedFieldDef::cast(self.0.borrowed()).unwrap() | ||
1948 | } | 1671 | } |
1949 | } | 1672 | pub fn owned(&self) -> NamedFieldNode { |
1950 | 1673 | NamedFieldNode { syntax: self.syntax.owned() } | |
1951 | impl<'a> From<NamedFieldDef<'a>> for NamedFieldDefNode { | ||
1952 | fn from(ast: NamedFieldDef<'a>) -> NamedFieldDefNode { | ||
1953 | let syntax = ast.syntax().owned(); | ||
1954 | NamedFieldDefNode(syntax) | ||
1955 | } | 1674 | } |
1956 | } | 1675 | } |
1676 | |||
1677 | |||
1678 | impl<'a> NamedField<'a> {} | ||
1679 | |||
1680 | // NamedFieldDef | ||
1957 | #[derive(Debug, Clone, Copy)] | 1681 | #[derive(Debug, Clone, Copy)] |
1958 | pub struct NamedFieldDef<'a> { | 1682 | pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1959 | syntax: SyntaxNodeRef<'a>, | 1683 | syntax: SyntaxNode<R>, |
1960 | } | 1684 | } |
1685 | pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>; | ||
1961 | 1686 | ||
1962 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { | 1687 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { |
1963 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1688 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1969,31 +1694,26 @@ impl<'a> AstNode<'a> for NamedFieldDef<'a> { | |||
1969 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1694 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1970 | } | 1695 | } |
1971 | 1696 | ||
1697 | impl<R: TreeRoot<RaTypes>> NamedFieldDefNode<R> { | ||
1698 | pub fn borrowed(&self) -> NamedFieldDef { | ||
1699 | NamedFieldDefNode { syntax: self.syntax.borrowed() } | ||
1700 | } | ||
1701 | pub fn owned(&self) -> NamedFieldDefNode { | ||
1702 | NamedFieldDefNode { syntax: self.syntax.owned() } | ||
1703 | } | ||
1704 | } | ||
1705 | |||
1706 | |||
1972 | impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} | 1707 | impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} |
1973 | impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} | 1708 | impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} |
1974 | impl<'a> NamedFieldDef<'a> {} | 1709 | impl<'a> NamedFieldDef<'a> {} |
1975 | 1710 | ||
1976 | // NamedFieldList | 1711 | // NamedFieldList |
1977 | |||
1978 | #[derive(Debug, Clone)] | ||
1979 | pub struct NamedFieldListNode(SyntaxNode); | ||
1980 | |||
1981 | impl NamedFieldListNode { | ||
1982 | pub fn ast(&self) -> NamedFieldList { | ||
1983 | NamedFieldList::cast(self.0.borrowed()).unwrap() | ||
1984 | } | ||
1985 | } | ||
1986 | |||
1987 | impl<'a> From<NamedFieldList<'a>> for NamedFieldListNode { | ||
1988 | fn from(ast: NamedFieldList<'a>) -> NamedFieldListNode { | ||
1989 | let syntax = ast.syntax().owned(); | ||
1990 | NamedFieldListNode(syntax) | ||
1991 | } | ||
1992 | } | ||
1993 | #[derive(Debug, Clone, Copy)] | 1712 | #[derive(Debug, Clone, Copy)] |
1994 | pub struct NamedFieldList<'a> { | 1713 | pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1995 | syntax: SyntaxNodeRef<'a>, | 1714 | syntax: SyntaxNode<R>, |
1996 | } | 1715 | } |
1716 | pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>; | ||
1997 | 1717 | ||
1998 | impl<'a> AstNode<'a> for NamedFieldList<'a> { | 1718 | impl<'a> AstNode<'a> for NamedFieldList<'a> { |
1999 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1719 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2005,29 +1725,24 @@ impl<'a> AstNode<'a> for NamedFieldList<'a> { | |||
2005 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1725 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2006 | } | 1726 | } |
2007 | 1727 | ||
2008 | impl<'a> NamedFieldList<'a> {} | 1728 | impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> { |
2009 | 1729 | pub fn borrowed(&self) -> NamedFieldList { | |
2010 | // NeverType | 1730 | NamedFieldListNode { syntax: self.syntax.borrowed() } |
2011 | |||
2012 | #[derive(Debug, Clone)] | ||
2013 | pub struct NeverTypeNode(SyntaxNode); | ||
2014 | |||
2015 | impl NeverTypeNode { | ||
2016 | pub fn ast(&self) -> NeverType { | ||
2017 | NeverType::cast(self.0.borrowed()).unwrap() | ||
2018 | } | 1731 | } |
2019 | } | 1732 | pub fn owned(&self) -> NamedFieldListNode { |
2020 | 1733 | NamedFieldListNode { syntax: self.syntax.owned() } | |
2021 | impl<'a> From<NeverType<'a>> for NeverTypeNode { | ||
2022 | fn from(ast: NeverType<'a>) -> NeverTypeNode { | ||
2023 | let syntax = ast.syntax().owned(); | ||
2024 | NeverTypeNode(syntax) | ||
2025 | } | 1734 | } |
2026 | } | 1735 | } |
1736 | |||
1737 | |||
1738 | impl<'a> NamedFieldList<'a> {} | ||
1739 | |||
1740 | // NeverType | ||
2027 | #[derive(Debug, Clone, Copy)] | 1741 | #[derive(Debug, Clone, Copy)] |
2028 | pub struct NeverType<'a> { | 1742 | pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2029 | syntax: SyntaxNodeRef<'a>, | 1743 | syntax: SyntaxNode<R>, |
2030 | } | 1744 | } |
1745 | pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>; | ||
2031 | 1746 | ||
2032 | impl<'a> AstNode<'a> for NeverType<'a> { | 1747 | impl<'a> AstNode<'a> for NeverType<'a> { |
2033 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1748 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2039,25 +1754,19 @@ impl<'a> AstNode<'a> for NeverType<'a> { | |||
2039 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1754 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2040 | } | 1755 | } |
2041 | 1756 | ||
2042 | impl<'a> NeverType<'a> {} | 1757 | impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> { |
2043 | 1758 | pub fn borrowed(&self) -> NeverType { | |
2044 | // NominalDef | 1759 | NeverTypeNode { syntax: self.syntax.borrowed() } |
2045 | |||
2046 | #[derive(Debug, Clone)] | ||
2047 | pub struct NominalDefNode(SyntaxNode); | ||
2048 | |||
2049 | impl NominalDefNode { | ||
2050 | pub fn ast(&self) -> NominalDef { | ||
2051 | NominalDef::cast(self.0.borrowed()).unwrap() | ||
2052 | } | 1760 | } |
2053 | } | 1761 | pub fn owned(&self) -> NeverTypeNode { |
2054 | 1762 | NeverTypeNode { syntax: self.syntax.owned() } | |
2055 | impl<'a> From<NominalDef<'a>> for NominalDefNode { | ||
2056 | fn from(ast: NominalDef<'a>) -> NominalDefNode { | ||
2057 | let syntax = ast.syntax().owned(); | ||
2058 | NominalDefNode(syntax) | ||
2059 | } | 1763 | } |
2060 | } | 1764 | } |
1765 | |||
1766 | |||
1767 | impl<'a> NeverType<'a> {} | ||
1768 | |||
1769 | // NominalDef | ||
2061 | #[derive(Debug, Clone, Copy)] | 1770 | #[derive(Debug, Clone, Copy)] |
2062 | pub enum NominalDef<'a> { | 1771 | pub enum NominalDef<'a> { |
2063 | StructDef(StructDef<'a>), | 1772 | StructDef(StructDef<'a>), |
@@ -2086,26 +1795,11 @@ impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} | |||
2086 | impl<'a> NominalDef<'a> {} | 1795 | impl<'a> NominalDef<'a> {} |
2087 | 1796 | ||
2088 | // Param | 1797 | // Param |
2089 | |||
2090 | #[derive(Debug, Clone)] | ||
2091 | pub struct ParamNode(SyntaxNode); | ||
2092 | |||
2093 | impl ParamNode { | ||
2094 | pub fn ast(&self) -> Param { | ||
2095 | Param::cast(self.0.borrowed()).unwrap() | ||
2096 | } | ||
2097 | } | ||
2098 | |||
2099 | impl<'a> From<Param<'a>> for ParamNode { | ||
2100 | fn from(ast: Param<'a>) -> ParamNode { | ||
2101 | let syntax = ast.syntax().owned(); | ||
2102 | ParamNode(syntax) | ||
2103 | } | ||
2104 | } | ||
2105 | #[derive(Debug, Clone, Copy)] | 1798 | #[derive(Debug, Clone, Copy)] |
2106 | pub struct Param<'a> { | 1799 | pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2107 | syntax: SyntaxNodeRef<'a>, | 1800 | syntax: SyntaxNode<R>, |
2108 | } | 1801 | } |
1802 | pub type Param<'a> = ParamNode<RefRoot<'a>>; | ||
2109 | 1803 | ||
2110 | impl<'a> AstNode<'a> for Param<'a> { | 1804 | impl<'a> AstNode<'a> for Param<'a> { |
2111 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1805 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2117,33 +1811,28 @@ impl<'a> AstNode<'a> for Param<'a> { | |||
2117 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1811 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2118 | } | 1812 | } |
2119 | 1813 | ||
2120 | impl<'a> Param<'a> { | 1814 | impl<R: TreeRoot<RaTypes>> ParamNode<R> { |
2121 | pub fn pat(self) -> Option<Pat<'a>> { | 1815 | pub fn borrowed(&self) -> Param { |
2122 | super::child_opt(self) | 1816 | ParamNode { syntax: self.syntax.borrowed() } |
1817 | } | ||
1818 | pub fn owned(&self) -> ParamNode { | ||
1819 | ParamNode { syntax: self.syntax.owned() } | ||
2123 | } | 1820 | } |
2124 | } | 1821 | } |
2125 | 1822 | ||
2126 | // ParamList | ||
2127 | |||
2128 | #[derive(Debug, Clone)] | ||
2129 | pub struct ParamListNode(SyntaxNode); | ||
2130 | 1823 | ||
2131 | impl ParamListNode { | 1824 | impl<'a> Param<'a> { |
2132 | pub fn ast(&self) -> ParamList { | 1825 | pub fn pat(self) -> Option<Pat<'a>> { |
2133 | ParamList::cast(self.0.borrowed()).unwrap() | 1826 | super::child_opt(self) |
2134 | } | 1827 | } |
2135 | } | 1828 | } |
2136 | 1829 | ||
2137 | impl<'a> From<ParamList<'a>> for ParamListNode { | 1830 | // ParamList |
2138 | fn from(ast: ParamList<'a>) -> ParamListNode { | ||
2139 | let syntax = ast.syntax().owned(); | ||
2140 | ParamListNode(syntax) | ||
2141 | } | ||
2142 | } | ||
2143 | #[derive(Debug, Clone, Copy)] | 1831 | #[derive(Debug, Clone, Copy)] |
2144 | pub struct ParamList<'a> { | 1832 | pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2145 | syntax: SyntaxNodeRef<'a>, | 1833 | syntax: SyntaxNode<R>, |
2146 | } | 1834 | } |
1835 | pub type ParamList<'a> = ParamListNode<RefRoot<'a>>; | ||
2147 | 1836 | ||
2148 | impl<'a> AstNode<'a> for ParamList<'a> { | 1837 | impl<'a> AstNode<'a> for ParamList<'a> { |
2149 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1838 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2155,6 +1844,16 @@ impl<'a> AstNode<'a> for ParamList<'a> { | |||
2155 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1844 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2156 | } | 1845 | } |
2157 | 1846 | ||
1847 | impl<R: TreeRoot<RaTypes>> ParamListNode<R> { | ||
1848 | pub fn borrowed(&self) -> ParamList { | ||
1849 | ParamListNode { syntax: self.syntax.borrowed() } | ||
1850 | } | ||
1851 | pub fn owned(&self) -> ParamListNode { | ||
1852 | ParamListNode { syntax: self.syntax.owned() } | ||
1853 | } | ||
1854 | } | ||
1855 | |||
1856 | |||
2158 | impl<'a> ParamList<'a> { | 1857 | impl<'a> ParamList<'a> { |
2159 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { | 1858 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { |
2160 | super::children(self) | 1859 | super::children(self) |
@@ -2166,26 +1865,11 @@ impl<'a> ParamList<'a> { | |||
2166 | } | 1865 | } |
2167 | 1866 | ||
2168 | // ParenExpr | 1867 | // ParenExpr |
2169 | |||
2170 | #[derive(Debug, Clone)] | ||
2171 | pub struct ParenExprNode(SyntaxNode); | ||
2172 | |||
2173 | impl ParenExprNode { | ||
2174 | pub fn ast(&self) -> ParenExpr { | ||
2175 | ParenExpr::cast(self.0.borrowed()).unwrap() | ||
2176 | } | ||
2177 | } | ||
2178 | |||
2179 | impl<'a> From<ParenExpr<'a>> for ParenExprNode { | ||
2180 | fn from(ast: ParenExpr<'a>) -> ParenExprNode { | ||
2181 | let syntax = ast.syntax().owned(); | ||
2182 | ParenExprNode(syntax) | ||
2183 | } | ||
2184 | } | ||
2185 | #[derive(Debug, Clone, Copy)] | 1868 | #[derive(Debug, Clone, Copy)] |
2186 | pub struct ParenExpr<'a> { | 1869 | pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2187 | syntax: SyntaxNodeRef<'a>, | 1870 | syntax: SyntaxNode<R>, |
2188 | } | 1871 | } |
1872 | pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>; | ||
2189 | 1873 | ||
2190 | impl<'a> AstNode<'a> for ParenExpr<'a> { | 1874 | impl<'a> AstNode<'a> for ParenExpr<'a> { |
2191 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1875 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2197,29 +1881,24 @@ impl<'a> AstNode<'a> for ParenExpr<'a> { | |||
2197 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1881 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2198 | } | 1882 | } |
2199 | 1883 | ||
2200 | impl<'a> ParenExpr<'a> {} | 1884 | impl<R: TreeRoot<RaTypes>> ParenExprNode<R> { |
2201 | 1885 | pub fn borrowed(&self) -> ParenExpr { | |
2202 | // ParenType | 1886 | ParenExprNode { syntax: self.syntax.borrowed() } |
2203 | |||
2204 | #[derive(Debug, Clone)] | ||
2205 | pub struct ParenTypeNode(SyntaxNode); | ||
2206 | |||
2207 | impl ParenTypeNode { | ||
2208 | pub fn ast(&self) -> ParenType { | ||
2209 | ParenType::cast(self.0.borrowed()).unwrap() | ||
2210 | } | 1887 | } |
2211 | } | 1888 | pub fn owned(&self) -> ParenExprNode { |
2212 | 1889 | ParenExprNode { syntax: self.syntax.owned() } | |
2213 | impl<'a> From<ParenType<'a>> for ParenTypeNode { | ||
2214 | fn from(ast: ParenType<'a>) -> ParenTypeNode { | ||
2215 | let syntax = ast.syntax().owned(); | ||
2216 | ParenTypeNode(syntax) | ||
2217 | } | 1890 | } |
2218 | } | 1891 | } |
1892 | |||
1893 | |||
1894 | impl<'a> ParenExpr<'a> {} | ||
1895 | |||
1896 | // ParenType | ||
2219 | #[derive(Debug, Clone, Copy)] | 1897 | #[derive(Debug, Clone, Copy)] |
2220 | pub struct ParenType<'a> { | 1898 | pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2221 | syntax: SyntaxNodeRef<'a>, | 1899 | syntax: SyntaxNode<R>, |
2222 | } | 1900 | } |
1901 | pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>; | ||
2223 | 1902 | ||
2224 | impl<'a> AstNode<'a> for ParenType<'a> { | 1903 | impl<'a> AstNode<'a> for ParenType<'a> { |
2225 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1904 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2231,25 +1910,19 @@ impl<'a> AstNode<'a> for ParenType<'a> { | |||
2231 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1910 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2232 | } | 1911 | } |
2233 | 1912 | ||
2234 | impl<'a> ParenType<'a> {} | 1913 | impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> { |
2235 | 1914 | pub fn borrowed(&self) -> ParenType { | |
2236 | // Pat | 1915 | ParenTypeNode { syntax: self.syntax.borrowed() } |
2237 | |||
2238 | #[derive(Debug, Clone)] | ||
2239 | pub struct PatNode(SyntaxNode); | ||
2240 | |||
2241 | impl PatNode { | ||
2242 | pub fn ast(&self) -> Pat { | ||
2243 | Pat::cast(self.0.borrowed()).unwrap() | ||
2244 | } | 1916 | } |
2245 | } | 1917 | pub fn owned(&self) -> ParenTypeNode { |
2246 | 1918 | ParenTypeNode { syntax: self.syntax.owned() } | |
2247 | impl<'a> From<Pat<'a>> for PatNode { | ||
2248 | fn from(ast: Pat<'a>) -> PatNode { | ||
2249 | let syntax = ast.syntax().owned(); | ||
2250 | PatNode(syntax) | ||
2251 | } | 1919 | } |
2252 | } | 1920 | } |
1921 | |||
1922 | |||
1923 | impl<'a> ParenType<'a> {} | ||
1924 | |||
1925 | // Pat | ||
2253 | #[derive(Debug, Clone, Copy)] | 1926 | #[derive(Debug, Clone, Copy)] |
2254 | pub enum Pat<'a> { | 1927 | pub enum Pat<'a> { |
2255 | RefPat(RefPat<'a>), | 1928 | RefPat(RefPat<'a>), |
@@ -2299,26 +1972,11 @@ impl<'a> AstNode<'a> for Pat<'a> { | |||
2299 | impl<'a> Pat<'a> {} | 1972 | impl<'a> Pat<'a> {} |
2300 | 1973 | ||
2301 | // Path | 1974 | // Path |
2302 | |||
2303 | #[derive(Debug, Clone)] | ||
2304 | pub struct PathNode(SyntaxNode); | ||
2305 | |||
2306 | impl PathNode { | ||
2307 | pub fn ast(&self) -> Path { | ||
2308 | Path::cast(self.0.borrowed()).unwrap() | ||
2309 | } | ||
2310 | } | ||
2311 | |||
2312 | impl<'a> From<Path<'a>> for PathNode { | ||
2313 | fn from(ast: Path<'a>) -> PathNode { | ||
2314 | let syntax = ast.syntax().owned(); | ||
2315 | PathNode(syntax) | ||
2316 | } | ||
2317 | } | ||
2318 | #[derive(Debug, Clone, Copy)] | 1975 | #[derive(Debug, Clone, Copy)] |
2319 | pub struct Path<'a> { | 1976 | pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2320 | syntax: SyntaxNodeRef<'a>, | 1977 | syntax: SyntaxNode<R>, |
2321 | } | 1978 | } |
1979 | pub type Path<'a> = PathNode<RefRoot<'a>>; | ||
2322 | 1980 | ||
2323 | impl<'a> AstNode<'a> for Path<'a> { | 1981 | impl<'a> AstNode<'a> for Path<'a> { |
2324 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1982 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2330,6 +1988,16 @@ impl<'a> AstNode<'a> for Path<'a> { | |||
2330 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1988 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2331 | } | 1989 | } |
2332 | 1990 | ||
1991 | impl<R: TreeRoot<RaTypes>> PathNode<R> { | ||
1992 | pub fn borrowed(&self) -> Path { | ||
1993 | PathNode { syntax: self.syntax.borrowed() } | ||
1994 | } | ||
1995 | pub fn owned(&self) -> PathNode { | ||
1996 | PathNode { syntax: self.syntax.owned() } | ||
1997 | } | ||
1998 | } | ||
1999 | |||
2000 | |||
2333 | impl<'a> Path<'a> { | 2001 | impl<'a> Path<'a> { |
2334 | pub fn segment(self) -> Option<PathSegment<'a>> { | 2002 | pub fn segment(self) -> Option<PathSegment<'a>> { |
2335 | super::child_opt(self) | 2003 | super::child_opt(self) |
@@ -2341,26 +2009,11 @@ impl<'a> Path<'a> { | |||
2341 | } | 2009 | } |
2342 | 2010 | ||
2343 | // PathExpr | 2011 | // PathExpr |
2344 | |||
2345 | #[derive(Debug, Clone)] | ||
2346 | pub struct PathExprNode(SyntaxNode); | ||
2347 | |||
2348 | impl PathExprNode { | ||
2349 | pub fn ast(&self) -> PathExpr { | ||
2350 | PathExpr::cast(self.0.borrowed()).unwrap() | ||
2351 | } | ||
2352 | } | ||
2353 | |||
2354 | impl<'a> From<PathExpr<'a>> for PathExprNode { | ||
2355 | fn from(ast: PathExpr<'a>) -> PathExprNode { | ||
2356 | let syntax = ast.syntax().owned(); | ||
2357 | PathExprNode(syntax) | ||
2358 | } | ||
2359 | } | ||
2360 | #[derive(Debug, Clone, Copy)] | 2012 | #[derive(Debug, Clone, Copy)] |
2361 | pub struct PathExpr<'a> { | 2013 | pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2362 | syntax: SyntaxNodeRef<'a>, | 2014 | syntax: SyntaxNode<R>, |
2363 | } | 2015 | } |
2016 | pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>; | ||
2364 | 2017 | ||
2365 | impl<'a> AstNode<'a> for PathExpr<'a> { | 2018 | impl<'a> AstNode<'a> for PathExpr<'a> { |
2366 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2019 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2372,33 +2025,28 @@ impl<'a> AstNode<'a> for PathExpr<'a> { | |||
2372 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2025 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2373 | } | 2026 | } |
2374 | 2027 | ||
2375 | impl<'a> PathExpr<'a> { | 2028 | impl<R: TreeRoot<RaTypes>> PathExprNode<R> { |
2376 | pub fn path(self) -> Option<Path<'a>> { | 2029 | pub fn borrowed(&self) -> PathExpr { |
2377 | super::child_opt(self) | 2030 | PathExprNode { syntax: self.syntax.borrowed() } |
2031 | } | ||
2032 | pub fn owned(&self) -> PathExprNode { | ||
2033 | PathExprNode { syntax: self.syntax.owned() } | ||
2378 | } | 2034 | } |
2379 | } | 2035 | } |
2380 | 2036 | ||
2381 | // PathPat | ||
2382 | |||
2383 | #[derive(Debug, Clone)] | ||
2384 | pub struct PathPatNode(SyntaxNode); | ||
2385 | 2037 | ||
2386 | impl PathPatNode { | 2038 | impl<'a> PathExpr<'a> { |
2387 | pub fn ast(&self) -> PathPat { | 2039 | pub fn path(self) -> Option<Path<'a>> { |
2388 | PathPat::cast(self.0.borrowed()).unwrap() | 2040 | super::child_opt(self) |
2389 | } | 2041 | } |
2390 | } | 2042 | } |
2391 | 2043 | ||
2392 | impl<'a> From<PathPat<'a>> for PathPatNode { | 2044 | // PathPat |
2393 | fn from(ast: PathPat<'a>) -> PathPatNode { | ||
2394 | let syntax = ast.syntax().owned(); | ||
2395 | PathPatNode(syntax) | ||
2396 | } | ||
2397 | } | ||
2398 | #[derive(Debug, Clone, Copy)] | 2045 | #[derive(Debug, Clone, Copy)] |
2399 | pub struct PathPat<'a> { | 2046 | pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2400 | syntax: SyntaxNodeRef<'a>, | 2047 | syntax: SyntaxNode<R>, |
2401 | } | 2048 | } |
2049 | pub type PathPat<'a> = PathPatNode<RefRoot<'a>>; | ||
2402 | 2050 | ||
2403 | impl<'a> AstNode<'a> for PathPat<'a> { | 2051 | impl<'a> AstNode<'a> for PathPat<'a> { |
2404 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2052 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2410,29 +2058,24 @@ impl<'a> AstNode<'a> for PathPat<'a> { | |||
2410 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2058 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2411 | } | 2059 | } |
2412 | 2060 | ||
2413 | impl<'a> PathPat<'a> {} | 2061 | impl<R: TreeRoot<RaTypes>> PathPatNode<R> { |
2414 | 2062 | pub fn borrowed(&self) -> PathPat { | |
2415 | // PathSegment | 2063 | PathPatNode { syntax: self.syntax.borrowed() } |
2416 | |||
2417 | #[derive(Debug, Clone)] | ||
2418 | pub struct PathSegmentNode(SyntaxNode); | ||
2419 | |||
2420 | impl PathSegmentNode { | ||
2421 | pub fn ast(&self) -> PathSegment { | ||
2422 | PathSegment::cast(self.0.borrowed()).unwrap() | ||
2423 | } | 2064 | } |
2424 | } | 2065 | pub fn owned(&self) -> PathPatNode { |
2425 | 2066 | PathPatNode { syntax: self.syntax.owned() } | |
2426 | impl<'a> From<PathSegment<'a>> for PathSegmentNode { | ||
2427 | fn from(ast: PathSegment<'a>) -> PathSegmentNode { | ||
2428 | let syntax = ast.syntax().owned(); | ||
2429 | PathSegmentNode(syntax) | ||
2430 | } | 2067 | } |
2431 | } | 2068 | } |
2069 | |||
2070 | |||
2071 | impl<'a> PathPat<'a> {} | ||
2072 | |||
2073 | // PathSegment | ||
2432 | #[derive(Debug, Clone, Copy)] | 2074 | #[derive(Debug, Clone, Copy)] |
2433 | pub struct PathSegment<'a> { | 2075 | pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2434 | syntax: SyntaxNodeRef<'a>, | 2076 | syntax: SyntaxNode<R>, |
2435 | } | 2077 | } |
2078 | pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>; | ||
2436 | 2079 | ||
2437 | impl<'a> AstNode<'a> for PathSegment<'a> { | 2080 | impl<'a> AstNode<'a> for PathSegment<'a> { |
2438 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2081 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2444,33 +2087,28 @@ impl<'a> AstNode<'a> for PathSegment<'a> { | |||
2444 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2087 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2445 | } | 2088 | } |
2446 | 2089 | ||
2447 | impl<'a> PathSegment<'a> { | 2090 | impl<R: TreeRoot<RaTypes>> PathSegmentNode<R> { |
2448 | pub fn name_ref(self) -> Option<NameRef<'a>> { | 2091 | pub fn borrowed(&self) -> PathSegment { |
2449 | super::child_opt(self) | 2092 | PathSegmentNode { syntax: self.syntax.borrowed() } |
2093 | } | ||
2094 | pub fn owned(&self) -> PathSegmentNode { | ||
2095 | PathSegmentNode { syntax: self.syntax.owned() } | ||
2450 | } | 2096 | } |
2451 | } | 2097 | } |
2452 | 2098 | ||
2453 | // PathType | ||
2454 | |||
2455 | #[derive(Debug, Clone)] | ||
2456 | pub struct PathTypeNode(SyntaxNode); | ||
2457 | 2099 | ||
2458 | impl PathTypeNode { | 2100 | impl<'a> PathSegment<'a> { |
2459 | pub fn ast(&self) -> PathType { | 2101 | pub fn name_ref(self) -> Option<NameRef<'a>> { |
2460 | PathType::cast(self.0.borrowed()).unwrap() | 2102 | super::child_opt(self) |
2461 | } | 2103 | } |
2462 | } | 2104 | } |
2463 | 2105 | ||
2464 | impl<'a> From<PathType<'a>> for PathTypeNode { | 2106 | // PathType |
2465 | fn from(ast: PathType<'a>) -> PathTypeNode { | ||
2466 | let syntax = ast.syntax().owned(); | ||
2467 | PathTypeNode(syntax) | ||
2468 | } | ||
2469 | } | ||
2470 | #[derive(Debug, Clone, Copy)] | 2107 | #[derive(Debug, Clone, Copy)] |
2471 | pub struct PathType<'a> { | 2108 | pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2472 | syntax: SyntaxNodeRef<'a>, | 2109 | syntax: SyntaxNode<R>, |
2473 | } | 2110 | } |
2111 | pub type PathType<'a> = PathTypeNode<RefRoot<'a>>; | ||
2474 | 2112 | ||
2475 | impl<'a> AstNode<'a> for PathType<'a> { | 2113 | impl<'a> AstNode<'a> for PathType<'a> { |
2476 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2114 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2482,29 +2120,24 @@ impl<'a> AstNode<'a> for PathType<'a> { | |||
2482 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2120 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2483 | } | 2121 | } |
2484 | 2122 | ||
2485 | impl<'a> PathType<'a> {} | 2123 | impl<R: TreeRoot<RaTypes>> PathTypeNode<R> { |
2486 | 2124 | pub fn borrowed(&self) -> PathType { | |
2487 | // PlaceholderPat | 2125 | PathTypeNode { syntax: self.syntax.borrowed() } |
2488 | |||
2489 | #[derive(Debug, Clone)] | ||
2490 | pub struct PlaceholderPatNode(SyntaxNode); | ||
2491 | |||
2492 | impl PlaceholderPatNode { | ||
2493 | pub fn ast(&self) -> PlaceholderPat { | ||
2494 | PlaceholderPat::cast(self.0.borrowed()).unwrap() | ||
2495 | } | 2126 | } |
2496 | } | 2127 | pub fn owned(&self) -> PathTypeNode { |
2497 | 2128 | PathTypeNode { syntax: self.syntax.owned() } | |
2498 | impl<'a> From<PlaceholderPat<'a>> for PlaceholderPatNode { | ||
2499 | fn from(ast: PlaceholderPat<'a>) -> PlaceholderPatNode { | ||
2500 | let syntax = ast.syntax().owned(); | ||
2501 | PlaceholderPatNode(syntax) | ||
2502 | } | 2129 | } |
2503 | } | 2130 | } |
2131 | |||
2132 | |||
2133 | impl<'a> PathType<'a> {} | ||
2134 | |||
2135 | // PlaceholderPat | ||
2504 | #[derive(Debug, Clone, Copy)] | 2136 | #[derive(Debug, Clone, Copy)] |
2505 | pub struct PlaceholderPat<'a> { | 2137 | pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2506 | syntax: SyntaxNodeRef<'a>, | 2138 | syntax: SyntaxNode<R>, |
2507 | } | 2139 | } |
2140 | pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>; | ||
2508 | 2141 | ||
2509 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { | 2142 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { |
2510 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2143 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2516,29 +2149,24 @@ impl<'a> AstNode<'a> for PlaceholderPat<'a> { | |||
2516 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2149 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2517 | } | 2150 | } |
2518 | 2151 | ||
2519 | impl<'a> PlaceholderPat<'a> {} | 2152 | impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> { |
2520 | 2153 | pub fn borrowed(&self) -> PlaceholderPat { | |
2521 | // PlaceholderType | 2154 | PlaceholderPatNode { syntax: self.syntax.borrowed() } |
2522 | |||
2523 | #[derive(Debug, Clone)] | ||
2524 | pub struct PlaceholderTypeNode(SyntaxNode); | ||
2525 | |||
2526 | impl PlaceholderTypeNode { | ||
2527 | pub fn ast(&self) -> PlaceholderType { | ||
2528 | PlaceholderType::cast(self.0.borrowed()).unwrap() | ||
2529 | } | 2155 | } |
2530 | } | 2156 | pub fn owned(&self) -> PlaceholderPatNode { |
2531 | 2157 | PlaceholderPatNode { syntax: self.syntax.owned() } | |
2532 | impl<'a> From<PlaceholderType<'a>> for PlaceholderTypeNode { | ||
2533 | fn from(ast: PlaceholderType<'a>) -> PlaceholderTypeNode { | ||
2534 | let syntax = ast.syntax().owned(); | ||
2535 | PlaceholderTypeNode(syntax) | ||
2536 | } | 2158 | } |
2537 | } | 2159 | } |
2160 | |||
2161 | |||
2162 | impl<'a> PlaceholderPat<'a> {} | ||
2163 | |||
2164 | // PlaceholderType | ||
2538 | #[derive(Debug, Clone, Copy)] | 2165 | #[derive(Debug, Clone, Copy)] |
2539 | pub struct PlaceholderType<'a> { | 2166 | pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2540 | syntax: SyntaxNodeRef<'a>, | 2167 | syntax: SyntaxNode<R>, |
2541 | } | 2168 | } |
2169 | pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>; | ||
2542 | 2170 | ||
2543 | impl<'a> AstNode<'a> for PlaceholderType<'a> { | 2171 | impl<'a> AstNode<'a> for PlaceholderType<'a> { |
2544 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2172 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2550,29 +2178,24 @@ impl<'a> AstNode<'a> for PlaceholderType<'a> { | |||
2550 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2178 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2551 | } | 2179 | } |
2552 | 2180 | ||
2553 | impl<'a> PlaceholderType<'a> {} | 2181 | impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> { |
2554 | 2182 | pub fn borrowed(&self) -> PlaceholderType { | |
2555 | // PointerType | 2183 | PlaceholderTypeNode { syntax: self.syntax.borrowed() } |
2556 | |||
2557 | #[derive(Debug, Clone)] | ||
2558 | pub struct PointerTypeNode(SyntaxNode); | ||
2559 | |||
2560 | impl PointerTypeNode { | ||
2561 | pub fn ast(&self) -> PointerType { | ||
2562 | PointerType::cast(self.0.borrowed()).unwrap() | ||
2563 | } | 2184 | } |
2564 | } | 2185 | pub fn owned(&self) -> PlaceholderTypeNode { |
2565 | 2186 | PlaceholderTypeNode { syntax: self.syntax.owned() } | |
2566 | impl<'a> From<PointerType<'a>> for PointerTypeNode { | ||
2567 | fn from(ast: PointerType<'a>) -> PointerTypeNode { | ||
2568 | let syntax = ast.syntax().owned(); | ||
2569 | PointerTypeNode(syntax) | ||
2570 | } | 2187 | } |
2571 | } | 2188 | } |
2189 | |||
2190 | |||
2191 | impl<'a> PlaceholderType<'a> {} | ||
2192 | |||
2193 | // PointerType | ||
2572 | #[derive(Debug, Clone, Copy)] | 2194 | #[derive(Debug, Clone, Copy)] |
2573 | pub struct PointerType<'a> { | 2195 | pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2574 | syntax: SyntaxNodeRef<'a>, | 2196 | syntax: SyntaxNode<R>, |
2575 | } | 2197 | } |
2198 | pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>; | ||
2576 | 2199 | ||
2577 | impl<'a> AstNode<'a> for PointerType<'a> { | 2200 | impl<'a> AstNode<'a> for PointerType<'a> { |
2578 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2201 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2584,29 +2207,24 @@ impl<'a> AstNode<'a> for PointerType<'a> { | |||
2584 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2207 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2585 | } | 2208 | } |
2586 | 2209 | ||
2587 | impl<'a> PointerType<'a> {} | 2210 | impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> { |
2588 | 2211 | pub fn borrowed(&self) -> PointerType { | |
2589 | // PrefixExpr | 2212 | PointerTypeNode { syntax: self.syntax.borrowed() } |
2590 | |||
2591 | #[derive(Debug, Clone)] | ||
2592 | pub struct PrefixExprNode(SyntaxNode); | ||
2593 | |||
2594 | impl PrefixExprNode { | ||
2595 | pub fn ast(&self) -> PrefixExpr { | ||
2596 | PrefixExpr::cast(self.0.borrowed()).unwrap() | ||
2597 | } | 2213 | } |
2598 | } | 2214 | pub fn owned(&self) -> PointerTypeNode { |
2599 | 2215 | PointerTypeNode { syntax: self.syntax.owned() } | |
2600 | impl<'a> From<PrefixExpr<'a>> for PrefixExprNode { | ||
2601 | fn from(ast: PrefixExpr<'a>) -> PrefixExprNode { | ||
2602 | let syntax = ast.syntax().owned(); | ||
2603 | PrefixExprNode(syntax) | ||
2604 | } | 2216 | } |
2605 | } | 2217 | } |
2218 | |||
2219 | |||
2220 | impl<'a> PointerType<'a> {} | ||
2221 | |||
2222 | // PrefixExpr | ||
2606 | #[derive(Debug, Clone, Copy)] | 2223 | #[derive(Debug, Clone, Copy)] |
2607 | pub struct PrefixExpr<'a> { | 2224 | pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2608 | syntax: SyntaxNodeRef<'a>, | 2225 | syntax: SyntaxNode<R>, |
2609 | } | 2226 | } |
2227 | pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>; | ||
2610 | 2228 | ||
2611 | impl<'a> AstNode<'a> for PrefixExpr<'a> { | 2229 | impl<'a> AstNode<'a> for PrefixExpr<'a> { |
2612 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2230 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2618,29 +2236,24 @@ impl<'a> AstNode<'a> for PrefixExpr<'a> { | |||
2618 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2236 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2619 | } | 2237 | } |
2620 | 2238 | ||
2621 | impl<'a> PrefixExpr<'a> {} | 2239 | impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> { |
2622 | 2240 | pub fn borrowed(&self) -> PrefixExpr { | |
2623 | // RangeExpr | 2241 | PrefixExprNode { syntax: self.syntax.borrowed() } |
2624 | |||
2625 | #[derive(Debug, Clone)] | ||
2626 | pub struct RangeExprNode(SyntaxNode); | ||
2627 | |||
2628 | impl RangeExprNode { | ||
2629 | pub fn ast(&self) -> RangeExpr { | ||
2630 | RangeExpr::cast(self.0.borrowed()).unwrap() | ||
2631 | } | 2242 | } |
2632 | } | 2243 | pub fn owned(&self) -> PrefixExprNode { |
2633 | 2244 | PrefixExprNode { syntax: self.syntax.owned() } | |
2634 | impl<'a> From<RangeExpr<'a>> for RangeExprNode { | ||
2635 | fn from(ast: RangeExpr<'a>) -> RangeExprNode { | ||
2636 | let syntax = ast.syntax().owned(); | ||
2637 | RangeExprNode(syntax) | ||
2638 | } | 2245 | } |
2639 | } | 2246 | } |
2247 | |||
2248 | |||
2249 | impl<'a> PrefixExpr<'a> {} | ||
2250 | |||
2251 | // RangeExpr | ||
2640 | #[derive(Debug, Clone, Copy)] | 2252 | #[derive(Debug, Clone, Copy)] |
2641 | pub struct RangeExpr<'a> { | 2253 | pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2642 | syntax: SyntaxNodeRef<'a>, | 2254 | syntax: SyntaxNode<R>, |
2643 | } | 2255 | } |
2256 | pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>; | ||
2644 | 2257 | ||
2645 | impl<'a> AstNode<'a> for RangeExpr<'a> { | 2258 | impl<'a> AstNode<'a> for RangeExpr<'a> { |
2646 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2259 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2652,29 +2265,24 @@ impl<'a> AstNode<'a> for RangeExpr<'a> { | |||
2652 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2265 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2653 | } | 2266 | } |
2654 | 2267 | ||
2655 | impl<'a> RangeExpr<'a> {} | 2268 | impl<R: TreeRoot<RaTypes>> RangeExprNode<R> { |
2656 | 2269 | pub fn borrowed(&self) -> RangeExpr { | |
2657 | // RangePat | 2270 | RangeExprNode { syntax: self.syntax.borrowed() } |
2658 | |||
2659 | #[derive(Debug, Clone)] | ||
2660 | pub struct RangePatNode(SyntaxNode); | ||
2661 | |||
2662 | impl RangePatNode { | ||
2663 | pub fn ast(&self) -> RangePat { | ||
2664 | RangePat::cast(self.0.borrowed()).unwrap() | ||
2665 | } | 2271 | } |
2666 | } | 2272 | pub fn owned(&self) -> RangeExprNode { |
2667 | 2273 | RangeExprNode { syntax: self.syntax.owned() } | |
2668 | impl<'a> From<RangePat<'a>> for RangePatNode { | ||
2669 | fn from(ast: RangePat<'a>) -> RangePatNode { | ||
2670 | let syntax = ast.syntax().owned(); | ||
2671 | RangePatNode(syntax) | ||
2672 | } | 2274 | } |
2673 | } | 2275 | } |
2276 | |||
2277 | |||
2278 | impl<'a> RangeExpr<'a> {} | ||
2279 | |||
2280 | // RangePat | ||
2674 | #[derive(Debug, Clone, Copy)] | 2281 | #[derive(Debug, Clone, Copy)] |
2675 | pub struct RangePat<'a> { | 2282 | pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2676 | syntax: SyntaxNodeRef<'a>, | 2283 | syntax: SyntaxNode<R>, |
2677 | } | 2284 | } |
2285 | pub type RangePat<'a> = RangePatNode<RefRoot<'a>>; | ||
2678 | 2286 | ||
2679 | impl<'a> AstNode<'a> for RangePat<'a> { | 2287 | impl<'a> AstNode<'a> for RangePat<'a> { |
2680 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2288 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2686,29 +2294,24 @@ impl<'a> AstNode<'a> for RangePat<'a> { | |||
2686 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2294 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2687 | } | 2295 | } |
2688 | 2296 | ||
2689 | impl<'a> RangePat<'a> {} | 2297 | impl<R: TreeRoot<RaTypes>> RangePatNode<R> { |
2690 | 2298 | pub fn borrowed(&self) -> RangePat { | |
2691 | // RefExpr | 2299 | RangePatNode { syntax: self.syntax.borrowed() } |
2692 | |||
2693 | #[derive(Debug, Clone)] | ||
2694 | pub struct RefExprNode(SyntaxNode); | ||
2695 | |||
2696 | impl RefExprNode { | ||
2697 | pub fn ast(&self) -> RefExpr { | ||
2698 | RefExpr::cast(self.0.borrowed()).unwrap() | ||
2699 | } | 2300 | } |
2700 | } | 2301 | pub fn owned(&self) -> RangePatNode { |
2701 | 2302 | RangePatNode { syntax: self.syntax.owned() } | |
2702 | impl<'a> From<RefExpr<'a>> for RefExprNode { | ||
2703 | fn from(ast: RefExpr<'a>) -> RefExprNode { | ||
2704 | let syntax = ast.syntax().owned(); | ||
2705 | RefExprNode(syntax) | ||
2706 | } | 2303 | } |
2707 | } | 2304 | } |
2305 | |||
2306 | |||
2307 | impl<'a> RangePat<'a> {} | ||
2308 | |||
2309 | // RefExpr | ||
2708 | #[derive(Debug, Clone, Copy)] | 2310 | #[derive(Debug, Clone, Copy)] |
2709 | pub struct RefExpr<'a> { | 2311 | pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2710 | syntax: SyntaxNodeRef<'a>, | 2312 | syntax: SyntaxNode<R>, |
2711 | } | 2313 | } |
2314 | pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>; | ||
2712 | 2315 | ||
2713 | impl<'a> AstNode<'a> for RefExpr<'a> { | 2316 | impl<'a> AstNode<'a> for RefExpr<'a> { |
2714 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2317 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2720,29 +2323,24 @@ impl<'a> AstNode<'a> for RefExpr<'a> { | |||
2720 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2323 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2721 | } | 2324 | } |
2722 | 2325 | ||
2723 | impl<'a> RefExpr<'a> {} | 2326 | impl<R: TreeRoot<RaTypes>> RefExprNode<R> { |
2724 | 2327 | pub fn borrowed(&self) -> RefExpr { | |
2725 | // RefPat | 2328 | RefExprNode { syntax: self.syntax.borrowed() } |
2726 | |||
2727 | #[derive(Debug, Clone)] | ||
2728 | pub struct RefPatNode(SyntaxNode); | ||
2729 | |||
2730 | impl RefPatNode { | ||
2731 | pub fn ast(&self) -> RefPat { | ||
2732 | RefPat::cast(self.0.borrowed()).unwrap() | ||
2733 | } | 2329 | } |
2734 | } | 2330 | pub fn owned(&self) -> RefExprNode { |
2735 | 2331 | RefExprNode { syntax: self.syntax.owned() } | |
2736 | impl<'a> From<RefPat<'a>> for RefPatNode { | ||
2737 | fn from(ast: RefPat<'a>) -> RefPatNode { | ||
2738 | let syntax = ast.syntax().owned(); | ||
2739 | RefPatNode(syntax) | ||
2740 | } | 2332 | } |
2741 | } | 2333 | } |
2334 | |||
2335 | |||
2336 | impl<'a> RefExpr<'a> {} | ||
2337 | |||
2338 | // RefPat | ||
2742 | #[derive(Debug, Clone, Copy)] | 2339 | #[derive(Debug, Clone, Copy)] |
2743 | pub struct RefPat<'a> { | 2340 | pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2744 | syntax: SyntaxNodeRef<'a>, | 2341 | syntax: SyntaxNode<R>, |
2745 | } | 2342 | } |
2343 | pub type RefPat<'a> = RefPatNode<RefRoot<'a>>; | ||
2746 | 2344 | ||
2747 | impl<'a> AstNode<'a> for RefPat<'a> { | 2345 | impl<'a> AstNode<'a> for RefPat<'a> { |
2748 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2346 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2754,29 +2352,24 @@ impl<'a> AstNode<'a> for RefPat<'a> { | |||
2754 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2352 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2755 | } | 2353 | } |
2756 | 2354 | ||
2757 | impl<'a> RefPat<'a> {} | 2355 | impl<R: TreeRoot<RaTypes>> RefPatNode<R> { |
2758 | 2356 | pub fn borrowed(&self) -> RefPat { | |
2759 | // ReferenceType | 2357 | RefPatNode { syntax: self.syntax.borrowed() } |
2760 | |||
2761 | #[derive(Debug, Clone)] | ||
2762 | pub struct ReferenceTypeNode(SyntaxNode); | ||
2763 | |||
2764 | impl ReferenceTypeNode { | ||
2765 | pub fn ast(&self) -> ReferenceType { | ||
2766 | ReferenceType::cast(self.0.borrowed()).unwrap() | ||
2767 | } | 2358 | } |
2768 | } | 2359 | pub fn owned(&self) -> RefPatNode { |
2769 | 2360 | RefPatNode { syntax: self.syntax.owned() } | |
2770 | impl<'a> From<ReferenceType<'a>> for ReferenceTypeNode { | ||
2771 | fn from(ast: ReferenceType<'a>) -> ReferenceTypeNode { | ||
2772 | let syntax = ast.syntax().owned(); | ||
2773 | ReferenceTypeNode(syntax) | ||
2774 | } | 2361 | } |
2775 | } | 2362 | } |
2363 | |||
2364 | |||
2365 | impl<'a> RefPat<'a> {} | ||
2366 | |||
2367 | // ReferenceType | ||
2776 | #[derive(Debug, Clone, Copy)] | 2368 | #[derive(Debug, Clone, Copy)] |
2777 | pub struct ReferenceType<'a> { | 2369 | pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2778 | syntax: SyntaxNodeRef<'a>, | 2370 | syntax: SyntaxNode<R>, |
2779 | } | 2371 | } |
2372 | pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>; | ||
2780 | 2373 | ||
2781 | impl<'a> AstNode<'a> for ReferenceType<'a> { | 2374 | impl<'a> AstNode<'a> for ReferenceType<'a> { |
2782 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2375 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2788,29 +2381,24 @@ impl<'a> AstNode<'a> for ReferenceType<'a> { | |||
2788 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2381 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2789 | } | 2382 | } |
2790 | 2383 | ||
2791 | impl<'a> ReferenceType<'a> {} | 2384 | impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> { |
2792 | 2385 | pub fn borrowed(&self) -> ReferenceType { | |
2793 | // RetType | 2386 | ReferenceTypeNode { syntax: self.syntax.borrowed() } |
2794 | |||
2795 | #[derive(Debug, Clone)] | ||
2796 | pub struct RetTypeNode(SyntaxNode); | ||
2797 | |||
2798 | impl RetTypeNode { | ||
2799 | pub fn ast(&self) -> RetType { | ||
2800 | RetType::cast(self.0.borrowed()).unwrap() | ||
2801 | } | 2387 | } |
2802 | } | 2388 | pub fn owned(&self) -> ReferenceTypeNode { |
2803 | 2389 | ReferenceTypeNode { syntax: self.syntax.owned() } | |
2804 | impl<'a> From<RetType<'a>> for RetTypeNode { | ||
2805 | fn from(ast: RetType<'a>) -> RetTypeNode { | ||
2806 | let syntax = ast.syntax().owned(); | ||
2807 | RetTypeNode(syntax) | ||
2808 | } | 2390 | } |
2809 | } | 2391 | } |
2392 | |||
2393 | |||
2394 | impl<'a> ReferenceType<'a> {} | ||
2395 | |||
2396 | // RetType | ||
2810 | #[derive(Debug, Clone, Copy)] | 2397 | #[derive(Debug, Clone, Copy)] |
2811 | pub struct RetType<'a> { | 2398 | pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2812 | syntax: SyntaxNodeRef<'a>, | 2399 | syntax: SyntaxNode<R>, |
2813 | } | 2400 | } |
2401 | pub type RetType<'a> = RetTypeNode<RefRoot<'a>>; | ||
2814 | 2402 | ||
2815 | impl<'a> AstNode<'a> for RetType<'a> { | 2403 | impl<'a> AstNode<'a> for RetType<'a> { |
2816 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2404 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2822,29 +2410,24 @@ impl<'a> AstNode<'a> for RetType<'a> { | |||
2822 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2410 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2823 | } | 2411 | } |
2824 | 2412 | ||
2825 | impl<'a> RetType<'a> {} | 2413 | impl<R: TreeRoot<RaTypes>> RetTypeNode<R> { |
2826 | 2414 | pub fn borrowed(&self) -> RetType { | |
2827 | // ReturnExpr | 2415 | RetTypeNode { syntax: self.syntax.borrowed() } |
2828 | |||
2829 | #[derive(Debug, Clone)] | ||
2830 | pub struct ReturnExprNode(SyntaxNode); | ||
2831 | |||
2832 | impl ReturnExprNode { | ||
2833 | pub fn ast(&self) -> ReturnExpr { | ||
2834 | ReturnExpr::cast(self.0.borrowed()).unwrap() | ||
2835 | } | 2416 | } |
2836 | } | 2417 | pub fn owned(&self) -> RetTypeNode { |
2837 | 2418 | RetTypeNode { syntax: self.syntax.owned() } | |
2838 | impl<'a> From<ReturnExpr<'a>> for ReturnExprNode { | ||
2839 | fn from(ast: ReturnExpr<'a>) -> ReturnExprNode { | ||
2840 | let syntax = ast.syntax().owned(); | ||
2841 | ReturnExprNode(syntax) | ||
2842 | } | 2419 | } |
2843 | } | 2420 | } |
2421 | |||
2422 | |||
2423 | impl<'a> RetType<'a> {} | ||
2424 | |||
2425 | // ReturnExpr | ||
2844 | #[derive(Debug, Clone, Copy)] | 2426 | #[derive(Debug, Clone, Copy)] |
2845 | pub struct ReturnExpr<'a> { | 2427 | pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2846 | syntax: SyntaxNodeRef<'a>, | 2428 | syntax: SyntaxNode<R>, |
2847 | } | 2429 | } |
2430 | pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>; | ||
2848 | 2431 | ||
2849 | impl<'a> AstNode<'a> for ReturnExpr<'a> { | 2432 | impl<'a> AstNode<'a> for ReturnExpr<'a> { |
2850 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2433 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2856,29 +2439,24 @@ impl<'a> AstNode<'a> for ReturnExpr<'a> { | |||
2856 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2439 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2857 | } | 2440 | } |
2858 | 2441 | ||
2859 | impl<'a> ReturnExpr<'a> {} | 2442 | impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> { |
2860 | 2443 | pub fn borrowed(&self) -> ReturnExpr { | |
2861 | // Root | 2444 | ReturnExprNode { syntax: self.syntax.borrowed() } |
2862 | |||
2863 | #[derive(Debug, Clone)] | ||
2864 | pub struct RootNode(SyntaxNode); | ||
2865 | |||
2866 | impl RootNode { | ||
2867 | pub fn ast(&self) -> Root { | ||
2868 | Root::cast(self.0.borrowed()).unwrap() | ||
2869 | } | 2445 | } |
2870 | } | 2446 | pub fn owned(&self) -> ReturnExprNode { |
2871 | 2447 | ReturnExprNode { syntax: self.syntax.owned() } | |
2872 | impl<'a> From<Root<'a>> for RootNode { | ||
2873 | fn from(ast: Root<'a>) -> RootNode { | ||
2874 | let syntax = ast.syntax().owned(); | ||
2875 | RootNode(syntax) | ||
2876 | } | 2448 | } |
2877 | } | 2449 | } |
2450 | |||
2451 | |||
2452 | impl<'a> ReturnExpr<'a> {} | ||
2453 | |||
2454 | // Root | ||
2878 | #[derive(Debug, Clone, Copy)] | 2455 | #[derive(Debug, Clone, Copy)] |
2879 | pub struct Root<'a> { | 2456 | pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2880 | syntax: SyntaxNodeRef<'a>, | 2457 | syntax: SyntaxNode<R>, |
2881 | } | 2458 | } |
2459 | pub type Root<'a> = RootNode<RefRoot<'a>>; | ||
2882 | 2460 | ||
2883 | impl<'a> AstNode<'a> for Root<'a> { | 2461 | impl<'a> AstNode<'a> for Root<'a> { |
2884 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2462 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2890,6 +2468,16 @@ impl<'a> AstNode<'a> for Root<'a> { | |||
2890 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2468 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2891 | } | 2469 | } |
2892 | 2470 | ||
2471 | impl<R: TreeRoot<RaTypes>> RootNode<R> { | ||
2472 | pub fn borrowed(&self) -> Root { | ||
2473 | RootNode { syntax: self.syntax.borrowed() } | ||
2474 | } | ||
2475 | pub fn owned(&self) -> RootNode { | ||
2476 | RootNode { syntax: self.syntax.owned() } | ||
2477 | } | ||
2478 | } | ||
2479 | |||
2480 | |||
2893 | impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} | 2481 | impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} |
2894 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} | 2482 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} |
2895 | impl<'a> Root<'a> { | 2483 | impl<'a> Root<'a> { |
@@ -2899,26 +2487,11 @@ impl<'a> Root<'a> { | |||
2899 | } | 2487 | } |
2900 | 2488 | ||
2901 | // SelfParam | 2489 | // SelfParam |
2902 | |||
2903 | #[derive(Debug, Clone)] | ||
2904 | pub struct SelfParamNode(SyntaxNode); | ||
2905 | |||
2906 | impl SelfParamNode { | ||
2907 | pub fn ast(&self) -> SelfParam { | ||
2908 | SelfParam::cast(self.0.borrowed()).unwrap() | ||
2909 | } | ||
2910 | } | ||
2911 | |||
2912 | impl<'a> From<SelfParam<'a>> for SelfParamNode { | ||
2913 | fn from(ast: SelfParam<'a>) -> SelfParamNode { | ||
2914 | let syntax = ast.syntax().owned(); | ||
2915 | SelfParamNode(syntax) | ||
2916 | } | ||
2917 | } | ||
2918 | #[derive(Debug, Clone, Copy)] | 2490 | #[derive(Debug, Clone, Copy)] |
2919 | pub struct SelfParam<'a> { | 2491 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2920 | syntax: SyntaxNodeRef<'a>, | 2492 | syntax: SyntaxNode<R>, |
2921 | } | 2493 | } |
2494 | pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>; | ||
2922 | 2495 | ||
2923 | impl<'a> AstNode<'a> for SelfParam<'a> { | 2496 | impl<'a> AstNode<'a> for SelfParam<'a> { |
2924 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2497 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2930,29 +2503,24 @@ impl<'a> AstNode<'a> for SelfParam<'a> { | |||
2930 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2503 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2931 | } | 2504 | } |
2932 | 2505 | ||
2933 | impl<'a> SelfParam<'a> {} | 2506 | impl<R: TreeRoot<RaTypes>> SelfParamNode<R> { |
2934 | 2507 | pub fn borrowed(&self) -> SelfParam { | |
2935 | // SlicePat | 2508 | SelfParamNode { syntax: self.syntax.borrowed() } |
2936 | |||
2937 | #[derive(Debug, Clone)] | ||
2938 | pub struct SlicePatNode(SyntaxNode); | ||
2939 | |||
2940 | impl SlicePatNode { | ||
2941 | pub fn ast(&self) -> SlicePat { | ||
2942 | SlicePat::cast(self.0.borrowed()).unwrap() | ||
2943 | } | 2509 | } |
2944 | } | 2510 | pub fn owned(&self) -> SelfParamNode { |
2945 | 2511 | SelfParamNode { syntax: self.syntax.owned() } | |
2946 | impl<'a> From<SlicePat<'a>> for SlicePatNode { | ||
2947 | fn from(ast: SlicePat<'a>) -> SlicePatNode { | ||
2948 | let syntax = ast.syntax().owned(); | ||
2949 | SlicePatNode(syntax) | ||
2950 | } | 2512 | } |
2951 | } | 2513 | } |
2514 | |||
2515 | |||
2516 | impl<'a> SelfParam<'a> {} | ||
2517 | |||
2518 | // SlicePat | ||
2952 | #[derive(Debug, Clone, Copy)] | 2519 | #[derive(Debug, Clone, Copy)] |
2953 | pub struct SlicePat<'a> { | 2520 | pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2954 | syntax: SyntaxNodeRef<'a>, | 2521 | syntax: SyntaxNode<R>, |
2955 | } | 2522 | } |
2523 | pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>; | ||
2956 | 2524 | ||
2957 | impl<'a> AstNode<'a> for SlicePat<'a> { | 2525 | impl<'a> AstNode<'a> for SlicePat<'a> { |
2958 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2526 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2964,29 +2532,24 @@ impl<'a> AstNode<'a> for SlicePat<'a> { | |||
2964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2532 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2965 | } | 2533 | } |
2966 | 2534 | ||
2967 | impl<'a> SlicePat<'a> {} | 2535 | impl<R: TreeRoot<RaTypes>> SlicePatNode<R> { |
2968 | 2536 | pub fn borrowed(&self) -> SlicePat { | |
2969 | // SliceType | 2537 | SlicePatNode { syntax: self.syntax.borrowed() } |
2970 | |||
2971 | #[derive(Debug, Clone)] | ||
2972 | pub struct SliceTypeNode(SyntaxNode); | ||
2973 | |||
2974 | impl SliceTypeNode { | ||
2975 | pub fn ast(&self) -> SliceType { | ||
2976 | SliceType::cast(self.0.borrowed()).unwrap() | ||
2977 | } | 2538 | } |
2978 | } | 2539 | pub fn owned(&self) -> SlicePatNode { |
2979 | 2540 | SlicePatNode { syntax: self.syntax.owned() } | |
2980 | impl<'a> From<SliceType<'a>> for SliceTypeNode { | ||
2981 | fn from(ast: SliceType<'a>) -> SliceTypeNode { | ||
2982 | let syntax = ast.syntax().owned(); | ||
2983 | SliceTypeNode(syntax) | ||
2984 | } | 2541 | } |
2985 | } | 2542 | } |
2543 | |||
2544 | |||
2545 | impl<'a> SlicePat<'a> {} | ||
2546 | |||
2547 | // SliceType | ||
2986 | #[derive(Debug, Clone, Copy)] | 2548 | #[derive(Debug, Clone, Copy)] |
2987 | pub struct SliceType<'a> { | 2549 | pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2988 | syntax: SyntaxNodeRef<'a>, | 2550 | syntax: SyntaxNode<R>, |
2989 | } | 2551 | } |
2552 | pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>; | ||
2990 | 2553 | ||
2991 | impl<'a> AstNode<'a> for SliceType<'a> { | 2554 | impl<'a> AstNode<'a> for SliceType<'a> { |
2992 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2555 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2998,29 +2561,24 @@ impl<'a> AstNode<'a> for SliceType<'a> { | |||
2998 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2561 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2999 | } | 2562 | } |
3000 | 2563 | ||
3001 | impl<'a> SliceType<'a> {} | 2564 | impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> { |
3002 | 2565 | pub fn borrowed(&self) -> SliceType { | |
3003 | // StaticDef | 2566 | SliceTypeNode { syntax: self.syntax.borrowed() } |
3004 | |||
3005 | #[derive(Debug, Clone)] | ||
3006 | pub struct StaticDefNode(SyntaxNode); | ||
3007 | |||
3008 | impl StaticDefNode { | ||
3009 | pub fn ast(&self) -> StaticDef { | ||
3010 | StaticDef::cast(self.0.borrowed()).unwrap() | ||
3011 | } | 2567 | } |
3012 | } | 2568 | pub fn owned(&self) -> SliceTypeNode { |
3013 | 2569 | SliceTypeNode { syntax: self.syntax.owned() } | |
3014 | impl<'a> From<StaticDef<'a>> for StaticDefNode { | ||
3015 | fn from(ast: StaticDef<'a>) -> StaticDefNode { | ||
3016 | let syntax = ast.syntax().owned(); | ||
3017 | StaticDefNode(syntax) | ||
3018 | } | 2570 | } |
3019 | } | 2571 | } |
2572 | |||
2573 | |||
2574 | impl<'a> SliceType<'a> {} | ||
2575 | |||
2576 | // StaticDef | ||
3020 | #[derive(Debug, Clone, Copy)] | 2577 | #[derive(Debug, Clone, Copy)] |
3021 | pub struct StaticDef<'a> { | 2578 | pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3022 | syntax: SyntaxNodeRef<'a>, | 2579 | syntax: SyntaxNode<R>, |
3023 | } | 2580 | } |
2581 | pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>; | ||
3024 | 2582 | ||
3025 | impl<'a> AstNode<'a> for StaticDef<'a> { | 2583 | impl<'a> AstNode<'a> for StaticDef<'a> { |
3026 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2584 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3032,28 +2590,22 @@ impl<'a> AstNode<'a> for StaticDef<'a> { | |||
3032 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2590 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3033 | } | 2591 | } |
3034 | 2592 | ||
2593 | impl<R: TreeRoot<RaTypes>> StaticDefNode<R> { | ||
2594 | pub fn borrowed(&self) -> StaticDef { | ||
2595 | StaticDefNode { syntax: self.syntax.borrowed() } | ||
2596 | } | ||
2597 | pub fn owned(&self) -> StaticDefNode { | ||
2598 | StaticDefNode { syntax: self.syntax.owned() } | ||
2599 | } | ||
2600 | } | ||
2601 | |||
2602 | |||
3035 | impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} | 2603 | impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} |
3036 | impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} | 2604 | impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} |
3037 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} | 2605 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} |
3038 | impl<'a> StaticDef<'a> {} | 2606 | impl<'a> StaticDef<'a> {} |
3039 | 2607 | ||
3040 | // Stmt | 2608 | // Stmt |
3041 | |||
3042 | #[derive(Debug, Clone)] | ||
3043 | pub struct StmtNode(SyntaxNode); | ||
3044 | |||
3045 | impl StmtNode { | ||
3046 | pub fn ast(&self) -> Stmt { | ||
3047 | Stmt::cast(self.0.borrowed()).unwrap() | ||
3048 | } | ||
3049 | } | ||
3050 | |||
3051 | impl<'a> From<Stmt<'a>> for StmtNode { | ||
3052 | fn from(ast: Stmt<'a>) -> StmtNode { | ||
3053 | let syntax = ast.syntax().owned(); | ||
3054 | StmtNode(syntax) | ||
3055 | } | ||
3056 | } | ||
3057 | #[derive(Debug, Clone, Copy)] | 2609 | #[derive(Debug, Clone, Copy)] |
3058 | pub enum Stmt<'a> { | 2610 | pub enum Stmt<'a> { |
3059 | ExprStmt(ExprStmt<'a>), | 2611 | ExprStmt(ExprStmt<'a>), |
@@ -3079,26 +2631,11 @@ impl<'a> AstNode<'a> for Stmt<'a> { | |||
3079 | impl<'a> Stmt<'a> {} | 2631 | impl<'a> Stmt<'a> {} |
3080 | 2632 | ||
3081 | // StructDef | 2633 | // StructDef |
3082 | |||
3083 | #[derive(Debug, Clone)] | ||
3084 | pub struct StructDefNode(SyntaxNode); | ||
3085 | |||
3086 | impl StructDefNode { | ||
3087 | pub fn ast(&self) -> StructDef { | ||
3088 | StructDef::cast(self.0.borrowed()).unwrap() | ||
3089 | } | ||
3090 | } | ||
3091 | |||
3092 | impl<'a> From<StructDef<'a>> for StructDefNode { | ||
3093 | fn from(ast: StructDef<'a>) -> StructDefNode { | ||
3094 | let syntax = ast.syntax().owned(); | ||
3095 | StructDefNode(syntax) | ||
3096 | } | ||
3097 | } | ||
3098 | #[derive(Debug, Clone, Copy)] | 2634 | #[derive(Debug, Clone, Copy)] |
3099 | pub struct StructDef<'a> { | 2635 | pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3100 | syntax: SyntaxNodeRef<'a>, | 2636 | syntax: SyntaxNode<R>, |
3101 | } | 2637 | } |
2638 | pub type StructDef<'a> = StructDefNode<RefRoot<'a>>; | ||
3102 | 2639 | ||
3103 | impl<'a> AstNode<'a> for StructDef<'a> { | 2640 | impl<'a> AstNode<'a> for StructDef<'a> { |
3104 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2641 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3110,6 +2647,16 @@ impl<'a> AstNode<'a> for StructDef<'a> { | |||
3110 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2647 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3111 | } | 2648 | } |
3112 | 2649 | ||
2650 | impl<R: TreeRoot<RaTypes>> StructDefNode<R> { | ||
2651 | pub fn borrowed(&self) -> StructDef { | ||
2652 | StructDefNode { syntax: self.syntax.borrowed() } | ||
2653 | } | ||
2654 | pub fn owned(&self) -> StructDefNode { | ||
2655 | StructDefNode { syntax: self.syntax.owned() } | ||
2656 | } | ||
2657 | } | ||
2658 | |||
2659 | |||
3113 | impl<'a> ast::NameOwner<'a> for StructDef<'a> {} | 2660 | impl<'a> ast::NameOwner<'a> for StructDef<'a> {} |
3114 | impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} | 2661 | impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} |
3115 | impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} | 2662 | impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} |
@@ -3120,26 +2667,11 @@ impl<'a> StructDef<'a> { | |||
3120 | } | 2667 | } |
3121 | 2668 | ||
3122 | // StructLit | 2669 | // StructLit |
3123 | |||
3124 | #[derive(Debug, Clone)] | ||
3125 | pub struct StructLitNode(SyntaxNode); | ||
3126 | |||
3127 | impl StructLitNode { | ||
3128 | pub fn ast(&self) -> StructLit { | ||
3129 | StructLit::cast(self.0.borrowed()).unwrap() | ||
3130 | } | ||
3131 | } | ||
3132 | |||
3133 | impl<'a> From<StructLit<'a>> for StructLitNode { | ||
3134 | fn from(ast: StructLit<'a>) -> StructLitNode { | ||
3135 | let syntax = ast.syntax().owned(); | ||
3136 | StructLitNode(syntax) | ||
3137 | } | ||
3138 | } | ||
3139 | #[derive(Debug, Clone, Copy)] | 2670 | #[derive(Debug, Clone, Copy)] |
3140 | pub struct StructLit<'a> { | 2671 | pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3141 | syntax: SyntaxNodeRef<'a>, | 2672 | syntax: SyntaxNode<R>, |
3142 | } | 2673 | } |
2674 | pub type StructLit<'a> = StructLitNode<RefRoot<'a>>; | ||
3143 | 2675 | ||
3144 | impl<'a> AstNode<'a> for StructLit<'a> { | 2676 | impl<'a> AstNode<'a> for StructLit<'a> { |
3145 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2677 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3151,29 +2683,24 @@ impl<'a> AstNode<'a> for StructLit<'a> { | |||
3151 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2683 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3152 | } | 2684 | } |
3153 | 2685 | ||
3154 | impl<'a> StructLit<'a> {} | 2686 | impl<R: TreeRoot<RaTypes>> StructLitNode<R> { |
3155 | 2687 | pub fn borrowed(&self) -> StructLit { | |
3156 | // StructPat | 2688 | StructLitNode { syntax: self.syntax.borrowed() } |
3157 | |||
3158 | #[derive(Debug, Clone)] | ||
3159 | pub struct StructPatNode(SyntaxNode); | ||
3160 | |||
3161 | impl StructPatNode { | ||
3162 | pub fn ast(&self) -> StructPat { | ||
3163 | StructPat::cast(self.0.borrowed()).unwrap() | ||
3164 | } | 2689 | } |
3165 | } | 2690 | pub fn owned(&self) -> StructLitNode { |
3166 | 2691 | StructLitNode { syntax: self.syntax.owned() } | |
3167 | impl<'a> From<StructPat<'a>> for StructPatNode { | ||
3168 | fn from(ast: StructPat<'a>) -> StructPatNode { | ||
3169 | let syntax = ast.syntax().owned(); | ||
3170 | StructPatNode(syntax) | ||
3171 | } | 2692 | } |
3172 | } | 2693 | } |
2694 | |||
2695 | |||
2696 | impl<'a> StructLit<'a> {} | ||
2697 | |||
2698 | // StructPat | ||
3173 | #[derive(Debug, Clone, Copy)] | 2699 | #[derive(Debug, Clone, Copy)] |
3174 | pub struct StructPat<'a> { | 2700 | pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3175 | syntax: SyntaxNodeRef<'a>, | 2701 | syntax: SyntaxNode<R>, |
3176 | } | 2702 | } |
2703 | pub type StructPat<'a> = StructPatNode<RefRoot<'a>>; | ||
3177 | 2704 | ||
3178 | impl<'a> AstNode<'a> for StructPat<'a> { | 2705 | impl<'a> AstNode<'a> for StructPat<'a> { |
3179 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2706 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3185,29 +2712,24 @@ impl<'a> AstNode<'a> for StructPat<'a> { | |||
3185 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2712 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3186 | } | 2713 | } |
3187 | 2714 | ||
3188 | impl<'a> StructPat<'a> {} | 2715 | impl<R: TreeRoot<RaTypes>> StructPatNode<R> { |
3189 | 2716 | pub fn borrowed(&self) -> StructPat { | |
3190 | // TokenTree | 2717 | StructPatNode { syntax: self.syntax.borrowed() } |
3191 | |||
3192 | #[derive(Debug, Clone)] | ||
3193 | pub struct TokenTreeNode(SyntaxNode); | ||
3194 | |||
3195 | impl TokenTreeNode { | ||
3196 | pub fn ast(&self) -> TokenTree { | ||
3197 | TokenTree::cast(self.0.borrowed()).unwrap() | ||
3198 | } | 2718 | } |
3199 | } | 2719 | pub fn owned(&self) -> StructPatNode { |
3200 | 2720 | StructPatNode { syntax: self.syntax.owned() } | |
3201 | impl<'a> From<TokenTree<'a>> for TokenTreeNode { | ||
3202 | fn from(ast: TokenTree<'a>) -> TokenTreeNode { | ||
3203 | let syntax = ast.syntax().owned(); | ||
3204 | TokenTreeNode(syntax) | ||
3205 | } | 2721 | } |
3206 | } | 2722 | } |
2723 | |||
2724 | |||
2725 | impl<'a> StructPat<'a> {} | ||
2726 | |||
2727 | // TokenTree | ||
3207 | #[derive(Debug, Clone, Copy)] | 2728 | #[derive(Debug, Clone, Copy)] |
3208 | pub struct TokenTree<'a> { | 2729 | pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3209 | syntax: SyntaxNodeRef<'a>, | 2730 | syntax: SyntaxNode<R>, |
3210 | } | 2731 | } |
2732 | pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>; | ||
3211 | 2733 | ||
3212 | impl<'a> AstNode<'a> for TokenTree<'a> { | 2734 | impl<'a> AstNode<'a> for TokenTree<'a> { |
3213 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2735 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3219,29 +2741,24 @@ impl<'a> AstNode<'a> for TokenTree<'a> { | |||
3219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2741 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3220 | } | 2742 | } |
3221 | 2743 | ||
3222 | impl<'a> TokenTree<'a> {} | 2744 | impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> { |
3223 | 2745 | pub fn borrowed(&self) -> TokenTree { | |
3224 | // TraitDef | 2746 | TokenTreeNode { syntax: self.syntax.borrowed() } |
3225 | |||
3226 | #[derive(Debug, Clone)] | ||
3227 | pub struct TraitDefNode(SyntaxNode); | ||
3228 | |||
3229 | impl TraitDefNode { | ||
3230 | pub fn ast(&self) -> TraitDef { | ||
3231 | TraitDef::cast(self.0.borrowed()).unwrap() | ||
3232 | } | 2747 | } |
3233 | } | 2748 | pub fn owned(&self) -> TokenTreeNode { |
3234 | 2749 | TokenTreeNode { syntax: self.syntax.owned() } | |
3235 | impl<'a> From<TraitDef<'a>> for TraitDefNode { | ||
3236 | fn from(ast: TraitDef<'a>) -> TraitDefNode { | ||
3237 | let syntax = ast.syntax().owned(); | ||
3238 | TraitDefNode(syntax) | ||
3239 | } | 2750 | } |
3240 | } | 2751 | } |
2752 | |||
2753 | |||
2754 | impl<'a> TokenTree<'a> {} | ||
2755 | |||
2756 | // TraitDef | ||
3241 | #[derive(Debug, Clone, Copy)] | 2757 | #[derive(Debug, Clone, Copy)] |
3242 | pub struct TraitDef<'a> { | 2758 | pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3243 | syntax: SyntaxNodeRef<'a>, | 2759 | syntax: SyntaxNode<R>, |
3244 | } | 2760 | } |
2761 | pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>; | ||
3245 | 2762 | ||
3246 | impl<'a> AstNode<'a> for TraitDef<'a> { | 2763 | impl<'a> AstNode<'a> for TraitDef<'a> { |
3247 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2764 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3253,31 +2770,26 @@ impl<'a> AstNode<'a> for TraitDef<'a> { | |||
3253 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2770 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3254 | } | 2771 | } |
3255 | 2772 | ||
2773 | impl<R: TreeRoot<RaTypes>> TraitDefNode<R> { | ||
2774 | pub fn borrowed(&self) -> TraitDef { | ||
2775 | TraitDefNode { syntax: self.syntax.borrowed() } | ||
2776 | } | ||
2777 | pub fn owned(&self) -> TraitDefNode { | ||
2778 | TraitDefNode { syntax: self.syntax.owned() } | ||
2779 | } | ||
2780 | } | ||
2781 | |||
2782 | |||
3256 | impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} | 2783 | impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} |
3257 | impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} | 2784 | impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} |
3258 | impl<'a> TraitDef<'a> {} | 2785 | impl<'a> TraitDef<'a> {} |
3259 | 2786 | ||
3260 | // TryExpr | 2787 | // TryExpr |
3261 | |||
3262 | #[derive(Debug, Clone)] | ||
3263 | pub struct TryExprNode(SyntaxNode); | ||
3264 | |||
3265 | impl TryExprNode { | ||
3266 | pub fn ast(&self) -> TryExpr { | ||
3267 | TryExpr::cast(self.0.borrowed()).unwrap() | ||
3268 | } | ||
3269 | } | ||
3270 | |||
3271 | impl<'a> From<TryExpr<'a>> for TryExprNode { | ||
3272 | fn from(ast: TryExpr<'a>) -> TryExprNode { | ||
3273 | let syntax = ast.syntax().owned(); | ||
3274 | TryExprNode(syntax) | ||
3275 | } | ||
3276 | } | ||
3277 | #[derive(Debug, Clone, Copy)] | 2788 | #[derive(Debug, Clone, Copy)] |
3278 | pub struct TryExpr<'a> { | 2789 | pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3279 | syntax: SyntaxNodeRef<'a>, | 2790 | syntax: SyntaxNode<R>, |
3280 | } | 2791 | } |
2792 | pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>; | ||
3281 | 2793 | ||
3282 | impl<'a> AstNode<'a> for TryExpr<'a> { | 2794 | impl<'a> AstNode<'a> for TryExpr<'a> { |
3283 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2795 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3289,29 +2801,24 @@ impl<'a> AstNode<'a> for TryExpr<'a> { | |||
3289 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2801 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3290 | } | 2802 | } |
3291 | 2803 | ||
3292 | impl<'a> TryExpr<'a> {} | 2804 | impl<R: TreeRoot<RaTypes>> TryExprNode<R> { |
3293 | 2805 | pub fn borrowed(&self) -> TryExpr { | |
3294 | // TupleExpr | 2806 | TryExprNode { syntax: self.syntax.borrowed() } |
3295 | |||
3296 | #[derive(Debug, Clone)] | ||
3297 | pub struct TupleExprNode(SyntaxNode); | ||
3298 | |||
3299 | impl TupleExprNode { | ||
3300 | pub fn ast(&self) -> TupleExpr { | ||
3301 | TupleExpr::cast(self.0.borrowed()).unwrap() | ||
3302 | } | 2807 | } |
3303 | } | 2808 | pub fn owned(&self) -> TryExprNode { |
3304 | 2809 | TryExprNode { syntax: self.syntax.owned() } | |
3305 | impl<'a> From<TupleExpr<'a>> for TupleExprNode { | ||
3306 | fn from(ast: TupleExpr<'a>) -> TupleExprNode { | ||
3307 | let syntax = ast.syntax().owned(); | ||
3308 | TupleExprNode(syntax) | ||
3309 | } | 2810 | } |
3310 | } | 2811 | } |
2812 | |||
2813 | |||
2814 | impl<'a> TryExpr<'a> {} | ||
2815 | |||
2816 | // TupleExpr | ||
3311 | #[derive(Debug, Clone, Copy)] | 2817 | #[derive(Debug, Clone, Copy)] |
3312 | pub struct TupleExpr<'a> { | 2818 | pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3313 | syntax: SyntaxNodeRef<'a>, | 2819 | syntax: SyntaxNode<R>, |
3314 | } | 2820 | } |
2821 | pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>; | ||
3315 | 2822 | ||
3316 | impl<'a> AstNode<'a> for TupleExpr<'a> { | 2823 | impl<'a> AstNode<'a> for TupleExpr<'a> { |
3317 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2824 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3323,29 +2830,24 @@ impl<'a> AstNode<'a> for TupleExpr<'a> { | |||
3323 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2830 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3324 | } | 2831 | } |
3325 | 2832 | ||
3326 | impl<'a> TupleExpr<'a> {} | 2833 | impl<R: TreeRoot<RaTypes>> TupleExprNode<R> { |
3327 | 2834 | pub fn borrowed(&self) -> TupleExpr { | |
3328 | // TuplePat | 2835 | TupleExprNode { syntax: self.syntax.borrowed() } |
3329 | |||
3330 | #[derive(Debug, Clone)] | ||
3331 | pub struct TuplePatNode(SyntaxNode); | ||
3332 | |||
3333 | impl TuplePatNode { | ||
3334 | pub fn ast(&self) -> TuplePat { | ||
3335 | TuplePat::cast(self.0.borrowed()).unwrap() | ||
3336 | } | 2836 | } |
3337 | } | 2837 | pub fn owned(&self) -> TupleExprNode { |
3338 | 2838 | TupleExprNode { syntax: self.syntax.owned() } | |
3339 | impl<'a> From<TuplePat<'a>> for TuplePatNode { | ||
3340 | fn from(ast: TuplePat<'a>) -> TuplePatNode { | ||
3341 | let syntax = ast.syntax().owned(); | ||
3342 | TuplePatNode(syntax) | ||
3343 | } | 2839 | } |
3344 | } | 2840 | } |
2841 | |||
2842 | |||
2843 | impl<'a> TupleExpr<'a> {} | ||
2844 | |||
2845 | // TuplePat | ||
3345 | #[derive(Debug, Clone, Copy)] | 2846 | #[derive(Debug, Clone, Copy)] |
3346 | pub struct TuplePat<'a> { | 2847 | pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3347 | syntax: SyntaxNodeRef<'a>, | 2848 | syntax: SyntaxNode<R>, |
3348 | } | 2849 | } |
2850 | pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>; | ||
3349 | 2851 | ||
3350 | impl<'a> AstNode<'a> for TuplePat<'a> { | 2852 | impl<'a> AstNode<'a> for TuplePat<'a> { |
3351 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2853 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3357,29 +2859,24 @@ impl<'a> AstNode<'a> for TuplePat<'a> { | |||
3357 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2859 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3358 | } | 2860 | } |
3359 | 2861 | ||
3360 | impl<'a> TuplePat<'a> {} | 2862 | impl<R: TreeRoot<RaTypes>> TuplePatNode<R> { |
3361 | 2863 | pub fn borrowed(&self) -> TuplePat { | |
3362 | // TupleStructPat | 2864 | TuplePatNode { syntax: self.syntax.borrowed() } |
3363 | |||
3364 | #[derive(Debug, Clone)] | ||
3365 | pub struct TupleStructPatNode(SyntaxNode); | ||
3366 | |||
3367 | impl TupleStructPatNode { | ||
3368 | pub fn ast(&self) -> TupleStructPat { | ||
3369 | TupleStructPat::cast(self.0.borrowed()).unwrap() | ||
3370 | } | 2865 | } |
3371 | } | 2866 | pub fn owned(&self) -> TuplePatNode { |
3372 | 2867 | TuplePatNode { syntax: self.syntax.owned() } | |
3373 | impl<'a> From<TupleStructPat<'a>> for TupleStructPatNode { | ||
3374 | fn from(ast: TupleStructPat<'a>) -> TupleStructPatNode { | ||
3375 | let syntax = ast.syntax().owned(); | ||
3376 | TupleStructPatNode(syntax) | ||
3377 | } | 2868 | } |
3378 | } | 2869 | } |
2870 | |||
2871 | |||
2872 | impl<'a> TuplePat<'a> {} | ||
2873 | |||
2874 | // TupleStructPat | ||
3379 | #[derive(Debug, Clone, Copy)] | 2875 | #[derive(Debug, Clone, Copy)] |
3380 | pub struct TupleStructPat<'a> { | 2876 | pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3381 | syntax: SyntaxNodeRef<'a>, | 2877 | syntax: SyntaxNode<R>, |
3382 | } | 2878 | } |
2879 | pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>; | ||
3383 | 2880 | ||
3384 | impl<'a> AstNode<'a> for TupleStructPat<'a> { | 2881 | impl<'a> AstNode<'a> for TupleStructPat<'a> { |
3385 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2882 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3391,29 +2888,24 @@ impl<'a> AstNode<'a> for TupleStructPat<'a> { | |||
3391 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2888 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3392 | } | 2889 | } |
3393 | 2890 | ||
3394 | impl<'a> TupleStructPat<'a> {} | 2891 | impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> { |
3395 | 2892 | pub fn borrowed(&self) -> TupleStructPat { | |
3396 | // TupleType | 2893 | TupleStructPatNode { syntax: self.syntax.borrowed() } |
3397 | |||
3398 | #[derive(Debug, Clone)] | ||
3399 | pub struct TupleTypeNode(SyntaxNode); | ||
3400 | |||
3401 | impl TupleTypeNode { | ||
3402 | pub fn ast(&self) -> TupleType { | ||
3403 | TupleType::cast(self.0.borrowed()).unwrap() | ||
3404 | } | 2894 | } |
3405 | } | 2895 | pub fn owned(&self) -> TupleStructPatNode { |
3406 | 2896 | TupleStructPatNode { syntax: self.syntax.owned() } | |
3407 | impl<'a> From<TupleType<'a>> for TupleTypeNode { | ||
3408 | fn from(ast: TupleType<'a>) -> TupleTypeNode { | ||
3409 | let syntax = ast.syntax().owned(); | ||
3410 | TupleTypeNode(syntax) | ||
3411 | } | 2897 | } |
3412 | } | 2898 | } |
2899 | |||
2900 | |||
2901 | impl<'a> TupleStructPat<'a> {} | ||
2902 | |||
2903 | // TupleType | ||
3413 | #[derive(Debug, Clone, Copy)] | 2904 | #[derive(Debug, Clone, Copy)] |
3414 | pub struct TupleType<'a> { | 2905 | pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3415 | syntax: SyntaxNodeRef<'a>, | 2906 | syntax: SyntaxNode<R>, |
3416 | } | 2907 | } |
2908 | pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>; | ||
3417 | 2909 | ||
3418 | impl<'a> AstNode<'a> for TupleType<'a> { | 2910 | impl<'a> AstNode<'a> for TupleType<'a> { |
3419 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2911 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3425,29 +2917,24 @@ impl<'a> AstNode<'a> for TupleType<'a> { | |||
3425 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2917 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3426 | } | 2918 | } |
3427 | 2919 | ||
3428 | impl<'a> TupleType<'a> {} | 2920 | impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> { |
3429 | 2921 | pub fn borrowed(&self) -> TupleType { | |
3430 | // TypeDef | 2922 | TupleTypeNode { syntax: self.syntax.borrowed() } |
3431 | |||
3432 | #[derive(Debug, Clone)] | ||
3433 | pub struct TypeDefNode(SyntaxNode); | ||
3434 | |||
3435 | impl TypeDefNode { | ||
3436 | pub fn ast(&self) -> TypeDef { | ||
3437 | TypeDef::cast(self.0.borrowed()).unwrap() | ||
3438 | } | 2923 | } |
3439 | } | 2924 | pub fn owned(&self) -> TupleTypeNode { |
3440 | 2925 | TupleTypeNode { syntax: self.syntax.owned() } | |
3441 | impl<'a> From<TypeDef<'a>> for TypeDefNode { | ||
3442 | fn from(ast: TypeDef<'a>) -> TypeDefNode { | ||
3443 | let syntax = ast.syntax().owned(); | ||
3444 | TypeDefNode(syntax) | ||
3445 | } | 2926 | } |
3446 | } | 2927 | } |
2928 | |||
2929 | |||
2930 | impl<'a> TupleType<'a> {} | ||
2931 | |||
2932 | // TypeDef | ||
3447 | #[derive(Debug, Clone, Copy)] | 2933 | #[derive(Debug, Clone, Copy)] |
3448 | pub struct TypeDef<'a> { | 2934 | pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3449 | syntax: SyntaxNodeRef<'a>, | 2935 | syntax: SyntaxNode<R>, |
3450 | } | 2936 | } |
2937 | pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>; | ||
3451 | 2938 | ||
3452 | impl<'a> AstNode<'a> for TypeDef<'a> { | 2939 | impl<'a> AstNode<'a> for TypeDef<'a> { |
3453 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2940 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3459,32 +2946,27 @@ impl<'a> AstNode<'a> for TypeDef<'a> { | |||
3459 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2946 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3460 | } | 2947 | } |
3461 | 2948 | ||
2949 | impl<R: TreeRoot<RaTypes>> TypeDefNode<R> { | ||
2950 | pub fn borrowed(&self) -> TypeDef { | ||
2951 | TypeDefNode { syntax: self.syntax.borrowed() } | ||
2952 | } | ||
2953 | pub fn owned(&self) -> TypeDefNode { | ||
2954 | TypeDefNode { syntax: self.syntax.owned() } | ||
2955 | } | ||
2956 | } | ||
2957 | |||
2958 | |||
3462 | impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} | 2959 | impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} |
3463 | impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} | 2960 | impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} |
3464 | impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} | 2961 | impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} |
3465 | impl<'a> TypeDef<'a> {} | 2962 | impl<'a> TypeDef<'a> {} |
3466 | 2963 | ||
3467 | // TypeParam | 2964 | // TypeParam |
3468 | |||
3469 | #[derive(Debug, Clone)] | ||
3470 | pub struct TypeParamNode(SyntaxNode); | ||
3471 | |||
3472 | impl TypeParamNode { | ||
3473 | pub fn ast(&self) -> TypeParam { | ||
3474 | TypeParam::cast(self.0.borrowed()).unwrap() | ||
3475 | } | ||
3476 | } | ||
3477 | |||
3478 | impl<'a> From<TypeParam<'a>> for TypeParamNode { | ||
3479 | fn from(ast: TypeParam<'a>) -> TypeParamNode { | ||
3480 | let syntax = ast.syntax().owned(); | ||
3481 | TypeParamNode(syntax) | ||
3482 | } | ||
3483 | } | ||
3484 | #[derive(Debug, Clone, Copy)] | 2965 | #[derive(Debug, Clone, Copy)] |
3485 | pub struct TypeParam<'a> { | 2966 | pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3486 | syntax: SyntaxNodeRef<'a>, | 2967 | syntax: SyntaxNode<R>, |
3487 | } | 2968 | } |
2969 | pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>; | ||
3488 | 2970 | ||
3489 | impl<'a> AstNode<'a> for TypeParam<'a> { | 2971 | impl<'a> AstNode<'a> for TypeParam<'a> { |
3490 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2972 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3496,30 +2978,25 @@ impl<'a> AstNode<'a> for TypeParam<'a> { | |||
3496 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2978 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3497 | } | 2979 | } |
3498 | 2980 | ||
2981 | impl<R: TreeRoot<RaTypes>> TypeParamNode<R> { | ||
2982 | pub fn borrowed(&self) -> TypeParam { | ||
2983 | TypeParamNode { syntax: self.syntax.borrowed() } | ||
2984 | } | ||
2985 | pub fn owned(&self) -> TypeParamNode { | ||
2986 | TypeParamNode { syntax: self.syntax.owned() } | ||
2987 | } | ||
2988 | } | ||
2989 | |||
2990 | |||
3499 | impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} | 2991 | impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} |
3500 | impl<'a> TypeParam<'a> {} | 2992 | impl<'a> TypeParam<'a> {} |
3501 | 2993 | ||
3502 | // TypeParamList | 2994 | // TypeParamList |
3503 | |||
3504 | #[derive(Debug, Clone)] | ||
3505 | pub struct TypeParamListNode(SyntaxNode); | ||
3506 | |||
3507 | impl TypeParamListNode { | ||
3508 | pub fn ast(&self) -> TypeParamList { | ||
3509 | TypeParamList::cast(self.0.borrowed()).unwrap() | ||
3510 | } | ||
3511 | } | ||
3512 | |||
3513 | impl<'a> From<TypeParamList<'a>> for TypeParamListNode { | ||
3514 | fn from(ast: TypeParamList<'a>) -> TypeParamListNode { | ||
3515 | let syntax = ast.syntax().owned(); | ||
3516 | TypeParamListNode(syntax) | ||
3517 | } | ||
3518 | } | ||
3519 | #[derive(Debug, Clone, Copy)] | 2995 | #[derive(Debug, Clone, Copy)] |
3520 | pub struct TypeParamList<'a> { | 2996 | pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3521 | syntax: SyntaxNodeRef<'a>, | 2997 | syntax: SyntaxNode<R>, |
3522 | } | 2998 | } |
2999 | pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>; | ||
3523 | 3000 | ||
3524 | impl<'a> AstNode<'a> for TypeParamList<'a> { | 3001 | impl<'a> AstNode<'a> for TypeParamList<'a> { |
3525 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3002 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3531,6 +3008,16 @@ impl<'a> AstNode<'a> for TypeParamList<'a> { | |||
3531 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3008 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3532 | } | 3009 | } |
3533 | 3010 | ||
3011 | impl<R: TreeRoot<RaTypes>> TypeParamListNode<R> { | ||
3012 | pub fn borrowed(&self) -> TypeParamList { | ||
3013 | TypeParamListNode { syntax: self.syntax.borrowed() } | ||
3014 | } | ||
3015 | pub fn owned(&self) -> TypeParamListNode { | ||
3016 | TypeParamListNode { syntax: self.syntax.owned() } | ||
3017 | } | ||
3018 | } | ||
3019 | |||
3020 | |||
3534 | impl<'a> TypeParamList<'a> { | 3021 | impl<'a> TypeParamList<'a> { |
3535 | pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { | 3022 | pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { |
3536 | super::children(self) | 3023 | super::children(self) |
@@ -3542,22 +3029,6 @@ impl<'a> TypeParamList<'a> { | |||
3542 | } | 3029 | } |
3543 | 3030 | ||
3544 | // TypeRef | 3031 | // TypeRef |
3545 | |||
3546 | #[derive(Debug, Clone)] | ||
3547 | pub struct TypeRefNode(SyntaxNode); | ||
3548 | |||
3549 | impl TypeRefNode { | ||
3550 | pub fn ast(&self) -> TypeRef { | ||
3551 | TypeRef::cast(self.0.borrowed()).unwrap() | ||
3552 | } | ||
3553 | } | ||
3554 | |||
3555 | impl<'a> From<TypeRef<'a>> for TypeRefNode { | ||
3556 | fn from(ast: TypeRef<'a>) -> TypeRefNode { | ||
3557 | let syntax = ast.syntax().owned(); | ||
3558 | TypeRefNode(syntax) | ||
3559 | } | ||
3560 | } | ||
3561 | #[derive(Debug, Clone, Copy)] | 3032 | #[derive(Debug, Clone, Copy)] |
3562 | pub enum TypeRef<'a> { | 3033 | pub enum TypeRef<'a> { |
3563 | ParenType(ParenType<'a>), | 3034 | ParenType(ParenType<'a>), |
@@ -3616,26 +3087,11 @@ impl<'a> AstNode<'a> for TypeRef<'a> { | |||
3616 | impl<'a> TypeRef<'a> {} | 3087 | impl<'a> TypeRef<'a> {} |
3617 | 3088 | ||
3618 | // UseItem | 3089 | // UseItem |
3619 | |||
3620 | #[derive(Debug, Clone)] | ||
3621 | pub struct UseItemNode(SyntaxNode); | ||
3622 | |||
3623 | impl UseItemNode { | ||
3624 | pub fn ast(&self) -> UseItem { | ||
3625 | UseItem::cast(self.0.borrowed()).unwrap() | ||
3626 | } | ||
3627 | } | ||
3628 | |||
3629 | impl<'a> From<UseItem<'a>> for UseItemNode { | ||
3630 | fn from(ast: UseItem<'a>) -> UseItemNode { | ||
3631 | let syntax = ast.syntax().owned(); | ||
3632 | UseItemNode(syntax) | ||
3633 | } | ||
3634 | } | ||
3635 | #[derive(Debug, Clone, Copy)] | 3090 | #[derive(Debug, Clone, Copy)] |
3636 | pub struct UseItem<'a> { | 3091 | pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3637 | syntax: SyntaxNodeRef<'a>, | 3092 | syntax: SyntaxNode<R>, |
3638 | } | 3093 | } |
3094 | pub type UseItem<'a> = UseItemNode<RefRoot<'a>>; | ||
3639 | 3095 | ||
3640 | impl<'a> AstNode<'a> for UseItem<'a> { | 3096 | impl<'a> AstNode<'a> for UseItem<'a> { |
3641 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3097 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3647,33 +3103,28 @@ impl<'a> AstNode<'a> for UseItem<'a> { | |||
3647 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3103 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3648 | } | 3104 | } |
3649 | 3105 | ||
3650 | impl<'a> UseItem<'a> { | 3106 | impl<R: TreeRoot<RaTypes>> UseItemNode<R> { |
3651 | pub fn use_tree(self) -> Option<UseTree<'a>> { | 3107 | pub fn borrowed(&self) -> UseItem { |
3652 | super::child_opt(self) | 3108 | UseItemNode { syntax: self.syntax.borrowed() } |
3109 | } | ||
3110 | pub fn owned(&self) -> UseItemNode { | ||
3111 | UseItemNode { syntax: self.syntax.owned() } | ||
3653 | } | 3112 | } |
3654 | } | 3113 | } |
3655 | 3114 | ||
3656 | // UseTree | ||
3657 | 3115 | ||
3658 | #[derive(Debug, Clone)] | 3116 | impl<'a> UseItem<'a> { |
3659 | pub struct UseTreeNode(SyntaxNode); | 3117 | pub fn use_tree(self) -> Option<UseTree<'a>> { |
3660 | 3118 | super::child_opt(self) | |
3661 | impl UseTreeNode { | ||
3662 | pub fn ast(&self) -> UseTree { | ||
3663 | UseTree::cast(self.0.borrowed()).unwrap() | ||
3664 | } | 3119 | } |
3665 | } | 3120 | } |
3666 | 3121 | ||
3667 | impl<'a> From<UseTree<'a>> for UseTreeNode { | 3122 | // UseTree |
3668 | fn from(ast: UseTree<'a>) -> UseTreeNode { | ||
3669 | let syntax = ast.syntax().owned(); | ||
3670 | UseTreeNode(syntax) | ||
3671 | } | ||
3672 | } | ||
3673 | #[derive(Debug, Clone, Copy)] | 3123 | #[derive(Debug, Clone, Copy)] |
3674 | pub struct UseTree<'a> { | 3124 | pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3675 | syntax: SyntaxNodeRef<'a>, | 3125 | syntax: SyntaxNode<R>, |
3676 | } | 3126 | } |
3127 | pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>; | ||
3677 | 3128 | ||
3678 | impl<'a> AstNode<'a> for UseTree<'a> { | 3129 | impl<'a> AstNode<'a> for UseTree<'a> { |
3679 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3130 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3685,6 +3136,16 @@ impl<'a> AstNode<'a> for UseTree<'a> { | |||
3685 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3136 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3686 | } | 3137 | } |
3687 | 3138 | ||
3139 | impl<R: TreeRoot<RaTypes>> UseTreeNode<R> { | ||
3140 | pub fn borrowed(&self) -> UseTree { | ||
3141 | UseTreeNode { syntax: self.syntax.borrowed() } | ||
3142 | } | ||
3143 | pub fn owned(&self) -> UseTreeNode { | ||
3144 | UseTreeNode { syntax: self.syntax.owned() } | ||
3145 | } | ||
3146 | } | ||
3147 | |||
3148 | |||
3688 | impl<'a> UseTree<'a> { | 3149 | impl<'a> UseTree<'a> { |
3689 | pub fn path(self) -> Option<Path<'a>> { | 3150 | pub fn path(self) -> Option<Path<'a>> { |
3690 | super::child_opt(self) | 3151 | super::child_opt(self) |
@@ -3696,26 +3157,11 @@ impl<'a> UseTree<'a> { | |||
3696 | } | 3157 | } |
3697 | 3158 | ||
3698 | // UseTreeList | 3159 | // UseTreeList |
3699 | |||
3700 | #[derive(Debug, Clone)] | ||
3701 | pub struct UseTreeListNode(SyntaxNode); | ||
3702 | |||
3703 | impl UseTreeListNode { | ||
3704 | pub fn ast(&self) -> UseTreeList { | ||
3705 | UseTreeList::cast(self.0.borrowed()).unwrap() | ||
3706 | } | ||
3707 | } | ||
3708 | |||
3709 | impl<'a> From<UseTreeList<'a>> for UseTreeListNode { | ||
3710 | fn from(ast: UseTreeList<'a>) -> UseTreeListNode { | ||
3711 | let syntax = ast.syntax().owned(); | ||
3712 | UseTreeListNode(syntax) | ||
3713 | } | ||
3714 | } | ||
3715 | #[derive(Debug, Clone, Copy)] | 3160 | #[derive(Debug, Clone, Copy)] |
3716 | pub struct UseTreeList<'a> { | 3161 | pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3717 | syntax: SyntaxNodeRef<'a>, | 3162 | syntax: SyntaxNode<R>, |
3718 | } | 3163 | } |
3164 | pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>; | ||
3719 | 3165 | ||
3720 | impl<'a> AstNode<'a> for UseTreeList<'a> { | 3166 | impl<'a> AstNode<'a> for UseTreeList<'a> { |
3721 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3167 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3727,33 +3173,28 @@ impl<'a> AstNode<'a> for UseTreeList<'a> { | |||
3727 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3173 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3728 | } | 3174 | } |
3729 | 3175 | ||
3730 | impl<'a> UseTreeList<'a> { | 3176 | impl<R: TreeRoot<RaTypes>> UseTreeListNode<R> { |
3731 | pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { | 3177 | pub fn borrowed(&self) -> UseTreeList { |
3732 | super::children(self) | 3178 | UseTreeListNode { syntax: self.syntax.borrowed() } |
3179 | } | ||
3180 | pub fn owned(&self) -> UseTreeListNode { | ||
3181 | UseTreeListNode { syntax: self.syntax.owned() } | ||
3733 | } | 3182 | } |
3734 | } | 3183 | } |
3735 | 3184 | ||
3736 | // WhereClause | ||
3737 | 3185 | ||
3738 | #[derive(Debug, Clone)] | 3186 | impl<'a> UseTreeList<'a> { |
3739 | pub struct WhereClauseNode(SyntaxNode); | 3187 | pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { |
3740 | 3188 | super::children(self) | |
3741 | impl WhereClauseNode { | ||
3742 | pub fn ast(&self) -> WhereClause { | ||
3743 | WhereClause::cast(self.0.borrowed()).unwrap() | ||
3744 | } | 3189 | } |
3745 | } | 3190 | } |
3746 | 3191 | ||
3747 | impl<'a> From<WhereClause<'a>> for WhereClauseNode { | 3192 | // WhereClause |
3748 | fn from(ast: WhereClause<'a>) -> WhereClauseNode { | ||
3749 | let syntax = ast.syntax().owned(); | ||
3750 | WhereClauseNode(syntax) | ||
3751 | } | ||
3752 | } | ||
3753 | #[derive(Debug, Clone, Copy)] | 3193 | #[derive(Debug, Clone, Copy)] |
3754 | pub struct WhereClause<'a> { | 3194 | pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3755 | syntax: SyntaxNodeRef<'a>, | 3195 | syntax: SyntaxNode<R>, |
3756 | } | 3196 | } |
3197 | pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>; | ||
3757 | 3198 | ||
3758 | impl<'a> AstNode<'a> for WhereClause<'a> { | 3199 | impl<'a> AstNode<'a> for WhereClause<'a> { |
3759 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3200 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3765,29 +3206,24 @@ impl<'a> AstNode<'a> for WhereClause<'a> { | |||
3765 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3206 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3766 | } | 3207 | } |
3767 | 3208 | ||
3768 | impl<'a> WhereClause<'a> {} | 3209 | impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> { |
3769 | 3210 | pub fn borrowed(&self) -> WhereClause { | |
3770 | // WhileExpr | 3211 | WhereClauseNode { syntax: self.syntax.borrowed() } |
3771 | |||
3772 | #[derive(Debug, Clone)] | ||
3773 | pub struct WhileExprNode(SyntaxNode); | ||
3774 | |||
3775 | impl WhileExprNode { | ||
3776 | pub fn ast(&self) -> WhileExpr { | ||
3777 | WhileExpr::cast(self.0.borrowed()).unwrap() | ||
3778 | } | 3212 | } |
3779 | } | 3213 | pub fn owned(&self) -> WhereClauseNode { |
3780 | 3214 | WhereClauseNode { syntax: self.syntax.owned() } | |
3781 | impl<'a> From<WhileExpr<'a>> for WhileExprNode { | ||
3782 | fn from(ast: WhileExpr<'a>) -> WhileExprNode { | ||
3783 | let syntax = ast.syntax().owned(); | ||
3784 | WhileExprNode(syntax) | ||
3785 | } | 3215 | } |
3786 | } | 3216 | } |
3217 | |||
3218 | |||
3219 | impl<'a> WhereClause<'a> {} | ||
3220 | |||
3221 | // WhileExpr | ||
3787 | #[derive(Debug, Clone, Copy)] | 3222 | #[derive(Debug, Clone, Copy)] |
3788 | pub struct WhileExpr<'a> { | 3223 | pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3789 | syntax: SyntaxNodeRef<'a>, | 3224 | syntax: SyntaxNode<R>, |
3790 | } | 3225 | } |
3226 | pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>; | ||
3791 | 3227 | ||
3792 | impl<'a> AstNode<'a> for WhileExpr<'a> { | 3228 | impl<'a> AstNode<'a> for WhileExpr<'a> { |
3793 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3229 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3799,6 +3235,16 @@ impl<'a> AstNode<'a> for WhileExpr<'a> { | |||
3799 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3235 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3800 | } | 3236 | } |
3801 | 3237 | ||
3238 | impl<R: TreeRoot<RaTypes>> WhileExprNode<R> { | ||
3239 | pub fn borrowed(&self) -> WhileExpr { | ||
3240 | WhileExprNode { syntax: self.syntax.borrowed() } | ||
3241 | } | ||
3242 | pub fn owned(&self) -> WhileExprNode { | ||
3243 | WhileExprNode { syntax: self.syntax.owned() } | ||
3244 | } | ||
3245 | } | ||
3246 | |||
3247 | |||
3802 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} | 3248 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} |
3803 | impl<'a> WhileExpr<'a> { | 3249 | impl<'a> WhileExpr<'a> { |
3804 | pub fn condition(self) -> Option<Condition<'a>> { | 3250 | pub fn condition(self) -> Option<Condition<'a>> { |
@@ -3807,26 +3253,11 @@ impl<'a> WhileExpr<'a> { | |||
3807 | } | 3253 | } |
3808 | 3254 | ||
3809 | // Whitespace | 3255 | // Whitespace |
3810 | |||
3811 | #[derive(Debug, Clone)] | ||
3812 | pub struct WhitespaceNode(SyntaxNode); | ||
3813 | |||
3814 | impl WhitespaceNode { | ||
3815 | pub fn ast(&self) -> Whitespace { | ||
3816 | Whitespace::cast(self.0.borrowed()).unwrap() | ||
3817 | } | ||
3818 | } | ||
3819 | |||
3820 | impl<'a> From<Whitespace<'a>> for WhitespaceNode { | ||
3821 | fn from(ast: Whitespace<'a>) -> WhitespaceNode { | ||
3822 | let syntax = ast.syntax().owned(); | ||
3823 | WhitespaceNode(syntax) | ||
3824 | } | ||
3825 | } | ||
3826 | #[derive(Debug, Clone, Copy)] | 3256 | #[derive(Debug, Clone, Copy)] |
3827 | pub struct Whitespace<'a> { | 3257 | pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3828 | syntax: SyntaxNodeRef<'a>, | 3258 | syntax: SyntaxNode<R>, |
3829 | } | 3259 | } |
3260 | pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>; | ||
3830 | 3261 | ||
3831 | impl<'a> AstNode<'a> for Whitespace<'a> { | 3262 | impl<'a> AstNode<'a> for Whitespace<'a> { |
3832 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3263 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3838,5 +3269,15 @@ impl<'a> AstNode<'a> for Whitespace<'a> { | |||
3838 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3269 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3839 | } | 3270 | } |
3840 | 3271 | ||
3272 | impl<R: TreeRoot<RaTypes>> WhitespaceNode<R> { | ||
3273 | pub fn borrowed(&self) -> Whitespace { | ||
3274 | WhitespaceNode { syntax: self.syntax.borrowed() } | ||
3275 | } | ||
3276 | pub fn owned(&self) -> WhitespaceNode { | ||
3277 | WhitespaceNode { syntax: self.syntax.owned() } | ||
3278 | } | ||
3279 | } | ||
3280 | |||
3281 | |||
3841 | impl<'a> Whitespace<'a> {} | 3282 | impl<'a> Whitespace<'a> {} |
3842 | 3283 | ||