diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 3011 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 32 |
2 files changed, 1237 insertions, 1806 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 75769a4e9..d473478a9 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -6,30 +6,16 @@ | |||
6 | use crate::{ | 6 | use crate::{ |
7 | ast, | 7 | ast, |
8 | SyntaxNode, SyntaxNodeRef, AstNode, | 8 | SyntaxNode, SyntaxNodeRef, AstNode, |
9 | yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, | ||
9 | SyntaxKind::*, | 10 | SyntaxKind::*, |
10 | }; | 11 | }; |
11 | 12 | ||
12 | // ArgList | 13 | // 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)] | 14 | #[derive(Debug, Clone, Copy)] |
30 | pub struct ArgList<'a> { | 15 | pub struct ArgListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
31 | syntax: SyntaxNodeRef<'a>, | 16 | syntax: SyntaxNode<R>, |
32 | } | 17 | } |
18 | pub type ArgList<'a> = ArgListNode<RefRoot<'a>>; | ||
33 | 19 | ||
34 | impl<'a> AstNode<'a> for ArgList<'a> { | 20 | impl<'a> AstNode<'a> for ArgList<'a> { |
35 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 21 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -41,33 +27,28 @@ impl<'a> AstNode<'a> for ArgList<'a> { | |||
41 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 27 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
42 | } | 28 | } |
43 | 29 | ||
44 | impl<'a> ArgList<'a> { | 30 | impl<R: TreeRoot<RaTypes>> ArgListNode<R> { |
45 | pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { | 31 | pub fn borrowed(&self) -> ArgList { |
46 | super::children(self) | 32 | ArgListNode { syntax: self.syntax.borrowed() } |
33 | } | ||
34 | pub fn owned(&self) -> ArgListNode { | ||
35 | ArgListNode { syntax: self.syntax.owned() } | ||
47 | } | 36 | } |
48 | } | 37 | } |
49 | 38 | ||
50 | // ArrayExpr | ||
51 | |||
52 | #[derive(Debug, Clone)] | ||
53 | pub struct ArrayExprNode(SyntaxNode); | ||
54 | 39 | ||
55 | impl ArrayExprNode { | 40 | impl<'a> ArgList<'a> { |
56 | pub fn ast(&self) -> ArrayExpr { | 41 | pub fn args(self) -> impl Iterator<Item = Expr<'a>> + 'a { |
57 | ArrayExpr::cast(self.0.borrowed()).unwrap() | 42 | super::children(self) |
58 | } | 43 | } |
59 | } | 44 | } |
60 | 45 | ||
61 | impl<'a> From<ArrayExpr<'a>> for ArrayExprNode { | 46 | // ArrayExpr |
62 | fn from(ast: ArrayExpr<'a>) -> ArrayExprNode { | ||
63 | let syntax = ast.syntax().owned(); | ||
64 | ArrayExprNode(syntax) | ||
65 | } | ||
66 | } | ||
67 | #[derive(Debug, Clone, Copy)] | 47 | #[derive(Debug, Clone, Copy)] |
68 | pub struct ArrayExpr<'a> { | 48 | pub struct ArrayExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
69 | syntax: SyntaxNodeRef<'a>, | 49 | syntax: SyntaxNode<R>, |
70 | } | 50 | } |
51 | pub type ArrayExpr<'a> = ArrayExprNode<RefRoot<'a>>; | ||
71 | 52 | ||
72 | impl<'a> AstNode<'a> for ArrayExpr<'a> { | 53 | impl<'a> AstNode<'a> for ArrayExpr<'a> { |
73 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 54 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -79,29 +60,24 @@ impl<'a> AstNode<'a> for ArrayExpr<'a> { | |||
79 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 60 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
80 | } | 61 | } |
81 | 62 | ||
82 | impl<'a> ArrayExpr<'a> {} | 63 | impl<R: TreeRoot<RaTypes>> ArrayExprNode<R> { |
83 | 64 | pub fn borrowed(&self) -> ArrayExpr { | |
84 | // ArrayType | 65 | 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 | } | 66 | } |
93 | } | 67 | pub fn owned(&self) -> ArrayExprNode { |
94 | 68 | 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 | } | 69 | } |
100 | } | 70 | } |
71 | |||
72 | |||
73 | impl<'a> ArrayExpr<'a> {} | ||
74 | |||
75 | // ArrayType | ||
101 | #[derive(Debug, Clone, Copy)] | 76 | #[derive(Debug, Clone, Copy)] |
102 | pub struct ArrayType<'a> { | 77 | pub struct ArrayTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
103 | syntax: SyntaxNodeRef<'a>, | 78 | syntax: SyntaxNode<R>, |
104 | } | 79 | } |
80 | pub type ArrayType<'a> = ArrayTypeNode<RefRoot<'a>>; | ||
105 | 81 | ||
106 | impl<'a> AstNode<'a> for ArrayType<'a> { | 82 | impl<'a> AstNode<'a> for ArrayType<'a> { |
107 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 83 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -113,29 +89,24 @@ impl<'a> AstNode<'a> for ArrayType<'a> { | |||
113 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 89 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
114 | } | 90 | } |
115 | 91 | ||
116 | impl<'a> ArrayType<'a> {} | 92 | impl<R: TreeRoot<RaTypes>> ArrayTypeNode<R> { |
117 | 93 | pub fn borrowed(&self) -> ArrayType { | |
118 | // Attr | 94 | 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 | } | 95 | } |
127 | } | 96 | pub fn owned(&self) -> ArrayTypeNode { |
128 | 97 | 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 | } | 98 | } |
134 | } | 99 | } |
100 | |||
101 | |||
102 | impl<'a> ArrayType<'a> {} | ||
103 | |||
104 | // Attr | ||
135 | #[derive(Debug, Clone, Copy)] | 105 | #[derive(Debug, Clone, Copy)] |
136 | pub struct Attr<'a> { | 106 | pub struct AttrNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
137 | syntax: SyntaxNodeRef<'a>, | 107 | syntax: SyntaxNode<R>, |
138 | } | 108 | } |
109 | pub type Attr<'a> = AttrNode<RefRoot<'a>>; | ||
139 | 110 | ||
140 | impl<'a> AstNode<'a> for Attr<'a> { | 111 | impl<'a> AstNode<'a> for Attr<'a> { |
141 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 112 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -147,33 +118,28 @@ impl<'a> AstNode<'a> for Attr<'a> { | |||
147 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 118 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
148 | } | 119 | } |
149 | 120 | ||
150 | impl<'a> Attr<'a> { | 121 | impl<R: TreeRoot<RaTypes>> AttrNode<R> { |
151 | pub fn value(self) -> Option<TokenTree<'a>> { | 122 | pub fn borrowed(&self) -> Attr { |
152 | super::child_opt(self) | 123 | AttrNode { syntax: self.syntax.borrowed() } |
124 | } | ||
125 | pub fn owned(&self) -> AttrNode { | ||
126 | AttrNode { syntax: self.syntax.owned() } | ||
153 | } | 127 | } |
154 | } | 128 | } |
155 | 129 | ||
156 | // BinExpr | ||
157 | |||
158 | #[derive(Debug, Clone)] | ||
159 | pub struct BinExprNode(SyntaxNode); | ||
160 | 130 | ||
161 | impl BinExprNode { | 131 | impl<'a> Attr<'a> { |
162 | pub fn ast(&self) -> BinExpr { | 132 | pub fn value(self) -> Option<TokenTree<'a>> { |
163 | BinExpr::cast(self.0.borrowed()).unwrap() | 133 | super::child_opt(self) |
164 | } | 134 | } |
165 | } | 135 | } |
166 | 136 | ||
167 | impl<'a> From<BinExpr<'a>> for BinExprNode { | 137 | // BinExpr |
168 | fn from(ast: BinExpr<'a>) -> BinExprNode { | ||
169 | let syntax = ast.syntax().owned(); | ||
170 | BinExprNode(syntax) | ||
171 | } | ||
172 | } | ||
173 | #[derive(Debug, Clone, Copy)] | 138 | #[derive(Debug, Clone, Copy)] |
174 | pub struct BinExpr<'a> { | 139 | pub struct BinExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
175 | syntax: SyntaxNodeRef<'a>, | 140 | syntax: SyntaxNode<R>, |
176 | } | 141 | } |
142 | pub type BinExpr<'a> = BinExprNode<RefRoot<'a>>; | ||
177 | 143 | ||
178 | impl<'a> AstNode<'a> for BinExpr<'a> { | 144 | impl<'a> AstNode<'a> for BinExpr<'a> { |
179 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 145 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -185,29 +151,24 @@ impl<'a> AstNode<'a> for BinExpr<'a> { | |||
185 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 151 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
186 | } | 152 | } |
187 | 153 | ||
188 | impl<'a> BinExpr<'a> {} | 154 | impl<R: TreeRoot<RaTypes>> BinExprNode<R> { |
189 | 155 | pub fn borrowed(&self) -> BinExpr { | |
190 | // BindPat | 156 | 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 | } | 157 | } |
199 | } | 158 | pub fn owned(&self) -> BinExprNode { |
200 | 159 | 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 | } | 160 | } |
206 | } | 161 | } |
162 | |||
163 | |||
164 | impl<'a> BinExpr<'a> {} | ||
165 | |||
166 | // BindPat | ||
207 | #[derive(Debug, Clone, Copy)] | 167 | #[derive(Debug, Clone, Copy)] |
208 | pub struct BindPat<'a> { | 168 | pub struct BindPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
209 | syntax: SyntaxNodeRef<'a>, | 169 | syntax: SyntaxNode<R>, |
210 | } | 170 | } |
171 | pub type BindPat<'a> = BindPatNode<RefRoot<'a>>; | ||
211 | 172 | ||
212 | impl<'a> AstNode<'a> for BindPat<'a> { | 173 | impl<'a> AstNode<'a> for BindPat<'a> { |
213 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 174 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -219,30 +180,25 @@ impl<'a> AstNode<'a> for BindPat<'a> { | |||
219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 180 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
220 | } | 181 | } |
221 | 182 | ||
183 | impl<R: TreeRoot<RaTypes>> BindPatNode<R> { | ||
184 | pub fn borrowed(&self) -> BindPat { | ||
185 | BindPatNode { syntax: self.syntax.borrowed() } | ||
186 | } | ||
187 | pub fn owned(&self) -> BindPatNode { | ||
188 | BindPatNode { syntax: self.syntax.owned() } | ||
189 | } | ||
190 | } | ||
191 | |||
192 | |||
222 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} | 193 | impl<'a> ast::NameOwner<'a> for BindPat<'a> {} |
223 | impl<'a> BindPat<'a> {} | 194 | impl<'a> BindPat<'a> {} |
224 | 195 | ||
225 | // Block | 196 | // 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)] | 197 | #[derive(Debug, Clone, Copy)] |
243 | pub struct Block<'a> { | 198 | pub struct BlockNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
244 | syntax: SyntaxNodeRef<'a>, | 199 | syntax: SyntaxNode<R>, |
245 | } | 200 | } |
201 | pub type Block<'a> = BlockNode<RefRoot<'a>>; | ||
246 | 202 | ||
247 | impl<'a> AstNode<'a> for Block<'a> { | 203 | impl<'a> AstNode<'a> for Block<'a> { |
248 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 204 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -254,6 +210,16 @@ impl<'a> AstNode<'a> for Block<'a> { | |||
254 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 210 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
255 | } | 211 | } |
256 | 212 | ||
213 | impl<R: TreeRoot<RaTypes>> BlockNode<R> { | ||
214 | pub fn borrowed(&self) -> Block { | ||
215 | BlockNode { syntax: self.syntax.borrowed() } | ||
216 | } | ||
217 | pub fn owned(&self) -> BlockNode { | ||
218 | BlockNode { syntax: self.syntax.owned() } | ||
219 | } | ||
220 | } | ||
221 | |||
222 | |||
257 | impl<'a> Block<'a> { | 223 | impl<'a> Block<'a> { |
258 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { | 224 | pub fn statements(self) -> impl Iterator<Item = Stmt<'a>> + 'a { |
259 | super::children(self) | 225 | super::children(self) |
@@ -265,26 +231,11 @@ impl<'a> Block<'a> { | |||
265 | } | 231 | } |
266 | 232 | ||
267 | // BlockExpr | 233 | // 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)] | 234 | #[derive(Debug, Clone, Copy)] |
285 | pub struct BlockExpr<'a> { | 235 | pub struct BlockExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
286 | syntax: SyntaxNodeRef<'a>, | 236 | syntax: SyntaxNode<R>, |
287 | } | 237 | } |
238 | pub type BlockExpr<'a> = BlockExprNode<RefRoot<'a>>; | ||
288 | 239 | ||
289 | impl<'a> AstNode<'a> for BlockExpr<'a> { | 240 | impl<'a> AstNode<'a> for BlockExpr<'a> { |
290 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 241 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -296,33 +247,28 @@ impl<'a> AstNode<'a> for BlockExpr<'a> { | |||
296 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 247 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
297 | } | 248 | } |
298 | 249 | ||
299 | impl<'a> BlockExpr<'a> { | 250 | impl<R: TreeRoot<RaTypes>> BlockExprNode<R> { |
300 | pub fn block(self) -> Option<Block<'a>> { | 251 | pub fn borrowed(&self) -> BlockExpr { |
301 | super::child_opt(self) | 252 | BlockExprNode { syntax: self.syntax.borrowed() } |
253 | } | ||
254 | pub fn owned(&self) -> BlockExprNode { | ||
255 | BlockExprNode { syntax: self.syntax.owned() } | ||
302 | } | 256 | } |
303 | } | 257 | } |
304 | 258 | ||
305 | // BreakExpr | ||
306 | 259 | ||
307 | #[derive(Debug, Clone)] | 260 | impl<'a> BlockExpr<'a> { |
308 | pub struct BreakExprNode(SyntaxNode); | 261 | pub fn block(self) -> Option<Block<'a>> { |
309 | 262 | super::child_opt(self) | |
310 | impl BreakExprNode { | ||
311 | pub fn ast(&self) -> BreakExpr { | ||
312 | BreakExpr::cast(self.0.borrowed()).unwrap() | ||
313 | } | 263 | } |
314 | } | 264 | } |
315 | 265 | ||
316 | impl<'a> From<BreakExpr<'a>> for BreakExprNode { | 266 | // BreakExpr |
317 | fn from(ast: BreakExpr<'a>) -> BreakExprNode { | ||
318 | let syntax = ast.syntax().owned(); | ||
319 | BreakExprNode(syntax) | ||
320 | } | ||
321 | } | ||
322 | #[derive(Debug, Clone, Copy)] | 267 | #[derive(Debug, Clone, Copy)] |
323 | pub struct BreakExpr<'a> { | 268 | pub struct BreakExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
324 | syntax: SyntaxNodeRef<'a>, | 269 | syntax: SyntaxNode<R>, |
325 | } | 270 | } |
271 | pub type BreakExpr<'a> = BreakExprNode<RefRoot<'a>>; | ||
326 | 272 | ||
327 | impl<'a> AstNode<'a> for BreakExpr<'a> { | 273 | impl<'a> AstNode<'a> for BreakExpr<'a> { |
328 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 274 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -334,29 +280,24 @@ impl<'a> AstNode<'a> for BreakExpr<'a> { | |||
334 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 280 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
335 | } | 281 | } |
336 | 282 | ||
337 | impl<'a> BreakExpr<'a> {} | 283 | impl<R: TreeRoot<RaTypes>> BreakExprNode<R> { |
338 | 284 | pub fn borrowed(&self) -> BreakExpr { | |
339 | // CallExpr | 285 | 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 | } | 286 | } |
348 | } | 287 | pub fn owned(&self) -> BreakExprNode { |
349 | 288 | 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 | } | 289 | } |
355 | } | 290 | } |
291 | |||
292 | |||
293 | impl<'a> BreakExpr<'a> {} | ||
294 | |||
295 | // CallExpr | ||
356 | #[derive(Debug, Clone, Copy)] | 296 | #[derive(Debug, Clone, Copy)] |
357 | pub struct CallExpr<'a> { | 297 | pub struct CallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
358 | syntax: SyntaxNodeRef<'a>, | 298 | syntax: SyntaxNode<R>, |
359 | } | 299 | } |
300 | pub type CallExpr<'a> = CallExprNode<RefRoot<'a>>; | ||
360 | 301 | ||
361 | impl<'a> AstNode<'a> for CallExpr<'a> { | 302 | impl<'a> AstNode<'a> for CallExpr<'a> { |
362 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 303 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -368,6 +309,16 @@ impl<'a> AstNode<'a> for CallExpr<'a> { | |||
368 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 309 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
369 | } | 310 | } |
370 | 311 | ||
312 | impl<R: TreeRoot<RaTypes>> CallExprNode<R> { | ||
313 | pub fn borrowed(&self) -> CallExpr { | ||
314 | CallExprNode { syntax: self.syntax.borrowed() } | ||
315 | } | ||
316 | pub fn owned(&self) -> CallExprNode { | ||
317 | CallExprNode { syntax: self.syntax.owned() } | ||
318 | } | ||
319 | } | ||
320 | |||
321 | |||
371 | impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} | 322 | impl<'a> ast::ArgListOwner<'a> for CallExpr<'a> {} |
372 | impl<'a> CallExpr<'a> { | 323 | impl<'a> CallExpr<'a> { |
373 | pub fn expr(self) -> Option<Expr<'a>> { | 324 | pub fn expr(self) -> Option<Expr<'a>> { |
@@ -376,26 +327,11 @@ impl<'a> CallExpr<'a> { | |||
376 | } | 327 | } |
377 | 328 | ||
378 | // CastExpr | 329 | // 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)] | 330 | #[derive(Debug, Clone, Copy)] |
396 | pub struct CastExpr<'a> { | 331 | pub struct CastExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
397 | syntax: SyntaxNodeRef<'a>, | 332 | syntax: SyntaxNode<R>, |
398 | } | 333 | } |
334 | pub type CastExpr<'a> = CastExprNode<RefRoot<'a>>; | ||
399 | 335 | ||
400 | impl<'a> AstNode<'a> for CastExpr<'a> { | 336 | impl<'a> AstNode<'a> for CastExpr<'a> { |
401 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 337 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -407,29 +343,24 @@ impl<'a> AstNode<'a> for CastExpr<'a> { | |||
407 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 343 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
408 | } | 344 | } |
409 | 345 | ||
410 | impl<'a> CastExpr<'a> {} | 346 | impl<R: TreeRoot<RaTypes>> CastExprNode<R> { |
411 | 347 | pub fn borrowed(&self) -> CastExpr { | |
412 | // Char | 348 | 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 | } | 349 | } |
421 | } | 350 | pub fn owned(&self) -> CastExprNode { |
422 | 351 | 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 | } | 352 | } |
428 | } | 353 | } |
354 | |||
355 | |||
356 | impl<'a> CastExpr<'a> {} | ||
357 | |||
358 | // Char | ||
429 | #[derive(Debug, Clone, Copy)] | 359 | #[derive(Debug, Clone, Copy)] |
430 | pub struct Char<'a> { | 360 | pub struct CharNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
431 | syntax: SyntaxNodeRef<'a>, | 361 | syntax: SyntaxNode<R>, |
432 | } | 362 | } |
363 | pub type Char<'a> = CharNode<RefRoot<'a>>; | ||
433 | 364 | ||
434 | impl<'a> AstNode<'a> for Char<'a> { | 365 | impl<'a> AstNode<'a> for Char<'a> { |
435 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 366 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -441,29 +372,24 @@ impl<'a> AstNode<'a> for Char<'a> { | |||
441 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 372 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
442 | } | 373 | } |
443 | 374 | ||
444 | impl<'a> Char<'a> {} | 375 | impl<R: TreeRoot<RaTypes>> CharNode<R> { |
445 | 376 | pub fn borrowed(&self) -> Char { | |
446 | // Comment | 377 | 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 | } | 378 | } |
455 | } | 379 | pub fn owned(&self) -> CharNode { |
456 | 380 | 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 | } | 381 | } |
462 | } | 382 | } |
383 | |||
384 | |||
385 | impl<'a> Char<'a> {} | ||
386 | |||
387 | // Comment | ||
463 | #[derive(Debug, Clone, Copy)] | 388 | #[derive(Debug, Clone, Copy)] |
464 | pub struct Comment<'a> { | 389 | pub struct CommentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
465 | syntax: SyntaxNodeRef<'a>, | 390 | syntax: SyntaxNode<R>, |
466 | } | 391 | } |
392 | pub type Comment<'a> = CommentNode<RefRoot<'a>>; | ||
467 | 393 | ||
468 | impl<'a> AstNode<'a> for Comment<'a> { | 394 | impl<'a> AstNode<'a> for Comment<'a> { |
469 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 395 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -475,29 +401,24 @@ impl<'a> AstNode<'a> for Comment<'a> { | |||
475 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 401 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
476 | } | 402 | } |
477 | 403 | ||
478 | impl<'a> Comment<'a> {} | 404 | impl<R: TreeRoot<RaTypes>> CommentNode<R> { |
479 | 405 | pub fn borrowed(&self) -> Comment { | |
480 | // Condition | 406 | 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 | } | 407 | } |
489 | } | 408 | pub fn owned(&self) -> CommentNode { |
490 | 409 | 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 | } | 410 | } |
496 | } | 411 | } |
412 | |||
413 | |||
414 | impl<'a> Comment<'a> {} | ||
415 | |||
416 | // Condition | ||
497 | #[derive(Debug, Clone, Copy)] | 417 | #[derive(Debug, Clone, Copy)] |
498 | pub struct Condition<'a> { | 418 | pub struct ConditionNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
499 | syntax: SyntaxNodeRef<'a>, | 419 | syntax: SyntaxNode<R>, |
500 | } | 420 | } |
421 | pub type Condition<'a> = ConditionNode<RefRoot<'a>>; | ||
501 | 422 | ||
502 | impl<'a> AstNode<'a> for Condition<'a> { | 423 | impl<'a> AstNode<'a> for Condition<'a> { |
503 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 424 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -509,6 +430,16 @@ impl<'a> AstNode<'a> for Condition<'a> { | |||
509 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 430 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
510 | } | 431 | } |
511 | 432 | ||
433 | impl<R: TreeRoot<RaTypes>> ConditionNode<R> { | ||
434 | pub fn borrowed(&self) -> Condition { | ||
435 | ConditionNode { syntax: self.syntax.borrowed() } | ||
436 | } | ||
437 | pub fn owned(&self) -> ConditionNode { | ||
438 | ConditionNode { syntax: self.syntax.owned() } | ||
439 | } | ||
440 | } | ||
441 | |||
442 | |||
512 | impl<'a> Condition<'a> { | 443 | impl<'a> Condition<'a> { |
513 | pub fn pat(self) -> Option<Pat<'a>> { | 444 | pub fn pat(self) -> Option<Pat<'a>> { |
514 | super::child_opt(self) | 445 | super::child_opt(self) |
@@ -520,26 +451,11 @@ impl<'a> Condition<'a> { | |||
520 | } | 451 | } |
521 | 452 | ||
522 | // ConstDef | 453 | // 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)] | 454 | #[derive(Debug, Clone, Copy)] |
540 | pub struct ConstDef<'a> { | 455 | pub struct ConstDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
541 | syntax: SyntaxNodeRef<'a>, | 456 | syntax: SyntaxNode<R>, |
542 | } | 457 | } |
458 | pub type ConstDef<'a> = ConstDefNode<RefRoot<'a>>; | ||
543 | 459 | ||
544 | impl<'a> AstNode<'a> for ConstDef<'a> { | 460 | impl<'a> AstNode<'a> for ConstDef<'a> { |
545 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 461 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -551,32 +467,27 @@ impl<'a> AstNode<'a> for ConstDef<'a> { | |||
551 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 467 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
552 | } | 468 | } |
553 | 469 | ||
470 | impl<R: TreeRoot<RaTypes>> ConstDefNode<R> { | ||
471 | pub fn borrowed(&self) -> ConstDef { | ||
472 | ConstDefNode { syntax: self.syntax.borrowed() } | ||
473 | } | ||
474 | pub fn owned(&self) -> ConstDefNode { | ||
475 | ConstDefNode { syntax: self.syntax.owned() } | ||
476 | } | ||
477 | } | ||
478 | |||
479 | |||
554 | impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} | 480 | impl<'a> ast::NameOwner<'a> for ConstDef<'a> {} |
555 | impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} | 481 | impl<'a> ast::TypeParamsOwner<'a> for ConstDef<'a> {} |
556 | impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} | 482 | impl<'a> ast::AttrsOwner<'a> for ConstDef<'a> {} |
557 | impl<'a> ConstDef<'a> {} | 483 | impl<'a> ConstDef<'a> {} |
558 | 484 | ||
559 | // ContinueExpr | 485 | // 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)] | 486 | #[derive(Debug, Clone, Copy)] |
577 | pub struct ContinueExpr<'a> { | 487 | pub struct ContinueExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
578 | syntax: SyntaxNodeRef<'a>, | 488 | syntax: SyntaxNode<R>, |
579 | } | 489 | } |
490 | pub type ContinueExpr<'a> = ContinueExprNode<RefRoot<'a>>; | ||
580 | 491 | ||
581 | impl<'a> AstNode<'a> for ContinueExpr<'a> { | 492 | impl<'a> AstNode<'a> for ContinueExpr<'a> { |
582 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 493 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -588,29 +499,24 @@ impl<'a> AstNode<'a> for ContinueExpr<'a> { | |||
588 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 499 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
589 | } | 500 | } |
590 | 501 | ||
591 | impl<'a> ContinueExpr<'a> {} | 502 | impl<R: TreeRoot<RaTypes>> ContinueExprNode<R> { |
592 | 503 | pub fn borrowed(&self) -> ContinueExpr { | |
593 | // DynTraitType | 504 | 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 | } | 505 | } |
602 | } | 506 | pub fn owned(&self) -> ContinueExprNode { |
603 | 507 | 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 | } | 508 | } |
609 | } | 509 | } |
510 | |||
511 | |||
512 | impl<'a> ContinueExpr<'a> {} | ||
513 | |||
514 | // DynTraitType | ||
610 | #[derive(Debug, Clone, Copy)] | 515 | #[derive(Debug, Clone, Copy)] |
611 | pub struct DynTraitType<'a> { | 516 | pub struct DynTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
612 | syntax: SyntaxNodeRef<'a>, | 517 | syntax: SyntaxNode<R>, |
613 | } | 518 | } |
519 | pub type DynTraitType<'a> = DynTraitTypeNode<RefRoot<'a>>; | ||
614 | 520 | ||
615 | impl<'a> AstNode<'a> for DynTraitType<'a> { | 521 | impl<'a> AstNode<'a> for DynTraitType<'a> { |
616 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 522 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -622,29 +528,24 @@ impl<'a> AstNode<'a> for DynTraitType<'a> { | |||
622 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 528 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
623 | } | 529 | } |
624 | 530 | ||
625 | impl<'a> DynTraitType<'a> {} | 531 | impl<R: TreeRoot<RaTypes>> DynTraitTypeNode<R> { |
626 | 532 | pub fn borrowed(&self) -> DynTraitType { | |
627 | // EnumDef | 533 | 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 | } | 534 | } |
636 | } | 535 | pub fn owned(&self) -> DynTraitTypeNode { |
637 | 536 | 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 | } | 537 | } |
643 | } | 538 | } |
539 | |||
540 | |||
541 | impl<'a> DynTraitType<'a> {} | ||
542 | |||
543 | // EnumDef | ||
644 | #[derive(Debug, Clone, Copy)] | 544 | #[derive(Debug, Clone, Copy)] |
645 | pub struct EnumDef<'a> { | 545 | pub struct EnumDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
646 | syntax: SyntaxNodeRef<'a>, | 546 | syntax: SyntaxNode<R>, |
647 | } | 547 | } |
548 | pub type EnumDef<'a> = EnumDefNode<RefRoot<'a>>; | ||
648 | 549 | ||
649 | impl<'a> AstNode<'a> for EnumDef<'a> { | 550 | impl<'a> AstNode<'a> for EnumDef<'a> { |
650 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 551 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -656,28 +557,22 @@ impl<'a> AstNode<'a> for EnumDef<'a> { | |||
656 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 557 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
657 | } | 558 | } |
658 | 559 | ||
560 | impl<R: TreeRoot<RaTypes>> EnumDefNode<R> { | ||
561 | pub fn borrowed(&self) -> EnumDef { | ||
562 | EnumDefNode { syntax: self.syntax.borrowed() } | ||
563 | } | ||
564 | pub fn owned(&self) -> EnumDefNode { | ||
565 | EnumDefNode { syntax: self.syntax.owned() } | ||
566 | } | ||
567 | } | ||
568 | |||
569 | |||
659 | impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} | 570 | impl<'a> ast::NameOwner<'a> for EnumDef<'a> {} |
660 | impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} | 571 | impl<'a> ast::TypeParamsOwner<'a> for EnumDef<'a> {} |
661 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} | 572 | impl<'a> ast::AttrsOwner<'a> for EnumDef<'a> {} |
662 | impl<'a> EnumDef<'a> {} | 573 | impl<'a> EnumDef<'a> {} |
663 | 574 | ||
664 | // Expr | 575 | // 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)] | 576 | #[derive(Debug, Clone, Copy)] |
682 | pub enum Expr<'a> { | 577 | pub enum Expr<'a> { |
683 | TupleExpr(TupleExpr<'a>), | 578 | TupleExpr(TupleExpr<'a>), |
@@ -793,26 +688,11 @@ impl<'a> AstNode<'a> for Expr<'a> { | |||
793 | impl<'a> Expr<'a> {} | 688 | impl<'a> Expr<'a> {} |
794 | 689 | ||
795 | // ExprStmt | 690 | // 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)] | 691 | #[derive(Debug, Clone, Copy)] |
813 | pub struct ExprStmt<'a> { | 692 | pub struct ExprStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
814 | syntax: SyntaxNodeRef<'a>, | 693 | syntax: SyntaxNode<R>, |
815 | } | 694 | } |
695 | pub type ExprStmt<'a> = ExprStmtNode<RefRoot<'a>>; | ||
816 | 696 | ||
817 | impl<'a> AstNode<'a> for ExprStmt<'a> { | 697 | impl<'a> AstNode<'a> for ExprStmt<'a> { |
818 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 698 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -824,33 +704,28 @@ impl<'a> AstNode<'a> for ExprStmt<'a> { | |||
824 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 704 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
825 | } | 705 | } |
826 | 706 | ||
827 | impl<'a> ExprStmt<'a> { | 707 | impl<R: TreeRoot<RaTypes>> ExprStmtNode<R> { |
828 | pub fn expr(self) -> Option<Expr<'a>> { | 708 | pub fn borrowed(&self) -> ExprStmt { |
829 | super::child_opt(self) | 709 | ExprStmtNode { syntax: self.syntax.borrowed() } |
710 | } | ||
711 | pub fn owned(&self) -> ExprStmtNode { | ||
712 | ExprStmtNode { syntax: self.syntax.owned() } | ||
830 | } | 713 | } |
831 | } | 714 | } |
832 | 715 | ||
833 | // ExternCrateItem | ||
834 | 716 | ||
835 | #[derive(Debug, Clone)] | 717 | impl<'a> ExprStmt<'a> { |
836 | pub struct ExternCrateItemNode(SyntaxNode); | 718 | pub fn expr(self) -> Option<Expr<'a>> { |
837 | 719 | super::child_opt(self) | |
838 | impl ExternCrateItemNode { | ||
839 | pub fn ast(&self) -> ExternCrateItem { | ||
840 | ExternCrateItem::cast(self.0.borrowed()).unwrap() | ||
841 | } | 720 | } |
842 | } | 721 | } |
843 | 722 | ||
844 | impl<'a> From<ExternCrateItem<'a>> for ExternCrateItemNode { | 723 | // ExternCrateItem |
845 | fn from(ast: ExternCrateItem<'a>) -> ExternCrateItemNode { | ||
846 | let syntax = ast.syntax().owned(); | ||
847 | ExternCrateItemNode(syntax) | ||
848 | } | ||
849 | } | ||
850 | #[derive(Debug, Clone, Copy)] | 724 | #[derive(Debug, Clone, Copy)] |
851 | pub struct ExternCrateItem<'a> { | 725 | pub struct ExternCrateItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
852 | syntax: SyntaxNodeRef<'a>, | 726 | syntax: SyntaxNode<R>, |
853 | } | 727 | } |
728 | pub type ExternCrateItem<'a> = ExternCrateItemNode<RefRoot<'a>>; | ||
854 | 729 | ||
855 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { | 730 | impl<'a> AstNode<'a> for ExternCrateItem<'a> { |
856 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 731 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -862,29 +737,24 @@ impl<'a> AstNode<'a> for ExternCrateItem<'a> { | |||
862 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 737 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
863 | } | 738 | } |
864 | 739 | ||
865 | impl<'a> ExternCrateItem<'a> {} | 740 | impl<R: TreeRoot<RaTypes>> ExternCrateItemNode<R> { |
866 | 741 | pub fn borrowed(&self) -> ExternCrateItem { | |
867 | // FieldExpr | 742 | 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 | } | 743 | } |
876 | } | 744 | pub fn owned(&self) -> ExternCrateItemNode { |
877 | 745 | 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 | } | 746 | } |
883 | } | 747 | } |
748 | |||
749 | |||
750 | impl<'a> ExternCrateItem<'a> {} | ||
751 | |||
752 | // FieldExpr | ||
884 | #[derive(Debug, Clone, Copy)] | 753 | #[derive(Debug, Clone, Copy)] |
885 | pub struct FieldExpr<'a> { | 754 | pub struct FieldExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
886 | syntax: SyntaxNodeRef<'a>, | 755 | syntax: SyntaxNode<R>, |
887 | } | 756 | } |
757 | pub type FieldExpr<'a> = FieldExprNode<RefRoot<'a>>; | ||
888 | 758 | ||
889 | impl<'a> AstNode<'a> for FieldExpr<'a> { | 759 | impl<'a> AstNode<'a> for FieldExpr<'a> { |
890 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 760 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -896,29 +766,24 @@ impl<'a> AstNode<'a> for FieldExpr<'a> { | |||
896 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 766 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
897 | } | 767 | } |
898 | 768 | ||
899 | impl<'a> FieldExpr<'a> {} | 769 | impl<R: TreeRoot<RaTypes>> FieldExprNode<R> { |
900 | 770 | pub fn borrowed(&self) -> FieldExpr { | |
901 | // FieldPatList | 771 | 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 | } | 772 | } |
910 | } | 773 | pub fn owned(&self) -> FieldExprNode { |
911 | 774 | 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 | } | 775 | } |
917 | } | 776 | } |
777 | |||
778 | |||
779 | impl<'a> FieldExpr<'a> {} | ||
780 | |||
781 | // FieldPatList | ||
918 | #[derive(Debug, Clone, Copy)] | 782 | #[derive(Debug, Clone, Copy)] |
919 | pub struct FieldPatList<'a> { | 783 | pub struct FieldPatListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
920 | syntax: SyntaxNodeRef<'a>, | 784 | syntax: SyntaxNode<R>, |
921 | } | 785 | } |
786 | pub type FieldPatList<'a> = FieldPatListNode<RefRoot<'a>>; | ||
922 | 787 | ||
923 | impl<'a> AstNode<'a> for FieldPatList<'a> { | 788 | impl<'a> AstNode<'a> for FieldPatList<'a> { |
924 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 789 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -930,29 +795,24 @@ impl<'a> AstNode<'a> for FieldPatList<'a> { | |||
930 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 795 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
931 | } | 796 | } |
932 | 797 | ||
933 | impl<'a> FieldPatList<'a> {} | 798 | impl<R: TreeRoot<RaTypes>> FieldPatListNode<R> { |
934 | 799 | pub fn borrowed(&self) -> FieldPatList { | |
935 | // FnDef | 800 | 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 | } | 801 | } |
944 | } | 802 | pub fn owned(&self) -> FieldPatListNode { |
945 | 803 | 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 | } | 804 | } |
951 | } | 805 | } |
806 | |||
807 | |||
808 | impl<'a> FieldPatList<'a> {} | ||
809 | |||
810 | // FnDef | ||
952 | #[derive(Debug, Clone, Copy)] | 811 | #[derive(Debug, Clone, Copy)] |
953 | pub struct FnDef<'a> { | 812 | pub struct FnDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
954 | syntax: SyntaxNodeRef<'a>, | 813 | syntax: SyntaxNode<R>, |
955 | } | 814 | } |
815 | pub type FnDef<'a> = FnDefNode<RefRoot<'a>>; | ||
956 | 816 | ||
957 | impl<'a> AstNode<'a> for FnDef<'a> { | 817 | impl<'a> AstNode<'a> for FnDef<'a> { |
958 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 818 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -964,6 +824,16 @@ impl<'a> AstNode<'a> for FnDef<'a> { | |||
964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 824 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
965 | } | 825 | } |
966 | 826 | ||
827 | impl<R: TreeRoot<RaTypes>> FnDefNode<R> { | ||
828 | pub fn borrowed(&self) -> FnDef { | ||
829 | FnDefNode { syntax: self.syntax.borrowed() } | ||
830 | } | ||
831 | pub fn owned(&self) -> FnDefNode { | ||
832 | FnDefNode { syntax: self.syntax.owned() } | ||
833 | } | ||
834 | } | ||
835 | |||
836 | |||
967 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} | 837 | impl<'a> ast::NameOwner<'a> for FnDef<'a> {} |
968 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} | 838 | impl<'a> ast::TypeParamsOwner<'a> for FnDef<'a> {} |
969 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} | 839 | impl<'a> ast::AttrsOwner<'a> for FnDef<'a> {} |
@@ -983,26 +853,11 @@ impl<'a> FnDef<'a> { | |||
983 | } | 853 | } |
984 | 854 | ||
985 | // FnPointerType | 855 | // 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)] | 856 | #[derive(Debug, Clone, Copy)] |
1003 | pub struct FnPointerType<'a> { | 857 | pub struct FnPointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1004 | syntax: SyntaxNodeRef<'a>, | 858 | syntax: SyntaxNode<R>, |
1005 | } | 859 | } |
860 | pub type FnPointerType<'a> = FnPointerTypeNode<RefRoot<'a>>; | ||
1006 | 861 | ||
1007 | impl<'a> AstNode<'a> for FnPointerType<'a> { | 862 | impl<'a> AstNode<'a> for FnPointerType<'a> { |
1008 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 863 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1014,29 +869,24 @@ impl<'a> AstNode<'a> for FnPointerType<'a> { | |||
1014 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 869 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1015 | } | 870 | } |
1016 | 871 | ||
1017 | impl<'a> FnPointerType<'a> {} | 872 | impl<R: TreeRoot<RaTypes>> FnPointerTypeNode<R> { |
1018 | 873 | pub fn borrowed(&self) -> FnPointerType { | |
1019 | // ForExpr | 874 | 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 | } | 875 | } |
1028 | } | 876 | pub fn owned(&self) -> FnPointerTypeNode { |
1029 | 877 | 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 | } | 878 | } |
1035 | } | 879 | } |
880 | |||
881 | |||
882 | impl<'a> FnPointerType<'a> {} | ||
883 | |||
884 | // ForExpr | ||
1036 | #[derive(Debug, Clone, Copy)] | 885 | #[derive(Debug, Clone, Copy)] |
1037 | pub struct ForExpr<'a> { | 886 | pub struct ForExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1038 | syntax: SyntaxNodeRef<'a>, | 887 | syntax: SyntaxNode<R>, |
1039 | } | 888 | } |
889 | pub type ForExpr<'a> = ForExprNode<RefRoot<'a>>; | ||
1040 | 890 | ||
1041 | impl<'a> AstNode<'a> for ForExpr<'a> { | 891 | impl<'a> AstNode<'a> for ForExpr<'a> { |
1042 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 892 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1048,6 +898,16 @@ impl<'a> AstNode<'a> for ForExpr<'a> { | |||
1048 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 898 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1049 | } | 899 | } |
1050 | 900 | ||
901 | impl<R: TreeRoot<RaTypes>> ForExprNode<R> { | ||
902 | pub fn borrowed(&self) -> ForExpr { | ||
903 | ForExprNode { syntax: self.syntax.borrowed() } | ||
904 | } | ||
905 | pub fn owned(&self) -> ForExprNode { | ||
906 | ForExprNode { syntax: self.syntax.owned() } | ||
907 | } | ||
908 | } | ||
909 | |||
910 | |||
1051 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} | 911 | impl<'a> ast::LoopBodyOwner<'a> for ForExpr<'a> {} |
1052 | impl<'a> ForExpr<'a> { | 912 | impl<'a> ForExpr<'a> { |
1053 | pub fn pat(self) -> Option<Pat<'a>> { | 913 | pub fn pat(self) -> Option<Pat<'a>> { |
@@ -1060,26 +920,11 @@ impl<'a> ForExpr<'a> { | |||
1060 | } | 920 | } |
1061 | 921 | ||
1062 | // ForType | 922 | // 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)] | 923 | #[derive(Debug, Clone, Copy)] |
1080 | pub struct ForType<'a> { | 924 | pub struct ForTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1081 | syntax: SyntaxNodeRef<'a>, | 925 | syntax: SyntaxNode<R>, |
1082 | } | 926 | } |
927 | pub type ForType<'a> = ForTypeNode<RefRoot<'a>>; | ||
1083 | 928 | ||
1084 | impl<'a> AstNode<'a> for ForType<'a> { | 929 | impl<'a> AstNode<'a> for ForType<'a> { |
1085 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 930 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1091,29 +936,24 @@ impl<'a> AstNode<'a> for ForType<'a> { | |||
1091 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 936 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1092 | } | 937 | } |
1093 | 938 | ||
1094 | impl<'a> ForType<'a> {} | 939 | impl<R: TreeRoot<RaTypes>> ForTypeNode<R> { |
1095 | 940 | pub fn borrowed(&self) -> ForType { | |
1096 | // IfExpr | 941 | 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 | } | 942 | } |
1105 | } | 943 | pub fn owned(&self) -> ForTypeNode { |
1106 | 944 | 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 | } | 945 | } |
1112 | } | 946 | } |
947 | |||
948 | |||
949 | impl<'a> ForType<'a> {} | ||
950 | |||
951 | // IfExpr | ||
1113 | #[derive(Debug, Clone, Copy)] | 952 | #[derive(Debug, Clone, Copy)] |
1114 | pub struct IfExpr<'a> { | 953 | pub struct IfExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1115 | syntax: SyntaxNodeRef<'a>, | 954 | syntax: SyntaxNode<R>, |
1116 | } | 955 | } |
956 | pub type IfExpr<'a> = IfExprNode<RefRoot<'a>>; | ||
1117 | 957 | ||
1118 | impl<'a> AstNode<'a> for IfExpr<'a> { | 958 | impl<'a> AstNode<'a> for IfExpr<'a> { |
1119 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 959 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1125,33 +965,28 @@ impl<'a> AstNode<'a> for IfExpr<'a> { | |||
1125 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 965 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1126 | } | 966 | } |
1127 | 967 | ||
1128 | impl<'a> IfExpr<'a> { | 968 | impl<R: TreeRoot<RaTypes>> IfExprNode<R> { |
1129 | pub fn condition(self) -> Option<Condition<'a>> { | 969 | pub fn borrowed(&self) -> IfExpr { |
1130 | super::child_opt(self) | 970 | IfExprNode { syntax: self.syntax.borrowed() } |
971 | } | ||
972 | pub fn owned(&self) -> IfExprNode { | ||
973 | IfExprNode { syntax: self.syntax.owned() } | ||
1131 | } | 974 | } |
1132 | } | 975 | } |
1133 | 976 | ||
1134 | // ImplItem | ||
1135 | |||
1136 | #[derive(Debug, Clone)] | ||
1137 | pub struct ImplItemNode(SyntaxNode); | ||
1138 | 977 | ||
1139 | impl ImplItemNode { | 978 | impl<'a> IfExpr<'a> { |
1140 | pub fn ast(&self) -> ImplItem { | 979 | pub fn condition(self) -> Option<Condition<'a>> { |
1141 | ImplItem::cast(self.0.borrowed()).unwrap() | 980 | super::child_opt(self) |
1142 | } | 981 | } |
1143 | } | 982 | } |
1144 | 983 | ||
1145 | impl<'a> From<ImplItem<'a>> for ImplItemNode { | 984 | // ImplItem |
1146 | fn from(ast: ImplItem<'a>) -> ImplItemNode { | ||
1147 | let syntax = ast.syntax().owned(); | ||
1148 | ImplItemNode(syntax) | ||
1149 | } | ||
1150 | } | ||
1151 | #[derive(Debug, Clone, Copy)] | 985 | #[derive(Debug, Clone, Copy)] |
1152 | pub struct ImplItem<'a> { | 986 | pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1153 | syntax: SyntaxNodeRef<'a>, | 987 | syntax: SyntaxNode<R>, |
1154 | } | 988 | } |
989 | pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>; | ||
1155 | 990 | ||
1156 | impl<'a> AstNode<'a> for ImplItem<'a> { | 991 | impl<'a> AstNode<'a> for ImplItem<'a> { |
1157 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 992 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1163,29 +998,24 @@ impl<'a> AstNode<'a> for ImplItem<'a> { | |||
1163 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 998 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1164 | } | 999 | } |
1165 | 1000 | ||
1166 | impl<'a> ImplItem<'a> {} | 1001 | impl<R: TreeRoot<RaTypes>> ImplItemNode<R> { |
1167 | 1002 | pub fn borrowed(&self) -> ImplItem { | |
1168 | // ImplTraitType | 1003 | 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 | } | 1004 | } |
1177 | } | 1005 | pub fn owned(&self) -> ImplItemNode { |
1178 | 1006 | 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 | } | 1007 | } |
1184 | } | 1008 | } |
1009 | |||
1010 | |||
1011 | impl<'a> ImplItem<'a> {} | ||
1012 | |||
1013 | // ImplTraitType | ||
1185 | #[derive(Debug, Clone, Copy)] | 1014 | #[derive(Debug, Clone, Copy)] |
1186 | pub struct ImplTraitType<'a> { | 1015 | pub struct ImplTraitTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1187 | syntax: SyntaxNodeRef<'a>, | 1016 | syntax: SyntaxNode<R>, |
1188 | } | 1017 | } |
1018 | pub type ImplTraitType<'a> = ImplTraitTypeNode<RefRoot<'a>>; | ||
1189 | 1019 | ||
1190 | impl<'a> AstNode<'a> for ImplTraitType<'a> { | 1020 | impl<'a> AstNode<'a> for ImplTraitType<'a> { |
1191 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1021 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1197,29 +1027,24 @@ impl<'a> AstNode<'a> for ImplTraitType<'a> { | |||
1197 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1027 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1198 | } | 1028 | } |
1199 | 1029 | ||
1200 | impl<'a> ImplTraitType<'a> {} | 1030 | impl<R: TreeRoot<RaTypes>> ImplTraitTypeNode<R> { |
1201 | 1031 | pub fn borrowed(&self) -> ImplTraitType { | |
1202 | // IndexExpr | 1032 | 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 | } | 1033 | } |
1211 | } | 1034 | pub fn owned(&self) -> ImplTraitTypeNode { |
1212 | 1035 | 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 | } | 1036 | } |
1218 | } | 1037 | } |
1038 | |||
1039 | |||
1040 | impl<'a> ImplTraitType<'a> {} | ||
1041 | |||
1042 | // IndexExpr | ||
1219 | #[derive(Debug, Clone, Copy)] | 1043 | #[derive(Debug, Clone, Copy)] |
1220 | pub struct IndexExpr<'a> { | 1044 | pub struct IndexExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1221 | syntax: SyntaxNodeRef<'a>, | 1045 | syntax: SyntaxNode<R>, |
1222 | } | 1046 | } |
1047 | pub type IndexExpr<'a> = IndexExprNode<RefRoot<'a>>; | ||
1223 | 1048 | ||
1224 | impl<'a> AstNode<'a> for IndexExpr<'a> { | 1049 | impl<'a> AstNode<'a> for IndexExpr<'a> { |
1225 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1050 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1231,29 +1056,24 @@ impl<'a> AstNode<'a> for IndexExpr<'a> { | |||
1231 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1056 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1232 | } | 1057 | } |
1233 | 1058 | ||
1234 | impl<'a> IndexExpr<'a> {} | 1059 | impl<R: TreeRoot<RaTypes>> IndexExprNode<R> { |
1235 | 1060 | pub fn borrowed(&self) -> IndexExpr { | |
1236 | // ItemList | 1061 | 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 | } | 1062 | } |
1245 | } | 1063 | pub fn owned(&self) -> IndexExprNode { |
1246 | 1064 | 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 | } | 1065 | } |
1252 | } | 1066 | } |
1067 | |||
1068 | |||
1069 | impl<'a> IndexExpr<'a> {} | ||
1070 | |||
1071 | // ItemList | ||
1253 | #[derive(Debug, Clone, Copy)] | 1072 | #[derive(Debug, Clone, Copy)] |
1254 | pub struct ItemList<'a> { | 1073 | pub struct ItemListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1255 | syntax: SyntaxNodeRef<'a>, | 1074 | syntax: SyntaxNode<R>, |
1256 | } | 1075 | } |
1076 | pub type ItemList<'a> = ItemListNode<RefRoot<'a>>; | ||
1257 | 1077 | ||
1258 | impl<'a> AstNode<'a> for ItemList<'a> { | 1078 | impl<'a> AstNode<'a> for ItemList<'a> { |
1259 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1079 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1265,31 +1085,26 @@ impl<'a> AstNode<'a> for ItemList<'a> { | |||
1265 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1085 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1266 | } | 1086 | } |
1267 | 1087 | ||
1088 | impl<R: TreeRoot<RaTypes>> ItemListNode<R> { | ||
1089 | pub fn borrowed(&self) -> ItemList { | ||
1090 | ItemListNode { syntax: self.syntax.borrowed() } | ||
1091 | } | ||
1092 | pub fn owned(&self) -> ItemListNode { | ||
1093 | ItemListNode { syntax: self.syntax.owned() } | ||
1094 | } | ||
1095 | } | ||
1096 | |||
1097 | |||
1268 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} | 1098 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} |
1269 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} | 1099 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} |
1270 | impl<'a> ItemList<'a> {} | 1100 | impl<'a> ItemList<'a> {} |
1271 | 1101 | ||
1272 | // Label | 1102 | // 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)] | 1103 | #[derive(Debug, Clone, Copy)] |
1290 | pub struct Label<'a> { | 1104 | pub struct LabelNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1291 | syntax: SyntaxNodeRef<'a>, | 1105 | syntax: SyntaxNode<R>, |
1292 | } | 1106 | } |
1107 | pub type Label<'a> = LabelNode<RefRoot<'a>>; | ||
1293 | 1108 | ||
1294 | impl<'a> AstNode<'a> for Label<'a> { | 1109 | impl<'a> AstNode<'a> for Label<'a> { |
1295 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1110 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1301,29 +1116,24 @@ impl<'a> AstNode<'a> for Label<'a> { | |||
1301 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1116 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1302 | } | 1117 | } |
1303 | 1118 | ||
1304 | impl<'a> Label<'a> {} | 1119 | impl<R: TreeRoot<RaTypes>> LabelNode<R> { |
1305 | 1120 | pub fn borrowed(&self) -> Label { | |
1306 | // LambdaExpr | 1121 | 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 | } | 1122 | } |
1315 | } | 1123 | pub fn owned(&self) -> LabelNode { |
1316 | 1124 | 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 | } | 1125 | } |
1322 | } | 1126 | } |
1127 | |||
1128 | |||
1129 | impl<'a> Label<'a> {} | ||
1130 | |||
1131 | // LambdaExpr | ||
1323 | #[derive(Debug, Clone, Copy)] | 1132 | #[derive(Debug, Clone, Copy)] |
1324 | pub struct LambdaExpr<'a> { | 1133 | pub struct LambdaExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1325 | syntax: SyntaxNodeRef<'a>, | 1134 | syntax: SyntaxNode<R>, |
1326 | } | 1135 | } |
1136 | pub type LambdaExpr<'a> = LambdaExprNode<RefRoot<'a>>; | ||
1327 | 1137 | ||
1328 | impl<'a> AstNode<'a> for LambdaExpr<'a> { | 1138 | impl<'a> AstNode<'a> for LambdaExpr<'a> { |
1329 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1139 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1335,6 +1145,16 @@ impl<'a> AstNode<'a> for LambdaExpr<'a> { | |||
1335 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1145 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1336 | } | 1146 | } |
1337 | 1147 | ||
1148 | impl<R: TreeRoot<RaTypes>> LambdaExprNode<R> { | ||
1149 | pub fn borrowed(&self) -> LambdaExpr { | ||
1150 | LambdaExprNode { syntax: self.syntax.borrowed() } | ||
1151 | } | ||
1152 | pub fn owned(&self) -> LambdaExprNode { | ||
1153 | LambdaExprNode { syntax: self.syntax.owned() } | ||
1154 | } | ||
1155 | } | ||
1156 | |||
1157 | |||
1338 | impl<'a> LambdaExpr<'a> { | 1158 | impl<'a> LambdaExpr<'a> { |
1339 | pub fn param_list(self) -> Option<ParamList<'a>> { | 1159 | pub fn param_list(self) -> Option<ParamList<'a>> { |
1340 | super::child_opt(self) | 1160 | super::child_opt(self) |
@@ -1346,26 +1166,11 @@ impl<'a> LambdaExpr<'a> { | |||
1346 | } | 1166 | } |
1347 | 1167 | ||
1348 | // LetStmt | 1168 | // 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)] | 1169 | #[derive(Debug, Clone, Copy)] |
1366 | pub struct LetStmt<'a> { | 1170 | pub struct LetStmtNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1367 | syntax: SyntaxNodeRef<'a>, | 1171 | syntax: SyntaxNode<R>, |
1368 | } | 1172 | } |
1173 | pub type LetStmt<'a> = LetStmtNode<RefRoot<'a>>; | ||
1369 | 1174 | ||
1370 | impl<'a> AstNode<'a> for LetStmt<'a> { | 1175 | impl<'a> AstNode<'a> for LetStmt<'a> { |
1371 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1176 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1377,6 +1182,16 @@ impl<'a> AstNode<'a> for LetStmt<'a> { | |||
1377 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1182 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1378 | } | 1183 | } |
1379 | 1184 | ||
1185 | impl<R: TreeRoot<RaTypes>> LetStmtNode<R> { | ||
1186 | pub fn borrowed(&self) -> LetStmt { | ||
1187 | LetStmtNode { syntax: self.syntax.borrowed() } | ||
1188 | } | ||
1189 | pub fn owned(&self) -> LetStmtNode { | ||
1190 | LetStmtNode { syntax: self.syntax.owned() } | ||
1191 | } | ||
1192 | } | ||
1193 | |||
1194 | |||
1380 | impl<'a> LetStmt<'a> { | 1195 | impl<'a> LetStmt<'a> { |
1381 | pub fn pat(self) -> Option<Pat<'a>> { | 1196 | pub fn pat(self) -> Option<Pat<'a>> { |
1382 | super::child_opt(self) | 1197 | super::child_opt(self) |
@@ -1388,26 +1203,11 @@ impl<'a> LetStmt<'a> { | |||
1388 | } | 1203 | } |
1389 | 1204 | ||
1390 | // Lifetime | 1205 | // 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)] | 1206 | #[derive(Debug, Clone, Copy)] |
1408 | pub struct Lifetime<'a> { | 1207 | pub struct LifetimeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1409 | syntax: SyntaxNodeRef<'a>, | 1208 | syntax: SyntaxNode<R>, |
1410 | } | 1209 | } |
1210 | pub type Lifetime<'a> = LifetimeNode<RefRoot<'a>>; | ||
1411 | 1211 | ||
1412 | impl<'a> AstNode<'a> for Lifetime<'a> { | 1212 | impl<'a> AstNode<'a> for Lifetime<'a> { |
1413 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1213 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1419,29 +1219,24 @@ impl<'a> AstNode<'a> for Lifetime<'a> { | |||
1419 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1420 | } | 1220 | } |
1421 | 1221 | ||
1422 | impl<'a> Lifetime<'a> {} | 1222 | impl<R: TreeRoot<RaTypes>> LifetimeNode<R> { |
1423 | 1223 | pub fn borrowed(&self) -> Lifetime { | |
1424 | // LifetimeParam | 1224 | 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 | } | 1225 | } |
1433 | } | 1226 | pub fn owned(&self) -> LifetimeNode { |
1434 | 1227 | 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 | } | 1228 | } |
1440 | } | 1229 | } |
1230 | |||
1231 | |||
1232 | impl<'a> Lifetime<'a> {} | ||
1233 | |||
1234 | // LifetimeParam | ||
1441 | #[derive(Debug, Clone, Copy)] | 1235 | #[derive(Debug, Clone, Copy)] |
1442 | pub struct LifetimeParam<'a> { | 1236 | pub struct LifetimeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1443 | syntax: SyntaxNodeRef<'a>, | 1237 | syntax: SyntaxNode<R>, |
1444 | } | 1238 | } |
1239 | pub type LifetimeParam<'a> = LifetimeParamNode<RefRoot<'a>>; | ||
1445 | 1240 | ||
1446 | impl<'a> AstNode<'a> for LifetimeParam<'a> { | 1241 | impl<'a> AstNode<'a> for LifetimeParam<'a> { |
1447 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1242 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1453,33 +1248,28 @@ impl<'a> AstNode<'a> for LifetimeParam<'a> { | |||
1453 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1248 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1454 | } | 1249 | } |
1455 | 1250 | ||
1456 | impl<'a> LifetimeParam<'a> { | 1251 | impl<R: TreeRoot<RaTypes>> LifetimeParamNode<R> { |
1457 | pub fn lifetime(self) -> Option<Lifetime<'a>> { | 1252 | pub fn borrowed(&self) -> LifetimeParam { |
1458 | super::child_opt(self) | 1253 | LifetimeParamNode { syntax: self.syntax.borrowed() } |
1254 | } | ||
1255 | pub fn owned(&self) -> LifetimeParamNode { | ||
1256 | LifetimeParamNode { syntax: self.syntax.owned() } | ||
1459 | } | 1257 | } |
1460 | } | 1258 | } |
1461 | 1259 | ||
1462 | // Literal | ||
1463 | |||
1464 | #[derive(Debug, Clone)] | ||
1465 | pub struct LiteralNode(SyntaxNode); | ||
1466 | 1260 | ||
1467 | impl LiteralNode { | 1261 | impl<'a> LifetimeParam<'a> { |
1468 | pub fn ast(&self) -> Literal { | 1262 | pub fn lifetime(self) -> Option<Lifetime<'a>> { |
1469 | Literal::cast(self.0.borrowed()).unwrap() | 1263 | super::child_opt(self) |
1470 | } | 1264 | } |
1471 | } | 1265 | } |
1472 | 1266 | ||
1473 | impl<'a> From<Literal<'a>> for LiteralNode { | 1267 | // Literal |
1474 | fn from(ast: Literal<'a>) -> LiteralNode { | ||
1475 | let syntax = ast.syntax().owned(); | ||
1476 | LiteralNode(syntax) | ||
1477 | } | ||
1478 | } | ||
1479 | #[derive(Debug, Clone, Copy)] | 1268 | #[derive(Debug, Clone, Copy)] |
1480 | pub struct Literal<'a> { | 1269 | pub struct LiteralNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1481 | syntax: SyntaxNodeRef<'a>, | 1270 | syntax: SyntaxNode<R>, |
1482 | } | 1271 | } |
1272 | pub type Literal<'a> = LiteralNode<RefRoot<'a>>; | ||
1483 | 1273 | ||
1484 | impl<'a> AstNode<'a> for Literal<'a> { | 1274 | impl<'a> AstNode<'a> for Literal<'a> { |
1485 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1275 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1491,29 +1281,24 @@ impl<'a> AstNode<'a> for Literal<'a> { | |||
1491 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1281 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1492 | } | 1282 | } |
1493 | 1283 | ||
1494 | impl<'a> Literal<'a> {} | 1284 | impl<R: TreeRoot<RaTypes>> LiteralNode<R> { |
1495 | 1285 | pub fn borrowed(&self) -> Literal { | |
1496 | // LoopExpr | 1286 | 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 | } | 1287 | } |
1505 | } | 1288 | pub fn owned(&self) -> LiteralNode { |
1506 | 1289 | 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 | } | 1290 | } |
1512 | } | 1291 | } |
1292 | |||
1293 | |||
1294 | impl<'a> Literal<'a> {} | ||
1295 | |||
1296 | // LoopExpr | ||
1513 | #[derive(Debug, Clone, Copy)] | 1297 | #[derive(Debug, Clone, Copy)] |
1514 | pub struct LoopExpr<'a> { | 1298 | pub struct LoopExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1515 | syntax: SyntaxNodeRef<'a>, | 1299 | syntax: SyntaxNode<R>, |
1516 | } | 1300 | } |
1301 | pub type LoopExpr<'a> = LoopExprNode<RefRoot<'a>>; | ||
1517 | 1302 | ||
1518 | impl<'a> AstNode<'a> for LoopExpr<'a> { | 1303 | impl<'a> AstNode<'a> for LoopExpr<'a> { |
1519 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1304 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1525,30 +1310,25 @@ impl<'a> AstNode<'a> for LoopExpr<'a> { | |||
1525 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1310 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1526 | } | 1311 | } |
1527 | 1312 | ||
1313 | impl<R: TreeRoot<RaTypes>> LoopExprNode<R> { | ||
1314 | pub fn borrowed(&self) -> LoopExpr { | ||
1315 | LoopExprNode { syntax: self.syntax.borrowed() } | ||
1316 | } | ||
1317 | pub fn owned(&self) -> LoopExprNode { | ||
1318 | LoopExprNode { syntax: self.syntax.owned() } | ||
1319 | } | ||
1320 | } | ||
1321 | |||
1322 | |||
1528 | impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} | 1323 | impl<'a> ast::LoopBodyOwner<'a> for LoopExpr<'a> {} |
1529 | impl<'a> LoopExpr<'a> {} | 1324 | impl<'a> LoopExpr<'a> {} |
1530 | 1325 | ||
1531 | // MatchArm | 1326 | // 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)] | 1327 | #[derive(Debug, Clone, Copy)] |
1549 | pub struct MatchArm<'a> { | 1328 | pub struct MatchArmNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1550 | syntax: SyntaxNodeRef<'a>, | 1329 | syntax: SyntaxNode<R>, |
1551 | } | 1330 | } |
1331 | pub type MatchArm<'a> = MatchArmNode<RefRoot<'a>>; | ||
1552 | 1332 | ||
1553 | impl<'a> AstNode<'a> for MatchArm<'a> { | 1333 | impl<'a> AstNode<'a> for MatchArm<'a> { |
1554 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1334 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1560,6 +1340,16 @@ impl<'a> AstNode<'a> for MatchArm<'a> { | |||
1560 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1340 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1561 | } | 1341 | } |
1562 | 1342 | ||
1343 | impl<R: TreeRoot<RaTypes>> MatchArmNode<R> { | ||
1344 | pub fn borrowed(&self) -> MatchArm { | ||
1345 | MatchArmNode { syntax: self.syntax.borrowed() } | ||
1346 | } | ||
1347 | pub fn owned(&self) -> MatchArmNode { | ||
1348 | MatchArmNode { syntax: self.syntax.owned() } | ||
1349 | } | ||
1350 | } | ||
1351 | |||
1352 | |||
1563 | impl<'a> MatchArm<'a> { | 1353 | impl<'a> MatchArm<'a> { |
1564 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { | 1354 | pub fn pats(self) -> impl Iterator<Item = Pat<'a>> + 'a { |
1565 | super::children(self) | 1355 | super::children(self) |
@@ -1575,26 +1365,11 @@ impl<'a> MatchArm<'a> { | |||
1575 | } | 1365 | } |
1576 | 1366 | ||
1577 | // MatchArmList | 1367 | // 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)] | 1368 | #[derive(Debug, Clone, Copy)] |
1595 | pub struct MatchArmList<'a> { | 1369 | pub struct MatchArmListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1596 | syntax: SyntaxNodeRef<'a>, | 1370 | syntax: SyntaxNode<R>, |
1597 | } | 1371 | } |
1372 | pub type MatchArmList<'a> = MatchArmListNode<RefRoot<'a>>; | ||
1598 | 1373 | ||
1599 | impl<'a> AstNode<'a> for MatchArmList<'a> { | 1374 | impl<'a> AstNode<'a> for MatchArmList<'a> { |
1600 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1375 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1606,33 +1381,28 @@ impl<'a> AstNode<'a> for MatchArmList<'a> { | |||
1606 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1381 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1607 | } | 1382 | } |
1608 | 1383 | ||
1609 | impl<'a> MatchArmList<'a> { | 1384 | impl<R: TreeRoot<RaTypes>> MatchArmListNode<R> { |
1610 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { | 1385 | pub fn borrowed(&self) -> MatchArmList { |
1611 | super::children(self) | 1386 | MatchArmListNode { syntax: self.syntax.borrowed() } |
1387 | } | ||
1388 | pub fn owned(&self) -> MatchArmListNode { | ||
1389 | MatchArmListNode { syntax: self.syntax.owned() } | ||
1612 | } | 1390 | } |
1613 | } | 1391 | } |
1614 | 1392 | ||
1615 | // MatchExpr | ||
1616 | |||
1617 | #[derive(Debug, Clone)] | ||
1618 | pub struct MatchExprNode(SyntaxNode); | ||
1619 | 1393 | ||
1620 | impl MatchExprNode { | 1394 | impl<'a> MatchArmList<'a> { |
1621 | pub fn ast(&self) -> MatchExpr { | 1395 | pub fn arms(self) -> impl Iterator<Item = MatchArm<'a>> + 'a { |
1622 | MatchExpr::cast(self.0.borrowed()).unwrap() | 1396 | super::children(self) |
1623 | } | 1397 | } |
1624 | } | 1398 | } |
1625 | 1399 | ||
1626 | impl<'a> From<MatchExpr<'a>> for MatchExprNode { | 1400 | // MatchExpr |
1627 | fn from(ast: MatchExpr<'a>) -> MatchExprNode { | ||
1628 | let syntax = ast.syntax().owned(); | ||
1629 | MatchExprNode(syntax) | ||
1630 | } | ||
1631 | } | ||
1632 | #[derive(Debug, Clone, Copy)] | 1401 | #[derive(Debug, Clone, Copy)] |
1633 | pub struct MatchExpr<'a> { | 1402 | pub struct MatchExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1634 | syntax: SyntaxNodeRef<'a>, | 1403 | syntax: SyntaxNode<R>, |
1635 | } | 1404 | } |
1405 | pub type MatchExpr<'a> = MatchExprNode<RefRoot<'a>>; | ||
1636 | 1406 | ||
1637 | impl<'a> AstNode<'a> for MatchExpr<'a> { | 1407 | impl<'a> AstNode<'a> for MatchExpr<'a> { |
1638 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1408 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1644,6 +1414,16 @@ impl<'a> AstNode<'a> for MatchExpr<'a> { | |||
1644 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1414 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1645 | } | 1415 | } |
1646 | 1416 | ||
1417 | impl<R: TreeRoot<RaTypes>> MatchExprNode<R> { | ||
1418 | pub fn borrowed(&self) -> MatchExpr { | ||
1419 | MatchExprNode { syntax: self.syntax.borrowed() } | ||
1420 | } | ||
1421 | pub fn owned(&self) -> MatchExprNode { | ||
1422 | MatchExprNode { syntax: self.syntax.owned() } | ||
1423 | } | ||
1424 | } | ||
1425 | |||
1426 | |||
1647 | impl<'a> MatchExpr<'a> { | 1427 | impl<'a> MatchExpr<'a> { |
1648 | pub fn expr(self) -> Option<Expr<'a>> { | 1428 | pub fn expr(self) -> Option<Expr<'a>> { |
1649 | super::child_opt(self) | 1429 | super::child_opt(self) |
@@ -1655,26 +1435,11 @@ impl<'a> MatchExpr<'a> { | |||
1655 | } | 1435 | } |
1656 | 1436 | ||
1657 | // MatchGuard | 1437 | // 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)] | 1438 | #[derive(Debug, Clone, Copy)] |
1675 | pub struct MatchGuard<'a> { | 1439 | pub struct MatchGuardNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1676 | syntax: SyntaxNodeRef<'a>, | 1440 | syntax: SyntaxNode<R>, |
1677 | } | 1441 | } |
1442 | pub type MatchGuard<'a> = MatchGuardNode<RefRoot<'a>>; | ||
1678 | 1443 | ||
1679 | impl<'a> AstNode<'a> for MatchGuard<'a> { | 1444 | impl<'a> AstNode<'a> for MatchGuard<'a> { |
1680 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1445 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1686,29 +1451,24 @@ impl<'a> AstNode<'a> for MatchGuard<'a> { | |||
1686 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1451 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1687 | } | 1452 | } |
1688 | 1453 | ||
1689 | impl<'a> MatchGuard<'a> {} | 1454 | impl<R: TreeRoot<RaTypes>> MatchGuardNode<R> { |
1690 | 1455 | pub fn borrowed(&self) -> MatchGuard { | |
1691 | // MethodCallExpr | 1456 | 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 | } | 1457 | } |
1700 | } | 1458 | pub fn owned(&self) -> MatchGuardNode { |
1701 | 1459 | 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 | } | 1460 | } |
1707 | } | 1461 | } |
1462 | |||
1463 | |||
1464 | impl<'a> MatchGuard<'a> {} | ||
1465 | |||
1466 | // MethodCallExpr | ||
1708 | #[derive(Debug, Clone, Copy)] | 1467 | #[derive(Debug, Clone, Copy)] |
1709 | pub struct MethodCallExpr<'a> { | 1468 | pub struct MethodCallExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1710 | syntax: SyntaxNodeRef<'a>, | 1469 | syntax: SyntaxNode<R>, |
1711 | } | 1470 | } |
1471 | pub type MethodCallExpr<'a> = MethodCallExprNode<RefRoot<'a>>; | ||
1712 | 1472 | ||
1713 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { | 1473 | impl<'a> AstNode<'a> for MethodCallExpr<'a> { |
1714 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1474 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1720,6 +1480,16 @@ impl<'a> AstNode<'a> for MethodCallExpr<'a> { | |||
1720 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1480 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1721 | } | 1481 | } |
1722 | 1482 | ||
1483 | impl<R: TreeRoot<RaTypes>> MethodCallExprNode<R> { | ||
1484 | pub fn borrowed(&self) -> MethodCallExpr { | ||
1485 | MethodCallExprNode { syntax: self.syntax.borrowed() } | ||
1486 | } | ||
1487 | pub fn owned(&self) -> MethodCallExprNode { | ||
1488 | MethodCallExprNode { syntax: self.syntax.owned() } | ||
1489 | } | ||
1490 | } | ||
1491 | |||
1492 | |||
1723 | impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} | 1493 | impl<'a> ast::ArgListOwner<'a> for MethodCallExpr<'a> {} |
1724 | impl<'a> MethodCallExpr<'a> { | 1494 | impl<'a> MethodCallExpr<'a> { |
1725 | pub fn expr(self) -> Option<Expr<'a>> { | 1495 | pub fn expr(self) -> Option<Expr<'a>> { |
@@ -1728,26 +1498,11 @@ impl<'a> MethodCallExpr<'a> { | |||
1728 | } | 1498 | } |
1729 | 1499 | ||
1730 | // Module | 1500 | // 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)] | 1501 | #[derive(Debug, Clone, Copy)] |
1748 | pub struct Module<'a> { | 1502 | pub struct ModuleNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1749 | syntax: SyntaxNodeRef<'a>, | 1503 | syntax: SyntaxNode<R>, |
1750 | } | 1504 | } |
1505 | pub type Module<'a> = ModuleNode<RefRoot<'a>>; | ||
1751 | 1506 | ||
1752 | impl<'a> AstNode<'a> for Module<'a> { | 1507 | impl<'a> AstNode<'a> for Module<'a> { |
1753 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1508 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1759,6 +1514,16 @@ impl<'a> AstNode<'a> for Module<'a> { | |||
1759 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1514 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1760 | } | 1515 | } |
1761 | 1516 | ||
1517 | impl<R: TreeRoot<RaTypes>> ModuleNode<R> { | ||
1518 | pub fn borrowed(&self) -> Module { | ||
1519 | ModuleNode { syntax: self.syntax.borrowed() } | ||
1520 | } | ||
1521 | pub fn owned(&self) -> ModuleNode { | ||
1522 | ModuleNode { syntax: self.syntax.owned() } | ||
1523 | } | ||
1524 | } | ||
1525 | |||
1526 | |||
1762 | impl<'a> ast::NameOwner<'a> for Module<'a> {} | 1527 | impl<'a> ast::NameOwner<'a> for Module<'a> {} |
1763 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} | 1528 | impl<'a> ast::AttrsOwner<'a> for Module<'a> {} |
1764 | impl<'a> Module<'a> { | 1529 | impl<'a> Module<'a> { |
@@ -1768,22 +1533,6 @@ impl<'a> Module<'a> { | |||
1768 | } | 1533 | } |
1769 | 1534 | ||
1770 | // ModuleItem | 1535 | // 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)] | 1536 | #[derive(Debug, Clone, Copy)] |
1788 | pub enum ModuleItem<'a> { | 1537 | pub enum ModuleItem<'a> { |
1789 | StructDef(StructDef<'a>), | 1538 | StructDef(StructDef<'a>), |
@@ -1836,26 +1585,11 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
1836 | impl<'a> ModuleItem<'a> {} | 1585 | impl<'a> ModuleItem<'a> {} |
1837 | 1586 | ||
1838 | // Name | 1587 | // 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)] | 1588 | #[derive(Debug, Clone, Copy)] |
1856 | pub struct Name<'a> { | 1589 | pub struct NameNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1857 | syntax: SyntaxNodeRef<'a>, | 1590 | syntax: SyntaxNode<R>, |
1858 | } | 1591 | } |
1592 | pub type Name<'a> = NameNode<RefRoot<'a>>; | ||
1859 | 1593 | ||
1860 | impl<'a> AstNode<'a> for Name<'a> { | 1594 | impl<'a> AstNode<'a> for Name<'a> { |
1861 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1595 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1867,29 +1601,24 @@ impl<'a> AstNode<'a> for Name<'a> { | |||
1867 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1601 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1868 | } | 1602 | } |
1869 | 1603 | ||
1870 | impl<'a> Name<'a> {} | 1604 | impl<R: TreeRoot<RaTypes>> NameNode<R> { |
1871 | 1605 | pub fn borrowed(&self) -> Name { | |
1872 | // NameRef | 1606 | 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 | } | 1607 | } |
1881 | } | 1608 | pub fn owned(&self) -> NameNode { |
1882 | 1609 | 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 | } | 1610 | } |
1888 | } | 1611 | } |
1612 | |||
1613 | |||
1614 | impl<'a> Name<'a> {} | ||
1615 | |||
1616 | // NameRef | ||
1889 | #[derive(Debug, Clone, Copy)] | 1617 | #[derive(Debug, Clone, Copy)] |
1890 | pub struct NameRef<'a> { | 1618 | pub struct NameRefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1891 | syntax: SyntaxNodeRef<'a>, | 1619 | syntax: SyntaxNode<R>, |
1892 | } | 1620 | } |
1621 | pub type NameRef<'a> = NameRefNode<RefRoot<'a>>; | ||
1893 | 1622 | ||
1894 | impl<'a> AstNode<'a> for NameRef<'a> { | 1623 | impl<'a> AstNode<'a> for NameRef<'a> { |
1895 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1624 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1901,29 +1630,24 @@ impl<'a> AstNode<'a> for NameRef<'a> { | |||
1901 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1630 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1902 | } | 1631 | } |
1903 | 1632 | ||
1904 | impl<'a> NameRef<'a> {} | 1633 | impl<R: TreeRoot<RaTypes>> NameRefNode<R> { |
1905 | 1634 | pub fn borrowed(&self) -> NameRef { | |
1906 | // NamedField | 1635 | 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 | } | 1636 | } |
1915 | } | 1637 | pub fn owned(&self) -> NameRefNode { |
1916 | 1638 | 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 | } | 1639 | } |
1922 | } | 1640 | } |
1641 | |||
1642 | |||
1643 | impl<'a> NameRef<'a> {} | ||
1644 | |||
1645 | // NamedField | ||
1923 | #[derive(Debug, Clone, Copy)] | 1646 | #[derive(Debug, Clone, Copy)] |
1924 | pub struct NamedField<'a> { | 1647 | pub struct NamedFieldNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1925 | syntax: SyntaxNodeRef<'a>, | 1648 | syntax: SyntaxNode<R>, |
1926 | } | 1649 | } |
1650 | pub type NamedField<'a> = NamedFieldNode<RefRoot<'a>>; | ||
1927 | 1651 | ||
1928 | impl<'a> AstNode<'a> for NamedField<'a> { | 1652 | impl<'a> AstNode<'a> for NamedField<'a> { |
1929 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1653 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1935,29 +1659,24 @@ impl<'a> AstNode<'a> for NamedField<'a> { | |||
1935 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1659 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1936 | } | 1660 | } |
1937 | 1661 | ||
1938 | impl<'a> NamedField<'a> {} | 1662 | impl<R: TreeRoot<RaTypes>> NamedFieldNode<R> { |
1939 | 1663 | pub fn borrowed(&self) -> NamedField { | |
1940 | // NamedFieldDef | 1664 | 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 | } | 1665 | } |
1949 | } | 1666 | pub fn owned(&self) -> NamedFieldNode { |
1950 | 1667 | 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 | } | 1668 | } |
1956 | } | 1669 | } |
1670 | |||
1671 | |||
1672 | impl<'a> NamedField<'a> {} | ||
1673 | |||
1674 | // NamedFieldDef | ||
1957 | #[derive(Debug, Clone, Copy)] | 1675 | #[derive(Debug, Clone, Copy)] |
1958 | pub struct NamedFieldDef<'a> { | 1676 | pub struct NamedFieldDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1959 | syntax: SyntaxNodeRef<'a>, | 1677 | syntax: SyntaxNode<R>, |
1960 | } | 1678 | } |
1679 | pub type NamedFieldDef<'a> = NamedFieldDefNode<RefRoot<'a>>; | ||
1961 | 1680 | ||
1962 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { | 1681 | impl<'a> AstNode<'a> for NamedFieldDef<'a> { |
1963 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1682 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -1969,31 +1688,26 @@ impl<'a> AstNode<'a> for NamedFieldDef<'a> { | |||
1969 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1688 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1970 | } | 1689 | } |
1971 | 1690 | ||
1691 | impl<R: TreeRoot<RaTypes>> NamedFieldDefNode<R> { | ||
1692 | pub fn borrowed(&self) -> NamedFieldDef { | ||
1693 | NamedFieldDefNode { syntax: self.syntax.borrowed() } | ||
1694 | } | ||
1695 | pub fn owned(&self) -> NamedFieldDefNode { | ||
1696 | NamedFieldDefNode { syntax: self.syntax.owned() } | ||
1697 | } | ||
1698 | } | ||
1699 | |||
1700 | |||
1972 | impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} | 1701 | impl<'a> ast::NameOwner<'a> for NamedFieldDef<'a> {} |
1973 | impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} | 1702 | impl<'a> ast::AttrsOwner<'a> for NamedFieldDef<'a> {} |
1974 | impl<'a> NamedFieldDef<'a> {} | 1703 | impl<'a> NamedFieldDef<'a> {} |
1975 | 1704 | ||
1976 | // NamedFieldList | 1705 | // 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)] | 1706 | #[derive(Debug, Clone, Copy)] |
1994 | pub struct NamedFieldList<'a> { | 1707 | pub struct NamedFieldListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1995 | syntax: SyntaxNodeRef<'a>, | 1708 | syntax: SyntaxNode<R>, |
1996 | } | 1709 | } |
1710 | pub type NamedFieldList<'a> = NamedFieldListNode<RefRoot<'a>>; | ||
1997 | 1711 | ||
1998 | impl<'a> AstNode<'a> for NamedFieldList<'a> { | 1712 | impl<'a> AstNode<'a> for NamedFieldList<'a> { |
1999 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1713 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2005,29 +1719,24 @@ impl<'a> AstNode<'a> for NamedFieldList<'a> { | |||
2005 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1719 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2006 | } | 1720 | } |
2007 | 1721 | ||
2008 | impl<'a> NamedFieldList<'a> {} | 1722 | impl<R: TreeRoot<RaTypes>> NamedFieldListNode<R> { |
2009 | 1723 | pub fn borrowed(&self) -> NamedFieldList { | |
2010 | // NeverType | 1724 | 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 | } | 1725 | } |
2019 | } | 1726 | pub fn owned(&self) -> NamedFieldListNode { |
2020 | 1727 | 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 | } | 1728 | } |
2026 | } | 1729 | } |
1730 | |||
1731 | |||
1732 | impl<'a> NamedFieldList<'a> {} | ||
1733 | |||
1734 | // NeverType | ||
2027 | #[derive(Debug, Clone, Copy)] | 1735 | #[derive(Debug, Clone, Copy)] |
2028 | pub struct NeverType<'a> { | 1736 | pub struct NeverTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2029 | syntax: SyntaxNodeRef<'a>, | 1737 | syntax: SyntaxNode<R>, |
2030 | } | 1738 | } |
1739 | pub type NeverType<'a> = NeverTypeNode<RefRoot<'a>>; | ||
2031 | 1740 | ||
2032 | impl<'a> AstNode<'a> for NeverType<'a> { | 1741 | impl<'a> AstNode<'a> for NeverType<'a> { |
2033 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1742 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2039,25 +1748,19 @@ impl<'a> AstNode<'a> for NeverType<'a> { | |||
2039 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1748 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2040 | } | 1749 | } |
2041 | 1750 | ||
2042 | impl<'a> NeverType<'a> {} | 1751 | impl<R: TreeRoot<RaTypes>> NeverTypeNode<R> { |
2043 | 1752 | pub fn borrowed(&self) -> NeverType { | |
2044 | // NominalDef | 1753 | 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 | } | 1754 | } |
2053 | } | 1755 | pub fn owned(&self) -> NeverTypeNode { |
2054 | 1756 | 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 | } | 1757 | } |
2060 | } | 1758 | } |
1759 | |||
1760 | |||
1761 | impl<'a> NeverType<'a> {} | ||
1762 | |||
1763 | // NominalDef | ||
2061 | #[derive(Debug, Clone, Copy)] | 1764 | #[derive(Debug, Clone, Copy)] |
2062 | pub enum NominalDef<'a> { | 1765 | pub enum NominalDef<'a> { |
2063 | StructDef(StructDef<'a>), | 1766 | StructDef(StructDef<'a>), |
@@ -2086,26 +1789,11 @@ impl<'a> ast::AttrsOwner<'a> for NominalDef<'a> {} | |||
2086 | impl<'a> NominalDef<'a> {} | 1789 | impl<'a> NominalDef<'a> {} |
2087 | 1790 | ||
2088 | // Param | 1791 | // 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)] | 1792 | #[derive(Debug, Clone, Copy)] |
2106 | pub struct Param<'a> { | 1793 | pub struct ParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2107 | syntax: SyntaxNodeRef<'a>, | 1794 | syntax: SyntaxNode<R>, |
2108 | } | 1795 | } |
1796 | pub type Param<'a> = ParamNode<RefRoot<'a>>; | ||
2109 | 1797 | ||
2110 | impl<'a> AstNode<'a> for Param<'a> { | 1798 | impl<'a> AstNode<'a> for Param<'a> { |
2111 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1799 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2117,33 +1805,28 @@ impl<'a> AstNode<'a> for Param<'a> { | |||
2117 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1805 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2118 | } | 1806 | } |
2119 | 1807 | ||
2120 | impl<'a> Param<'a> { | 1808 | impl<R: TreeRoot<RaTypes>> ParamNode<R> { |
2121 | pub fn pat(self) -> Option<Pat<'a>> { | 1809 | pub fn borrowed(&self) -> Param { |
2122 | super::child_opt(self) | 1810 | ParamNode { syntax: self.syntax.borrowed() } |
1811 | } | ||
1812 | pub fn owned(&self) -> ParamNode { | ||
1813 | ParamNode { syntax: self.syntax.owned() } | ||
2123 | } | 1814 | } |
2124 | } | 1815 | } |
2125 | 1816 | ||
2126 | // ParamList | ||
2127 | |||
2128 | #[derive(Debug, Clone)] | ||
2129 | pub struct ParamListNode(SyntaxNode); | ||
2130 | 1817 | ||
2131 | impl ParamListNode { | 1818 | impl<'a> Param<'a> { |
2132 | pub fn ast(&self) -> ParamList { | 1819 | pub fn pat(self) -> Option<Pat<'a>> { |
2133 | ParamList::cast(self.0.borrowed()).unwrap() | 1820 | super::child_opt(self) |
2134 | } | 1821 | } |
2135 | } | 1822 | } |
2136 | 1823 | ||
2137 | impl<'a> From<ParamList<'a>> for ParamListNode { | 1824 | // ParamList |
2138 | fn from(ast: ParamList<'a>) -> ParamListNode { | ||
2139 | let syntax = ast.syntax().owned(); | ||
2140 | ParamListNode(syntax) | ||
2141 | } | ||
2142 | } | ||
2143 | #[derive(Debug, Clone, Copy)] | 1825 | #[derive(Debug, Clone, Copy)] |
2144 | pub struct ParamList<'a> { | 1826 | pub struct ParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2145 | syntax: SyntaxNodeRef<'a>, | 1827 | syntax: SyntaxNode<R>, |
2146 | } | 1828 | } |
1829 | pub type ParamList<'a> = ParamListNode<RefRoot<'a>>; | ||
2147 | 1830 | ||
2148 | impl<'a> AstNode<'a> for ParamList<'a> { | 1831 | impl<'a> AstNode<'a> for ParamList<'a> { |
2149 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1832 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2155,6 +1838,16 @@ impl<'a> AstNode<'a> for ParamList<'a> { | |||
2155 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1838 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2156 | } | 1839 | } |
2157 | 1840 | ||
1841 | impl<R: TreeRoot<RaTypes>> ParamListNode<R> { | ||
1842 | pub fn borrowed(&self) -> ParamList { | ||
1843 | ParamListNode { syntax: self.syntax.borrowed() } | ||
1844 | } | ||
1845 | pub fn owned(&self) -> ParamListNode { | ||
1846 | ParamListNode { syntax: self.syntax.owned() } | ||
1847 | } | ||
1848 | } | ||
1849 | |||
1850 | |||
2158 | impl<'a> ParamList<'a> { | 1851 | impl<'a> ParamList<'a> { |
2159 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { | 1852 | pub fn params(self) -> impl Iterator<Item = Param<'a>> + 'a { |
2160 | super::children(self) | 1853 | super::children(self) |
@@ -2166,26 +1859,11 @@ impl<'a> ParamList<'a> { | |||
2166 | } | 1859 | } |
2167 | 1860 | ||
2168 | // ParenExpr | 1861 | // 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)] | 1862 | #[derive(Debug, Clone, Copy)] |
2186 | pub struct ParenExpr<'a> { | 1863 | pub struct ParenExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2187 | syntax: SyntaxNodeRef<'a>, | 1864 | syntax: SyntaxNode<R>, |
2188 | } | 1865 | } |
1866 | pub type ParenExpr<'a> = ParenExprNode<RefRoot<'a>>; | ||
2189 | 1867 | ||
2190 | impl<'a> AstNode<'a> for ParenExpr<'a> { | 1868 | impl<'a> AstNode<'a> for ParenExpr<'a> { |
2191 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1869 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2197,29 +1875,24 @@ impl<'a> AstNode<'a> for ParenExpr<'a> { | |||
2197 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1875 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2198 | } | 1876 | } |
2199 | 1877 | ||
2200 | impl<'a> ParenExpr<'a> {} | 1878 | impl<R: TreeRoot<RaTypes>> ParenExprNode<R> { |
2201 | 1879 | pub fn borrowed(&self) -> ParenExpr { | |
2202 | // ParenType | 1880 | 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 | } | 1881 | } |
2211 | } | 1882 | pub fn owned(&self) -> ParenExprNode { |
2212 | 1883 | 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 | } | 1884 | } |
2218 | } | 1885 | } |
1886 | |||
1887 | |||
1888 | impl<'a> ParenExpr<'a> {} | ||
1889 | |||
1890 | // ParenType | ||
2219 | #[derive(Debug, Clone, Copy)] | 1891 | #[derive(Debug, Clone, Copy)] |
2220 | pub struct ParenType<'a> { | 1892 | pub struct ParenTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2221 | syntax: SyntaxNodeRef<'a>, | 1893 | syntax: SyntaxNode<R>, |
2222 | } | 1894 | } |
1895 | pub type ParenType<'a> = ParenTypeNode<RefRoot<'a>>; | ||
2223 | 1896 | ||
2224 | impl<'a> AstNode<'a> for ParenType<'a> { | 1897 | impl<'a> AstNode<'a> for ParenType<'a> { |
2225 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1898 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2231,25 +1904,19 @@ impl<'a> AstNode<'a> for ParenType<'a> { | |||
2231 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1904 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2232 | } | 1905 | } |
2233 | 1906 | ||
2234 | impl<'a> ParenType<'a> {} | 1907 | impl<R: TreeRoot<RaTypes>> ParenTypeNode<R> { |
2235 | 1908 | pub fn borrowed(&self) -> ParenType { | |
2236 | // Pat | 1909 | 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 | } | 1910 | } |
2245 | } | 1911 | pub fn owned(&self) -> ParenTypeNode { |
2246 | 1912 | 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 | } | 1913 | } |
2252 | } | 1914 | } |
1915 | |||
1916 | |||
1917 | impl<'a> ParenType<'a> {} | ||
1918 | |||
1919 | // Pat | ||
2253 | #[derive(Debug, Clone, Copy)] | 1920 | #[derive(Debug, Clone, Copy)] |
2254 | pub enum Pat<'a> { | 1921 | pub enum Pat<'a> { |
2255 | RefPat(RefPat<'a>), | 1922 | RefPat(RefPat<'a>), |
@@ -2299,26 +1966,11 @@ impl<'a> AstNode<'a> for Pat<'a> { | |||
2299 | impl<'a> Pat<'a> {} | 1966 | impl<'a> Pat<'a> {} |
2300 | 1967 | ||
2301 | // Path | 1968 | // 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)] | 1969 | #[derive(Debug, Clone, Copy)] |
2319 | pub struct Path<'a> { | 1970 | pub struct PathNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2320 | syntax: SyntaxNodeRef<'a>, | 1971 | syntax: SyntaxNode<R>, |
2321 | } | 1972 | } |
1973 | pub type Path<'a> = PathNode<RefRoot<'a>>; | ||
2322 | 1974 | ||
2323 | impl<'a> AstNode<'a> for Path<'a> { | 1975 | impl<'a> AstNode<'a> for Path<'a> { |
2324 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1976 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2330,6 +1982,16 @@ impl<'a> AstNode<'a> for Path<'a> { | |||
2330 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1982 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2331 | } | 1983 | } |
2332 | 1984 | ||
1985 | impl<R: TreeRoot<RaTypes>> PathNode<R> { | ||
1986 | pub fn borrowed(&self) -> Path { | ||
1987 | PathNode { syntax: self.syntax.borrowed() } | ||
1988 | } | ||
1989 | pub fn owned(&self) -> PathNode { | ||
1990 | PathNode { syntax: self.syntax.owned() } | ||
1991 | } | ||
1992 | } | ||
1993 | |||
1994 | |||
2333 | impl<'a> Path<'a> { | 1995 | impl<'a> Path<'a> { |
2334 | pub fn segment(self) -> Option<PathSegment<'a>> { | 1996 | pub fn segment(self) -> Option<PathSegment<'a>> { |
2335 | super::child_opt(self) | 1997 | super::child_opt(self) |
@@ -2341,26 +2003,11 @@ impl<'a> Path<'a> { | |||
2341 | } | 2003 | } |
2342 | 2004 | ||
2343 | // PathExpr | 2005 | // 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)] | 2006 | #[derive(Debug, Clone, Copy)] |
2361 | pub struct PathExpr<'a> { | 2007 | pub struct PathExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2362 | syntax: SyntaxNodeRef<'a>, | 2008 | syntax: SyntaxNode<R>, |
2363 | } | 2009 | } |
2010 | pub type PathExpr<'a> = PathExprNode<RefRoot<'a>>; | ||
2364 | 2011 | ||
2365 | impl<'a> AstNode<'a> for PathExpr<'a> { | 2012 | impl<'a> AstNode<'a> for PathExpr<'a> { |
2366 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2013 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2372,33 +2019,28 @@ impl<'a> AstNode<'a> for PathExpr<'a> { | |||
2372 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2019 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2373 | } | 2020 | } |
2374 | 2021 | ||
2375 | impl<'a> PathExpr<'a> { | 2022 | impl<R: TreeRoot<RaTypes>> PathExprNode<R> { |
2376 | pub fn path(self) -> Option<Path<'a>> { | 2023 | pub fn borrowed(&self) -> PathExpr { |
2377 | super::child_opt(self) | 2024 | PathExprNode { syntax: self.syntax.borrowed() } |
2025 | } | ||
2026 | pub fn owned(&self) -> PathExprNode { | ||
2027 | PathExprNode { syntax: self.syntax.owned() } | ||
2378 | } | 2028 | } |
2379 | } | 2029 | } |
2380 | 2030 | ||
2381 | // PathPat | ||
2382 | |||
2383 | #[derive(Debug, Clone)] | ||
2384 | pub struct PathPatNode(SyntaxNode); | ||
2385 | 2031 | ||
2386 | impl PathPatNode { | 2032 | impl<'a> PathExpr<'a> { |
2387 | pub fn ast(&self) -> PathPat { | 2033 | pub fn path(self) -> Option<Path<'a>> { |
2388 | PathPat::cast(self.0.borrowed()).unwrap() | 2034 | super::child_opt(self) |
2389 | } | 2035 | } |
2390 | } | 2036 | } |
2391 | 2037 | ||
2392 | impl<'a> From<PathPat<'a>> for PathPatNode { | 2038 | // PathPat |
2393 | fn from(ast: PathPat<'a>) -> PathPatNode { | ||
2394 | let syntax = ast.syntax().owned(); | ||
2395 | PathPatNode(syntax) | ||
2396 | } | ||
2397 | } | ||
2398 | #[derive(Debug, Clone, Copy)] | 2039 | #[derive(Debug, Clone, Copy)] |
2399 | pub struct PathPat<'a> { | 2040 | pub struct PathPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2400 | syntax: SyntaxNodeRef<'a>, | 2041 | syntax: SyntaxNode<R>, |
2401 | } | 2042 | } |
2043 | pub type PathPat<'a> = PathPatNode<RefRoot<'a>>; | ||
2402 | 2044 | ||
2403 | impl<'a> AstNode<'a> for PathPat<'a> { | 2045 | impl<'a> AstNode<'a> for PathPat<'a> { |
2404 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2046 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2410,29 +2052,24 @@ impl<'a> AstNode<'a> for PathPat<'a> { | |||
2410 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2052 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2411 | } | 2053 | } |
2412 | 2054 | ||
2413 | impl<'a> PathPat<'a> {} | 2055 | impl<R: TreeRoot<RaTypes>> PathPatNode<R> { |
2414 | 2056 | pub fn borrowed(&self) -> PathPat { | |
2415 | // PathSegment | 2057 | 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 | } | 2058 | } |
2424 | } | 2059 | pub fn owned(&self) -> PathPatNode { |
2425 | 2060 | 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 | } | 2061 | } |
2431 | } | 2062 | } |
2063 | |||
2064 | |||
2065 | impl<'a> PathPat<'a> {} | ||
2066 | |||
2067 | // PathSegment | ||
2432 | #[derive(Debug, Clone, Copy)] | 2068 | #[derive(Debug, Clone, Copy)] |
2433 | pub struct PathSegment<'a> { | 2069 | pub struct PathSegmentNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2434 | syntax: SyntaxNodeRef<'a>, | 2070 | syntax: SyntaxNode<R>, |
2435 | } | 2071 | } |
2072 | pub type PathSegment<'a> = PathSegmentNode<RefRoot<'a>>; | ||
2436 | 2073 | ||
2437 | impl<'a> AstNode<'a> for PathSegment<'a> { | 2074 | impl<'a> AstNode<'a> for PathSegment<'a> { |
2438 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2075 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2444,33 +2081,28 @@ impl<'a> AstNode<'a> for PathSegment<'a> { | |||
2444 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2081 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2445 | } | 2082 | } |
2446 | 2083 | ||
2447 | impl<'a> PathSegment<'a> { | 2084 | impl<R: TreeRoot<RaTypes>> PathSegmentNode<R> { |
2448 | pub fn name_ref(self) -> Option<NameRef<'a>> { | 2085 | pub fn borrowed(&self) -> PathSegment { |
2449 | super::child_opt(self) | 2086 | PathSegmentNode { syntax: self.syntax.borrowed() } |
2087 | } | ||
2088 | pub fn owned(&self) -> PathSegmentNode { | ||
2089 | PathSegmentNode { syntax: self.syntax.owned() } | ||
2450 | } | 2090 | } |
2451 | } | 2091 | } |
2452 | 2092 | ||
2453 | // PathType | ||
2454 | |||
2455 | #[derive(Debug, Clone)] | ||
2456 | pub struct PathTypeNode(SyntaxNode); | ||
2457 | 2093 | ||
2458 | impl PathTypeNode { | 2094 | impl<'a> PathSegment<'a> { |
2459 | pub fn ast(&self) -> PathType { | 2095 | pub fn name_ref(self) -> Option<NameRef<'a>> { |
2460 | PathType::cast(self.0.borrowed()).unwrap() | 2096 | super::child_opt(self) |
2461 | } | 2097 | } |
2462 | } | 2098 | } |
2463 | 2099 | ||
2464 | impl<'a> From<PathType<'a>> for PathTypeNode { | 2100 | // PathType |
2465 | fn from(ast: PathType<'a>) -> PathTypeNode { | ||
2466 | let syntax = ast.syntax().owned(); | ||
2467 | PathTypeNode(syntax) | ||
2468 | } | ||
2469 | } | ||
2470 | #[derive(Debug, Clone, Copy)] | 2101 | #[derive(Debug, Clone, Copy)] |
2471 | pub struct PathType<'a> { | 2102 | pub struct PathTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2472 | syntax: SyntaxNodeRef<'a>, | 2103 | syntax: SyntaxNode<R>, |
2473 | } | 2104 | } |
2105 | pub type PathType<'a> = PathTypeNode<RefRoot<'a>>; | ||
2474 | 2106 | ||
2475 | impl<'a> AstNode<'a> for PathType<'a> { | 2107 | impl<'a> AstNode<'a> for PathType<'a> { |
2476 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2108 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2482,29 +2114,24 @@ impl<'a> AstNode<'a> for PathType<'a> { | |||
2482 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2114 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2483 | } | 2115 | } |
2484 | 2116 | ||
2485 | impl<'a> PathType<'a> {} | 2117 | impl<R: TreeRoot<RaTypes>> PathTypeNode<R> { |
2486 | 2118 | pub fn borrowed(&self) -> PathType { | |
2487 | // PlaceholderPat | 2119 | 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 | } | 2120 | } |
2496 | } | 2121 | pub fn owned(&self) -> PathTypeNode { |
2497 | 2122 | 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 | } | 2123 | } |
2503 | } | 2124 | } |
2125 | |||
2126 | |||
2127 | impl<'a> PathType<'a> {} | ||
2128 | |||
2129 | // PlaceholderPat | ||
2504 | #[derive(Debug, Clone, Copy)] | 2130 | #[derive(Debug, Clone, Copy)] |
2505 | pub struct PlaceholderPat<'a> { | 2131 | pub struct PlaceholderPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2506 | syntax: SyntaxNodeRef<'a>, | 2132 | syntax: SyntaxNode<R>, |
2507 | } | 2133 | } |
2134 | pub type PlaceholderPat<'a> = PlaceholderPatNode<RefRoot<'a>>; | ||
2508 | 2135 | ||
2509 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { | 2136 | impl<'a> AstNode<'a> for PlaceholderPat<'a> { |
2510 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2137 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2516,29 +2143,24 @@ impl<'a> AstNode<'a> for PlaceholderPat<'a> { | |||
2516 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2143 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2517 | } | 2144 | } |
2518 | 2145 | ||
2519 | impl<'a> PlaceholderPat<'a> {} | 2146 | impl<R: TreeRoot<RaTypes>> PlaceholderPatNode<R> { |
2520 | 2147 | pub fn borrowed(&self) -> PlaceholderPat { | |
2521 | // PlaceholderType | 2148 | 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 | } | 2149 | } |
2530 | } | 2150 | pub fn owned(&self) -> PlaceholderPatNode { |
2531 | 2151 | 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 | } | 2152 | } |
2537 | } | 2153 | } |
2154 | |||
2155 | |||
2156 | impl<'a> PlaceholderPat<'a> {} | ||
2157 | |||
2158 | // PlaceholderType | ||
2538 | #[derive(Debug, Clone, Copy)] | 2159 | #[derive(Debug, Clone, Copy)] |
2539 | pub struct PlaceholderType<'a> { | 2160 | pub struct PlaceholderTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2540 | syntax: SyntaxNodeRef<'a>, | 2161 | syntax: SyntaxNode<R>, |
2541 | } | 2162 | } |
2163 | pub type PlaceholderType<'a> = PlaceholderTypeNode<RefRoot<'a>>; | ||
2542 | 2164 | ||
2543 | impl<'a> AstNode<'a> for PlaceholderType<'a> { | 2165 | impl<'a> AstNode<'a> for PlaceholderType<'a> { |
2544 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2166 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2550,29 +2172,24 @@ impl<'a> AstNode<'a> for PlaceholderType<'a> { | |||
2550 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2172 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2551 | } | 2173 | } |
2552 | 2174 | ||
2553 | impl<'a> PlaceholderType<'a> {} | 2175 | impl<R: TreeRoot<RaTypes>> PlaceholderTypeNode<R> { |
2554 | 2176 | pub fn borrowed(&self) -> PlaceholderType { | |
2555 | // PointerType | 2177 | 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 | } | 2178 | } |
2564 | } | 2179 | pub fn owned(&self) -> PlaceholderTypeNode { |
2565 | 2180 | 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 | } | 2181 | } |
2571 | } | 2182 | } |
2183 | |||
2184 | |||
2185 | impl<'a> PlaceholderType<'a> {} | ||
2186 | |||
2187 | // PointerType | ||
2572 | #[derive(Debug, Clone, Copy)] | 2188 | #[derive(Debug, Clone, Copy)] |
2573 | pub struct PointerType<'a> { | 2189 | pub struct PointerTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2574 | syntax: SyntaxNodeRef<'a>, | 2190 | syntax: SyntaxNode<R>, |
2575 | } | 2191 | } |
2192 | pub type PointerType<'a> = PointerTypeNode<RefRoot<'a>>; | ||
2576 | 2193 | ||
2577 | impl<'a> AstNode<'a> for PointerType<'a> { | 2194 | impl<'a> AstNode<'a> for PointerType<'a> { |
2578 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2195 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2584,29 +2201,24 @@ impl<'a> AstNode<'a> for PointerType<'a> { | |||
2584 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2201 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2585 | } | 2202 | } |
2586 | 2203 | ||
2587 | impl<'a> PointerType<'a> {} | 2204 | impl<R: TreeRoot<RaTypes>> PointerTypeNode<R> { |
2588 | 2205 | pub fn borrowed(&self) -> PointerType { | |
2589 | // PrefixExpr | 2206 | 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 | } | 2207 | } |
2598 | } | 2208 | pub fn owned(&self) -> PointerTypeNode { |
2599 | 2209 | 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 | } | 2210 | } |
2605 | } | 2211 | } |
2212 | |||
2213 | |||
2214 | impl<'a> PointerType<'a> {} | ||
2215 | |||
2216 | // PrefixExpr | ||
2606 | #[derive(Debug, Clone, Copy)] | 2217 | #[derive(Debug, Clone, Copy)] |
2607 | pub struct PrefixExpr<'a> { | 2218 | pub struct PrefixExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2608 | syntax: SyntaxNodeRef<'a>, | 2219 | syntax: SyntaxNode<R>, |
2609 | } | 2220 | } |
2221 | pub type PrefixExpr<'a> = PrefixExprNode<RefRoot<'a>>; | ||
2610 | 2222 | ||
2611 | impl<'a> AstNode<'a> for PrefixExpr<'a> { | 2223 | impl<'a> AstNode<'a> for PrefixExpr<'a> { |
2612 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2224 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2618,29 +2230,24 @@ impl<'a> AstNode<'a> for PrefixExpr<'a> { | |||
2618 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2230 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2619 | } | 2231 | } |
2620 | 2232 | ||
2621 | impl<'a> PrefixExpr<'a> {} | 2233 | impl<R: TreeRoot<RaTypes>> PrefixExprNode<R> { |
2622 | 2234 | pub fn borrowed(&self) -> PrefixExpr { | |
2623 | // RangeExpr | 2235 | 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 | } | 2236 | } |
2632 | } | 2237 | pub fn owned(&self) -> PrefixExprNode { |
2633 | 2238 | 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 | } | 2239 | } |
2639 | } | 2240 | } |
2241 | |||
2242 | |||
2243 | impl<'a> PrefixExpr<'a> {} | ||
2244 | |||
2245 | // RangeExpr | ||
2640 | #[derive(Debug, Clone, Copy)] | 2246 | #[derive(Debug, Clone, Copy)] |
2641 | pub struct RangeExpr<'a> { | 2247 | pub struct RangeExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2642 | syntax: SyntaxNodeRef<'a>, | 2248 | syntax: SyntaxNode<R>, |
2643 | } | 2249 | } |
2250 | pub type RangeExpr<'a> = RangeExprNode<RefRoot<'a>>; | ||
2644 | 2251 | ||
2645 | impl<'a> AstNode<'a> for RangeExpr<'a> { | 2252 | impl<'a> AstNode<'a> for RangeExpr<'a> { |
2646 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2253 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2652,29 +2259,24 @@ impl<'a> AstNode<'a> for RangeExpr<'a> { | |||
2652 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2259 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2653 | } | 2260 | } |
2654 | 2261 | ||
2655 | impl<'a> RangeExpr<'a> {} | 2262 | impl<R: TreeRoot<RaTypes>> RangeExprNode<R> { |
2656 | 2263 | pub fn borrowed(&self) -> RangeExpr { | |
2657 | // RangePat | 2264 | 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 | } | 2265 | } |
2666 | } | 2266 | pub fn owned(&self) -> RangeExprNode { |
2667 | 2267 | 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 | } | 2268 | } |
2673 | } | 2269 | } |
2270 | |||
2271 | |||
2272 | impl<'a> RangeExpr<'a> {} | ||
2273 | |||
2274 | // RangePat | ||
2674 | #[derive(Debug, Clone, Copy)] | 2275 | #[derive(Debug, Clone, Copy)] |
2675 | pub struct RangePat<'a> { | 2276 | pub struct RangePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2676 | syntax: SyntaxNodeRef<'a>, | 2277 | syntax: SyntaxNode<R>, |
2677 | } | 2278 | } |
2279 | pub type RangePat<'a> = RangePatNode<RefRoot<'a>>; | ||
2678 | 2280 | ||
2679 | impl<'a> AstNode<'a> for RangePat<'a> { | 2281 | impl<'a> AstNode<'a> for RangePat<'a> { |
2680 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2282 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2686,29 +2288,24 @@ impl<'a> AstNode<'a> for RangePat<'a> { | |||
2686 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2288 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2687 | } | 2289 | } |
2688 | 2290 | ||
2689 | impl<'a> RangePat<'a> {} | 2291 | impl<R: TreeRoot<RaTypes>> RangePatNode<R> { |
2690 | 2292 | pub fn borrowed(&self) -> RangePat { | |
2691 | // RefExpr | 2293 | 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 | } | 2294 | } |
2700 | } | 2295 | pub fn owned(&self) -> RangePatNode { |
2701 | 2296 | 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 | } | 2297 | } |
2707 | } | 2298 | } |
2299 | |||
2300 | |||
2301 | impl<'a> RangePat<'a> {} | ||
2302 | |||
2303 | // RefExpr | ||
2708 | #[derive(Debug, Clone, Copy)] | 2304 | #[derive(Debug, Clone, Copy)] |
2709 | pub struct RefExpr<'a> { | 2305 | pub struct RefExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2710 | syntax: SyntaxNodeRef<'a>, | 2306 | syntax: SyntaxNode<R>, |
2711 | } | 2307 | } |
2308 | pub type RefExpr<'a> = RefExprNode<RefRoot<'a>>; | ||
2712 | 2309 | ||
2713 | impl<'a> AstNode<'a> for RefExpr<'a> { | 2310 | impl<'a> AstNode<'a> for RefExpr<'a> { |
2714 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2311 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2720,29 +2317,24 @@ impl<'a> AstNode<'a> for RefExpr<'a> { | |||
2720 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2317 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2721 | } | 2318 | } |
2722 | 2319 | ||
2723 | impl<'a> RefExpr<'a> {} | 2320 | impl<R: TreeRoot<RaTypes>> RefExprNode<R> { |
2724 | 2321 | pub fn borrowed(&self) -> RefExpr { | |
2725 | // RefPat | 2322 | 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 | } | 2323 | } |
2734 | } | 2324 | pub fn owned(&self) -> RefExprNode { |
2735 | 2325 | 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 | } | 2326 | } |
2741 | } | 2327 | } |
2328 | |||
2329 | |||
2330 | impl<'a> RefExpr<'a> {} | ||
2331 | |||
2332 | // RefPat | ||
2742 | #[derive(Debug, Clone, Copy)] | 2333 | #[derive(Debug, Clone, Copy)] |
2743 | pub struct RefPat<'a> { | 2334 | pub struct RefPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2744 | syntax: SyntaxNodeRef<'a>, | 2335 | syntax: SyntaxNode<R>, |
2745 | } | 2336 | } |
2337 | pub type RefPat<'a> = RefPatNode<RefRoot<'a>>; | ||
2746 | 2338 | ||
2747 | impl<'a> AstNode<'a> for RefPat<'a> { | 2339 | impl<'a> AstNode<'a> for RefPat<'a> { |
2748 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2340 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2754,29 +2346,24 @@ impl<'a> AstNode<'a> for RefPat<'a> { | |||
2754 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2346 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2755 | } | 2347 | } |
2756 | 2348 | ||
2757 | impl<'a> RefPat<'a> {} | 2349 | impl<R: TreeRoot<RaTypes>> RefPatNode<R> { |
2758 | 2350 | pub fn borrowed(&self) -> RefPat { | |
2759 | // ReferenceType | 2351 | 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 | } | 2352 | } |
2768 | } | 2353 | pub fn owned(&self) -> RefPatNode { |
2769 | 2354 | 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 | } | 2355 | } |
2775 | } | 2356 | } |
2357 | |||
2358 | |||
2359 | impl<'a> RefPat<'a> {} | ||
2360 | |||
2361 | // ReferenceType | ||
2776 | #[derive(Debug, Clone, Copy)] | 2362 | #[derive(Debug, Clone, Copy)] |
2777 | pub struct ReferenceType<'a> { | 2363 | pub struct ReferenceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2778 | syntax: SyntaxNodeRef<'a>, | 2364 | syntax: SyntaxNode<R>, |
2779 | } | 2365 | } |
2366 | pub type ReferenceType<'a> = ReferenceTypeNode<RefRoot<'a>>; | ||
2780 | 2367 | ||
2781 | impl<'a> AstNode<'a> for ReferenceType<'a> { | 2368 | impl<'a> AstNode<'a> for ReferenceType<'a> { |
2782 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2369 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2788,29 +2375,24 @@ impl<'a> AstNode<'a> for ReferenceType<'a> { | |||
2788 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2375 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2789 | } | 2376 | } |
2790 | 2377 | ||
2791 | impl<'a> ReferenceType<'a> {} | 2378 | impl<R: TreeRoot<RaTypes>> ReferenceTypeNode<R> { |
2792 | 2379 | pub fn borrowed(&self) -> ReferenceType { | |
2793 | // RetType | 2380 | 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 | } | 2381 | } |
2802 | } | 2382 | pub fn owned(&self) -> ReferenceTypeNode { |
2803 | 2383 | 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 | } | 2384 | } |
2809 | } | 2385 | } |
2386 | |||
2387 | |||
2388 | impl<'a> ReferenceType<'a> {} | ||
2389 | |||
2390 | // RetType | ||
2810 | #[derive(Debug, Clone, Copy)] | 2391 | #[derive(Debug, Clone, Copy)] |
2811 | pub struct RetType<'a> { | 2392 | pub struct RetTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2812 | syntax: SyntaxNodeRef<'a>, | 2393 | syntax: SyntaxNode<R>, |
2813 | } | 2394 | } |
2395 | pub type RetType<'a> = RetTypeNode<RefRoot<'a>>; | ||
2814 | 2396 | ||
2815 | impl<'a> AstNode<'a> for RetType<'a> { | 2397 | impl<'a> AstNode<'a> for RetType<'a> { |
2816 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2398 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2822,29 +2404,24 @@ impl<'a> AstNode<'a> for RetType<'a> { | |||
2822 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2404 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2823 | } | 2405 | } |
2824 | 2406 | ||
2825 | impl<'a> RetType<'a> {} | 2407 | impl<R: TreeRoot<RaTypes>> RetTypeNode<R> { |
2826 | 2408 | pub fn borrowed(&self) -> RetType { | |
2827 | // ReturnExpr | 2409 | 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 | } | 2410 | } |
2836 | } | 2411 | pub fn owned(&self) -> RetTypeNode { |
2837 | 2412 | 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 | } | 2413 | } |
2843 | } | 2414 | } |
2415 | |||
2416 | |||
2417 | impl<'a> RetType<'a> {} | ||
2418 | |||
2419 | // ReturnExpr | ||
2844 | #[derive(Debug, Clone, Copy)] | 2420 | #[derive(Debug, Clone, Copy)] |
2845 | pub struct ReturnExpr<'a> { | 2421 | pub struct ReturnExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2846 | syntax: SyntaxNodeRef<'a>, | 2422 | syntax: SyntaxNode<R>, |
2847 | } | 2423 | } |
2424 | pub type ReturnExpr<'a> = ReturnExprNode<RefRoot<'a>>; | ||
2848 | 2425 | ||
2849 | impl<'a> AstNode<'a> for ReturnExpr<'a> { | 2426 | impl<'a> AstNode<'a> for ReturnExpr<'a> { |
2850 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2427 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2856,29 +2433,24 @@ impl<'a> AstNode<'a> for ReturnExpr<'a> { | |||
2856 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2433 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2857 | } | 2434 | } |
2858 | 2435 | ||
2859 | impl<'a> ReturnExpr<'a> {} | 2436 | impl<R: TreeRoot<RaTypes>> ReturnExprNode<R> { |
2860 | 2437 | pub fn borrowed(&self) -> ReturnExpr { | |
2861 | // Root | 2438 | 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 | } | 2439 | } |
2870 | } | 2440 | pub fn owned(&self) -> ReturnExprNode { |
2871 | 2441 | 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 | } | 2442 | } |
2877 | } | 2443 | } |
2444 | |||
2445 | |||
2446 | impl<'a> ReturnExpr<'a> {} | ||
2447 | |||
2448 | // Root | ||
2878 | #[derive(Debug, Clone, Copy)] | 2449 | #[derive(Debug, Clone, Copy)] |
2879 | pub struct Root<'a> { | 2450 | pub struct RootNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2880 | syntax: SyntaxNodeRef<'a>, | 2451 | syntax: SyntaxNode<R>, |
2881 | } | 2452 | } |
2453 | pub type Root<'a> = RootNode<RefRoot<'a>>; | ||
2882 | 2454 | ||
2883 | impl<'a> AstNode<'a> for Root<'a> { | 2455 | impl<'a> AstNode<'a> for Root<'a> { |
2884 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2456 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2890,6 +2462,16 @@ impl<'a> AstNode<'a> for Root<'a> { | |||
2890 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2462 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2891 | } | 2463 | } |
2892 | 2464 | ||
2465 | impl<R: TreeRoot<RaTypes>> RootNode<R> { | ||
2466 | pub fn borrowed(&self) -> Root { | ||
2467 | RootNode { syntax: self.syntax.borrowed() } | ||
2468 | } | ||
2469 | pub fn owned(&self) -> RootNode { | ||
2470 | RootNode { syntax: self.syntax.owned() } | ||
2471 | } | ||
2472 | } | ||
2473 | |||
2474 | |||
2893 | impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} | 2475 | impl<'a> ast::ModuleItemOwner<'a> for Root<'a> {} |
2894 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} | 2476 | impl<'a> ast::FnDefOwner<'a> for Root<'a> {} |
2895 | impl<'a> Root<'a> { | 2477 | impl<'a> Root<'a> { |
@@ -2899,26 +2481,11 @@ impl<'a> Root<'a> { | |||
2899 | } | 2481 | } |
2900 | 2482 | ||
2901 | // SelfParam | 2483 | // 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)] | 2484 | #[derive(Debug, Clone, Copy)] |
2919 | pub struct SelfParam<'a> { | 2485 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2920 | syntax: SyntaxNodeRef<'a>, | 2486 | syntax: SyntaxNode<R>, |
2921 | } | 2487 | } |
2488 | pub type SelfParam<'a> = SelfParamNode<RefRoot<'a>>; | ||
2922 | 2489 | ||
2923 | impl<'a> AstNode<'a> for SelfParam<'a> { | 2490 | impl<'a> AstNode<'a> for SelfParam<'a> { |
2924 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2491 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2930,29 +2497,24 @@ impl<'a> AstNode<'a> for SelfParam<'a> { | |||
2930 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2497 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2931 | } | 2498 | } |
2932 | 2499 | ||
2933 | impl<'a> SelfParam<'a> {} | 2500 | impl<R: TreeRoot<RaTypes>> SelfParamNode<R> { |
2934 | 2501 | pub fn borrowed(&self) -> SelfParam { | |
2935 | // SlicePat | 2502 | 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 | } | 2503 | } |
2944 | } | 2504 | pub fn owned(&self) -> SelfParamNode { |
2945 | 2505 | 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 | } | 2506 | } |
2951 | } | 2507 | } |
2508 | |||
2509 | |||
2510 | impl<'a> SelfParam<'a> {} | ||
2511 | |||
2512 | // SlicePat | ||
2952 | #[derive(Debug, Clone, Copy)] | 2513 | #[derive(Debug, Clone, Copy)] |
2953 | pub struct SlicePat<'a> { | 2514 | pub struct SlicePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2954 | syntax: SyntaxNodeRef<'a>, | 2515 | syntax: SyntaxNode<R>, |
2955 | } | 2516 | } |
2517 | pub type SlicePat<'a> = SlicePatNode<RefRoot<'a>>; | ||
2956 | 2518 | ||
2957 | impl<'a> AstNode<'a> for SlicePat<'a> { | 2519 | impl<'a> AstNode<'a> for SlicePat<'a> { |
2958 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2520 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2964,29 +2526,24 @@ impl<'a> AstNode<'a> for SlicePat<'a> { | |||
2964 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2526 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2965 | } | 2527 | } |
2966 | 2528 | ||
2967 | impl<'a> SlicePat<'a> {} | 2529 | impl<R: TreeRoot<RaTypes>> SlicePatNode<R> { |
2968 | 2530 | pub fn borrowed(&self) -> SlicePat { | |
2969 | // SliceType | 2531 | 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 | } | 2532 | } |
2978 | } | 2533 | pub fn owned(&self) -> SlicePatNode { |
2979 | 2534 | 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 | } | 2535 | } |
2985 | } | 2536 | } |
2537 | |||
2538 | |||
2539 | impl<'a> SlicePat<'a> {} | ||
2540 | |||
2541 | // SliceType | ||
2986 | #[derive(Debug, Clone, Copy)] | 2542 | #[derive(Debug, Clone, Copy)] |
2987 | pub struct SliceType<'a> { | 2543 | pub struct SliceTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
2988 | syntax: SyntaxNodeRef<'a>, | 2544 | syntax: SyntaxNode<R>, |
2989 | } | 2545 | } |
2546 | pub type SliceType<'a> = SliceTypeNode<RefRoot<'a>>; | ||
2990 | 2547 | ||
2991 | impl<'a> AstNode<'a> for SliceType<'a> { | 2548 | impl<'a> AstNode<'a> for SliceType<'a> { |
2992 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2549 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -2998,29 +2555,24 @@ impl<'a> AstNode<'a> for SliceType<'a> { | |||
2998 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2555 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
2999 | } | 2556 | } |
3000 | 2557 | ||
3001 | impl<'a> SliceType<'a> {} | 2558 | impl<R: TreeRoot<RaTypes>> SliceTypeNode<R> { |
3002 | 2559 | pub fn borrowed(&self) -> SliceType { | |
3003 | // StaticDef | 2560 | 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 | } | 2561 | } |
3012 | } | 2562 | pub fn owned(&self) -> SliceTypeNode { |
3013 | 2563 | 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 | } | 2564 | } |
3019 | } | 2565 | } |
2566 | |||
2567 | |||
2568 | impl<'a> SliceType<'a> {} | ||
2569 | |||
2570 | // StaticDef | ||
3020 | #[derive(Debug, Clone, Copy)] | 2571 | #[derive(Debug, Clone, Copy)] |
3021 | pub struct StaticDef<'a> { | 2572 | pub struct StaticDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3022 | syntax: SyntaxNodeRef<'a>, | 2573 | syntax: SyntaxNode<R>, |
3023 | } | 2574 | } |
2575 | pub type StaticDef<'a> = StaticDefNode<RefRoot<'a>>; | ||
3024 | 2576 | ||
3025 | impl<'a> AstNode<'a> for StaticDef<'a> { | 2577 | impl<'a> AstNode<'a> for StaticDef<'a> { |
3026 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2578 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3032,28 +2584,22 @@ impl<'a> AstNode<'a> for StaticDef<'a> { | |||
3032 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2584 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3033 | } | 2585 | } |
3034 | 2586 | ||
2587 | impl<R: TreeRoot<RaTypes>> StaticDefNode<R> { | ||
2588 | pub fn borrowed(&self) -> StaticDef { | ||
2589 | StaticDefNode { syntax: self.syntax.borrowed() } | ||
2590 | } | ||
2591 | pub fn owned(&self) -> StaticDefNode { | ||
2592 | StaticDefNode { syntax: self.syntax.owned() } | ||
2593 | } | ||
2594 | } | ||
2595 | |||
2596 | |||
3035 | impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} | 2597 | impl<'a> ast::NameOwner<'a> for StaticDef<'a> {} |
3036 | impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} | 2598 | impl<'a> ast::TypeParamsOwner<'a> for StaticDef<'a> {} |
3037 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} | 2599 | impl<'a> ast::AttrsOwner<'a> for StaticDef<'a> {} |
3038 | impl<'a> StaticDef<'a> {} | 2600 | impl<'a> StaticDef<'a> {} |
3039 | 2601 | ||
3040 | // Stmt | 2602 | // 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)] | 2603 | #[derive(Debug, Clone, Copy)] |
3058 | pub enum Stmt<'a> { | 2604 | pub enum Stmt<'a> { |
3059 | ExprStmt(ExprStmt<'a>), | 2605 | ExprStmt(ExprStmt<'a>), |
@@ -3079,26 +2625,11 @@ impl<'a> AstNode<'a> for Stmt<'a> { | |||
3079 | impl<'a> Stmt<'a> {} | 2625 | impl<'a> Stmt<'a> {} |
3080 | 2626 | ||
3081 | // StructDef | 2627 | // 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)] | 2628 | #[derive(Debug, Clone, Copy)] |
3099 | pub struct StructDef<'a> { | 2629 | pub struct StructDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3100 | syntax: SyntaxNodeRef<'a>, | 2630 | syntax: SyntaxNode<R>, |
3101 | } | 2631 | } |
2632 | pub type StructDef<'a> = StructDefNode<RefRoot<'a>>; | ||
3102 | 2633 | ||
3103 | impl<'a> AstNode<'a> for StructDef<'a> { | 2634 | impl<'a> AstNode<'a> for StructDef<'a> { |
3104 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2635 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3110,6 +2641,16 @@ impl<'a> AstNode<'a> for StructDef<'a> { | |||
3110 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2641 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3111 | } | 2642 | } |
3112 | 2643 | ||
2644 | impl<R: TreeRoot<RaTypes>> StructDefNode<R> { | ||
2645 | pub fn borrowed(&self) -> StructDef { | ||
2646 | StructDefNode { syntax: self.syntax.borrowed() } | ||
2647 | } | ||
2648 | pub fn owned(&self) -> StructDefNode { | ||
2649 | StructDefNode { syntax: self.syntax.owned() } | ||
2650 | } | ||
2651 | } | ||
2652 | |||
2653 | |||
3113 | impl<'a> ast::NameOwner<'a> for StructDef<'a> {} | 2654 | impl<'a> ast::NameOwner<'a> for StructDef<'a> {} |
3114 | impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} | 2655 | impl<'a> ast::TypeParamsOwner<'a> for StructDef<'a> {} |
3115 | impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} | 2656 | impl<'a> ast::AttrsOwner<'a> for StructDef<'a> {} |
@@ -3120,26 +2661,11 @@ impl<'a> StructDef<'a> { | |||
3120 | } | 2661 | } |
3121 | 2662 | ||
3122 | // StructLit | 2663 | // 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)] | 2664 | #[derive(Debug, Clone, Copy)] |
3140 | pub struct StructLit<'a> { | 2665 | pub struct StructLitNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3141 | syntax: SyntaxNodeRef<'a>, | 2666 | syntax: SyntaxNode<R>, |
3142 | } | 2667 | } |
2668 | pub type StructLit<'a> = StructLitNode<RefRoot<'a>>; | ||
3143 | 2669 | ||
3144 | impl<'a> AstNode<'a> for StructLit<'a> { | 2670 | impl<'a> AstNode<'a> for StructLit<'a> { |
3145 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2671 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3151,29 +2677,24 @@ impl<'a> AstNode<'a> for StructLit<'a> { | |||
3151 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2677 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3152 | } | 2678 | } |
3153 | 2679 | ||
3154 | impl<'a> StructLit<'a> {} | 2680 | impl<R: TreeRoot<RaTypes>> StructLitNode<R> { |
3155 | 2681 | pub fn borrowed(&self) -> StructLit { | |
3156 | // StructPat | 2682 | 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 | } | 2683 | } |
3165 | } | 2684 | pub fn owned(&self) -> StructLitNode { |
3166 | 2685 | 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 | } | 2686 | } |
3172 | } | 2687 | } |
2688 | |||
2689 | |||
2690 | impl<'a> StructLit<'a> {} | ||
2691 | |||
2692 | // StructPat | ||
3173 | #[derive(Debug, Clone, Copy)] | 2693 | #[derive(Debug, Clone, Copy)] |
3174 | pub struct StructPat<'a> { | 2694 | pub struct StructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3175 | syntax: SyntaxNodeRef<'a>, | 2695 | syntax: SyntaxNode<R>, |
3176 | } | 2696 | } |
2697 | pub type StructPat<'a> = StructPatNode<RefRoot<'a>>; | ||
3177 | 2698 | ||
3178 | impl<'a> AstNode<'a> for StructPat<'a> { | 2699 | impl<'a> AstNode<'a> for StructPat<'a> { |
3179 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2700 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3185,29 +2706,24 @@ impl<'a> AstNode<'a> for StructPat<'a> { | |||
3185 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2706 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3186 | } | 2707 | } |
3187 | 2708 | ||
3188 | impl<'a> StructPat<'a> {} | 2709 | impl<R: TreeRoot<RaTypes>> StructPatNode<R> { |
3189 | 2710 | pub fn borrowed(&self) -> StructPat { | |
3190 | // TokenTree | 2711 | 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 | } | 2712 | } |
3199 | } | 2713 | pub fn owned(&self) -> StructPatNode { |
3200 | 2714 | 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 | } | 2715 | } |
3206 | } | 2716 | } |
2717 | |||
2718 | |||
2719 | impl<'a> StructPat<'a> {} | ||
2720 | |||
2721 | // TokenTree | ||
3207 | #[derive(Debug, Clone, Copy)] | 2722 | #[derive(Debug, Clone, Copy)] |
3208 | pub struct TokenTree<'a> { | 2723 | pub struct TokenTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3209 | syntax: SyntaxNodeRef<'a>, | 2724 | syntax: SyntaxNode<R>, |
3210 | } | 2725 | } |
2726 | pub type TokenTree<'a> = TokenTreeNode<RefRoot<'a>>; | ||
3211 | 2727 | ||
3212 | impl<'a> AstNode<'a> for TokenTree<'a> { | 2728 | impl<'a> AstNode<'a> for TokenTree<'a> { |
3213 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2729 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3219,29 +2735,24 @@ impl<'a> AstNode<'a> for TokenTree<'a> { | |||
3219 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2735 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3220 | } | 2736 | } |
3221 | 2737 | ||
3222 | impl<'a> TokenTree<'a> {} | 2738 | impl<R: TreeRoot<RaTypes>> TokenTreeNode<R> { |
3223 | 2739 | pub fn borrowed(&self) -> TokenTree { | |
3224 | // TraitDef | 2740 | 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 | } | 2741 | } |
3233 | } | 2742 | pub fn owned(&self) -> TokenTreeNode { |
3234 | 2743 | 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 | } | 2744 | } |
3240 | } | 2745 | } |
2746 | |||
2747 | |||
2748 | impl<'a> TokenTree<'a> {} | ||
2749 | |||
2750 | // TraitDef | ||
3241 | #[derive(Debug, Clone, Copy)] | 2751 | #[derive(Debug, Clone, Copy)] |
3242 | pub struct TraitDef<'a> { | 2752 | pub struct TraitDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3243 | syntax: SyntaxNodeRef<'a>, | 2753 | syntax: SyntaxNode<R>, |
3244 | } | 2754 | } |
2755 | pub type TraitDef<'a> = TraitDefNode<RefRoot<'a>>; | ||
3245 | 2756 | ||
3246 | impl<'a> AstNode<'a> for TraitDef<'a> { | 2757 | impl<'a> AstNode<'a> for TraitDef<'a> { |
3247 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2758 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3253,31 +2764,26 @@ impl<'a> AstNode<'a> for TraitDef<'a> { | |||
3253 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2764 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3254 | } | 2765 | } |
3255 | 2766 | ||
2767 | impl<R: TreeRoot<RaTypes>> TraitDefNode<R> { | ||
2768 | pub fn borrowed(&self) -> TraitDef { | ||
2769 | TraitDefNode { syntax: self.syntax.borrowed() } | ||
2770 | } | ||
2771 | pub fn owned(&self) -> TraitDefNode { | ||
2772 | TraitDefNode { syntax: self.syntax.owned() } | ||
2773 | } | ||
2774 | } | ||
2775 | |||
2776 | |||
3256 | impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} | 2777 | impl<'a> ast::NameOwner<'a> for TraitDef<'a> {} |
3257 | impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} | 2778 | impl<'a> ast::AttrsOwner<'a> for TraitDef<'a> {} |
3258 | impl<'a> TraitDef<'a> {} | 2779 | impl<'a> TraitDef<'a> {} |
3259 | 2780 | ||
3260 | // TryExpr | 2781 | // 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)] | 2782 | #[derive(Debug, Clone, Copy)] |
3278 | pub struct TryExpr<'a> { | 2783 | pub struct TryExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3279 | syntax: SyntaxNodeRef<'a>, | 2784 | syntax: SyntaxNode<R>, |
3280 | } | 2785 | } |
2786 | pub type TryExpr<'a> = TryExprNode<RefRoot<'a>>; | ||
3281 | 2787 | ||
3282 | impl<'a> AstNode<'a> for TryExpr<'a> { | 2788 | impl<'a> AstNode<'a> for TryExpr<'a> { |
3283 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2789 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3289,29 +2795,24 @@ impl<'a> AstNode<'a> for TryExpr<'a> { | |||
3289 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2795 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3290 | } | 2796 | } |
3291 | 2797 | ||
3292 | impl<'a> TryExpr<'a> {} | 2798 | impl<R: TreeRoot<RaTypes>> TryExprNode<R> { |
3293 | 2799 | pub fn borrowed(&self) -> TryExpr { | |
3294 | // TupleExpr | 2800 | 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 | } | 2801 | } |
3303 | } | 2802 | pub fn owned(&self) -> TryExprNode { |
3304 | 2803 | 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 | } | 2804 | } |
3310 | } | 2805 | } |
2806 | |||
2807 | |||
2808 | impl<'a> TryExpr<'a> {} | ||
2809 | |||
2810 | // TupleExpr | ||
3311 | #[derive(Debug, Clone, Copy)] | 2811 | #[derive(Debug, Clone, Copy)] |
3312 | pub struct TupleExpr<'a> { | 2812 | pub struct TupleExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3313 | syntax: SyntaxNodeRef<'a>, | 2813 | syntax: SyntaxNode<R>, |
3314 | } | 2814 | } |
2815 | pub type TupleExpr<'a> = TupleExprNode<RefRoot<'a>>; | ||
3315 | 2816 | ||
3316 | impl<'a> AstNode<'a> for TupleExpr<'a> { | 2817 | impl<'a> AstNode<'a> for TupleExpr<'a> { |
3317 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2818 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3323,29 +2824,24 @@ impl<'a> AstNode<'a> for TupleExpr<'a> { | |||
3323 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2824 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3324 | } | 2825 | } |
3325 | 2826 | ||
3326 | impl<'a> TupleExpr<'a> {} | 2827 | impl<R: TreeRoot<RaTypes>> TupleExprNode<R> { |
3327 | 2828 | pub fn borrowed(&self) -> TupleExpr { | |
3328 | // TuplePat | 2829 | 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 | } | 2830 | } |
3337 | } | 2831 | pub fn owned(&self) -> TupleExprNode { |
3338 | 2832 | 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 | } | 2833 | } |
3344 | } | 2834 | } |
2835 | |||
2836 | |||
2837 | impl<'a> TupleExpr<'a> {} | ||
2838 | |||
2839 | // TuplePat | ||
3345 | #[derive(Debug, Clone, Copy)] | 2840 | #[derive(Debug, Clone, Copy)] |
3346 | pub struct TuplePat<'a> { | 2841 | pub struct TuplePatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3347 | syntax: SyntaxNodeRef<'a>, | 2842 | syntax: SyntaxNode<R>, |
3348 | } | 2843 | } |
2844 | pub type TuplePat<'a> = TuplePatNode<RefRoot<'a>>; | ||
3349 | 2845 | ||
3350 | impl<'a> AstNode<'a> for TuplePat<'a> { | 2846 | impl<'a> AstNode<'a> for TuplePat<'a> { |
3351 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2847 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3357,29 +2853,24 @@ impl<'a> AstNode<'a> for TuplePat<'a> { | |||
3357 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2853 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3358 | } | 2854 | } |
3359 | 2855 | ||
3360 | impl<'a> TuplePat<'a> {} | 2856 | impl<R: TreeRoot<RaTypes>> TuplePatNode<R> { |
3361 | 2857 | pub fn borrowed(&self) -> TuplePat { | |
3362 | // TupleStructPat | 2858 | 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 | } | 2859 | } |
3371 | } | 2860 | pub fn owned(&self) -> TuplePatNode { |
3372 | 2861 | 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 | } | 2862 | } |
3378 | } | 2863 | } |
2864 | |||
2865 | |||
2866 | impl<'a> TuplePat<'a> {} | ||
2867 | |||
2868 | // TupleStructPat | ||
3379 | #[derive(Debug, Clone, Copy)] | 2869 | #[derive(Debug, Clone, Copy)] |
3380 | pub struct TupleStructPat<'a> { | 2870 | pub struct TupleStructPatNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3381 | syntax: SyntaxNodeRef<'a>, | 2871 | syntax: SyntaxNode<R>, |
3382 | } | 2872 | } |
2873 | pub type TupleStructPat<'a> = TupleStructPatNode<RefRoot<'a>>; | ||
3383 | 2874 | ||
3384 | impl<'a> AstNode<'a> for TupleStructPat<'a> { | 2875 | impl<'a> AstNode<'a> for TupleStructPat<'a> { |
3385 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2876 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3391,29 +2882,24 @@ impl<'a> AstNode<'a> for TupleStructPat<'a> { | |||
3391 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2882 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3392 | } | 2883 | } |
3393 | 2884 | ||
3394 | impl<'a> TupleStructPat<'a> {} | 2885 | impl<R: TreeRoot<RaTypes>> TupleStructPatNode<R> { |
3395 | 2886 | pub fn borrowed(&self) -> TupleStructPat { | |
3396 | // TupleType | 2887 | 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 | } | 2888 | } |
3405 | } | 2889 | pub fn owned(&self) -> TupleStructPatNode { |
3406 | 2890 | 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 | } | 2891 | } |
3412 | } | 2892 | } |
2893 | |||
2894 | |||
2895 | impl<'a> TupleStructPat<'a> {} | ||
2896 | |||
2897 | // TupleType | ||
3413 | #[derive(Debug, Clone, Copy)] | 2898 | #[derive(Debug, Clone, Copy)] |
3414 | pub struct TupleType<'a> { | 2899 | pub struct TupleTypeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3415 | syntax: SyntaxNodeRef<'a>, | 2900 | syntax: SyntaxNode<R>, |
3416 | } | 2901 | } |
2902 | pub type TupleType<'a> = TupleTypeNode<RefRoot<'a>>; | ||
3417 | 2903 | ||
3418 | impl<'a> AstNode<'a> for TupleType<'a> { | 2904 | impl<'a> AstNode<'a> for TupleType<'a> { |
3419 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2905 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3425,29 +2911,24 @@ impl<'a> AstNode<'a> for TupleType<'a> { | |||
3425 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2911 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3426 | } | 2912 | } |
3427 | 2913 | ||
3428 | impl<'a> TupleType<'a> {} | 2914 | impl<R: TreeRoot<RaTypes>> TupleTypeNode<R> { |
3429 | 2915 | pub fn borrowed(&self) -> TupleType { | |
3430 | // TypeDef | 2916 | 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 | } | 2917 | } |
3439 | } | 2918 | pub fn owned(&self) -> TupleTypeNode { |
3440 | 2919 | 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 | } | 2920 | } |
3446 | } | 2921 | } |
2922 | |||
2923 | |||
2924 | impl<'a> TupleType<'a> {} | ||
2925 | |||
2926 | // TypeDef | ||
3447 | #[derive(Debug, Clone, Copy)] | 2927 | #[derive(Debug, Clone, Copy)] |
3448 | pub struct TypeDef<'a> { | 2928 | pub struct TypeDefNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3449 | syntax: SyntaxNodeRef<'a>, | 2929 | syntax: SyntaxNode<R>, |
3450 | } | 2930 | } |
2931 | pub type TypeDef<'a> = TypeDefNode<RefRoot<'a>>; | ||
3451 | 2932 | ||
3452 | impl<'a> AstNode<'a> for TypeDef<'a> { | 2933 | impl<'a> AstNode<'a> for TypeDef<'a> { |
3453 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2934 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3459,32 +2940,27 @@ impl<'a> AstNode<'a> for TypeDef<'a> { | |||
3459 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2940 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3460 | } | 2941 | } |
3461 | 2942 | ||
2943 | impl<R: TreeRoot<RaTypes>> TypeDefNode<R> { | ||
2944 | pub fn borrowed(&self) -> TypeDef { | ||
2945 | TypeDefNode { syntax: self.syntax.borrowed() } | ||
2946 | } | ||
2947 | pub fn owned(&self) -> TypeDefNode { | ||
2948 | TypeDefNode { syntax: self.syntax.owned() } | ||
2949 | } | ||
2950 | } | ||
2951 | |||
2952 | |||
3462 | impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} | 2953 | impl<'a> ast::NameOwner<'a> for TypeDef<'a> {} |
3463 | impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} | 2954 | impl<'a> ast::TypeParamsOwner<'a> for TypeDef<'a> {} |
3464 | impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} | 2955 | impl<'a> ast::AttrsOwner<'a> for TypeDef<'a> {} |
3465 | impl<'a> TypeDef<'a> {} | 2956 | impl<'a> TypeDef<'a> {} |
3466 | 2957 | ||
3467 | // TypeParam | 2958 | // 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)] | 2959 | #[derive(Debug, Clone, Copy)] |
3485 | pub struct TypeParam<'a> { | 2960 | pub struct TypeParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3486 | syntax: SyntaxNodeRef<'a>, | 2961 | syntax: SyntaxNode<R>, |
3487 | } | 2962 | } |
2963 | pub type TypeParam<'a> = TypeParamNode<RefRoot<'a>>; | ||
3488 | 2964 | ||
3489 | impl<'a> AstNode<'a> for TypeParam<'a> { | 2965 | impl<'a> AstNode<'a> for TypeParam<'a> { |
3490 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2966 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3496,30 +2972,25 @@ impl<'a> AstNode<'a> for TypeParam<'a> { | |||
3496 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 2972 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3497 | } | 2973 | } |
3498 | 2974 | ||
2975 | impl<R: TreeRoot<RaTypes>> TypeParamNode<R> { | ||
2976 | pub fn borrowed(&self) -> TypeParam { | ||
2977 | TypeParamNode { syntax: self.syntax.borrowed() } | ||
2978 | } | ||
2979 | pub fn owned(&self) -> TypeParamNode { | ||
2980 | TypeParamNode { syntax: self.syntax.owned() } | ||
2981 | } | ||
2982 | } | ||
2983 | |||
2984 | |||
3499 | impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} | 2985 | impl<'a> ast::NameOwner<'a> for TypeParam<'a> {} |
3500 | impl<'a> TypeParam<'a> {} | 2986 | impl<'a> TypeParam<'a> {} |
3501 | 2987 | ||
3502 | // TypeParamList | 2988 | // 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)] | 2989 | #[derive(Debug, Clone, Copy)] |
3520 | pub struct TypeParamList<'a> { | 2990 | pub struct TypeParamListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3521 | syntax: SyntaxNodeRef<'a>, | 2991 | syntax: SyntaxNode<R>, |
3522 | } | 2992 | } |
2993 | pub type TypeParamList<'a> = TypeParamListNode<RefRoot<'a>>; | ||
3523 | 2994 | ||
3524 | impl<'a> AstNode<'a> for TypeParamList<'a> { | 2995 | impl<'a> AstNode<'a> for TypeParamList<'a> { |
3525 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 2996 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3531,6 +3002,16 @@ impl<'a> AstNode<'a> for TypeParamList<'a> { | |||
3531 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3002 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3532 | } | 3003 | } |
3533 | 3004 | ||
3005 | impl<R: TreeRoot<RaTypes>> TypeParamListNode<R> { | ||
3006 | pub fn borrowed(&self) -> TypeParamList { | ||
3007 | TypeParamListNode { syntax: self.syntax.borrowed() } | ||
3008 | } | ||
3009 | pub fn owned(&self) -> TypeParamListNode { | ||
3010 | TypeParamListNode { syntax: self.syntax.owned() } | ||
3011 | } | ||
3012 | } | ||
3013 | |||
3014 | |||
3534 | impl<'a> TypeParamList<'a> { | 3015 | impl<'a> TypeParamList<'a> { |
3535 | pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { | 3016 | pub fn type_params(self) -> impl Iterator<Item = TypeParam<'a>> + 'a { |
3536 | super::children(self) | 3017 | super::children(self) |
@@ -3542,22 +3023,6 @@ impl<'a> TypeParamList<'a> { | |||
3542 | } | 3023 | } |
3543 | 3024 | ||
3544 | // TypeRef | 3025 | // 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)] | 3026 | #[derive(Debug, Clone, Copy)] |
3562 | pub enum TypeRef<'a> { | 3027 | pub enum TypeRef<'a> { |
3563 | ParenType(ParenType<'a>), | 3028 | ParenType(ParenType<'a>), |
@@ -3616,26 +3081,11 @@ impl<'a> AstNode<'a> for TypeRef<'a> { | |||
3616 | impl<'a> TypeRef<'a> {} | 3081 | impl<'a> TypeRef<'a> {} |
3617 | 3082 | ||
3618 | // UseItem | 3083 | // 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)] | 3084 | #[derive(Debug, Clone, Copy)] |
3636 | pub struct UseItem<'a> { | 3085 | pub struct UseItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3637 | syntax: SyntaxNodeRef<'a>, | 3086 | syntax: SyntaxNode<R>, |
3638 | } | 3087 | } |
3088 | pub type UseItem<'a> = UseItemNode<RefRoot<'a>>; | ||
3639 | 3089 | ||
3640 | impl<'a> AstNode<'a> for UseItem<'a> { | 3090 | impl<'a> AstNode<'a> for UseItem<'a> { |
3641 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3091 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3647,33 +3097,28 @@ impl<'a> AstNode<'a> for UseItem<'a> { | |||
3647 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3097 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3648 | } | 3098 | } |
3649 | 3099 | ||
3650 | impl<'a> UseItem<'a> { | 3100 | impl<R: TreeRoot<RaTypes>> UseItemNode<R> { |
3651 | pub fn use_tree(self) -> Option<UseTree<'a>> { | 3101 | pub fn borrowed(&self) -> UseItem { |
3652 | super::child_opt(self) | 3102 | UseItemNode { syntax: self.syntax.borrowed() } |
3103 | } | ||
3104 | pub fn owned(&self) -> UseItemNode { | ||
3105 | UseItemNode { syntax: self.syntax.owned() } | ||
3653 | } | 3106 | } |
3654 | } | 3107 | } |
3655 | 3108 | ||
3656 | // UseTree | ||
3657 | 3109 | ||
3658 | #[derive(Debug, Clone)] | 3110 | impl<'a> UseItem<'a> { |
3659 | pub struct UseTreeNode(SyntaxNode); | 3111 | pub fn use_tree(self) -> Option<UseTree<'a>> { |
3660 | 3112 | super::child_opt(self) | |
3661 | impl UseTreeNode { | ||
3662 | pub fn ast(&self) -> UseTree { | ||
3663 | UseTree::cast(self.0.borrowed()).unwrap() | ||
3664 | } | 3113 | } |
3665 | } | 3114 | } |
3666 | 3115 | ||
3667 | impl<'a> From<UseTree<'a>> for UseTreeNode { | 3116 | // UseTree |
3668 | fn from(ast: UseTree<'a>) -> UseTreeNode { | ||
3669 | let syntax = ast.syntax().owned(); | ||
3670 | UseTreeNode(syntax) | ||
3671 | } | ||
3672 | } | ||
3673 | #[derive(Debug, Clone, Copy)] | 3117 | #[derive(Debug, Clone, Copy)] |
3674 | pub struct UseTree<'a> { | 3118 | pub struct UseTreeNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3675 | syntax: SyntaxNodeRef<'a>, | 3119 | syntax: SyntaxNode<R>, |
3676 | } | 3120 | } |
3121 | pub type UseTree<'a> = UseTreeNode<RefRoot<'a>>; | ||
3677 | 3122 | ||
3678 | impl<'a> AstNode<'a> for UseTree<'a> { | 3123 | impl<'a> AstNode<'a> for UseTree<'a> { |
3679 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3124 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3685,6 +3130,16 @@ impl<'a> AstNode<'a> for UseTree<'a> { | |||
3685 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3130 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3686 | } | 3131 | } |
3687 | 3132 | ||
3133 | impl<R: TreeRoot<RaTypes>> UseTreeNode<R> { | ||
3134 | pub fn borrowed(&self) -> UseTree { | ||
3135 | UseTreeNode { syntax: self.syntax.borrowed() } | ||
3136 | } | ||
3137 | pub fn owned(&self) -> UseTreeNode { | ||
3138 | UseTreeNode { syntax: self.syntax.owned() } | ||
3139 | } | ||
3140 | } | ||
3141 | |||
3142 | |||
3688 | impl<'a> UseTree<'a> { | 3143 | impl<'a> UseTree<'a> { |
3689 | pub fn path(self) -> Option<Path<'a>> { | 3144 | pub fn path(self) -> Option<Path<'a>> { |
3690 | super::child_opt(self) | 3145 | super::child_opt(self) |
@@ -3696,26 +3151,11 @@ impl<'a> UseTree<'a> { | |||
3696 | } | 3151 | } |
3697 | 3152 | ||
3698 | // UseTreeList | 3153 | // 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)] | 3154 | #[derive(Debug, Clone, Copy)] |
3716 | pub struct UseTreeList<'a> { | 3155 | pub struct UseTreeListNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3717 | syntax: SyntaxNodeRef<'a>, | 3156 | syntax: SyntaxNode<R>, |
3718 | } | 3157 | } |
3158 | pub type UseTreeList<'a> = UseTreeListNode<RefRoot<'a>>; | ||
3719 | 3159 | ||
3720 | impl<'a> AstNode<'a> for UseTreeList<'a> { | 3160 | impl<'a> AstNode<'a> for UseTreeList<'a> { |
3721 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3161 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3727,33 +3167,28 @@ impl<'a> AstNode<'a> for UseTreeList<'a> { | |||
3727 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3167 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3728 | } | 3168 | } |
3729 | 3169 | ||
3730 | impl<'a> UseTreeList<'a> { | 3170 | impl<R: TreeRoot<RaTypes>> UseTreeListNode<R> { |
3731 | pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { | 3171 | pub fn borrowed(&self) -> UseTreeList { |
3732 | super::children(self) | 3172 | UseTreeListNode { syntax: self.syntax.borrowed() } |
3173 | } | ||
3174 | pub fn owned(&self) -> UseTreeListNode { | ||
3175 | UseTreeListNode { syntax: self.syntax.owned() } | ||
3733 | } | 3176 | } |
3734 | } | 3177 | } |
3735 | 3178 | ||
3736 | // WhereClause | ||
3737 | 3179 | ||
3738 | #[derive(Debug, Clone)] | 3180 | impl<'a> UseTreeList<'a> { |
3739 | pub struct WhereClauseNode(SyntaxNode); | 3181 | pub fn use_trees(self) -> impl Iterator<Item = UseTree<'a>> + 'a { |
3740 | 3182 | super::children(self) | |
3741 | impl WhereClauseNode { | ||
3742 | pub fn ast(&self) -> WhereClause { | ||
3743 | WhereClause::cast(self.0.borrowed()).unwrap() | ||
3744 | } | 3183 | } |
3745 | } | 3184 | } |
3746 | 3185 | ||
3747 | impl<'a> From<WhereClause<'a>> for WhereClauseNode { | 3186 | // WhereClause |
3748 | fn from(ast: WhereClause<'a>) -> WhereClauseNode { | ||
3749 | let syntax = ast.syntax().owned(); | ||
3750 | WhereClauseNode(syntax) | ||
3751 | } | ||
3752 | } | ||
3753 | #[derive(Debug, Clone, Copy)] | 3187 | #[derive(Debug, Clone, Copy)] |
3754 | pub struct WhereClause<'a> { | 3188 | pub struct WhereClauseNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3755 | syntax: SyntaxNodeRef<'a>, | 3189 | syntax: SyntaxNode<R>, |
3756 | } | 3190 | } |
3191 | pub type WhereClause<'a> = WhereClauseNode<RefRoot<'a>>; | ||
3757 | 3192 | ||
3758 | impl<'a> AstNode<'a> for WhereClause<'a> { | 3193 | impl<'a> AstNode<'a> for WhereClause<'a> { |
3759 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3194 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3765,29 +3200,24 @@ impl<'a> AstNode<'a> for WhereClause<'a> { | |||
3765 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3200 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3766 | } | 3201 | } |
3767 | 3202 | ||
3768 | impl<'a> WhereClause<'a> {} | 3203 | impl<R: TreeRoot<RaTypes>> WhereClauseNode<R> { |
3769 | 3204 | pub fn borrowed(&self) -> WhereClause { | |
3770 | // WhileExpr | 3205 | 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 | } | 3206 | } |
3779 | } | 3207 | pub fn owned(&self) -> WhereClauseNode { |
3780 | 3208 | 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 | } | 3209 | } |
3786 | } | 3210 | } |
3211 | |||
3212 | |||
3213 | impl<'a> WhereClause<'a> {} | ||
3214 | |||
3215 | // WhileExpr | ||
3787 | #[derive(Debug, Clone, Copy)] | 3216 | #[derive(Debug, Clone, Copy)] |
3788 | pub struct WhileExpr<'a> { | 3217 | pub struct WhileExprNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3789 | syntax: SyntaxNodeRef<'a>, | 3218 | syntax: SyntaxNode<R>, |
3790 | } | 3219 | } |
3220 | pub type WhileExpr<'a> = WhileExprNode<RefRoot<'a>>; | ||
3791 | 3221 | ||
3792 | impl<'a> AstNode<'a> for WhileExpr<'a> { | 3222 | impl<'a> AstNode<'a> for WhileExpr<'a> { |
3793 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3223 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3799,6 +3229,16 @@ impl<'a> AstNode<'a> for WhileExpr<'a> { | |||
3799 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3229 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3800 | } | 3230 | } |
3801 | 3231 | ||
3232 | impl<R: TreeRoot<RaTypes>> WhileExprNode<R> { | ||
3233 | pub fn borrowed(&self) -> WhileExpr { | ||
3234 | WhileExprNode { syntax: self.syntax.borrowed() } | ||
3235 | } | ||
3236 | pub fn owned(&self) -> WhileExprNode { | ||
3237 | WhileExprNode { syntax: self.syntax.owned() } | ||
3238 | } | ||
3239 | } | ||
3240 | |||
3241 | |||
3802 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} | 3242 | impl<'a> ast::LoopBodyOwner<'a> for WhileExpr<'a> {} |
3803 | impl<'a> WhileExpr<'a> { | 3243 | impl<'a> WhileExpr<'a> { |
3804 | pub fn condition(self) -> Option<Condition<'a>> { | 3244 | pub fn condition(self) -> Option<Condition<'a>> { |
@@ -3807,26 +3247,11 @@ impl<'a> WhileExpr<'a> { | |||
3807 | } | 3247 | } |
3808 | 3248 | ||
3809 | // Whitespace | 3249 | // 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)] | 3250 | #[derive(Debug, Clone, Copy)] |
3827 | pub struct Whitespace<'a> { | 3251 | pub struct WhitespaceNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
3828 | syntax: SyntaxNodeRef<'a>, | 3252 | syntax: SyntaxNode<R>, |
3829 | } | 3253 | } |
3254 | pub type Whitespace<'a> = WhitespaceNode<RefRoot<'a>>; | ||
3830 | 3255 | ||
3831 | impl<'a> AstNode<'a> for Whitespace<'a> { | 3256 | impl<'a> AstNode<'a> for Whitespace<'a> { |
3832 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 3257 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -3838,5 +3263,15 @@ impl<'a> AstNode<'a> for Whitespace<'a> { | |||
3838 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 3263 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
3839 | } | 3264 | } |
3840 | 3265 | ||
3266 | impl<R: TreeRoot<RaTypes>> WhitespaceNode<R> { | ||
3267 | pub fn borrowed(&self) -> Whitespace { | ||
3268 | WhitespaceNode { syntax: self.syntax.borrowed() } | ||
3269 | } | ||
3270 | pub fn owned(&self) -> WhitespaceNode { | ||
3271 | WhitespaceNode { syntax: self.syntax.owned() } | ||
3272 | } | ||
3273 | } | ||
3274 | |||
3275 | |||
3841 | impl<'a> Whitespace<'a> {} | 3276 | impl<'a> Whitespace<'a> {} |
3842 | 3277 | ||
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index 1321f0def..6e28575b2 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -8,27 +8,12 @@ the below applies to the result of this template | |||
8 | use crate::{ | 8 | use crate::{ |
9 | ast, | 9 | ast, |
10 | SyntaxNode, SyntaxNodeRef, AstNode, | 10 | SyntaxNode, SyntaxNodeRef, AstNode, |
11 | yellow::{TreeRoot, RaTypes, OwnedRoot, RefRoot}, | ||
11 | SyntaxKind::*, | 12 | SyntaxKind::*, |
12 | }; | 13 | }; |
13 | {% for node, methods in ast %} | 14 | {% for node, methods in ast %} |
14 | // {{ node }} | 15 | // {{ node }} |
15 | 16 | ||
16 | #[derive(Debug, Clone)] | ||
17 | pub struct {{ node }}Node(SyntaxNode); | ||
18 | |||
19 | impl {{ node }}Node { | ||
20 | pub fn ast(&self) -> {{ node }} { | ||
21 | {{ node }}::cast(self.0.borrowed()).unwrap() | ||
22 | } | ||
23 | } | ||
24 | |||
25 | impl<'a> From<{{ node }}<'a>> for {{ node }}Node { | ||
26 | fn from(ast: {{ node}}<'a>) -> {{ node }}Node { | ||
27 | let syntax = ast.syntax().owned(); | ||
28 | {{ node }}Node(syntax) | ||
29 | } | ||
30 | } | ||
31 | |||
32 | {%- if methods.enum %} | 17 | {%- if methods.enum %} |
33 | #[derive(Debug, Clone, Copy)] | 18 | #[derive(Debug, Clone, Copy)] |
34 | pub enum {{ node }}<'a> { | 19 | pub enum {{ node }}<'a> { |
@@ -56,9 +41,10 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
56 | } | 41 | } |
57 | {% else %} | 42 | {% else %} |
58 | #[derive(Debug, Clone, Copy)] | 43 | #[derive(Debug, Clone, Copy)] |
59 | pub struct {{ node }}<'a> { | 44 | pub struct {{ node }}Node<R: TreeRoot<RaTypes> = OwnedRoot> { |
60 | syntax: SyntaxNodeRef<'a>, | 45 | syntax: SyntaxNode<R>, |
61 | } | 46 | } |
47 | pub type {{ node }}<'a> = {{ node }}Node<RefRoot<'a>>; | ||
62 | 48 | ||
63 | impl<'a> AstNode<'a> for {{ node }}<'a> { | 49 | impl<'a> AstNode<'a> for {{ node }}<'a> { |
64 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 50 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
@@ -69,6 +55,16 @@ impl<'a> AstNode<'a> for {{ node }}<'a> { | |||
69 | } | 55 | } |
70 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 56 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
71 | } | 57 | } |
58 | |||
59 | impl<R: TreeRoot<RaTypes>> {{ node }}Node<R> { | ||
60 | pub fn borrowed(&self) -> {{ node }} { | ||
61 | {{ node }}Node { syntax: self.syntax.borrowed() } | ||
62 | } | ||
63 | pub fn owned(&self) -> {{ node }}Node { | ||
64 | {{ node }}Node { syntax: self.syntax.owned() } | ||
65 | } | ||
66 | } | ||
67 | |||
72 | {% endif %} | 68 | {% endif %} |
73 | {% if methods.traits -%} | 69 | {% if methods.traits -%} |
74 | {%- for t in methods.traits -%} | 70 | {%- for t in methods.traits -%} |