diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 3030 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/tokens.rs | 62 |
2 files changed, 3030 insertions, 62 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 0c339b987..385fddc89 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1,11 +1,3037 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` | 1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` |
2 | 2 | ||
3 | #[allow(unused_imports)] | ||
3 | use crate::{ | 4 | use crate::{ |
4 | ast::{self, AstChildren, AstNode}, | 5 | ast::{self, AstChildren, AstNode, AstToken}, |
6 | NodeOrToken, SyntaxElement, | ||
5 | SyntaxKind::{self, *}, | 7 | SyntaxKind::{self, *}, |
6 | SyntaxNode, | 8 | SyntaxNode, SyntaxToken, |
7 | }; | 9 | }; |
8 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 10 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
11 | pub struct Semi { | ||
12 | pub(crate) syntax: SyntaxToken, | ||
13 | } | ||
14 | impl std::fmt::Display for Semi { | ||
15 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
16 | std::fmt::Display::fmt(&self.syntax, f) | ||
17 | } | ||
18 | } | ||
19 | impl AstToken for Semi { | ||
20 | fn can_cast(kind: SyntaxKind) -> bool { | ||
21 | match kind { | ||
22 | SEMI => true, | ||
23 | _ => false, | ||
24 | } | ||
25 | } | ||
26 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
27 | if Self::can_cast(syntax.kind()) { | ||
28 | Some(Self { syntax }) | ||
29 | } else { | ||
30 | None | ||
31 | } | ||
32 | } | ||
33 | fn syntax(&self) -> &SyntaxToken { | ||
34 | &self.syntax | ||
35 | } | ||
36 | } | ||
37 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
38 | pub struct Comma { | ||
39 | pub(crate) syntax: SyntaxToken, | ||
40 | } | ||
41 | impl std::fmt::Display for Comma { | ||
42 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
43 | std::fmt::Display::fmt(&self.syntax, f) | ||
44 | } | ||
45 | } | ||
46 | impl AstToken for Comma { | ||
47 | fn can_cast(kind: SyntaxKind) -> bool { | ||
48 | match kind { | ||
49 | COMMA => true, | ||
50 | _ => false, | ||
51 | } | ||
52 | } | ||
53 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
54 | if Self::can_cast(syntax.kind()) { | ||
55 | Some(Self { syntax }) | ||
56 | } else { | ||
57 | None | ||
58 | } | ||
59 | } | ||
60 | fn syntax(&self) -> &SyntaxToken { | ||
61 | &self.syntax | ||
62 | } | ||
63 | } | ||
64 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
65 | pub struct LParen { | ||
66 | pub(crate) syntax: SyntaxToken, | ||
67 | } | ||
68 | impl std::fmt::Display for LParen { | ||
69 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
70 | std::fmt::Display::fmt(&self.syntax, f) | ||
71 | } | ||
72 | } | ||
73 | impl AstToken for LParen { | ||
74 | fn can_cast(kind: SyntaxKind) -> bool { | ||
75 | match kind { | ||
76 | L_PAREN => true, | ||
77 | _ => false, | ||
78 | } | ||
79 | } | ||
80 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
81 | if Self::can_cast(syntax.kind()) { | ||
82 | Some(Self { syntax }) | ||
83 | } else { | ||
84 | None | ||
85 | } | ||
86 | } | ||
87 | fn syntax(&self) -> &SyntaxToken { | ||
88 | &self.syntax | ||
89 | } | ||
90 | } | ||
91 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
92 | pub struct RParen { | ||
93 | pub(crate) syntax: SyntaxToken, | ||
94 | } | ||
95 | impl std::fmt::Display for RParen { | ||
96 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
97 | std::fmt::Display::fmt(&self.syntax, f) | ||
98 | } | ||
99 | } | ||
100 | impl AstToken for RParen { | ||
101 | fn can_cast(kind: SyntaxKind) -> bool { | ||
102 | match kind { | ||
103 | R_PAREN => true, | ||
104 | _ => false, | ||
105 | } | ||
106 | } | ||
107 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
108 | if Self::can_cast(syntax.kind()) { | ||
109 | Some(Self { syntax }) | ||
110 | } else { | ||
111 | None | ||
112 | } | ||
113 | } | ||
114 | fn syntax(&self) -> &SyntaxToken { | ||
115 | &self.syntax | ||
116 | } | ||
117 | } | ||
118 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
119 | pub struct LCurly { | ||
120 | pub(crate) syntax: SyntaxToken, | ||
121 | } | ||
122 | impl std::fmt::Display for LCurly { | ||
123 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
124 | std::fmt::Display::fmt(&self.syntax, f) | ||
125 | } | ||
126 | } | ||
127 | impl AstToken for LCurly { | ||
128 | fn can_cast(kind: SyntaxKind) -> bool { | ||
129 | match kind { | ||
130 | L_CURLY => true, | ||
131 | _ => false, | ||
132 | } | ||
133 | } | ||
134 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
135 | if Self::can_cast(syntax.kind()) { | ||
136 | Some(Self { syntax }) | ||
137 | } else { | ||
138 | None | ||
139 | } | ||
140 | } | ||
141 | fn syntax(&self) -> &SyntaxToken { | ||
142 | &self.syntax | ||
143 | } | ||
144 | } | ||
145 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
146 | pub struct RCurly { | ||
147 | pub(crate) syntax: SyntaxToken, | ||
148 | } | ||
149 | impl std::fmt::Display for RCurly { | ||
150 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
151 | std::fmt::Display::fmt(&self.syntax, f) | ||
152 | } | ||
153 | } | ||
154 | impl AstToken for RCurly { | ||
155 | fn can_cast(kind: SyntaxKind) -> bool { | ||
156 | match kind { | ||
157 | R_CURLY => true, | ||
158 | _ => false, | ||
159 | } | ||
160 | } | ||
161 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
162 | if Self::can_cast(syntax.kind()) { | ||
163 | Some(Self { syntax }) | ||
164 | } else { | ||
165 | None | ||
166 | } | ||
167 | } | ||
168 | fn syntax(&self) -> &SyntaxToken { | ||
169 | &self.syntax | ||
170 | } | ||
171 | } | ||
172 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
173 | pub struct LBrack { | ||
174 | pub(crate) syntax: SyntaxToken, | ||
175 | } | ||
176 | impl std::fmt::Display for LBrack { | ||
177 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
178 | std::fmt::Display::fmt(&self.syntax, f) | ||
179 | } | ||
180 | } | ||
181 | impl AstToken for LBrack { | ||
182 | fn can_cast(kind: SyntaxKind) -> bool { | ||
183 | match kind { | ||
184 | L_BRACK => true, | ||
185 | _ => false, | ||
186 | } | ||
187 | } | ||
188 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
189 | if Self::can_cast(syntax.kind()) { | ||
190 | Some(Self { syntax }) | ||
191 | } else { | ||
192 | None | ||
193 | } | ||
194 | } | ||
195 | fn syntax(&self) -> &SyntaxToken { | ||
196 | &self.syntax | ||
197 | } | ||
198 | } | ||
199 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
200 | pub struct RBrack { | ||
201 | pub(crate) syntax: SyntaxToken, | ||
202 | } | ||
203 | impl std::fmt::Display for RBrack { | ||
204 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
205 | std::fmt::Display::fmt(&self.syntax, f) | ||
206 | } | ||
207 | } | ||
208 | impl AstToken for RBrack { | ||
209 | fn can_cast(kind: SyntaxKind) -> bool { | ||
210 | match kind { | ||
211 | R_BRACK => true, | ||
212 | _ => false, | ||
213 | } | ||
214 | } | ||
215 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
216 | if Self::can_cast(syntax.kind()) { | ||
217 | Some(Self { syntax }) | ||
218 | } else { | ||
219 | None | ||
220 | } | ||
221 | } | ||
222 | fn syntax(&self) -> &SyntaxToken { | ||
223 | &self.syntax | ||
224 | } | ||
225 | } | ||
226 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
227 | pub struct LAngle { | ||
228 | pub(crate) syntax: SyntaxToken, | ||
229 | } | ||
230 | impl std::fmt::Display for LAngle { | ||
231 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
232 | std::fmt::Display::fmt(&self.syntax, f) | ||
233 | } | ||
234 | } | ||
235 | impl AstToken for LAngle { | ||
236 | fn can_cast(kind: SyntaxKind) -> bool { | ||
237 | match kind { | ||
238 | L_ANGLE => true, | ||
239 | _ => false, | ||
240 | } | ||
241 | } | ||
242 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
243 | if Self::can_cast(syntax.kind()) { | ||
244 | Some(Self { syntax }) | ||
245 | } else { | ||
246 | None | ||
247 | } | ||
248 | } | ||
249 | fn syntax(&self) -> &SyntaxToken { | ||
250 | &self.syntax | ||
251 | } | ||
252 | } | ||
253 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
254 | pub struct RAngle { | ||
255 | pub(crate) syntax: SyntaxToken, | ||
256 | } | ||
257 | impl std::fmt::Display for RAngle { | ||
258 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
259 | std::fmt::Display::fmt(&self.syntax, f) | ||
260 | } | ||
261 | } | ||
262 | impl AstToken for RAngle { | ||
263 | fn can_cast(kind: SyntaxKind) -> bool { | ||
264 | match kind { | ||
265 | R_ANGLE => true, | ||
266 | _ => false, | ||
267 | } | ||
268 | } | ||
269 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
270 | if Self::can_cast(syntax.kind()) { | ||
271 | Some(Self { syntax }) | ||
272 | } else { | ||
273 | None | ||
274 | } | ||
275 | } | ||
276 | fn syntax(&self) -> &SyntaxToken { | ||
277 | &self.syntax | ||
278 | } | ||
279 | } | ||
280 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
281 | pub struct At { | ||
282 | pub(crate) syntax: SyntaxToken, | ||
283 | } | ||
284 | impl std::fmt::Display for At { | ||
285 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
286 | std::fmt::Display::fmt(&self.syntax, f) | ||
287 | } | ||
288 | } | ||
289 | impl AstToken for At { | ||
290 | fn can_cast(kind: SyntaxKind) -> bool { | ||
291 | match kind { | ||
292 | AT => true, | ||
293 | _ => false, | ||
294 | } | ||
295 | } | ||
296 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
297 | if Self::can_cast(syntax.kind()) { | ||
298 | Some(Self { syntax }) | ||
299 | } else { | ||
300 | None | ||
301 | } | ||
302 | } | ||
303 | fn syntax(&self) -> &SyntaxToken { | ||
304 | &self.syntax | ||
305 | } | ||
306 | } | ||
307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
308 | pub struct Pound { | ||
309 | pub(crate) syntax: SyntaxToken, | ||
310 | } | ||
311 | impl std::fmt::Display for Pound { | ||
312 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
313 | std::fmt::Display::fmt(&self.syntax, f) | ||
314 | } | ||
315 | } | ||
316 | impl AstToken for Pound { | ||
317 | fn can_cast(kind: SyntaxKind) -> bool { | ||
318 | match kind { | ||
319 | POUND => true, | ||
320 | _ => false, | ||
321 | } | ||
322 | } | ||
323 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
324 | if Self::can_cast(syntax.kind()) { | ||
325 | Some(Self { syntax }) | ||
326 | } else { | ||
327 | None | ||
328 | } | ||
329 | } | ||
330 | fn syntax(&self) -> &SyntaxToken { | ||
331 | &self.syntax | ||
332 | } | ||
333 | } | ||
334 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
335 | pub struct Tilde { | ||
336 | pub(crate) syntax: SyntaxToken, | ||
337 | } | ||
338 | impl std::fmt::Display for Tilde { | ||
339 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
340 | std::fmt::Display::fmt(&self.syntax, f) | ||
341 | } | ||
342 | } | ||
343 | impl AstToken for Tilde { | ||
344 | fn can_cast(kind: SyntaxKind) -> bool { | ||
345 | match kind { | ||
346 | TILDE => true, | ||
347 | _ => false, | ||
348 | } | ||
349 | } | ||
350 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
351 | if Self::can_cast(syntax.kind()) { | ||
352 | Some(Self { syntax }) | ||
353 | } else { | ||
354 | None | ||
355 | } | ||
356 | } | ||
357 | fn syntax(&self) -> &SyntaxToken { | ||
358 | &self.syntax | ||
359 | } | ||
360 | } | ||
361 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
362 | pub struct Question { | ||
363 | pub(crate) syntax: SyntaxToken, | ||
364 | } | ||
365 | impl std::fmt::Display for Question { | ||
366 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
367 | std::fmt::Display::fmt(&self.syntax, f) | ||
368 | } | ||
369 | } | ||
370 | impl AstToken for Question { | ||
371 | fn can_cast(kind: SyntaxKind) -> bool { | ||
372 | match kind { | ||
373 | QUESTION => true, | ||
374 | _ => false, | ||
375 | } | ||
376 | } | ||
377 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
378 | if Self::can_cast(syntax.kind()) { | ||
379 | Some(Self { syntax }) | ||
380 | } else { | ||
381 | None | ||
382 | } | ||
383 | } | ||
384 | fn syntax(&self) -> &SyntaxToken { | ||
385 | &self.syntax | ||
386 | } | ||
387 | } | ||
388 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
389 | pub struct Dollar { | ||
390 | pub(crate) syntax: SyntaxToken, | ||
391 | } | ||
392 | impl std::fmt::Display for Dollar { | ||
393 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
394 | std::fmt::Display::fmt(&self.syntax, f) | ||
395 | } | ||
396 | } | ||
397 | impl AstToken for Dollar { | ||
398 | fn can_cast(kind: SyntaxKind) -> bool { | ||
399 | match kind { | ||
400 | DOLLAR => true, | ||
401 | _ => false, | ||
402 | } | ||
403 | } | ||
404 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
405 | if Self::can_cast(syntax.kind()) { | ||
406 | Some(Self { syntax }) | ||
407 | } else { | ||
408 | None | ||
409 | } | ||
410 | } | ||
411 | fn syntax(&self) -> &SyntaxToken { | ||
412 | &self.syntax | ||
413 | } | ||
414 | } | ||
415 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
416 | pub struct Amp { | ||
417 | pub(crate) syntax: SyntaxToken, | ||
418 | } | ||
419 | impl std::fmt::Display for Amp { | ||
420 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
421 | std::fmt::Display::fmt(&self.syntax, f) | ||
422 | } | ||
423 | } | ||
424 | impl AstToken for Amp { | ||
425 | fn can_cast(kind: SyntaxKind) -> bool { | ||
426 | match kind { | ||
427 | AMP => true, | ||
428 | _ => false, | ||
429 | } | ||
430 | } | ||
431 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
432 | if Self::can_cast(syntax.kind()) { | ||
433 | Some(Self { syntax }) | ||
434 | } else { | ||
435 | None | ||
436 | } | ||
437 | } | ||
438 | fn syntax(&self) -> &SyntaxToken { | ||
439 | &self.syntax | ||
440 | } | ||
441 | } | ||
442 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
443 | pub struct Pipe { | ||
444 | pub(crate) syntax: SyntaxToken, | ||
445 | } | ||
446 | impl std::fmt::Display for Pipe { | ||
447 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
448 | std::fmt::Display::fmt(&self.syntax, f) | ||
449 | } | ||
450 | } | ||
451 | impl AstToken for Pipe { | ||
452 | fn can_cast(kind: SyntaxKind) -> bool { | ||
453 | match kind { | ||
454 | PIPE => true, | ||
455 | _ => false, | ||
456 | } | ||
457 | } | ||
458 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
459 | if Self::can_cast(syntax.kind()) { | ||
460 | Some(Self { syntax }) | ||
461 | } else { | ||
462 | None | ||
463 | } | ||
464 | } | ||
465 | fn syntax(&self) -> &SyntaxToken { | ||
466 | &self.syntax | ||
467 | } | ||
468 | } | ||
469 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
470 | pub struct Plus { | ||
471 | pub(crate) syntax: SyntaxToken, | ||
472 | } | ||
473 | impl std::fmt::Display for Plus { | ||
474 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
475 | std::fmt::Display::fmt(&self.syntax, f) | ||
476 | } | ||
477 | } | ||
478 | impl AstToken for Plus { | ||
479 | fn can_cast(kind: SyntaxKind) -> bool { | ||
480 | match kind { | ||
481 | PLUS => true, | ||
482 | _ => false, | ||
483 | } | ||
484 | } | ||
485 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
486 | if Self::can_cast(syntax.kind()) { | ||
487 | Some(Self { syntax }) | ||
488 | } else { | ||
489 | None | ||
490 | } | ||
491 | } | ||
492 | fn syntax(&self) -> &SyntaxToken { | ||
493 | &self.syntax | ||
494 | } | ||
495 | } | ||
496 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
497 | pub struct Star { | ||
498 | pub(crate) syntax: SyntaxToken, | ||
499 | } | ||
500 | impl std::fmt::Display for Star { | ||
501 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
502 | std::fmt::Display::fmt(&self.syntax, f) | ||
503 | } | ||
504 | } | ||
505 | impl AstToken for Star { | ||
506 | fn can_cast(kind: SyntaxKind) -> bool { | ||
507 | match kind { | ||
508 | STAR => true, | ||
509 | _ => false, | ||
510 | } | ||
511 | } | ||
512 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
513 | if Self::can_cast(syntax.kind()) { | ||
514 | Some(Self { syntax }) | ||
515 | } else { | ||
516 | None | ||
517 | } | ||
518 | } | ||
519 | fn syntax(&self) -> &SyntaxToken { | ||
520 | &self.syntax | ||
521 | } | ||
522 | } | ||
523 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
524 | pub struct Slash { | ||
525 | pub(crate) syntax: SyntaxToken, | ||
526 | } | ||
527 | impl std::fmt::Display for Slash { | ||
528 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
529 | std::fmt::Display::fmt(&self.syntax, f) | ||
530 | } | ||
531 | } | ||
532 | impl AstToken for Slash { | ||
533 | fn can_cast(kind: SyntaxKind) -> bool { | ||
534 | match kind { | ||
535 | SLASH => true, | ||
536 | _ => false, | ||
537 | } | ||
538 | } | ||
539 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
540 | if Self::can_cast(syntax.kind()) { | ||
541 | Some(Self { syntax }) | ||
542 | } else { | ||
543 | None | ||
544 | } | ||
545 | } | ||
546 | fn syntax(&self) -> &SyntaxToken { | ||
547 | &self.syntax | ||
548 | } | ||
549 | } | ||
550 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
551 | pub struct Caret { | ||
552 | pub(crate) syntax: SyntaxToken, | ||
553 | } | ||
554 | impl std::fmt::Display for Caret { | ||
555 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
556 | std::fmt::Display::fmt(&self.syntax, f) | ||
557 | } | ||
558 | } | ||
559 | impl AstToken for Caret { | ||
560 | fn can_cast(kind: SyntaxKind) -> bool { | ||
561 | match kind { | ||
562 | CARET => true, | ||
563 | _ => false, | ||
564 | } | ||
565 | } | ||
566 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
567 | if Self::can_cast(syntax.kind()) { | ||
568 | Some(Self { syntax }) | ||
569 | } else { | ||
570 | None | ||
571 | } | ||
572 | } | ||
573 | fn syntax(&self) -> &SyntaxToken { | ||
574 | &self.syntax | ||
575 | } | ||
576 | } | ||
577 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
578 | pub struct Percent { | ||
579 | pub(crate) syntax: SyntaxToken, | ||
580 | } | ||
581 | impl std::fmt::Display for Percent { | ||
582 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
583 | std::fmt::Display::fmt(&self.syntax, f) | ||
584 | } | ||
585 | } | ||
586 | impl AstToken for Percent { | ||
587 | fn can_cast(kind: SyntaxKind) -> bool { | ||
588 | match kind { | ||
589 | PERCENT => true, | ||
590 | _ => false, | ||
591 | } | ||
592 | } | ||
593 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
594 | if Self::can_cast(syntax.kind()) { | ||
595 | Some(Self { syntax }) | ||
596 | } else { | ||
597 | None | ||
598 | } | ||
599 | } | ||
600 | fn syntax(&self) -> &SyntaxToken { | ||
601 | &self.syntax | ||
602 | } | ||
603 | } | ||
604 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
605 | pub struct Underscore { | ||
606 | pub(crate) syntax: SyntaxToken, | ||
607 | } | ||
608 | impl std::fmt::Display for Underscore { | ||
609 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
610 | std::fmt::Display::fmt(&self.syntax, f) | ||
611 | } | ||
612 | } | ||
613 | impl AstToken for Underscore { | ||
614 | fn can_cast(kind: SyntaxKind) -> bool { | ||
615 | match kind { | ||
616 | UNDERSCORE => true, | ||
617 | _ => false, | ||
618 | } | ||
619 | } | ||
620 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
621 | if Self::can_cast(syntax.kind()) { | ||
622 | Some(Self { syntax }) | ||
623 | } else { | ||
624 | None | ||
625 | } | ||
626 | } | ||
627 | fn syntax(&self) -> &SyntaxToken { | ||
628 | &self.syntax | ||
629 | } | ||
630 | } | ||
631 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
632 | pub struct Dot { | ||
633 | pub(crate) syntax: SyntaxToken, | ||
634 | } | ||
635 | impl std::fmt::Display for Dot { | ||
636 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
637 | std::fmt::Display::fmt(&self.syntax, f) | ||
638 | } | ||
639 | } | ||
640 | impl AstToken for Dot { | ||
641 | fn can_cast(kind: SyntaxKind) -> bool { | ||
642 | match kind { | ||
643 | DOT => true, | ||
644 | _ => false, | ||
645 | } | ||
646 | } | ||
647 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
648 | if Self::can_cast(syntax.kind()) { | ||
649 | Some(Self { syntax }) | ||
650 | } else { | ||
651 | None | ||
652 | } | ||
653 | } | ||
654 | fn syntax(&self) -> &SyntaxToken { | ||
655 | &self.syntax | ||
656 | } | ||
657 | } | ||
658 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
659 | pub struct Dotdot { | ||
660 | pub(crate) syntax: SyntaxToken, | ||
661 | } | ||
662 | impl std::fmt::Display for Dotdot { | ||
663 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
664 | std::fmt::Display::fmt(&self.syntax, f) | ||
665 | } | ||
666 | } | ||
667 | impl AstToken for Dotdot { | ||
668 | fn can_cast(kind: SyntaxKind) -> bool { | ||
669 | match kind { | ||
670 | DOTDOT => true, | ||
671 | _ => false, | ||
672 | } | ||
673 | } | ||
674 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
675 | if Self::can_cast(syntax.kind()) { | ||
676 | Some(Self { syntax }) | ||
677 | } else { | ||
678 | None | ||
679 | } | ||
680 | } | ||
681 | fn syntax(&self) -> &SyntaxToken { | ||
682 | &self.syntax | ||
683 | } | ||
684 | } | ||
685 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
686 | pub struct Dotdotdot { | ||
687 | pub(crate) syntax: SyntaxToken, | ||
688 | } | ||
689 | impl std::fmt::Display for Dotdotdot { | ||
690 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
691 | std::fmt::Display::fmt(&self.syntax, f) | ||
692 | } | ||
693 | } | ||
694 | impl AstToken for Dotdotdot { | ||
695 | fn can_cast(kind: SyntaxKind) -> bool { | ||
696 | match kind { | ||
697 | DOTDOTDOT => true, | ||
698 | _ => false, | ||
699 | } | ||
700 | } | ||
701 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
702 | if Self::can_cast(syntax.kind()) { | ||
703 | Some(Self { syntax }) | ||
704 | } else { | ||
705 | None | ||
706 | } | ||
707 | } | ||
708 | fn syntax(&self) -> &SyntaxToken { | ||
709 | &self.syntax | ||
710 | } | ||
711 | } | ||
712 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
713 | pub struct Dotdoteq { | ||
714 | pub(crate) syntax: SyntaxToken, | ||
715 | } | ||
716 | impl std::fmt::Display for Dotdoteq { | ||
717 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
718 | std::fmt::Display::fmt(&self.syntax, f) | ||
719 | } | ||
720 | } | ||
721 | impl AstToken for Dotdoteq { | ||
722 | fn can_cast(kind: SyntaxKind) -> bool { | ||
723 | match kind { | ||
724 | DOTDOTEQ => true, | ||
725 | _ => false, | ||
726 | } | ||
727 | } | ||
728 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
729 | if Self::can_cast(syntax.kind()) { | ||
730 | Some(Self { syntax }) | ||
731 | } else { | ||
732 | None | ||
733 | } | ||
734 | } | ||
735 | fn syntax(&self) -> &SyntaxToken { | ||
736 | &self.syntax | ||
737 | } | ||
738 | } | ||
739 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
740 | pub struct Colon { | ||
741 | pub(crate) syntax: SyntaxToken, | ||
742 | } | ||
743 | impl std::fmt::Display for Colon { | ||
744 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
745 | std::fmt::Display::fmt(&self.syntax, f) | ||
746 | } | ||
747 | } | ||
748 | impl AstToken for Colon { | ||
749 | fn can_cast(kind: SyntaxKind) -> bool { | ||
750 | match kind { | ||
751 | COLON => true, | ||
752 | _ => false, | ||
753 | } | ||
754 | } | ||
755 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
756 | if Self::can_cast(syntax.kind()) { | ||
757 | Some(Self { syntax }) | ||
758 | } else { | ||
759 | None | ||
760 | } | ||
761 | } | ||
762 | fn syntax(&self) -> &SyntaxToken { | ||
763 | &self.syntax | ||
764 | } | ||
765 | } | ||
766 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
767 | pub struct Coloncolon { | ||
768 | pub(crate) syntax: SyntaxToken, | ||
769 | } | ||
770 | impl std::fmt::Display for Coloncolon { | ||
771 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
772 | std::fmt::Display::fmt(&self.syntax, f) | ||
773 | } | ||
774 | } | ||
775 | impl AstToken for Coloncolon { | ||
776 | fn can_cast(kind: SyntaxKind) -> bool { | ||
777 | match kind { | ||
778 | COLONCOLON => true, | ||
779 | _ => false, | ||
780 | } | ||
781 | } | ||
782 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
783 | if Self::can_cast(syntax.kind()) { | ||
784 | Some(Self { syntax }) | ||
785 | } else { | ||
786 | None | ||
787 | } | ||
788 | } | ||
789 | fn syntax(&self) -> &SyntaxToken { | ||
790 | &self.syntax | ||
791 | } | ||
792 | } | ||
793 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
794 | pub struct Eq { | ||
795 | pub(crate) syntax: SyntaxToken, | ||
796 | } | ||
797 | impl std::fmt::Display for Eq { | ||
798 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
799 | std::fmt::Display::fmt(&self.syntax, f) | ||
800 | } | ||
801 | } | ||
802 | impl AstToken for Eq { | ||
803 | fn can_cast(kind: SyntaxKind) -> bool { | ||
804 | match kind { | ||
805 | EQ => true, | ||
806 | _ => false, | ||
807 | } | ||
808 | } | ||
809 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
810 | if Self::can_cast(syntax.kind()) { | ||
811 | Some(Self { syntax }) | ||
812 | } else { | ||
813 | None | ||
814 | } | ||
815 | } | ||
816 | fn syntax(&self) -> &SyntaxToken { | ||
817 | &self.syntax | ||
818 | } | ||
819 | } | ||
820 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
821 | pub struct Eqeq { | ||
822 | pub(crate) syntax: SyntaxToken, | ||
823 | } | ||
824 | impl std::fmt::Display for Eqeq { | ||
825 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
826 | std::fmt::Display::fmt(&self.syntax, f) | ||
827 | } | ||
828 | } | ||
829 | impl AstToken for Eqeq { | ||
830 | fn can_cast(kind: SyntaxKind) -> bool { | ||
831 | match kind { | ||
832 | EQEQ => true, | ||
833 | _ => false, | ||
834 | } | ||
835 | } | ||
836 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
837 | if Self::can_cast(syntax.kind()) { | ||
838 | Some(Self { syntax }) | ||
839 | } else { | ||
840 | None | ||
841 | } | ||
842 | } | ||
843 | fn syntax(&self) -> &SyntaxToken { | ||
844 | &self.syntax | ||
845 | } | ||
846 | } | ||
847 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
848 | pub struct FatArrow { | ||
849 | pub(crate) syntax: SyntaxToken, | ||
850 | } | ||
851 | impl std::fmt::Display for FatArrow { | ||
852 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
853 | std::fmt::Display::fmt(&self.syntax, f) | ||
854 | } | ||
855 | } | ||
856 | impl AstToken for FatArrow { | ||
857 | fn can_cast(kind: SyntaxKind) -> bool { | ||
858 | match kind { | ||
859 | FAT_ARROW => true, | ||
860 | _ => false, | ||
861 | } | ||
862 | } | ||
863 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
864 | if Self::can_cast(syntax.kind()) { | ||
865 | Some(Self { syntax }) | ||
866 | } else { | ||
867 | None | ||
868 | } | ||
869 | } | ||
870 | fn syntax(&self) -> &SyntaxToken { | ||
871 | &self.syntax | ||
872 | } | ||
873 | } | ||
874 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
875 | pub struct Excl { | ||
876 | pub(crate) syntax: SyntaxToken, | ||
877 | } | ||
878 | impl std::fmt::Display for Excl { | ||
879 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
880 | std::fmt::Display::fmt(&self.syntax, f) | ||
881 | } | ||
882 | } | ||
883 | impl AstToken for Excl { | ||
884 | fn can_cast(kind: SyntaxKind) -> bool { | ||
885 | match kind { | ||
886 | EXCL => true, | ||
887 | _ => false, | ||
888 | } | ||
889 | } | ||
890 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
891 | if Self::can_cast(syntax.kind()) { | ||
892 | Some(Self { syntax }) | ||
893 | } else { | ||
894 | None | ||
895 | } | ||
896 | } | ||
897 | fn syntax(&self) -> &SyntaxToken { | ||
898 | &self.syntax | ||
899 | } | ||
900 | } | ||
901 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
902 | pub struct Neq { | ||
903 | pub(crate) syntax: SyntaxToken, | ||
904 | } | ||
905 | impl std::fmt::Display for Neq { | ||
906 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
907 | std::fmt::Display::fmt(&self.syntax, f) | ||
908 | } | ||
909 | } | ||
910 | impl AstToken for Neq { | ||
911 | fn can_cast(kind: SyntaxKind) -> bool { | ||
912 | match kind { | ||
913 | NEQ => true, | ||
914 | _ => false, | ||
915 | } | ||
916 | } | ||
917 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
918 | if Self::can_cast(syntax.kind()) { | ||
919 | Some(Self { syntax }) | ||
920 | } else { | ||
921 | None | ||
922 | } | ||
923 | } | ||
924 | fn syntax(&self) -> &SyntaxToken { | ||
925 | &self.syntax | ||
926 | } | ||
927 | } | ||
928 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
929 | pub struct Minus { | ||
930 | pub(crate) syntax: SyntaxToken, | ||
931 | } | ||
932 | impl std::fmt::Display for Minus { | ||
933 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
934 | std::fmt::Display::fmt(&self.syntax, f) | ||
935 | } | ||
936 | } | ||
937 | impl AstToken for Minus { | ||
938 | fn can_cast(kind: SyntaxKind) -> bool { | ||
939 | match kind { | ||
940 | MINUS => true, | ||
941 | _ => false, | ||
942 | } | ||
943 | } | ||
944 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
945 | if Self::can_cast(syntax.kind()) { | ||
946 | Some(Self { syntax }) | ||
947 | } else { | ||
948 | None | ||
949 | } | ||
950 | } | ||
951 | fn syntax(&self) -> &SyntaxToken { | ||
952 | &self.syntax | ||
953 | } | ||
954 | } | ||
955 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
956 | pub struct ThinArrow { | ||
957 | pub(crate) syntax: SyntaxToken, | ||
958 | } | ||
959 | impl std::fmt::Display for ThinArrow { | ||
960 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
961 | std::fmt::Display::fmt(&self.syntax, f) | ||
962 | } | ||
963 | } | ||
964 | impl AstToken for ThinArrow { | ||
965 | fn can_cast(kind: SyntaxKind) -> bool { | ||
966 | match kind { | ||
967 | THIN_ARROW => true, | ||
968 | _ => false, | ||
969 | } | ||
970 | } | ||
971 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
972 | if Self::can_cast(syntax.kind()) { | ||
973 | Some(Self { syntax }) | ||
974 | } else { | ||
975 | None | ||
976 | } | ||
977 | } | ||
978 | fn syntax(&self) -> &SyntaxToken { | ||
979 | &self.syntax | ||
980 | } | ||
981 | } | ||
982 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
983 | pub struct Lteq { | ||
984 | pub(crate) syntax: SyntaxToken, | ||
985 | } | ||
986 | impl std::fmt::Display for Lteq { | ||
987 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
988 | std::fmt::Display::fmt(&self.syntax, f) | ||
989 | } | ||
990 | } | ||
991 | impl AstToken for Lteq { | ||
992 | fn can_cast(kind: SyntaxKind) -> bool { | ||
993 | match kind { | ||
994 | LTEQ => true, | ||
995 | _ => false, | ||
996 | } | ||
997 | } | ||
998 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
999 | if Self::can_cast(syntax.kind()) { | ||
1000 | Some(Self { syntax }) | ||
1001 | } else { | ||
1002 | None | ||
1003 | } | ||
1004 | } | ||
1005 | fn syntax(&self) -> &SyntaxToken { | ||
1006 | &self.syntax | ||
1007 | } | ||
1008 | } | ||
1009 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1010 | pub struct Gteq { | ||
1011 | pub(crate) syntax: SyntaxToken, | ||
1012 | } | ||
1013 | impl std::fmt::Display for Gteq { | ||
1014 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1015 | std::fmt::Display::fmt(&self.syntax, f) | ||
1016 | } | ||
1017 | } | ||
1018 | impl AstToken for Gteq { | ||
1019 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1020 | match kind { | ||
1021 | GTEQ => true, | ||
1022 | _ => false, | ||
1023 | } | ||
1024 | } | ||
1025 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1026 | if Self::can_cast(syntax.kind()) { | ||
1027 | Some(Self { syntax }) | ||
1028 | } else { | ||
1029 | None | ||
1030 | } | ||
1031 | } | ||
1032 | fn syntax(&self) -> &SyntaxToken { | ||
1033 | &self.syntax | ||
1034 | } | ||
1035 | } | ||
1036 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1037 | pub struct Pluseq { | ||
1038 | pub(crate) syntax: SyntaxToken, | ||
1039 | } | ||
1040 | impl std::fmt::Display for Pluseq { | ||
1041 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1042 | std::fmt::Display::fmt(&self.syntax, f) | ||
1043 | } | ||
1044 | } | ||
1045 | impl AstToken for Pluseq { | ||
1046 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1047 | match kind { | ||
1048 | PLUSEQ => true, | ||
1049 | _ => false, | ||
1050 | } | ||
1051 | } | ||
1052 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1053 | if Self::can_cast(syntax.kind()) { | ||
1054 | Some(Self { syntax }) | ||
1055 | } else { | ||
1056 | None | ||
1057 | } | ||
1058 | } | ||
1059 | fn syntax(&self) -> &SyntaxToken { | ||
1060 | &self.syntax | ||
1061 | } | ||
1062 | } | ||
1063 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1064 | pub struct Minuseq { | ||
1065 | pub(crate) syntax: SyntaxToken, | ||
1066 | } | ||
1067 | impl std::fmt::Display for Minuseq { | ||
1068 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1069 | std::fmt::Display::fmt(&self.syntax, f) | ||
1070 | } | ||
1071 | } | ||
1072 | impl AstToken for Minuseq { | ||
1073 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1074 | match kind { | ||
1075 | MINUSEQ => true, | ||
1076 | _ => false, | ||
1077 | } | ||
1078 | } | ||
1079 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1080 | if Self::can_cast(syntax.kind()) { | ||
1081 | Some(Self { syntax }) | ||
1082 | } else { | ||
1083 | None | ||
1084 | } | ||
1085 | } | ||
1086 | fn syntax(&self) -> &SyntaxToken { | ||
1087 | &self.syntax | ||
1088 | } | ||
1089 | } | ||
1090 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1091 | pub struct Pipeeq { | ||
1092 | pub(crate) syntax: SyntaxToken, | ||
1093 | } | ||
1094 | impl std::fmt::Display for Pipeeq { | ||
1095 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1096 | std::fmt::Display::fmt(&self.syntax, f) | ||
1097 | } | ||
1098 | } | ||
1099 | impl AstToken for Pipeeq { | ||
1100 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1101 | match kind { | ||
1102 | PIPEEQ => true, | ||
1103 | _ => false, | ||
1104 | } | ||
1105 | } | ||
1106 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1107 | if Self::can_cast(syntax.kind()) { | ||
1108 | Some(Self { syntax }) | ||
1109 | } else { | ||
1110 | None | ||
1111 | } | ||
1112 | } | ||
1113 | fn syntax(&self) -> &SyntaxToken { | ||
1114 | &self.syntax | ||
1115 | } | ||
1116 | } | ||
1117 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1118 | pub struct Ampeq { | ||
1119 | pub(crate) syntax: SyntaxToken, | ||
1120 | } | ||
1121 | impl std::fmt::Display for Ampeq { | ||
1122 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1123 | std::fmt::Display::fmt(&self.syntax, f) | ||
1124 | } | ||
1125 | } | ||
1126 | impl AstToken for Ampeq { | ||
1127 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1128 | match kind { | ||
1129 | AMPEQ => true, | ||
1130 | _ => false, | ||
1131 | } | ||
1132 | } | ||
1133 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1134 | if Self::can_cast(syntax.kind()) { | ||
1135 | Some(Self { syntax }) | ||
1136 | } else { | ||
1137 | None | ||
1138 | } | ||
1139 | } | ||
1140 | fn syntax(&self) -> &SyntaxToken { | ||
1141 | &self.syntax | ||
1142 | } | ||
1143 | } | ||
1144 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1145 | pub struct Careteq { | ||
1146 | pub(crate) syntax: SyntaxToken, | ||
1147 | } | ||
1148 | impl std::fmt::Display for Careteq { | ||
1149 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1150 | std::fmt::Display::fmt(&self.syntax, f) | ||
1151 | } | ||
1152 | } | ||
1153 | impl AstToken for Careteq { | ||
1154 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1155 | match kind { | ||
1156 | CARETEQ => true, | ||
1157 | _ => false, | ||
1158 | } | ||
1159 | } | ||
1160 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1161 | if Self::can_cast(syntax.kind()) { | ||
1162 | Some(Self { syntax }) | ||
1163 | } else { | ||
1164 | None | ||
1165 | } | ||
1166 | } | ||
1167 | fn syntax(&self) -> &SyntaxToken { | ||
1168 | &self.syntax | ||
1169 | } | ||
1170 | } | ||
1171 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1172 | pub struct Slasheq { | ||
1173 | pub(crate) syntax: SyntaxToken, | ||
1174 | } | ||
1175 | impl std::fmt::Display for Slasheq { | ||
1176 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1177 | std::fmt::Display::fmt(&self.syntax, f) | ||
1178 | } | ||
1179 | } | ||
1180 | impl AstToken for Slasheq { | ||
1181 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1182 | match kind { | ||
1183 | SLASHEQ => true, | ||
1184 | _ => false, | ||
1185 | } | ||
1186 | } | ||
1187 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1188 | if Self::can_cast(syntax.kind()) { | ||
1189 | Some(Self { syntax }) | ||
1190 | } else { | ||
1191 | None | ||
1192 | } | ||
1193 | } | ||
1194 | fn syntax(&self) -> &SyntaxToken { | ||
1195 | &self.syntax | ||
1196 | } | ||
1197 | } | ||
1198 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1199 | pub struct Stareq { | ||
1200 | pub(crate) syntax: SyntaxToken, | ||
1201 | } | ||
1202 | impl std::fmt::Display for Stareq { | ||
1203 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1204 | std::fmt::Display::fmt(&self.syntax, f) | ||
1205 | } | ||
1206 | } | ||
1207 | impl AstToken for Stareq { | ||
1208 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1209 | match kind { | ||
1210 | STAREQ => true, | ||
1211 | _ => false, | ||
1212 | } | ||
1213 | } | ||
1214 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1215 | if Self::can_cast(syntax.kind()) { | ||
1216 | Some(Self { syntax }) | ||
1217 | } else { | ||
1218 | None | ||
1219 | } | ||
1220 | } | ||
1221 | fn syntax(&self) -> &SyntaxToken { | ||
1222 | &self.syntax | ||
1223 | } | ||
1224 | } | ||
1225 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1226 | pub struct Percenteq { | ||
1227 | pub(crate) syntax: SyntaxToken, | ||
1228 | } | ||
1229 | impl std::fmt::Display for Percenteq { | ||
1230 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1231 | std::fmt::Display::fmt(&self.syntax, f) | ||
1232 | } | ||
1233 | } | ||
1234 | impl AstToken for Percenteq { | ||
1235 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1236 | match kind { | ||
1237 | PERCENTEQ => true, | ||
1238 | _ => false, | ||
1239 | } | ||
1240 | } | ||
1241 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1242 | if Self::can_cast(syntax.kind()) { | ||
1243 | Some(Self { syntax }) | ||
1244 | } else { | ||
1245 | None | ||
1246 | } | ||
1247 | } | ||
1248 | fn syntax(&self) -> &SyntaxToken { | ||
1249 | &self.syntax | ||
1250 | } | ||
1251 | } | ||
1252 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1253 | pub struct Ampamp { | ||
1254 | pub(crate) syntax: SyntaxToken, | ||
1255 | } | ||
1256 | impl std::fmt::Display for Ampamp { | ||
1257 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1258 | std::fmt::Display::fmt(&self.syntax, f) | ||
1259 | } | ||
1260 | } | ||
1261 | impl AstToken for Ampamp { | ||
1262 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1263 | match kind { | ||
1264 | AMPAMP => true, | ||
1265 | _ => false, | ||
1266 | } | ||
1267 | } | ||
1268 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1269 | if Self::can_cast(syntax.kind()) { | ||
1270 | Some(Self { syntax }) | ||
1271 | } else { | ||
1272 | None | ||
1273 | } | ||
1274 | } | ||
1275 | fn syntax(&self) -> &SyntaxToken { | ||
1276 | &self.syntax | ||
1277 | } | ||
1278 | } | ||
1279 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1280 | pub struct Pipepipe { | ||
1281 | pub(crate) syntax: SyntaxToken, | ||
1282 | } | ||
1283 | impl std::fmt::Display for Pipepipe { | ||
1284 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1285 | std::fmt::Display::fmt(&self.syntax, f) | ||
1286 | } | ||
1287 | } | ||
1288 | impl AstToken for Pipepipe { | ||
1289 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1290 | match kind { | ||
1291 | PIPEPIPE => true, | ||
1292 | _ => false, | ||
1293 | } | ||
1294 | } | ||
1295 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1296 | if Self::can_cast(syntax.kind()) { | ||
1297 | Some(Self { syntax }) | ||
1298 | } else { | ||
1299 | None | ||
1300 | } | ||
1301 | } | ||
1302 | fn syntax(&self) -> &SyntaxToken { | ||
1303 | &self.syntax | ||
1304 | } | ||
1305 | } | ||
1306 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1307 | pub struct Shl { | ||
1308 | pub(crate) syntax: SyntaxToken, | ||
1309 | } | ||
1310 | impl std::fmt::Display for Shl { | ||
1311 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1312 | std::fmt::Display::fmt(&self.syntax, f) | ||
1313 | } | ||
1314 | } | ||
1315 | impl AstToken for Shl { | ||
1316 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1317 | match kind { | ||
1318 | SHL => true, | ||
1319 | _ => false, | ||
1320 | } | ||
1321 | } | ||
1322 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1323 | if Self::can_cast(syntax.kind()) { | ||
1324 | Some(Self { syntax }) | ||
1325 | } else { | ||
1326 | None | ||
1327 | } | ||
1328 | } | ||
1329 | fn syntax(&self) -> &SyntaxToken { | ||
1330 | &self.syntax | ||
1331 | } | ||
1332 | } | ||
1333 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1334 | pub struct Shr { | ||
1335 | pub(crate) syntax: SyntaxToken, | ||
1336 | } | ||
1337 | impl std::fmt::Display for Shr { | ||
1338 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1339 | std::fmt::Display::fmt(&self.syntax, f) | ||
1340 | } | ||
1341 | } | ||
1342 | impl AstToken for Shr { | ||
1343 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1344 | match kind { | ||
1345 | SHR => true, | ||
1346 | _ => false, | ||
1347 | } | ||
1348 | } | ||
1349 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1350 | if Self::can_cast(syntax.kind()) { | ||
1351 | Some(Self { syntax }) | ||
1352 | } else { | ||
1353 | None | ||
1354 | } | ||
1355 | } | ||
1356 | fn syntax(&self) -> &SyntaxToken { | ||
1357 | &self.syntax | ||
1358 | } | ||
1359 | } | ||
1360 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1361 | pub struct Shleq { | ||
1362 | pub(crate) syntax: SyntaxToken, | ||
1363 | } | ||
1364 | impl std::fmt::Display for Shleq { | ||
1365 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1366 | std::fmt::Display::fmt(&self.syntax, f) | ||
1367 | } | ||
1368 | } | ||
1369 | impl AstToken for Shleq { | ||
1370 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1371 | match kind { | ||
1372 | SHLEQ => true, | ||
1373 | _ => false, | ||
1374 | } | ||
1375 | } | ||
1376 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1377 | if Self::can_cast(syntax.kind()) { | ||
1378 | Some(Self { syntax }) | ||
1379 | } else { | ||
1380 | None | ||
1381 | } | ||
1382 | } | ||
1383 | fn syntax(&self) -> &SyntaxToken { | ||
1384 | &self.syntax | ||
1385 | } | ||
1386 | } | ||
1387 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1388 | pub struct Shreq { | ||
1389 | pub(crate) syntax: SyntaxToken, | ||
1390 | } | ||
1391 | impl std::fmt::Display for Shreq { | ||
1392 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1393 | std::fmt::Display::fmt(&self.syntax, f) | ||
1394 | } | ||
1395 | } | ||
1396 | impl AstToken for Shreq { | ||
1397 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1398 | match kind { | ||
1399 | SHREQ => true, | ||
1400 | _ => false, | ||
1401 | } | ||
1402 | } | ||
1403 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1404 | if Self::can_cast(syntax.kind()) { | ||
1405 | Some(Self { syntax }) | ||
1406 | } else { | ||
1407 | None | ||
1408 | } | ||
1409 | } | ||
1410 | fn syntax(&self) -> &SyntaxToken { | ||
1411 | &self.syntax | ||
1412 | } | ||
1413 | } | ||
1414 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1415 | pub struct AsKw { | ||
1416 | pub(crate) syntax: SyntaxToken, | ||
1417 | } | ||
1418 | impl std::fmt::Display for AsKw { | ||
1419 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1420 | std::fmt::Display::fmt(&self.syntax, f) | ||
1421 | } | ||
1422 | } | ||
1423 | impl AstToken for AsKw { | ||
1424 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1425 | match kind { | ||
1426 | AS_KW => true, | ||
1427 | _ => false, | ||
1428 | } | ||
1429 | } | ||
1430 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1431 | if Self::can_cast(syntax.kind()) { | ||
1432 | Some(Self { syntax }) | ||
1433 | } else { | ||
1434 | None | ||
1435 | } | ||
1436 | } | ||
1437 | fn syntax(&self) -> &SyntaxToken { | ||
1438 | &self.syntax | ||
1439 | } | ||
1440 | } | ||
1441 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1442 | pub struct AsyncKw { | ||
1443 | pub(crate) syntax: SyntaxToken, | ||
1444 | } | ||
1445 | impl std::fmt::Display for AsyncKw { | ||
1446 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1447 | std::fmt::Display::fmt(&self.syntax, f) | ||
1448 | } | ||
1449 | } | ||
1450 | impl AstToken for AsyncKw { | ||
1451 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1452 | match kind { | ||
1453 | ASYNC_KW => true, | ||
1454 | _ => false, | ||
1455 | } | ||
1456 | } | ||
1457 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1458 | if Self::can_cast(syntax.kind()) { | ||
1459 | Some(Self { syntax }) | ||
1460 | } else { | ||
1461 | None | ||
1462 | } | ||
1463 | } | ||
1464 | fn syntax(&self) -> &SyntaxToken { | ||
1465 | &self.syntax | ||
1466 | } | ||
1467 | } | ||
1468 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1469 | pub struct AwaitKw { | ||
1470 | pub(crate) syntax: SyntaxToken, | ||
1471 | } | ||
1472 | impl std::fmt::Display for AwaitKw { | ||
1473 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1474 | std::fmt::Display::fmt(&self.syntax, f) | ||
1475 | } | ||
1476 | } | ||
1477 | impl AstToken for AwaitKw { | ||
1478 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1479 | match kind { | ||
1480 | AWAIT_KW => true, | ||
1481 | _ => false, | ||
1482 | } | ||
1483 | } | ||
1484 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1485 | if Self::can_cast(syntax.kind()) { | ||
1486 | Some(Self { syntax }) | ||
1487 | } else { | ||
1488 | None | ||
1489 | } | ||
1490 | } | ||
1491 | fn syntax(&self) -> &SyntaxToken { | ||
1492 | &self.syntax | ||
1493 | } | ||
1494 | } | ||
1495 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1496 | pub struct BoxKw { | ||
1497 | pub(crate) syntax: SyntaxToken, | ||
1498 | } | ||
1499 | impl std::fmt::Display for BoxKw { | ||
1500 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1501 | std::fmt::Display::fmt(&self.syntax, f) | ||
1502 | } | ||
1503 | } | ||
1504 | impl AstToken for BoxKw { | ||
1505 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1506 | match kind { | ||
1507 | BOX_KW => true, | ||
1508 | _ => false, | ||
1509 | } | ||
1510 | } | ||
1511 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1512 | if Self::can_cast(syntax.kind()) { | ||
1513 | Some(Self { syntax }) | ||
1514 | } else { | ||
1515 | None | ||
1516 | } | ||
1517 | } | ||
1518 | fn syntax(&self) -> &SyntaxToken { | ||
1519 | &self.syntax | ||
1520 | } | ||
1521 | } | ||
1522 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1523 | pub struct BreakKw { | ||
1524 | pub(crate) syntax: SyntaxToken, | ||
1525 | } | ||
1526 | impl std::fmt::Display for BreakKw { | ||
1527 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1528 | std::fmt::Display::fmt(&self.syntax, f) | ||
1529 | } | ||
1530 | } | ||
1531 | impl AstToken for BreakKw { | ||
1532 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1533 | match kind { | ||
1534 | BREAK_KW => true, | ||
1535 | _ => false, | ||
1536 | } | ||
1537 | } | ||
1538 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1539 | if Self::can_cast(syntax.kind()) { | ||
1540 | Some(Self { syntax }) | ||
1541 | } else { | ||
1542 | None | ||
1543 | } | ||
1544 | } | ||
1545 | fn syntax(&self) -> &SyntaxToken { | ||
1546 | &self.syntax | ||
1547 | } | ||
1548 | } | ||
1549 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1550 | pub struct ConstKw { | ||
1551 | pub(crate) syntax: SyntaxToken, | ||
1552 | } | ||
1553 | impl std::fmt::Display for ConstKw { | ||
1554 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1555 | std::fmt::Display::fmt(&self.syntax, f) | ||
1556 | } | ||
1557 | } | ||
1558 | impl AstToken for ConstKw { | ||
1559 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1560 | match kind { | ||
1561 | CONST_KW => true, | ||
1562 | _ => false, | ||
1563 | } | ||
1564 | } | ||
1565 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1566 | if Self::can_cast(syntax.kind()) { | ||
1567 | Some(Self { syntax }) | ||
1568 | } else { | ||
1569 | None | ||
1570 | } | ||
1571 | } | ||
1572 | fn syntax(&self) -> &SyntaxToken { | ||
1573 | &self.syntax | ||
1574 | } | ||
1575 | } | ||
1576 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1577 | pub struct ContinueKw { | ||
1578 | pub(crate) syntax: SyntaxToken, | ||
1579 | } | ||
1580 | impl std::fmt::Display for ContinueKw { | ||
1581 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1582 | std::fmt::Display::fmt(&self.syntax, f) | ||
1583 | } | ||
1584 | } | ||
1585 | impl AstToken for ContinueKw { | ||
1586 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1587 | match kind { | ||
1588 | CONTINUE_KW => true, | ||
1589 | _ => false, | ||
1590 | } | ||
1591 | } | ||
1592 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1593 | if Self::can_cast(syntax.kind()) { | ||
1594 | Some(Self { syntax }) | ||
1595 | } else { | ||
1596 | None | ||
1597 | } | ||
1598 | } | ||
1599 | fn syntax(&self) -> &SyntaxToken { | ||
1600 | &self.syntax | ||
1601 | } | ||
1602 | } | ||
1603 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1604 | pub struct CrateKw { | ||
1605 | pub(crate) syntax: SyntaxToken, | ||
1606 | } | ||
1607 | impl std::fmt::Display for CrateKw { | ||
1608 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1609 | std::fmt::Display::fmt(&self.syntax, f) | ||
1610 | } | ||
1611 | } | ||
1612 | impl AstToken for CrateKw { | ||
1613 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1614 | match kind { | ||
1615 | CRATE_KW => true, | ||
1616 | _ => false, | ||
1617 | } | ||
1618 | } | ||
1619 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1620 | if Self::can_cast(syntax.kind()) { | ||
1621 | Some(Self { syntax }) | ||
1622 | } else { | ||
1623 | None | ||
1624 | } | ||
1625 | } | ||
1626 | fn syntax(&self) -> &SyntaxToken { | ||
1627 | &self.syntax | ||
1628 | } | ||
1629 | } | ||
1630 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1631 | pub struct DynKw { | ||
1632 | pub(crate) syntax: SyntaxToken, | ||
1633 | } | ||
1634 | impl std::fmt::Display for DynKw { | ||
1635 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1636 | std::fmt::Display::fmt(&self.syntax, f) | ||
1637 | } | ||
1638 | } | ||
1639 | impl AstToken for DynKw { | ||
1640 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1641 | match kind { | ||
1642 | DYN_KW => true, | ||
1643 | _ => false, | ||
1644 | } | ||
1645 | } | ||
1646 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1647 | if Self::can_cast(syntax.kind()) { | ||
1648 | Some(Self { syntax }) | ||
1649 | } else { | ||
1650 | None | ||
1651 | } | ||
1652 | } | ||
1653 | fn syntax(&self) -> &SyntaxToken { | ||
1654 | &self.syntax | ||
1655 | } | ||
1656 | } | ||
1657 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1658 | pub struct ElseKw { | ||
1659 | pub(crate) syntax: SyntaxToken, | ||
1660 | } | ||
1661 | impl std::fmt::Display for ElseKw { | ||
1662 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1663 | std::fmt::Display::fmt(&self.syntax, f) | ||
1664 | } | ||
1665 | } | ||
1666 | impl AstToken for ElseKw { | ||
1667 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1668 | match kind { | ||
1669 | ELSE_KW => true, | ||
1670 | _ => false, | ||
1671 | } | ||
1672 | } | ||
1673 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1674 | if Self::can_cast(syntax.kind()) { | ||
1675 | Some(Self { syntax }) | ||
1676 | } else { | ||
1677 | None | ||
1678 | } | ||
1679 | } | ||
1680 | fn syntax(&self) -> &SyntaxToken { | ||
1681 | &self.syntax | ||
1682 | } | ||
1683 | } | ||
1684 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1685 | pub struct EnumKw { | ||
1686 | pub(crate) syntax: SyntaxToken, | ||
1687 | } | ||
1688 | impl std::fmt::Display for EnumKw { | ||
1689 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1690 | std::fmt::Display::fmt(&self.syntax, f) | ||
1691 | } | ||
1692 | } | ||
1693 | impl AstToken for EnumKw { | ||
1694 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1695 | match kind { | ||
1696 | ENUM_KW => true, | ||
1697 | _ => false, | ||
1698 | } | ||
1699 | } | ||
1700 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1701 | if Self::can_cast(syntax.kind()) { | ||
1702 | Some(Self { syntax }) | ||
1703 | } else { | ||
1704 | None | ||
1705 | } | ||
1706 | } | ||
1707 | fn syntax(&self) -> &SyntaxToken { | ||
1708 | &self.syntax | ||
1709 | } | ||
1710 | } | ||
1711 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1712 | pub struct ExternKw { | ||
1713 | pub(crate) syntax: SyntaxToken, | ||
1714 | } | ||
1715 | impl std::fmt::Display for ExternKw { | ||
1716 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1717 | std::fmt::Display::fmt(&self.syntax, f) | ||
1718 | } | ||
1719 | } | ||
1720 | impl AstToken for ExternKw { | ||
1721 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1722 | match kind { | ||
1723 | EXTERN_KW => true, | ||
1724 | _ => false, | ||
1725 | } | ||
1726 | } | ||
1727 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1728 | if Self::can_cast(syntax.kind()) { | ||
1729 | Some(Self { syntax }) | ||
1730 | } else { | ||
1731 | None | ||
1732 | } | ||
1733 | } | ||
1734 | fn syntax(&self) -> &SyntaxToken { | ||
1735 | &self.syntax | ||
1736 | } | ||
1737 | } | ||
1738 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1739 | pub struct FalseKw { | ||
1740 | pub(crate) syntax: SyntaxToken, | ||
1741 | } | ||
1742 | impl std::fmt::Display for FalseKw { | ||
1743 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1744 | std::fmt::Display::fmt(&self.syntax, f) | ||
1745 | } | ||
1746 | } | ||
1747 | impl AstToken for FalseKw { | ||
1748 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1749 | match kind { | ||
1750 | FALSE_KW => true, | ||
1751 | _ => false, | ||
1752 | } | ||
1753 | } | ||
1754 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1755 | if Self::can_cast(syntax.kind()) { | ||
1756 | Some(Self { syntax }) | ||
1757 | } else { | ||
1758 | None | ||
1759 | } | ||
1760 | } | ||
1761 | fn syntax(&self) -> &SyntaxToken { | ||
1762 | &self.syntax | ||
1763 | } | ||
1764 | } | ||
1765 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1766 | pub struct FnKw { | ||
1767 | pub(crate) syntax: SyntaxToken, | ||
1768 | } | ||
1769 | impl std::fmt::Display for FnKw { | ||
1770 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1771 | std::fmt::Display::fmt(&self.syntax, f) | ||
1772 | } | ||
1773 | } | ||
1774 | impl AstToken for FnKw { | ||
1775 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1776 | match kind { | ||
1777 | FN_KW => true, | ||
1778 | _ => false, | ||
1779 | } | ||
1780 | } | ||
1781 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1782 | if Self::can_cast(syntax.kind()) { | ||
1783 | Some(Self { syntax }) | ||
1784 | } else { | ||
1785 | None | ||
1786 | } | ||
1787 | } | ||
1788 | fn syntax(&self) -> &SyntaxToken { | ||
1789 | &self.syntax | ||
1790 | } | ||
1791 | } | ||
1792 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1793 | pub struct ForKw { | ||
1794 | pub(crate) syntax: SyntaxToken, | ||
1795 | } | ||
1796 | impl std::fmt::Display for ForKw { | ||
1797 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1798 | std::fmt::Display::fmt(&self.syntax, f) | ||
1799 | } | ||
1800 | } | ||
1801 | impl AstToken for ForKw { | ||
1802 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1803 | match kind { | ||
1804 | FOR_KW => true, | ||
1805 | _ => false, | ||
1806 | } | ||
1807 | } | ||
1808 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1809 | if Self::can_cast(syntax.kind()) { | ||
1810 | Some(Self { syntax }) | ||
1811 | } else { | ||
1812 | None | ||
1813 | } | ||
1814 | } | ||
1815 | fn syntax(&self) -> &SyntaxToken { | ||
1816 | &self.syntax | ||
1817 | } | ||
1818 | } | ||
1819 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1820 | pub struct IfKw { | ||
1821 | pub(crate) syntax: SyntaxToken, | ||
1822 | } | ||
1823 | impl std::fmt::Display for IfKw { | ||
1824 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1825 | std::fmt::Display::fmt(&self.syntax, f) | ||
1826 | } | ||
1827 | } | ||
1828 | impl AstToken for IfKw { | ||
1829 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1830 | match kind { | ||
1831 | IF_KW => true, | ||
1832 | _ => false, | ||
1833 | } | ||
1834 | } | ||
1835 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1836 | if Self::can_cast(syntax.kind()) { | ||
1837 | Some(Self { syntax }) | ||
1838 | } else { | ||
1839 | None | ||
1840 | } | ||
1841 | } | ||
1842 | fn syntax(&self) -> &SyntaxToken { | ||
1843 | &self.syntax | ||
1844 | } | ||
1845 | } | ||
1846 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1847 | pub struct ImplKw { | ||
1848 | pub(crate) syntax: SyntaxToken, | ||
1849 | } | ||
1850 | impl std::fmt::Display for ImplKw { | ||
1851 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1852 | std::fmt::Display::fmt(&self.syntax, f) | ||
1853 | } | ||
1854 | } | ||
1855 | impl AstToken for ImplKw { | ||
1856 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1857 | match kind { | ||
1858 | IMPL_KW => true, | ||
1859 | _ => false, | ||
1860 | } | ||
1861 | } | ||
1862 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1863 | if Self::can_cast(syntax.kind()) { | ||
1864 | Some(Self { syntax }) | ||
1865 | } else { | ||
1866 | None | ||
1867 | } | ||
1868 | } | ||
1869 | fn syntax(&self) -> &SyntaxToken { | ||
1870 | &self.syntax | ||
1871 | } | ||
1872 | } | ||
1873 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1874 | pub struct InKw { | ||
1875 | pub(crate) syntax: SyntaxToken, | ||
1876 | } | ||
1877 | impl std::fmt::Display for InKw { | ||
1878 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1879 | std::fmt::Display::fmt(&self.syntax, f) | ||
1880 | } | ||
1881 | } | ||
1882 | impl AstToken for InKw { | ||
1883 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1884 | match kind { | ||
1885 | IN_KW => true, | ||
1886 | _ => false, | ||
1887 | } | ||
1888 | } | ||
1889 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1890 | if Self::can_cast(syntax.kind()) { | ||
1891 | Some(Self { syntax }) | ||
1892 | } else { | ||
1893 | None | ||
1894 | } | ||
1895 | } | ||
1896 | fn syntax(&self) -> &SyntaxToken { | ||
1897 | &self.syntax | ||
1898 | } | ||
1899 | } | ||
1900 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1901 | pub struct LetKw { | ||
1902 | pub(crate) syntax: SyntaxToken, | ||
1903 | } | ||
1904 | impl std::fmt::Display for LetKw { | ||
1905 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1906 | std::fmt::Display::fmt(&self.syntax, f) | ||
1907 | } | ||
1908 | } | ||
1909 | impl AstToken for LetKw { | ||
1910 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1911 | match kind { | ||
1912 | LET_KW => true, | ||
1913 | _ => false, | ||
1914 | } | ||
1915 | } | ||
1916 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1917 | if Self::can_cast(syntax.kind()) { | ||
1918 | Some(Self { syntax }) | ||
1919 | } else { | ||
1920 | None | ||
1921 | } | ||
1922 | } | ||
1923 | fn syntax(&self) -> &SyntaxToken { | ||
1924 | &self.syntax | ||
1925 | } | ||
1926 | } | ||
1927 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1928 | pub struct LoopKw { | ||
1929 | pub(crate) syntax: SyntaxToken, | ||
1930 | } | ||
1931 | impl std::fmt::Display for LoopKw { | ||
1932 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1933 | std::fmt::Display::fmt(&self.syntax, f) | ||
1934 | } | ||
1935 | } | ||
1936 | impl AstToken for LoopKw { | ||
1937 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1938 | match kind { | ||
1939 | LOOP_KW => true, | ||
1940 | _ => false, | ||
1941 | } | ||
1942 | } | ||
1943 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1944 | if Self::can_cast(syntax.kind()) { | ||
1945 | Some(Self { syntax }) | ||
1946 | } else { | ||
1947 | None | ||
1948 | } | ||
1949 | } | ||
1950 | fn syntax(&self) -> &SyntaxToken { | ||
1951 | &self.syntax | ||
1952 | } | ||
1953 | } | ||
1954 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1955 | pub struct MacroKw { | ||
1956 | pub(crate) syntax: SyntaxToken, | ||
1957 | } | ||
1958 | impl std::fmt::Display for MacroKw { | ||
1959 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1960 | std::fmt::Display::fmt(&self.syntax, f) | ||
1961 | } | ||
1962 | } | ||
1963 | impl AstToken for MacroKw { | ||
1964 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1965 | match kind { | ||
1966 | MACRO_KW => true, | ||
1967 | _ => false, | ||
1968 | } | ||
1969 | } | ||
1970 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1971 | if Self::can_cast(syntax.kind()) { | ||
1972 | Some(Self { syntax }) | ||
1973 | } else { | ||
1974 | None | ||
1975 | } | ||
1976 | } | ||
1977 | fn syntax(&self) -> &SyntaxToken { | ||
1978 | &self.syntax | ||
1979 | } | ||
1980 | } | ||
1981 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1982 | pub struct MatchKw { | ||
1983 | pub(crate) syntax: SyntaxToken, | ||
1984 | } | ||
1985 | impl std::fmt::Display for MatchKw { | ||
1986 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1987 | std::fmt::Display::fmt(&self.syntax, f) | ||
1988 | } | ||
1989 | } | ||
1990 | impl AstToken for MatchKw { | ||
1991 | fn can_cast(kind: SyntaxKind) -> bool { | ||
1992 | match kind { | ||
1993 | MATCH_KW => true, | ||
1994 | _ => false, | ||
1995 | } | ||
1996 | } | ||
1997 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1998 | if Self::can_cast(syntax.kind()) { | ||
1999 | Some(Self { syntax }) | ||
2000 | } else { | ||
2001 | None | ||
2002 | } | ||
2003 | } | ||
2004 | fn syntax(&self) -> &SyntaxToken { | ||
2005 | &self.syntax | ||
2006 | } | ||
2007 | } | ||
2008 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2009 | pub struct ModKw { | ||
2010 | pub(crate) syntax: SyntaxToken, | ||
2011 | } | ||
2012 | impl std::fmt::Display for ModKw { | ||
2013 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2014 | std::fmt::Display::fmt(&self.syntax, f) | ||
2015 | } | ||
2016 | } | ||
2017 | impl AstToken for ModKw { | ||
2018 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2019 | match kind { | ||
2020 | MOD_KW => true, | ||
2021 | _ => false, | ||
2022 | } | ||
2023 | } | ||
2024 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2025 | if Self::can_cast(syntax.kind()) { | ||
2026 | Some(Self { syntax }) | ||
2027 | } else { | ||
2028 | None | ||
2029 | } | ||
2030 | } | ||
2031 | fn syntax(&self) -> &SyntaxToken { | ||
2032 | &self.syntax | ||
2033 | } | ||
2034 | } | ||
2035 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2036 | pub struct MoveKw { | ||
2037 | pub(crate) syntax: SyntaxToken, | ||
2038 | } | ||
2039 | impl std::fmt::Display for MoveKw { | ||
2040 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2041 | std::fmt::Display::fmt(&self.syntax, f) | ||
2042 | } | ||
2043 | } | ||
2044 | impl AstToken for MoveKw { | ||
2045 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2046 | match kind { | ||
2047 | MOVE_KW => true, | ||
2048 | _ => false, | ||
2049 | } | ||
2050 | } | ||
2051 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2052 | if Self::can_cast(syntax.kind()) { | ||
2053 | Some(Self { syntax }) | ||
2054 | } else { | ||
2055 | None | ||
2056 | } | ||
2057 | } | ||
2058 | fn syntax(&self) -> &SyntaxToken { | ||
2059 | &self.syntax | ||
2060 | } | ||
2061 | } | ||
2062 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2063 | pub struct MutKw { | ||
2064 | pub(crate) syntax: SyntaxToken, | ||
2065 | } | ||
2066 | impl std::fmt::Display for MutKw { | ||
2067 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2068 | std::fmt::Display::fmt(&self.syntax, f) | ||
2069 | } | ||
2070 | } | ||
2071 | impl AstToken for MutKw { | ||
2072 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2073 | match kind { | ||
2074 | MUT_KW => true, | ||
2075 | _ => false, | ||
2076 | } | ||
2077 | } | ||
2078 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2079 | if Self::can_cast(syntax.kind()) { | ||
2080 | Some(Self { syntax }) | ||
2081 | } else { | ||
2082 | None | ||
2083 | } | ||
2084 | } | ||
2085 | fn syntax(&self) -> &SyntaxToken { | ||
2086 | &self.syntax | ||
2087 | } | ||
2088 | } | ||
2089 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2090 | pub struct PubKw { | ||
2091 | pub(crate) syntax: SyntaxToken, | ||
2092 | } | ||
2093 | impl std::fmt::Display for PubKw { | ||
2094 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2095 | std::fmt::Display::fmt(&self.syntax, f) | ||
2096 | } | ||
2097 | } | ||
2098 | impl AstToken for PubKw { | ||
2099 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2100 | match kind { | ||
2101 | PUB_KW => true, | ||
2102 | _ => false, | ||
2103 | } | ||
2104 | } | ||
2105 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2106 | if Self::can_cast(syntax.kind()) { | ||
2107 | Some(Self { syntax }) | ||
2108 | } else { | ||
2109 | None | ||
2110 | } | ||
2111 | } | ||
2112 | fn syntax(&self) -> &SyntaxToken { | ||
2113 | &self.syntax | ||
2114 | } | ||
2115 | } | ||
2116 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2117 | pub struct RefKw { | ||
2118 | pub(crate) syntax: SyntaxToken, | ||
2119 | } | ||
2120 | impl std::fmt::Display for RefKw { | ||
2121 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2122 | std::fmt::Display::fmt(&self.syntax, f) | ||
2123 | } | ||
2124 | } | ||
2125 | impl AstToken for RefKw { | ||
2126 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2127 | match kind { | ||
2128 | REF_KW => true, | ||
2129 | _ => false, | ||
2130 | } | ||
2131 | } | ||
2132 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2133 | if Self::can_cast(syntax.kind()) { | ||
2134 | Some(Self { syntax }) | ||
2135 | } else { | ||
2136 | None | ||
2137 | } | ||
2138 | } | ||
2139 | fn syntax(&self) -> &SyntaxToken { | ||
2140 | &self.syntax | ||
2141 | } | ||
2142 | } | ||
2143 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2144 | pub struct ReturnKw { | ||
2145 | pub(crate) syntax: SyntaxToken, | ||
2146 | } | ||
2147 | impl std::fmt::Display for ReturnKw { | ||
2148 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2149 | std::fmt::Display::fmt(&self.syntax, f) | ||
2150 | } | ||
2151 | } | ||
2152 | impl AstToken for ReturnKw { | ||
2153 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2154 | match kind { | ||
2155 | RETURN_KW => true, | ||
2156 | _ => false, | ||
2157 | } | ||
2158 | } | ||
2159 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2160 | if Self::can_cast(syntax.kind()) { | ||
2161 | Some(Self { syntax }) | ||
2162 | } else { | ||
2163 | None | ||
2164 | } | ||
2165 | } | ||
2166 | fn syntax(&self) -> &SyntaxToken { | ||
2167 | &self.syntax | ||
2168 | } | ||
2169 | } | ||
2170 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2171 | pub struct SelfKw { | ||
2172 | pub(crate) syntax: SyntaxToken, | ||
2173 | } | ||
2174 | impl std::fmt::Display for SelfKw { | ||
2175 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2176 | std::fmt::Display::fmt(&self.syntax, f) | ||
2177 | } | ||
2178 | } | ||
2179 | impl AstToken for SelfKw { | ||
2180 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2181 | match kind { | ||
2182 | SELF_KW => true, | ||
2183 | _ => false, | ||
2184 | } | ||
2185 | } | ||
2186 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2187 | if Self::can_cast(syntax.kind()) { | ||
2188 | Some(Self { syntax }) | ||
2189 | } else { | ||
2190 | None | ||
2191 | } | ||
2192 | } | ||
2193 | fn syntax(&self) -> &SyntaxToken { | ||
2194 | &self.syntax | ||
2195 | } | ||
2196 | } | ||
2197 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2198 | pub struct StaticKw { | ||
2199 | pub(crate) syntax: SyntaxToken, | ||
2200 | } | ||
2201 | impl std::fmt::Display for StaticKw { | ||
2202 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2203 | std::fmt::Display::fmt(&self.syntax, f) | ||
2204 | } | ||
2205 | } | ||
2206 | impl AstToken for StaticKw { | ||
2207 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2208 | match kind { | ||
2209 | STATIC_KW => true, | ||
2210 | _ => false, | ||
2211 | } | ||
2212 | } | ||
2213 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2214 | if Self::can_cast(syntax.kind()) { | ||
2215 | Some(Self { syntax }) | ||
2216 | } else { | ||
2217 | None | ||
2218 | } | ||
2219 | } | ||
2220 | fn syntax(&self) -> &SyntaxToken { | ||
2221 | &self.syntax | ||
2222 | } | ||
2223 | } | ||
2224 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2225 | pub struct StructKw { | ||
2226 | pub(crate) syntax: SyntaxToken, | ||
2227 | } | ||
2228 | impl std::fmt::Display for StructKw { | ||
2229 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2230 | std::fmt::Display::fmt(&self.syntax, f) | ||
2231 | } | ||
2232 | } | ||
2233 | impl AstToken for StructKw { | ||
2234 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2235 | match kind { | ||
2236 | STRUCT_KW => true, | ||
2237 | _ => false, | ||
2238 | } | ||
2239 | } | ||
2240 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2241 | if Self::can_cast(syntax.kind()) { | ||
2242 | Some(Self { syntax }) | ||
2243 | } else { | ||
2244 | None | ||
2245 | } | ||
2246 | } | ||
2247 | fn syntax(&self) -> &SyntaxToken { | ||
2248 | &self.syntax | ||
2249 | } | ||
2250 | } | ||
2251 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2252 | pub struct SuperKw { | ||
2253 | pub(crate) syntax: SyntaxToken, | ||
2254 | } | ||
2255 | impl std::fmt::Display for SuperKw { | ||
2256 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2257 | std::fmt::Display::fmt(&self.syntax, f) | ||
2258 | } | ||
2259 | } | ||
2260 | impl AstToken for SuperKw { | ||
2261 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2262 | match kind { | ||
2263 | SUPER_KW => true, | ||
2264 | _ => false, | ||
2265 | } | ||
2266 | } | ||
2267 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2268 | if Self::can_cast(syntax.kind()) { | ||
2269 | Some(Self { syntax }) | ||
2270 | } else { | ||
2271 | None | ||
2272 | } | ||
2273 | } | ||
2274 | fn syntax(&self) -> &SyntaxToken { | ||
2275 | &self.syntax | ||
2276 | } | ||
2277 | } | ||
2278 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2279 | pub struct TraitKw { | ||
2280 | pub(crate) syntax: SyntaxToken, | ||
2281 | } | ||
2282 | impl std::fmt::Display for TraitKw { | ||
2283 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2284 | std::fmt::Display::fmt(&self.syntax, f) | ||
2285 | } | ||
2286 | } | ||
2287 | impl AstToken for TraitKw { | ||
2288 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2289 | match kind { | ||
2290 | TRAIT_KW => true, | ||
2291 | _ => false, | ||
2292 | } | ||
2293 | } | ||
2294 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2295 | if Self::can_cast(syntax.kind()) { | ||
2296 | Some(Self { syntax }) | ||
2297 | } else { | ||
2298 | None | ||
2299 | } | ||
2300 | } | ||
2301 | fn syntax(&self) -> &SyntaxToken { | ||
2302 | &self.syntax | ||
2303 | } | ||
2304 | } | ||
2305 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2306 | pub struct TrueKw { | ||
2307 | pub(crate) syntax: SyntaxToken, | ||
2308 | } | ||
2309 | impl std::fmt::Display for TrueKw { | ||
2310 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2311 | std::fmt::Display::fmt(&self.syntax, f) | ||
2312 | } | ||
2313 | } | ||
2314 | impl AstToken for TrueKw { | ||
2315 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2316 | match kind { | ||
2317 | TRUE_KW => true, | ||
2318 | _ => false, | ||
2319 | } | ||
2320 | } | ||
2321 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2322 | if Self::can_cast(syntax.kind()) { | ||
2323 | Some(Self { syntax }) | ||
2324 | } else { | ||
2325 | None | ||
2326 | } | ||
2327 | } | ||
2328 | fn syntax(&self) -> &SyntaxToken { | ||
2329 | &self.syntax | ||
2330 | } | ||
2331 | } | ||
2332 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2333 | pub struct TryKw { | ||
2334 | pub(crate) syntax: SyntaxToken, | ||
2335 | } | ||
2336 | impl std::fmt::Display for TryKw { | ||
2337 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2338 | std::fmt::Display::fmt(&self.syntax, f) | ||
2339 | } | ||
2340 | } | ||
2341 | impl AstToken for TryKw { | ||
2342 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2343 | match kind { | ||
2344 | TRY_KW => true, | ||
2345 | _ => false, | ||
2346 | } | ||
2347 | } | ||
2348 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2349 | if Self::can_cast(syntax.kind()) { | ||
2350 | Some(Self { syntax }) | ||
2351 | } else { | ||
2352 | None | ||
2353 | } | ||
2354 | } | ||
2355 | fn syntax(&self) -> &SyntaxToken { | ||
2356 | &self.syntax | ||
2357 | } | ||
2358 | } | ||
2359 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2360 | pub struct TypeKw { | ||
2361 | pub(crate) syntax: SyntaxToken, | ||
2362 | } | ||
2363 | impl std::fmt::Display for TypeKw { | ||
2364 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2365 | std::fmt::Display::fmt(&self.syntax, f) | ||
2366 | } | ||
2367 | } | ||
2368 | impl AstToken for TypeKw { | ||
2369 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2370 | match kind { | ||
2371 | TYPE_KW => true, | ||
2372 | _ => false, | ||
2373 | } | ||
2374 | } | ||
2375 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2376 | if Self::can_cast(syntax.kind()) { | ||
2377 | Some(Self { syntax }) | ||
2378 | } else { | ||
2379 | None | ||
2380 | } | ||
2381 | } | ||
2382 | fn syntax(&self) -> &SyntaxToken { | ||
2383 | &self.syntax | ||
2384 | } | ||
2385 | } | ||
2386 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2387 | pub struct UnsafeKw { | ||
2388 | pub(crate) syntax: SyntaxToken, | ||
2389 | } | ||
2390 | impl std::fmt::Display for UnsafeKw { | ||
2391 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2392 | std::fmt::Display::fmt(&self.syntax, f) | ||
2393 | } | ||
2394 | } | ||
2395 | impl AstToken for UnsafeKw { | ||
2396 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2397 | match kind { | ||
2398 | UNSAFE_KW => true, | ||
2399 | _ => false, | ||
2400 | } | ||
2401 | } | ||
2402 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2403 | if Self::can_cast(syntax.kind()) { | ||
2404 | Some(Self { syntax }) | ||
2405 | } else { | ||
2406 | None | ||
2407 | } | ||
2408 | } | ||
2409 | fn syntax(&self) -> &SyntaxToken { | ||
2410 | &self.syntax | ||
2411 | } | ||
2412 | } | ||
2413 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2414 | pub struct UseKw { | ||
2415 | pub(crate) syntax: SyntaxToken, | ||
2416 | } | ||
2417 | impl std::fmt::Display for UseKw { | ||
2418 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2419 | std::fmt::Display::fmt(&self.syntax, f) | ||
2420 | } | ||
2421 | } | ||
2422 | impl AstToken for UseKw { | ||
2423 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2424 | match kind { | ||
2425 | USE_KW => true, | ||
2426 | _ => false, | ||
2427 | } | ||
2428 | } | ||
2429 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2430 | if Self::can_cast(syntax.kind()) { | ||
2431 | Some(Self { syntax }) | ||
2432 | } else { | ||
2433 | None | ||
2434 | } | ||
2435 | } | ||
2436 | fn syntax(&self) -> &SyntaxToken { | ||
2437 | &self.syntax | ||
2438 | } | ||
2439 | } | ||
2440 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2441 | pub struct WhereKw { | ||
2442 | pub(crate) syntax: SyntaxToken, | ||
2443 | } | ||
2444 | impl std::fmt::Display for WhereKw { | ||
2445 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2446 | std::fmt::Display::fmt(&self.syntax, f) | ||
2447 | } | ||
2448 | } | ||
2449 | impl AstToken for WhereKw { | ||
2450 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2451 | match kind { | ||
2452 | WHERE_KW => true, | ||
2453 | _ => false, | ||
2454 | } | ||
2455 | } | ||
2456 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2457 | if Self::can_cast(syntax.kind()) { | ||
2458 | Some(Self { syntax }) | ||
2459 | } else { | ||
2460 | None | ||
2461 | } | ||
2462 | } | ||
2463 | fn syntax(&self) -> &SyntaxToken { | ||
2464 | &self.syntax | ||
2465 | } | ||
2466 | } | ||
2467 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2468 | pub struct WhileKw { | ||
2469 | pub(crate) syntax: SyntaxToken, | ||
2470 | } | ||
2471 | impl std::fmt::Display for WhileKw { | ||
2472 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2473 | std::fmt::Display::fmt(&self.syntax, f) | ||
2474 | } | ||
2475 | } | ||
2476 | impl AstToken for WhileKw { | ||
2477 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2478 | match kind { | ||
2479 | WHILE_KW => true, | ||
2480 | _ => false, | ||
2481 | } | ||
2482 | } | ||
2483 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2484 | if Self::can_cast(syntax.kind()) { | ||
2485 | Some(Self { syntax }) | ||
2486 | } else { | ||
2487 | None | ||
2488 | } | ||
2489 | } | ||
2490 | fn syntax(&self) -> &SyntaxToken { | ||
2491 | &self.syntax | ||
2492 | } | ||
2493 | } | ||
2494 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2495 | pub struct AutoKw { | ||
2496 | pub(crate) syntax: SyntaxToken, | ||
2497 | } | ||
2498 | impl std::fmt::Display for AutoKw { | ||
2499 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2500 | std::fmt::Display::fmt(&self.syntax, f) | ||
2501 | } | ||
2502 | } | ||
2503 | impl AstToken for AutoKw { | ||
2504 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2505 | match kind { | ||
2506 | AUTO_KW => true, | ||
2507 | _ => false, | ||
2508 | } | ||
2509 | } | ||
2510 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2511 | if Self::can_cast(syntax.kind()) { | ||
2512 | Some(Self { syntax }) | ||
2513 | } else { | ||
2514 | None | ||
2515 | } | ||
2516 | } | ||
2517 | fn syntax(&self) -> &SyntaxToken { | ||
2518 | &self.syntax | ||
2519 | } | ||
2520 | } | ||
2521 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2522 | pub struct DefaultKw { | ||
2523 | pub(crate) syntax: SyntaxToken, | ||
2524 | } | ||
2525 | impl std::fmt::Display for DefaultKw { | ||
2526 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2527 | std::fmt::Display::fmt(&self.syntax, f) | ||
2528 | } | ||
2529 | } | ||
2530 | impl AstToken for DefaultKw { | ||
2531 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2532 | match kind { | ||
2533 | DEFAULT_KW => true, | ||
2534 | _ => false, | ||
2535 | } | ||
2536 | } | ||
2537 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2538 | if Self::can_cast(syntax.kind()) { | ||
2539 | Some(Self { syntax }) | ||
2540 | } else { | ||
2541 | None | ||
2542 | } | ||
2543 | } | ||
2544 | fn syntax(&self) -> &SyntaxToken { | ||
2545 | &self.syntax | ||
2546 | } | ||
2547 | } | ||
2548 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2549 | pub struct ExistentialKw { | ||
2550 | pub(crate) syntax: SyntaxToken, | ||
2551 | } | ||
2552 | impl std::fmt::Display for ExistentialKw { | ||
2553 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2554 | std::fmt::Display::fmt(&self.syntax, f) | ||
2555 | } | ||
2556 | } | ||
2557 | impl AstToken for ExistentialKw { | ||
2558 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2559 | match kind { | ||
2560 | EXISTENTIAL_KW => true, | ||
2561 | _ => false, | ||
2562 | } | ||
2563 | } | ||
2564 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2565 | if Self::can_cast(syntax.kind()) { | ||
2566 | Some(Self { syntax }) | ||
2567 | } else { | ||
2568 | None | ||
2569 | } | ||
2570 | } | ||
2571 | fn syntax(&self) -> &SyntaxToken { | ||
2572 | &self.syntax | ||
2573 | } | ||
2574 | } | ||
2575 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2576 | pub struct UnionKw { | ||
2577 | pub(crate) syntax: SyntaxToken, | ||
2578 | } | ||
2579 | impl std::fmt::Display for UnionKw { | ||
2580 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2581 | std::fmt::Display::fmt(&self.syntax, f) | ||
2582 | } | ||
2583 | } | ||
2584 | impl AstToken for UnionKw { | ||
2585 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2586 | match kind { | ||
2587 | UNION_KW => true, | ||
2588 | _ => false, | ||
2589 | } | ||
2590 | } | ||
2591 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2592 | if Self::can_cast(syntax.kind()) { | ||
2593 | Some(Self { syntax }) | ||
2594 | } else { | ||
2595 | None | ||
2596 | } | ||
2597 | } | ||
2598 | fn syntax(&self) -> &SyntaxToken { | ||
2599 | &self.syntax | ||
2600 | } | ||
2601 | } | ||
2602 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2603 | pub struct IntNumber { | ||
2604 | pub(crate) syntax: SyntaxToken, | ||
2605 | } | ||
2606 | impl std::fmt::Display for IntNumber { | ||
2607 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2608 | std::fmt::Display::fmt(&self.syntax, f) | ||
2609 | } | ||
2610 | } | ||
2611 | impl AstToken for IntNumber { | ||
2612 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2613 | match kind { | ||
2614 | INT_NUMBER => true, | ||
2615 | _ => false, | ||
2616 | } | ||
2617 | } | ||
2618 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2619 | if Self::can_cast(syntax.kind()) { | ||
2620 | Some(Self { syntax }) | ||
2621 | } else { | ||
2622 | None | ||
2623 | } | ||
2624 | } | ||
2625 | fn syntax(&self) -> &SyntaxToken { | ||
2626 | &self.syntax | ||
2627 | } | ||
2628 | } | ||
2629 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2630 | pub struct FloatNumber { | ||
2631 | pub(crate) syntax: SyntaxToken, | ||
2632 | } | ||
2633 | impl std::fmt::Display for FloatNumber { | ||
2634 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2635 | std::fmt::Display::fmt(&self.syntax, f) | ||
2636 | } | ||
2637 | } | ||
2638 | impl AstToken for FloatNumber { | ||
2639 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2640 | match kind { | ||
2641 | FLOAT_NUMBER => true, | ||
2642 | _ => false, | ||
2643 | } | ||
2644 | } | ||
2645 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2646 | if Self::can_cast(syntax.kind()) { | ||
2647 | Some(Self { syntax }) | ||
2648 | } else { | ||
2649 | None | ||
2650 | } | ||
2651 | } | ||
2652 | fn syntax(&self) -> &SyntaxToken { | ||
2653 | &self.syntax | ||
2654 | } | ||
2655 | } | ||
2656 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2657 | pub struct Char { | ||
2658 | pub(crate) syntax: SyntaxToken, | ||
2659 | } | ||
2660 | impl std::fmt::Display for Char { | ||
2661 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2662 | std::fmt::Display::fmt(&self.syntax, f) | ||
2663 | } | ||
2664 | } | ||
2665 | impl AstToken for Char { | ||
2666 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2667 | match kind { | ||
2668 | CHAR => true, | ||
2669 | _ => false, | ||
2670 | } | ||
2671 | } | ||
2672 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2673 | if Self::can_cast(syntax.kind()) { | ||
2674 | Some(Self { syntax }) | ||
2675 | } else { | ||
2676 | None | ||
2677 | } | ||
2678 | } | ||
2679 | fn syntax(&self) -> &SyntaxToken { | ||
2680 | &self.syntax | ||
2681 | } | ||
2682 | } | ||
2683 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2684 | pub struct Byte { | ||
2685 | pub(crate) syntax: SyntaxToken, | ||
2686 | } | ||
2687 | impl std::fmt::Display for Byte { | ||
2688 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2689 | std::fmt::Display::fmt(&self.syntax, f) | ||
2690 | } | ||
2691 | } | ||
2692 | impl AstToken for Byte { | ||
2693 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2694 | match kind { | ||
2695 | BYTE => true, | ||
2696 | _ => false, | ||
2697 | } | ||
2698 | } | ||
2699 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2700 | if Self::can_cast(syntax.kind()) { | ||
2701 | Some(Self { syntax }) | ||
2702 | } else { | ||
2703 | None | ||
2704 | } | ||
2705 | } | ||
2706 | fn syntax(&self) -> &SyntaxToken { | ||
2707 | &self.syntax | ||
2708 | } | ||
2709 | } | ||
2710 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2711 | pub struct String { | ||
2712 | pub(crate) syntax: SyntaxToken, | ||
2713 | } | ||
2714 | impl std::fmt::Display for String { | ||
2715 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2716 | std::fmt::Display::fmt(&self.syntax, f) | ||
2717 | } | ||
2718 | } | ||
2719 | impl AstToken for String { | ||
2720 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2721 | match kind { | ||
2722 | STRING => true, | ||
2723 | _ => false, | ||
2724 | } | ||
2725 | } | ||
2726 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2727 | if Self::can_cast(syntax.kind()) { | ||
2728 | Some(Self { syntax }) | ||
2729 | } else { | ||
2730 | None | ||
2731 | } | ||
2732 | } | ||
2733 | fn syntax(&self) -> &SyntaxToken { | ||
2734 | &self.syntax | ||
2735 | } | ||
2736 | } | ||
2737 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2738 | pub struct RawString { | ||
2739 | pub(crate) syntax: SyntaxToken, | ||
2740 | } | ||
2741 | impl std::fmt::Display for RawString { | ||
2742 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2743 | std::fmt::Display::fmt(&self.syntax, f) | ||
2744 | } | ||
2745 | } | ||
2746 | impl AstToken for RawString { | ||
2747 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2748 | match kind { | ||
2749 | RAW_STRING => true, | ||
2750 | _ => false, | ||
2751 | } | ||
2752 | } | ||
2753 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2754 | if Self::can_cast(syntax.kind()) { | ||
2755 | Some(Self { syntax }) | ||
2756 | } else { | ||
2757 | None | ||
2758 | } | ||
2759 | } | ||
2760 | fn syntax(&self) -> &SyntaxToken { | ||
2761 | &self.syntax | ||
2762 | } | ||
2763 | } | ||
2764 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2765 | pub struct ByteString { | ||
2766 | pub(crate) syntax: SyntaxToken, | ||
2767 | } | ||
2768 | impl std::fmt::Display for ByteString { | ||
2769 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2770 | std::fmt::Display::fmt(&self.syntax, f) | ||
2771 | } | ||
2772 | } | ||
2773 | impl AstToken for ByteString { | ||
2774 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2775 | match kind { | ||
2776 | BYTE_STRING => true, | ||
2777 | _ => false, | ||
2778 | } | ||
2779 | } | ||
2780 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2781 | if Self::can_cast(syntax.kind()) { | ||
2782 | Some(Self { syntax }) | ||
2783 | } else { | ||
2784 | None | ||
2785 | } | ||
2786 | } | ||
2787 | fn syntax(&self) -> &SyntaxToken { | ||
2788 | &self.syntax | ||
2789 | } | ||
2790 | } | ||
2791 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2792 | pub struct RawByteString { | ||
2793 | pub(crate) syntax: SyntaxToken, | ||
2794 | } | ||
2795 | impl std::fmt::Display for RawByteString { | ||
2796 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2797 | std::fmt::Display::fmt(&self.syntax, f) | ||
2798 | } | ||
2799 | } | ||
2800 | impl AstToken for RawByteString { | ||
2801 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2802 | match kind { | ||
2803 | RAW_BYTE_STRING => true, | ||
2804 | _ => false, | ||
2805 | } | ||
2806 | } | ||
2807 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2808 | if Self::can_cast(syntax.kind()) { | ||
2809 | Some(Self { syntax }) | ||
2810 | } else { | ||
2811 | None | ||
2812 | } | ||
2813 | } | ||
2814 | fn syntax(&self) -> &SyntaxToken { | ||
2815 | &self.syntax | ||
2816 | } | ||
2817 | } | ||
2818 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2819 | pub struct Error { | ||
2820 | pub(crate) syntax: SyntaxToken, | ||
2821 | } | ||
2822 | impl std::fmt::Display for Error { | ||
2823 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2824 | std::fmt::Display::fmt(&self.syntax, f) | ||
2825 | } | ||
2826 | } | ||
2827 | impl AstToken for Error { | ||
2828 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2829 | match kind { | ||
2830 | ERROR => true, | ||
2831 | _ => false, | ||
2832 | } | ||
2833 | } | ||
2834 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2835 | if Self::can_cast(syntax.kind()) { | ||
2836 | Some(Self { syntax }) | ||
2837 | } else { | ||
2838 | None | ||
2839 | } | ||
2840 | } | ||
2841 | fn syntax(&self) -> &SyntaxToken { | ||
2842 | &self.syntax | ||
2843 | } | ||
2844 | } | ||
2845 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2846 | pub struct Ident { | ||
2847 | pub(crate) syntax: SyntaxToken, | ||
2848 | } | ||
2849 | impl std::fmt::Display for Ident { | ||
2850 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2851 | std::fmt::Display::fmt(&self.syntax, f) | ||
2852 | } | ||
2853 | } | ||
2854 | impl AstToken for Ident { | ||
2855 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2856 | match kind { | ||
2857 | IDENT => true, | ||
2858 | _ => false, | ||
2859 | } | ||
2860 | } | ||
2861 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2862 | if Self::can_cast(syntax.kind()) { | ||
2863 | Some(Self { syntax }) | ||
2864 | } else { | ||
2865 | None | ||
2866 | } | ||
2867 | } | ||
2868 | fn syntax(&self) -> &SyntaxToken { | ||
2869 | &self.syntax | ||
2870 | } | ||
2871 | } | ||
2872 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2873 | pub struct Whitespace { | ||
2874 | pub(crate) syntax: SyntaxToken, | ||
2875 | } | ||
2876 | impl std::fmt::Display for Whitespace { | ||
2877 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2878 | std::fmt::Display::fmt(&self.syntax, f) | ||
2879 | } | ||
2880 | } | ||
2881 | impl AstToken for Whitespace { | ||
2882 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2883 | match kind { | ||
2884 | WHITESPACE => true, | ||
2885 | _ => false, | ||
2886 | } | ||
2887 | } | ||
2888 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2889 | if Self::can_cast(syntax.kind()) { | ||
2890 | Some(Self { syntax }) | ||
2891 | } else { | ||
2892 | None | ||
2893 | } | ||
2894 | } | ||
2895 | fn syntax(&self) -> &SyntaxToken { | ||
2896 | &self.syntax | ||
2897 | } | ||
2898 | } | ||
2899 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2900 | pub struct Lifetime { | ||
2901 | pub(crate) syntax: SyntaxToken, | ||
2902 | } | ||
2903 | impl std::fmt::Display for Lifetime { | ||
2904 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2905 | std::fmt::Display::fmt(&self.syntax, f) | ||
2906 | } | ||
2907 | } | ||
2908 | impl AstToken for Lifetime { | ||
2909 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2910 | match kind { | ||
2911 | LIFETIME => true, | ||
2912 | _ => false, | ||
2913 | } | ||
2914 | } | ||
2915 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2916 | if Self::can_cast(syntax.kind()) { | ||
2917 | Some(Self { syntax }) | ||
2918 | } else { | ||
2919 | None | ||
2920 | } | ||
2921 | } | ||
2922 | fn syntax(&self) -> &SyntaxToken { | ||
2923 | &self.syntax | ||
2924 | } | ||
2925 | } | ||
2926 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2927 | pub struct Comment { | ||
2928 | pub(crate) syntax: SyntaxToken, | ||
2929 | } | ||
2930 | impl std::fmt::Display for Comment { | ||
2931 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2932 | std::fmt::Display::fmt(&self.syntax, f) | ||
2933 | } | ||
2934 | } | ||
2935 | impl AstToken for Comment { | ||
2936 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2937 | match kind { | ||
2938 | COMMENT => true, | ||
2939 | _ => false, | ||
2940 | } | ||
2941 | } | ||
2942 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2943 | if Self::can_cast(syntax.kind()) { | ||
2944 | Some(Self { syntax }) | ||
2945 | } else { | ||
2946 | None | ||
2947 | } | ||
2948 | } | ||
2949 | fn syntax(&self) -> &SyntaxToken { | ||
2950 | &self.syntax | ||
2951 | } | ||
2952 | } | ||
2953 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2954 | pub struct Shebang { | ||
2955 | pub(crate) syntax: SyntaxToken, | ||
2956 | } | ||
2957 | impl std::fmt::Display for Shebang { | ||
2958 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2959 | std::fmt::Display::fmt(&self.syntax, f) | ||
2960 | } | ||
2961 | } | ||
2962 | impl AstToken for Shebang { | ||
2963 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2964 | match kind { | ||
2965 | SHEBANG => true, | ||
2966 | _ => false, | ||
2967 | } | ||
2968 | } | ||
2969 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2970 | if Self::can_cast(syntax.kind()) { | ||
2971 | Some(Self { syntax }) | ||
2972 | } else { | ||
2973 | None | ||
2974 | } | ||
2975 | } | ||
2976 | fn syntax(&self) -> &SyntaxToken { | ||
2977 | &self.syntax | ||
2978 | } | ||
2979 | } | ||
2980 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2981 | pub struct LDollar { | ||
2982 | pub(crate) syntax: SyntaxToken, | ||
2983 | } | ||
2984 | impl std::fmt::Display for LDollar { | ||
2985 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2986 | std::fmt::Display::fmt(&self.syntax, f) | ||
2987 | } | ||
2988 | } | ||
2989 | impl AstToken for LDollar { | ||
2990 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2991 | match kind { | ||
2992 | L_DOLLAR => true, | ||
2993 | _ => false, | ||
2994 | } | ||
2995 | } | ||
2996 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2997 | if Self::can_cast(syntax.kind()) { | ||
2998 | Some(Self { syntax }) | ||
2999 | } else { | ||
3000 | None | ||
3001 | } | ||
3002 | } | ||
3003 | fn syntax(&self) -> &SyntaxToken { | ||
3004 | &self.syntax | ||
3005 | } | ||
3006 | } | ||
3007 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3008 | pub struct RDollar { | ||
3009 | pub(crate) syntax: SyntaxToken, | ||
3010 | } | ||
3011 | impl std::fmt::Display for RDollar { | ||
3012 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3013 | std::fmt::Display::fmt(&self.syntax, f) | ||
3014 | } | ||
3015 | } | ||
3016 | impl AstToken for RDollar { | ||
3017 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3018 | match kind { | ||
3019 | R_DOLLAR => true, | ||
3020 | _ => false, | ||
3021 | } | ||
3022 | } | ||
3023 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
3024 | if Self::can_cast(syntax.kind()) { | ||
3025 | Some(Self { syntax }) | ||
3026 | } else { | ||
3027 | None | ||
3028 | } | ||
3029 | } | ||
3030 | fn syntax(&self) -> &SyntaxToken { | ||
3031 | &self.syntax | ||
3032 | } | ||
3033 | } | ||
3034 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
9 | pub struct SourceFile { | 3035 | pub struct SourceFile { |
10 | pub(crate) syntax: SyntaxNode, | 3036 | pub(crate) syntax: SyntaxNode, |
11 | } | 3037 | } |
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs index 1a51b8d3b..e8320b57e 100644 --- a/crates/ra_syntax/src/ast/tokens.rs +++ b/crates/ra_syntax/src/ast/tokens.rs | |||
@@ -1,26 +1,10 @@ | |||
1 | //! There are many AstNodes, but only a few tokens, so we hand-write them here. | 1 | //! There are many AstNodes, but only a few tokens, so we hand-write them here. |
2 | 2 | ||
3 | use crate::{ | 3 | use crate::{ |
4 | ast::AstToken, | 4 | ast::{AstToken, Comment, RawString, String, Whitespace}, |
5 | SyntaxKind::{COMMENT, RAW_STRING, STRING, WHITESPACE}, | 5 | TextRange, TextUnit, |
6 | SyntaxToken, TextRange, TextUnit, | ||
7 | }; | 6 | }; |
8 | 7 | ||
9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
10 | pub struct Comment(SyntaxToken); | ||
11 | |||
12 | impl AstToken for Comment { | ||
13 | fn cast(token: SyntaxToken) -> Option<Self> { | ||
14 | match token.kind() { | ||
15 | COMMENT => Some(Comment(token)), | ||
16 | _ => None, | ||
17 | } | ||
18 | } | ||
19 | fn syntax(&self) -> &SyntaxToken { | ||
20 | &self.0 | ||
21 | } | ||
22 | } | ||
23 | |||
24 | impl Comment { | 8 | impl Comment { |
25 | pub fn kind(&self) -> CommentKind { | 9 | pub fn kind(&self) -> CommentKind { |
26 | kind_by_prefix(self.text()) | 10 | kind_by_prefix(self.text()) |
@@ -89,20 +73,6 @@ fn prefix_by_kind(kind: CommentKind) -> &'static str { | |||
89 | unreachable!() | 73 | unreachable!() |
90 | } | 74 | } |
91 | 75 | ||
92 | pub struct Whitespace(SyntaxToken); | ||
93 | |||
94 | impl AstToken for Whitespace { | ||
95 | fn cast(token: SyntaxToken) -> Option<Self> { | ||
96 | match token.kind() { | ||
97 | WHITESPACE => Some(Whitespace(token)), | ||
98 | _ => None, | ||
99 | } | ||
100 | } | ||
101 | fn syntax(&self) -> &SyntaxToken { | ||
102 | &self.0 | ||
103 | } | ||
104 | } | ||
105 | |||
106 | impl Whitespace { | 76 | impl Whitespace { |
107 | pub fn spans_multiple_lines(&self) -> bool { | 77 | pub fn spans_multiple_lines(&self) -> bool { |
108 | let text = self.text(); | 78 | let text = self.text(); |
@@ -168,20 +138,6 @@ pub trait HasStringValue: HasQuotes { | |||
168 | fn value(&self) -> Option<std::string::String>; | 138 | fn value(&self) -> Option<std::string::String>; |
169 | } | 139 | } |
170 | 140 | ||
171 | pub struct String(SyntaxToken); | ||
172 | |||
173 | impl AstToken for String { | ||
174 | fn cast(token: SyntaxToken) -> Option<Self> { | ||
175 | match token.kind() { | ||
176 | STRING => Some(String(token)), | ||
177 | _ => None, | ||
178 | } | ||
179 | } | ||
180 | fn syntax(&self) -> &SyntaxToken { | ||
181 | &self.0 | ||
182 | } | ||
183 | } | ||
184 | |||
185 | impl HasStringValue for String { | 141 | impl HasStringValue for String { |
186 | fn value(&self) -> Option<std::string::String> { | 142 | fn value(&self) -> Option<std::string::String> { |
187 | let text = self.text().as_str(); | 143 | let text = self.text().as_str(); |
@@ -201,20 +157,6 @@ impl HasStringValue for String { | |||
201 | } | 157 | } |
202 | } | 158 | } |
203 | 159 | ||
204 | pub struct RawString(SyntaxToken); | ||
205 | |||
206 | impl AstToken for RawString { | ||
207 | fn cast(token: SyntaxToken) -> Option<Self> { | ||
208 | match token.kind() { | ||
209 | RAW_STRING => Some(RawString(token)), | ||
210 | _ => None, | ||
211 | } | ||
212 | } | ||
213 | fn syntax(&self) -> &SyntaxToken { | ||
214 | &self.0 | ||
215 | } | ||
216 | } | ||
217 | |||
218 | impl HasStringValue for RawString { | 160 | impl HasStringValue for RawString { |
219 | fn value(&self) -> Option<std::string::String> { | 161 | fn value(&self) -> Option<std::string::String> { |
220 | let text = self.text().as_str(); | 162 | let text = self.text().as_str(); |