diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 26 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 4 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 147 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 7881 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 4177 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/tokens.rs | 2808 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 10 |
7 files changed, 7089 insertions, 7964 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index b69cae234..d79310995 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -99,7 +99,7 @@ impl ast::ItemList { | |||
99 | None => match self.l_curly() { | 99 | None => match self.l_curly() { |
100 | Some(it) => ( | 100 | Some(it) => ( |
101 | " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), | 101 | " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), |
102 | InsertPosition::After(it), | 102 | InsertPosition::After(it.syntax().clone().into()), |
103 | ), | 103 | ), |
104 | None => return self.clone(), | 104 | None => return self.clone(), |
105 | }, | 105 | }, |
@@ -109,10 +109,6 @@ impl ast::ItemList { | |||
109 | [ws.ws().into(), item.syntax().clone().into()].into(); | 109 | [ws.ws().into(), item.syntax().clone().into()].into(); |
110 | self.insert_children(position, to_insert) | 110 | self.insert_children(position, to_insert) |
111 | } | 111 | } |
112 | |||
113 | fn l_curly(&self) -> Option<SyntaxElement> { | ||
114 | self.syntax().children_with_tokens().find(|it| it.kind() == T!['{']) | ||
115 | } | ||
116 | } | 112 | } |
117 | 113 | ||
118 | impl ast::RecordFieldList { | 114 | impl ast::RecordFieldList { |
@@ -147,7 +143,7 @@ impl ast::RecordFieldList { | |||
147 | macro_rules! after_l_curly { | 143 | macro_rules! after_l_curly { |
148 | () => {{ | 144 | () => {{ |
149 | let anchor = match self.l_curly() { | 145 | let anchor = match self.l_curly() { |
150 | Some(it) => it, | 146 | Some(it) => it.syntax().clone().into(), |
151 | None => return self.clone(), | 147 | None => return self.clone(), |
152 | }; | 148 | }; |
153 | InsertPosition::After(anchor) | 149 | InsertPosition::After(anchor) |
@@ -189,24 +185,20 @@ impl ast::RecordFieldList { | |||
189 | 185 | ||
190 | self.insert_children(position, to_insert) | 186 | self.insert_children(position, to_insert) |
191 | } | 187 | } |
192 | |||
193 | fn l_curly(&self) -> Option<SyntaxElement> { | ||
194 | self.syntax().children_with_tokens().find(|it| it.kind() == T!['{']) | ||
195 | } | ||
196 | } | 188 | } |
197 | 189 | ||
198 | impl ast::TypeParam { | 190 | impl ast::TypeParam { |
199 | #[must_use] | 191 | #[must_use] |
200 | pub fn remove_bounds(&self) -> ast::TypeParam { | 192 | pub fn remove_bounds(&self) -> ast::TypeParam { |
201 | let colon = match self.colon_token() { | 193 | let colon = match self.colon() { |
202 | Some(it) => it, | 194 | Some(it) => it, |
203 | None => return self.clone(), | 195 | None => return self.clone(), |
204 | }; | 196 | }; |
205 | let end = match self.type_bound_list() { | 197 | let end = match self.type_bound_list() { |
206 | Some(it) => it.syntax().clone().into(), | 198 | Some(it) => it.syntax().clone().into(), |
207 | None => colon.clone().into(), | 199 | None => colon.syntax().clone().into(), |
208 | }; | 200 | }; |
209 | self.replace_children(colon.into()..=end, iter::empty()) | 201 | self.replace_children(colon.syntax().clone().into()..=end, iter::empty()) |
210 | } | 202 | } |
211 | } | 203 | } |
212 | 204 | ||
@@ -305,8 +297,12 @@ impl ast::UseTree { | |||
305 | Some(it) => it, | 297 | Some(it) => it, |
306 | None => return self.clone(), | 298 | None => return self.clone(), |
307 | }; | 299 | }; |
308 | let use_tree = | 300 | let use_tree = make::use_tree( |
309 | make::use_tree(suffix.clone(), self.use_tree_list(), self.alias(), self.has_star()); | 301 | suffix.clone(), |
302 | self.use_tree_list(), | ||
303 | self.alias(), | ||
304 | self.star().is_some(), | ||
305 | ); | ||
310 | let nested = make::use_tree_list(iter::once(use_tree)); | 306 | let nested = make::use_tree_list(iter::once(use_tree)); |
311 | return make::use_tree(prefix.clone(), Some(nested), None, false); | 307 | return make::use_tree(prefix.clone(), Some(nested), None, false); |
312 | 308 | ||
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 8bbd946c0..40c8fca3b 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -52,6 +52,10 @@ impl ast::RefExpr { | |||
52 | pub fn is_mut(&self) -> bool { | 52 | pub fn is_mut(&self) -> bool { |
53 | self.syntax().children_with_tokens().any(|n| n.kind() == T![mut]) | 53 | self.syntax().children_with_tokens().any(|n| n.kind() == T![mut]) |
54 | } | 54 | } |
55 | |||
56 | pub fn raw_token(&self) -> Option<SyntaxToken> { | ||
57 | None // FIXME: implement &raw | ||
58 | } | ||
55 | } | 59 | } |
56 | 60 | ||
57 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | 61 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index bf7d137be..33fe60762 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -4,7 +4,9 @@ | |||
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | ast::{self, child_opt, children, AstNode, AttrInput, NameOwner, SyntaxNode}, | 7 | ast::{ |
8 | self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode, | ||
9 | }, | ||
8 | SmolStr, SyntaxElement, | 10 | SmolStr, SyntaxElement, |
9 | SyntaxKind::*, | 11 | SyntaxKind::*, |
10 | SyntaxToken, T, | 12 | SyntaxToken, T, |
@@ -130,13 +132,6 @@ impl ast::PathSegment { | |||
130 | }; | 132 | }; |
131 | Some(res) | 133 | Some(res) |
132 | } | 134 | } |
133 | |||
134 | pub fn has_colon_colon(&self) -> bool { | ||
135 | match self.syntax.first_child_or_token().map(|s| s.kind()) { | ||
136 | Some(T![::]) => true, | ||
137 | _ => false, | ||
138 | } | ||
139 | } | ||
140 | } | 135 | } |
141 | 136 | ||
142 | impl ast::Path { | 137 | impl ast::Path { |
@@ -154,12 +149,6 @@ impl ast::Module { | |||
154 | } | 149 | } |
155 | } | 150 | } |
156 | 151 | ||
157 | impl ast::UseTree { | ||
158 | pub fn has_star(&self) -> bool { | ||
159 | self.syntax().children_with_tokens().any(|it| it.kind() == T![*]) | ||
160 | } | ||
161 | } | ||
162 | |||
163 | impl ast::UseTreeList { | 152 | impl ast::UseTreeList { |
164 | pub fn parent_use_tree(&self) -> ast::UseTree { | 153 | pub fn parent_use_tree(&self) -> ast::UseTree { |
165 | self.syntax() | 154 | self.syntax() |
@@ -167,20 +156,6 @@ impl ast::UseTreeList { | |||
167 | .and_then(ast::UseTree::cast) | 156 | .and_then(ast::UseTree::cast) |
168 | .expect("UseTreeLists are always nested in UseTrees") | 157 | .expect("UseTreeLists are always nested in UseTrees") |
169 | } | 158 | } |
170 | pub fn l_curly(&self) -> Option<SyntaxToken> { | ||
171 | self.token(T!['{']) | ||
172 | } | ||
173 | |||
174 | pub fn r_curly(&self) -> Option<SyntaxToken> { | ||
175 | self.token(T!['}']) | ||
176 | } | ||
177 | |||
178 | fn token(&self, kind: SyntaxKind) -> Option<SyntaxToken> { | ||
179 | self.syntax() | ||
180 | .children_with_tokens() | ||
181 | .filter_map(|it| it.into_token()) | ||
182 | .find(|it| it.kind() == kind) | ||
183 | } | ||
184 | } | 159 | } |
185 | 160 | ||
186 | impl ast::ImplDef { | 161 | impl ast::ImplDef { |
@@ -387,24 +362,9 @@ pub enum SelfParamKind { | |||
387 | } | 362 | } |
388 | 363 | ||
389 | impl ast::SelfParam { | 364 | impl ast::SelfParam { |
390 | pub fn self_kw_token(&self) -> SyntaxToken { | ||
391 | self.syntax() | ||
392 | .children_with_tokens() | ||
393 | .filter_map(|it| it.into_token()) | ||
394 | .find(|it| it.kind() == T![self]) | ||
395 | .expect("invalid tree: self param must have self") | ||
396 | } | ||
397 | |||
398 | pub fn kind(&self) -> SelfParamKind { | 365 | pub fn kind(&self) -> SelfParamKind { |
399 | let borrowed = self.syntax().children_with_tokens().any(|n| n.kind() == T![&]); | 366 | if self.amp().is_some() { |
400 | if borrowed { | 367 | if self.amp_mut_kw().is_some() { |
401 | // check for a `mut` coming after the & -- `mut &self` != `&mut self` | ||
402 | if self | ||
403 | .syntax() | ||
404 | .children_with_tokens() | ||
405 | .skip_while(|n| n.kind() != T![&]) | ||
406 | .any(|n| n.kind() == T![mut]) | ||
407 | { | ||
408 | SelfParamKind::MutRef | 368 | SelfParamKind::MutRef |
409 | } else { | 369 | } else { |
410 | SelfParamKind::Ref | 370 | SelfParamKind::Ref |
@@ -413,32 +373,23 @@ impl ast::SelfParam { | |||
413 | SelfParamKind::Owned | 373 | SelfParamKind::Owned |
414 | } | 374 | } |
415 | } | 375 | } |
416 | } | ||
417 | 376 | ||
418 | impl ast::LifetimeParam { | 377 | /// the "mut" in "mut self", not the one in "&mut self" |
419 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | 378 | pub fn mut_kw(&self) -> Option<ast::MutKw> { |
420 | self.syntax() | 379 | self.syntax() |
421 | .children_with_tokens() | 380 | .children_with_tokens() |
422 | .filter_map(|it| it.into_token()) | 381 | .filter_map(|it| it.into_token()) |
423 | .find(|it| it.kind() == LIFETIME) | 382 | .take_while(|it| it.kind() != T![&]) |
383 | .find_map(ast::MutKw::cast) | ||
424 | } | 384 | } |
425 | } | ||
426 | 385 | ||
427 | impl ast::TypeParam { | 386 | /// the "mut" in "&mut self", not the one in "mut self" |
428 | pub fn colon_token(&self) -> Option<SyntaxToken> { | 387 | pub fn amp_mut_kw(&self) -> Option<ast::MutKw> { |
429 | self.syntax() | 388 | self.syntax() |
430 | .children_with_tokens() | 389 | .children_with_tokens() |
431 | .filter_map(|it| it.into_token()) | 390 | .filter_map(|it| it.into_token()) |
432 | .find(|it| it.kind() == T![:]) | 391 | .skip_while(|it| it.kind() != T![&]) |
433 | } | 392 | .find_map(ast::MutKw::cast) |
434 | } | ||
435 | |||
436 | impl ast::WherePred { | ||
437 | pub fn lifetime_token(&self) -> Option<SyntaxToken> { | ||
438 | self.syntax() | ||
439 | .children_with_tokens() | ||
440 | .filter_map(|it| it.into_token()) | ||
441 | .find(|it| it.kind() == LIFETIME) | ||
442 | } | 393 | } |
443 | } | 394 | } |
444 | 395 | ||
@@ -449,7 +400,7 @@ pub enum TypeBoundKind { | |||
449 | /// for<'a> ... | 400 | /// for<'a> ... |
450 | ForType(ast::ForType), | 401 | ForType(ast::ForType), |
451 | /// 'a | 402 | /// 'a |
452 | Lifetime(ast::SyntaxToken), | 403 | Lifetime(ast::Lifetime), |
453 | } | 404 | } |
454 | 405 | ||
455 | impl ast::TypeBound { | 406 | impl ast::TypeBound { |
@@ -465,21 +416,28 @@ impl ast::TypeBound { | |||
465 | } | 416 | } |
466 | } | 417 | } |
467 | 418 | ||
468 | fn lifetime(&self) -> Option<SyntaxToken> { | 419 | pub fn has_question_mark(&self) -> bool { |
469 | self.syntax() | 420 | self.question().is_some() |
470 | .children_with_tokens() | ||
471 | .filter_map(|it| it.into_token()) | ||
472 | .find(|it| it.kind() == LIFETIME) | ||
473 | } | 421 | } |
474 | 422 | ||
475 | pub fn question_mark_token(&self) -> Option<SyntaxToken> { | 423 | pub fn const_question(&self) -> Option<ast::Question> { |
476 | self.syntax() | 424 | self.syntax() |
477 | .children_with_tokens() | 425 | .children_with_tokens() |
478 | .filter_map(|it| it.into_token()) | 426 | .filter_map(|it| it.into_token()) |
479 | .find(|it| it.kind() == T![?]) | 427 | .take_while(|it| it.kind() != T![const]) |
428 | .find_map(ast::Question::cast) | ||
480 | } | 429 | } |
481 | pub fn has_question_mark(&self) -> bool { | 430 | |
482 | self.question_mark_token().is_some() | 431 | pub fn question(&self) -> Option<ast::Question> { |
432 | if self.const_kw().is_some() { | ||
433 | self.syntax() | ||
434 | .children_with_tokens() | ||
435 | .filter_map(|it| it.into_token()) | ||
436 | .skip_while(|it| it.kind() != T![const]) | ||
437 | .find_map(ast::Question::cast) | ||
438 | } else { | ||
439 | support::token(&self.syntax) | ||
440 | } | ||
483 | } | 441 | } |
484 | } | 442 | } |
485 | 443 | ||
@@ -493,6 +451,7 @@ pub enum VisibilityKind { | |||
493 | In(ast::Path), | 451 | In(ast::Path), |
494 | PubCrate, | 452 | PubCrate, |
495 | PubSuper, | 453 | PubSuper, |
454 | PubSelf, | ||
496 | Pub, | 455 | Pub, |
497 | } | 456 | } |
498 | 457 | ||
@@ -504,6 +463,8 @@ impl ast::Visibility { | |||
504 | VisibilityKind::PubCrate | 463 | VisibilityKind::PubCrate |
505 | } else if self.is_pub_super() { | 464 | } else if self.is_pub_super() { |
506 | VisibilityKind::PubSuper | 465 | VisibilityKind::PubSuper |
466 | } else if self.is_pub_self() { | ||
467 | VisibilityKind::PubSuper | ||
507 | } else { | 468 | } else { |
508 | VisibilityKind::Pub | 469 | VisibilityKind::Pub |
509 | } | 470 | } |
@@ -516,6 +477,10 @@ impl ast::Visibility { | |||
516 | fn is_pub_super(&self) -> bool { | 477 | fn is_pub_super(&self) -> bool { |
517 | self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) | 478 | self.syntax().children_with_tokens().any(|it| it.kind() == T![super]) |
518 | } | 479 | } |
480 | |||
481 | fn is_pub_self(&self) -> bool { | ||
482 | self.syntax().children_with_tokens().any(|it| it.kind() == T![self]) | ||
483 | } | ||
519 | } | 484 | } |
520 | 485 | ||
521 | impl ast::MacroCall { | 486 | impl ast::MacroCall { |
@@ -528,3 +493,41 @@ impl ast::MacroCall { | |||
528 | } | 493 | } |
529 | } | 494 | } |
530 | } | 495 | } |
496 | |||
497 | impl ast::LifetimeParam { | ||
498 | pub fn lifetime_bounds(&self) -> impl Iterator<Item = ast::Lifetime> { | ||
499 | self.syntax() | ||
500 | .children_with_tokens() | ||
501 | .filter_map(|it| it.into_token()) | ||
502 | .skip_while(|x| x.kind() != T![:]) | ||
503 | .filter_map(ast::Lifetime::cast) | ||
504 | } | ||
505 | } | ||
506 | |||
507 | impl ast::RangePat { | ||
508 | pub fn start(&self) -> Option<ast::Pat> { | ||
509 | self.syntax() | ||
510 | .children_with_tokens() | ||
511 | .take_while(|it| !ast::RangeSeparator::can_cast(it.kind())) | ||
512 | .filter_map(|it| it.into_node()) | ||
513 | .find_map(ast::Pat::cast) | ||
514 | } | ||
515 | |||
516 | pub fn end(&self) -> Option<ast::Pat> { | ||
517 | self.syntax() | ||
518 | .children_with_tokens() | ||
519 | .skip_while(|it| !ast::RangeSeparator::can_cast(it.kind())) | ||
520 | .filter_map(|it| it.into_node()) | ||
521 | .find_map(ast::Pat::cast) | ||
522 | } | ||
523 | } | ||
524 | |||
525 | impl ast::TokenTree { | ||
526 | pub fn left_delimiter(&self) -> Option<ast::LeftDelimiter> { | ||
527 | self.syntax().first_child_or_token()?.into_token().and_then(ast::LeftDelimiter::cast) | ||
528 | } | ||
529 | |||
530 | pub fn right_delimiter(&self) -> Option<ast::RightDelimiter> { | ||
531 | self.syntax().last_child_or_token()?.into_token().and_then(ast::RightDelimiter::cast) | ||
532 | } | ||
533 | } | ||
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index d2b055b0a..f5199e09f 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1,7877 +1,6 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` | 1 | //! This file is actually hand-written, but the submodules are indeed generated. |
2 | 2 | ||
3 | #[allow(unused_imports)] | 3 | #[rustfmt::skip] |
4 | use crate::{ | 4 | pub(super) mod nodes; |
5 | ast::{self, AstChildren, AstNode, AstToken}, | 5 | #[rustfmt::skip] |
6 | NodeOrToken, SyntaxElement, | 6 | pub(super) mod tokens; |
7 | SyntaxKind::{self, *}, | ||
8 | SyntaxNode, SyntaxToken, | ||
9 | }; | ||
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)] | ||
3035 | pub struct SourceFile { | ||
3036 | pub(crate) syntax: SyntaxNode, | ||
3037 | } | ||
3038 | impl std::fmt::Display for SourceFile { | ||
3039 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3040 | std::fmt::Display::fmt(self.syntax(), f) | ||
3041 | } | ||
3042 | } | ||
3043 | impl AstNode for SourceFile { | ||
3044 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3045 | match kind { | ||
3046 | SOURCE_FILE => true, | ||
3047 | _ => false, | ||
3048 | } | ||
3049 | } | ||
3050 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3051 | if Self::can_cast(syntax.kind()) { | ||
3052 | Some(Self { syntax }) | ||
3053 | } else { | ||
3054 | None | ||
3055 | } | ||
3056 | } | ||
3057 | fn syntax(&self) -> &SyntaxNode { | ||
3058 | &self.syntax | ||
3059 | } | ||
3060 | } | ||
3061 | impl ast::ModuleItemOwner for SourceFile {} | ||
3062 | impl ast::FnDefOwner for SourceFile {} | ||
3063 | impl SourceFile { | ||
3064 | pub fn modules(&self) -> AstChildren<Module> { | ||
3065 | AstChildren::new(&self.syntax) | ||
3066 | } | ||
3067 | } | ||
3068 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3069 | pub struct FnDef { | ||
3070 | pub(crate) syntax: SyntaxNode, | ||
3071 | } | ||
3072 | impl std::fmt::Display for FnDef { | ||
3073 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3074 | std::fmt::Display::fmt(self.syntax(), f) | ||
3075 | } | ||
3076 | } | ||
3077 | impl AstNode for FnDef { | ||
3078 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3079 | match kind { | ||
3080 | FN_DEF => true, | ||
3081 | _ => false, | ||
3082 | } | ||
3083 | } | ||
3084 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3085 | if Self::can_cast(syntax.kind()) { | ||
3086 | Some(Self { syntax }) | ||
3087 | } else { | ||
3088 | None | ||
3089 | } | ||
3090 | } | ||
3091 | fn syntax(&self) -> &SyntaxNode { | ||
3092 | &self.syntax | ||
3093 | } | ||
3094 | } | ||
3095 | impl ast::VisibilityOwner for FnDef {} | ||
3096 | impl ast::NameOwner for FnDef {} | ||
3097 | impl ast::TypeParamsOwner for FnDef {} | ||
3098 | impl ast::DocCommentsOwner for FnDef {} | ||
3099 | impl ast::AttrsOwner for FnDef {} | ||
3100 | impl FnDef { | ||
3101 | pub fn param_list(&self) -> Option<ParamList> { | ||
3102 | AstChildren::new(&self.syntax).next() | ||
3103 | } | ||
3104 | pub fn ret_type(&self) -> Option<RetType> { | ||
3105 | AstChildren::new(&self.syntax).next() | ||
3106 | } | ||
3107 | pub fn body(&self) -> Option<BlockExpr> { | ||
3108 | AstChildren::new(&self.syntax).next() | ||
3109 | } | ||
3110 | } | ||
3111 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3112 | pub struct RetType { | ||
3113 | pub(crate) syntax: SyntaxNode, | ||
3114 | } | ||
3115 | impl std::fmt::Display for RetType { | ||
3116 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3117 | std::fmt::Display::fmt(self.syntax(), f) | ||
3118 | } | ||
3119 | } | ||
3120 | impl AstNode for RetType { | ||
3121 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3122 | match kind { | ||
3123 | RET_TYPE => true, | ||
3124 | _ => false, | ||
3125 | } | ||
3126 | } | ||
3127 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3128 | if Self::can_cast(syntax.kind()) { | ||
3129 | Some(Self { syntax }) | ||
3130 | } else { | ||
3131 | None | ||
3132 | } | ||
3133 | } | ||
3134 | fn syntax(&self) -> &SyntaxNode { | ||
3135 | &self.syntax | ||
3136 | } | ||
3137 | } | ||
3138 | impl RetType { | ||
3139 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3140 | AstChildren::new(&self.syntax).next() | ||
3141 | } | ||
3142 | } | ||
3143 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3144 | pub struct StructDef { | ||
3145 | pub(crate) syntax: SyntaxNode, | ||
3146 | } | ||
3147 | impl std::fmt::Display for StructDef { | ||
3148 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3149 | std::fmt::Display::fmt(self.syntax(), f) | ||
3150 | } | ||
3151 | } | ||
3152 | impl AstNode for StructDef { | ||
3153 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3154 | match kind { | ||
3155 | STRUCT_DEF => true, | ||
3156 | _ => false, | ||
3157 | } | ||
3158 | } | ||
3159 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3160 | if Self::can_cast(syntax.kind()) { | ||
3161 | Some(Self { syntax }) | ||
3162 | } else { | ||
3163 | None | ||
3164 | } | ||
3165 | } | ||
3166 | fn syntax(&self) -> &SyntaxNode { | ||
3167 | &self.syntax | ||
3168 | } | ||
3169 | } | ||
3170 | impl ast::VisibilityOwner for StructDef {} | ||
3171 | impl ast::NameOwner for StructDef {} | ||
3172 | impl ast::TypeParamsOwner for StructDef {} | ||
3173 | impl ast::AttrsOwner for StructDef {} | ||
3174 | impl ast::DocCommentsOwner for StructDef {} | ||
3175 | impl StructDef {} | ||
3176 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3177 | pub struct UnionDef { | ||
3178 | pub(crate) syntax: SyntaxNode, | ||
3179 | } | ||
3180 | impl std::fmt::Display for UnionDef { | ||
3181 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3182 | std::fmt::Display::fmt(self.syntax(), f) | ||
3183 | } | ||
3184 | } | ||
3185 | impl AstNode for UnionDef { | ||
3186 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3187 | match kind { | ||
3188 | UNION_DEF => true, | ||
3189 | _ => false, | ||
3190 | } | ||
3191 | } | ||
3192 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3193 | if Self::can_cast(syntax.kind()) { | ||
3194 | Some(Self { syntax }) | ||
3195 | } else { | ||
3196 | None | ||
3197 | } | ||
3198 | } | ||
3199 | fn syntax(&self) -> &SyntaxNode { | ||
3200 | &self.syntax | ||
3201 | } | ||
3202 | } | ||
3203 | impl ast::VisibilityOwner for UnionDef {} | ||
3204 | impl ast::NameOwner for UnionDef {} | ||
3205 | impl ast::TypeParamsOwner for UnionDef {} | ||
3206 | impl ast::AttrsOwner for UnionDef {} | ||
3207 | impl ast::DocCommentsOwner for UnionDef {} | ||
3208 | impl UnionDef { | ||
3209 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { | ||
3210 | AstChildren::new(&self.syntax).next() | ||
3211 | } | ||
3212 | } | ||
3213 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3214 | pub struct RecordFieldDefList { | ||
3215 | pub(crate) syntax: SyntaxNode, | ||
3216 | } | ||
3217 | impl std::fmt::Display for RecordFieldDefList { | ||
3218 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3219 | std::fmt::Display::fmt(self.syntax(), f) | ||
3220 | } | ||
3221 | } | ||
3222 | impl AstNode for RecordFieldDefList { | ||
3223 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3224 | match kind { | ||
3225 | RECORD_FIELD_DEF_LIST => true, | ||
3226 | _ => false, | ||
3227 | } | ||
3228 | } | ||
3229 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3230 | if Self::can_cast(syntax.kind()) { | ||
3231 | Some(Self { syntax }) | ||
3232 | } else { | ||
3233 | None | ||
3234 | } | ||
3235 | } | ||
3236 | fn syntax(&self) -> &SyntaxNode { | ||
3237 | &self.syntax | ||
3238 | } | ||
3239 | } | ||
3240 | impl RecordFieldDefList { | ||
3241 | pub fn fields(&self) -> AstChildren<RecordFieldDef> { | ||
3242 | AstChildren::new(&self.syntax) | ||
3243 | } | ||
3244 | } | ||
3245 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3246 | pub struct RecordFieldDef { | ||
3247 | pub(crate) syntax: SyntaxNode, | ||
3248 | } | ||
3249 | impl std::fmt::Display for RecordFieldDef { | ||
3250 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3251 | std::fmt::Display::fmt(self.syntax(), f) | ||
3252 | } | ||
3253 | } | ||
3254 | impl AstNode for RecordFieldDef { | ||
3255 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3256 | match kind { | ||
3257 | RECORD_FIELD_DEF => true, | ||
3258 | _ => false, | ||
3259 | } | ||
3260 | } | ||
3261 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3262 | if Self::can_cast(syntax.kind()) { | ||
3263 | Some(Self { syntax }) | ||
3264 | } else { | ||
3265 | None | ||
3266 | } | ||
3267 | } | ||
3268 | fn syntax(&self) -> &SyntaxNode { | ||
3269 | &self.syntax | ||
3270 | } | ||
3271 | } | ||
3272 | impl ast::VisibilityOwner for RecordFieldDef {} | ||
3273 | impl ast::NameOwner for RecordFieldDef {} | ||
3274 | impl ast::AttrsOwner for RecordFieldDef {} | ||
3275 | impl ast::DocCommentsOwner for RecordFieldDef {} | ||
3276 | impl ast::TypeAscriptionOwner for RecordFieldDef {} | ||
3277 | impl RecordFieldDef {} | ||
3278 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3279 | pub struct TupleFieldDefList { | ||
3280 | pub(crate) syntax: SyntaxNode, | ||
3281 | } | ||
3282 | impl std::fmt::Display for TupleFieldDefList { | ||
3283 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3284 | std::fmt::Display::fmt(self.syntax(), f) | ||
3285 | } | ||
3286 | } | ||
3287 | impl AstNode for TupleFieldDefList { | ||
3288 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3289 | match kind { | ||
3290 | TUPLE_FIELD_DEF_LIST => true, | ||
3291 | _ => false, | ||
3292 | } | ||
3293 | } | ||
3294 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3295 | if Self::can_cast(syntax.kind()) { | ||
3296 | Some(Self { syntax }) | ||
3297 | } else { | ||
3298 | None | ||
3299 | } | ||
3300 | } | ||
3301 | fn syntax(&self) -> &SyntaxNode { | ||
3302 | &self.syntax | ||
3303 | } | ||
3304 | } | ||
3305 | impl TupleFieldDefList { | ||
3306 | pub fn fields(&self) -> AstChildren<TupleFieldDef> { | ||
3307 | AstChildren::new(&self.syntax) | ||
3308 | } | ||
3309 | } | ||
3310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3311 | pub struct TupleFieldDef { | ||
3312 | pub(crate) syntax: SyntaxNode, | ||
3313 | } | ||
3314 | impl std::fmt::Display for TupleFieldDef { | ||
3315 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3316 | std::fmt::Display::fmt(self.syntax(), f) | ||
3317 | } | ||
3318 | } | ||
3319 | impl AstNode for TupleFieldDef { | ||
3320 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3321 | match kind { | ||
3322 | TUPLE_FIELD_DEF => true, | ||
3323 | _ => false, | ||
3324 | } | ||
3325 | } | ||
3326 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3327 | if Self::can_cast(syntax.kind()) { | ||
3328 | Some(Self { syntax }) | ||
3329 | } else { | ||
3330 | None | ||
3331 | } | ||
3332 | } | ||
3333 | fn syntax(&self) -> &SyntaxNode { | ||
3334 | &self.syntax | ||
3335 | } | ||
3336 | } | ||
3337 | impl ast::VisibilityOwner for TupleFieldDef {} | ||
3338 | impl ast::AttrsOwner for TupleFieldDef {} | ||
3339 | impl TupleFieldDef { | ||
3340 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3341 | AstChildren::new(&self.syntax).next() | ||
3342 | } | ||
3343 | } | ||
3344 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3345 | pub struct EnumDef { | ||
3346 | pub(crate) syntax: SyntaxNode, | ||
3347 | } | ||
3348 | impl std::fmt::Display for EnumDef { | ||
3349 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3350 | std::fmt::Display::fmt(self.syntax(), f) | ||
3351 | } | ||
3352 | } | ||
3353 | impl AstNode for EnumDef { | ||
3354 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3355 | match kind { | ||
3356 | ENUM_DEF => true, | ||
3357 | _ => false, | ||
3358 | } | ||
3359 | } | ||
3360 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3361 | if Self::can_cast(syntax.kind()) { | ||
3362 | Some(Self { syntax }) | ||
3363 | } else { | ||
3364 | None | ||
3365 | } | ||
3366 | } | ||
3367 | fn syntax(&self) -> &SyntaxNode { | ||
3368 | &self.syntax | ||
3369 | } | ||
3370 | } | ||
3371 | impl ast::VisibilityOwner for EnumDef {} | ||
3372 | impl ast::NameOwner for EnumDef {} | ||
3373 | impl ast::TypeParamsOwner for EnumDef {} | ||
3374 | impl ast::AttrsOwner for EnumDef {} | ||
3375 | impl ast::DocCommentsOwner for EnumDef {} | ||
3376 | impl EnumDef { | ||
3377 | pub fn variant_list(&self) -> Option<EnumVariantList> { | ||
3378 | AstChildren::new(&self.syntax).next() | ||
3379 | } | ||
3380 | } | ||
3381 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3382 | pub struct EnumVariantList { | ||
3383 | pub(crate) syntax: SyntaxNode, | ||
3384 | } | ||
3385 | impl std::fmt::Display for EnumVariantList { | ||
3386 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3387 | std::fmt::Display::fmt(self.syntax(), f) | ||
3388 | } | ||
3389 | } | ||
3390 | impl AstNode for EnumVariantList { | ||
3391 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3392 | match kind { | ||
3393 | ENUM_VARIANT_LIST => true, | ||
3394 | _ => false, | ||
3395 | } | ||
3396 | } | ||
3397 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3398 | if Self::can_cast(syntax.kind()) { | ||
3399 | Some(Self { syntax }) | ||
3400 | } else { | ||
3401 | None | ||
3402 | } | ||
3403 | } | ||
3404 | fn syntax(&self) -> &SyntaxNode { | ||
3405 | &self.syntax | ||
3406 | } | ||
3407 | } | ||
3408 | impl EnumVariantList { | ||
3409 | pub fn variants(&self) -> AstChildren<EnumVariant> { | ||
3410 | AstChildren::new(&self.syntax) | ||
3411 | } | ||
3412 | } | ||
3413 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3414 | pub struct EnumVariant { | ||
3415 | pub(crate) syntax: SyntaxNode, | ||
3416 | } | ||
3417 | impl std::fmt::Display for EnumVariant { | ||
3418 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3419 | std::fmt::Display::fmt(self.syntax(), f) | ||
3420 | } | ||
3421 | } | ||
3422 | impl AstNode for EnumVariant { | ||
3423 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3424 | match kind { | ||
3425 | ENUM_VARIANT => true, | ||
3426 | _ => false, | ||
3427 | } | ||
3428 | } | ||
3429 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3430 | if Self::can_cast(syntax.kind()) { | ||
3431 | Some(Self { syntax }) | ||
3432 | } else { | ||
3433 | None | ||
3434 | } | ||
3435 | } | ||
3436 | fn syntax(&self) -> &SyntaxNode { | ||
3437 | &self.syntax | ||
3438 | } | ||
3439 | } | ||
3440 | impl ast::NameOwner for EnumVariant {} | ||
3441 | impl ast::DocCommentsOwner for EnumVariant {} | ||
3442 | impl ast::AttrsOwner for EnumVariant {} | ||
3443 | impl EnumVariant { | ||
3444 | pub fn expr(&self) -> Option<Expr> { | ||
3445 | AstChildren::new(&self.syntax).next() | ||
3446 | } | ||
3447 | } | ||
3448 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3449 | pub struct TraitDef { | ||
3450 | pub(crate) syntax: SyntaxNode, | ||
3451 | } | ||
3452 | impl std::fmt::Display for TraitDef { | ||
3453 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3454 | std::fmt::Display::fmt(self.syntax(), f) | ||
3455 | } | ||
3456 | } | ||
3457 | impl AstNode for TraitDef { | ||
3458 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3459 | match kind { | ||
3460 | TRAIT_DEF => true, | ||
3461 | _ => false, | ||
3462 | } | ||
3463 | } | ||
3464 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3465 | if Self::can_cast(syntax.kind()) { | ||
3466 | Some(Self { syntax }) | ||
3467 | } else { | ||
3468 | None | ||
3469 | } | ||
3470 | } | ||
3471 | fn syntax(&self) -> &SyntaxNode { | ||
3472 | &self.syntax | ||
3473 | } | ||
3474 | } | ||
3475 | impl ast::VisibilityOwner for TraitDef {} | ||
3476 | impl ast::NameOwner for TraitDef {} | ||
3477 | impl ast::AttrsOwner for TraitDef {} | ||
3478 | impl ast::DocCommentsOwner for TraitDef {} | ||
3479 | impl ast::TypeParamsOwner for TraitDef {} | ||
3480 | impl ast::TypeBoundsOwner for TraitDef {} | ||
3481 | impl TraitDef { | ||
3482 | pub fn item_list(&self) -> Option<ItemList> { | ||
3483 | AstChildren::new(&self.syntax).next() | ||
3484 | } | ||
3485 | } | ||
3486 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3487 | pub struct Module { | ||
3488 | pub(crate) syntax: SyntaxNode, | ||
3489 | } | ||
3490 | impl std::fmt::Display for Module { | ||
3491 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3492 | std::fmt::Display::fmt(self.syntax(), f) | ||
3493 | } | ||
3494 | } | ||
3495 | impl AstNode for Module { | ||
3496 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3497 | match kind { | ||
3498 | MODULE => true, | ||
3499 | _ => false, | ||
3500 | } | ||
3501 | } | ||
3502 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3503 | if Self::can_cast(syntax.kind()) { | ||
3504 | Some(Self { syntax }) | ||
3505 | } else { | ||
3506 | None | ||
3507 | } | ||
3508 | } | ||
3509 | fn syntax(&self) -> &SyntaxNode { | ||
3510 | &self.syntax | ||
3511 | } | ||
3512 | } | ||
3513 | impl ast::VisibilityOwner for Module {} | ||
3514 | impl ast::NameOwner for Module {} | ||
3515 | impl ast::AttrsOwner for Module {} | ||
3516 | impl ast::DocCommentsOwner for Module {} | ||
3517 | impl Module { | ||
3518 | pub fn item_list(&self) -> Option<ItemList> { | ||
3519 | AstChildren::new(&self.syntax).next() | ||
3520 | } | ||
3521 | } | ||
3522 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3523 | pub struct ItemList { | ||
3524 | pub(crate) syntax: SyntaxNode, | ||
3525 | } | ||
3526 | impl std::fmt::Display for ItemList { | ||
3527 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3528 | std::fmt::Display::fmt(self.syntax(), f) | ||
3529 | } | ||
3530 | } | ||
3531 | impl AstNode for ItemList { | ||
3532 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3533 | match kind { | ||
3534 | ITEM_LIST => true, | ||
3535 | _ => false, | ||
3536 | } | ||
3537 | } | ||
3538 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3539 | if Self::can_cast(syntax.kind()) { | ||
3540 | Some(Self { syntax }) | ||
3541 | } else { | ||
3542 | None | ||
3543 | } | ||
3544 | } | ||
3545 | fn syntax(&self) -> &SyntaxNode { | ||
3546 | &self.syntax | ||
3547 | } | ||
3548 | } | ||
3549 | impl ast::FnDefOwner for ItemList {} | ||
3550 | impl ast::ModuleItemOwner for ItemList {} | ||
3551 | impl ItemList { | ||
3552 | pub fn impl_items(&self) -> AstChildren<ImplItem> { | ||
3553 | AstChildren::new(&self.syntax) | ||
3554 | } | ||
3555 | } | ||
3556 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3557 | pub struct ConstDef { | ||
3558 | pub(crate) syntax: SyntaxNode, | ||
3559 | } | ||
3560 | impl std::fmt::Display for ConstDef { | ||
3561 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3562 | std::fmt::Display::fmt(self.syntax(), f) | ||
3563 | } | ||
3564 | } | ||
3565 | impl AstNode for ConstDef { | ||
3566 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3567 | match kind { | ||
3568 | CONST_DEF => true, | ||
3569 | _ => false, | ||
3570 | } | ||
3571 | } | ||
3572 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3573 | if Self::can_cast(syntax.kind()) { | ||
3574 | Some(Self { syntax }) | ||
3575 | } else { | ||
3576 | None | ||
3577 | } | ||
3578 | } | ||
3579 | fn syntax(&self) -> &SyntaxNode { | ||
3580 | &self.syntax | ||
3581 | } | ||
3582 | } | ||
3583 | impl ast::VisibilityOwner for ConstDef {} | ||
3584 | impl ast::NameOwner for ConstDef {} | ||
3585 | impl ast::TypeParamsOwner for ConstDef {} | ||
3586 | impl ast::AttrsOwner for ConstDef {} | ||
3587 | impl ast::DocCommentsOwner for ConstDef {} | ||
3588 | impl ast::TypeAscriptionOwner for ConstDef {} | ||
3589 | impl ConstDef { | ||
3590 | pub fn body(&self) -> Option<Expr> { | ||
3591 | AstChildren::new(&self.syntax).next() | ||
3592 | } | ||
3593 | } | ||
3594 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3595 | pub struct StaticDef { | ||
3596 | pub(crate) syntax: SyntaxNode, | ||
3597 | } | ||
3598 | impl std::fmt::Display for StaticDef { | ||
3599 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3600 | std::fmt::Display::fmt(self.syntax(), f) | ||
3601 | } | ||
3602 | } | ||
3603 | impl AstNode for StaticDef { | ||
3604 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3605 | match kind { | ||
3606 | STATIC_DEF => true, | ||
3607 | _ => false, | ||
3608 | } | ||
3609 | } | ||
3610 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3611 | if Self::can_cast(syntax.kind()) { | ||
3612 | Some(Self { syntax }) | ||
3613 | } else { | ||
3614 | None | ||
3615 | } | ||
3616 | } | ||
3617 | fn syntax(&self) -> &SyntaxNode { | ||
3618 | &self.syntax | ||
3619 | } | ||
3620 | } | ||
3621 | impl ast::VisibilityOwner for StaticDef {} | ||
3622 | impl ast::NameOwner for StaticDef {} | ||
3623 | impl ast::TypeParamsOwner for StaticDef {} | ||
3624 | impl ast::AttrsOwner for StaticDef {} | ||
3625 | impl ast::DocCommentsOwner for StaticDef {} | ||
3626 | impl ast::TypeAscriptionOwner for StaticDef {} | ||
3627 | impl StaticDef { | ||
3628 | pub fn body(&self) -> Option<Expr> { | ||
3629 | AstChildren::new(&self.syntax).next() | ||
3630 | } | ||
3631 | } | ||
3632 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3633 | pub struct TypeAliasDef { | ||
3634 | pub(crate) syntax: SyntaxNode, | ||
3635 | } | ||
3636 | impl std::fmt::Display for TypeAliasDef { | ||
3637 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3638 | std::fmt::Display::fmt(self.syntax(), f) | ||
3639 | } | ||
3640 | } | ||
3641 | impl AstNode for TypeAliasDef { | ||
3642 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3643 | match kind { | ||
3644 | TYPE_ALIAS_DEF => true, | ||
3645 | _ => false, | ||
3646 | } | ||
3647 | } | ||
3648 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3649 | if Self::can_cast(syntax.kind()) { | ||
3650 | Some(Self { syntax }) | ||
3651 | } else { | ||
3652 | None | ||
3653 | } | ||
3654 | } | ||
3655 | fn syntax(&self) -> &SyntaxNode { | ||
3656 | &self.syntax | ||
3657 | } | ||
3658 | } | ||
3659 | impl ast::VisibilityOwner for TypeAliasDef {} | ||
3660 | impl ast::NameOwner for TypeAliasDef {} | ||
3661 | impl ast::TypeParamsOwner for TypeAliasDef {} | ||
3662 | impl ast::AttrsOwner for TypeAliasDef {} | ||
3663 | impl ast::DocCommentsOwner for TypeAliasDef {} | ||
3664 | impl ast::TypeBoundsOwner for TypeAliasDef {} | ||
3665 | impl TypeAliasDef { | ||
3666 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3667 | AstChildren::new(&self.syntax).next() | ||
3668 | } | ||
3669 | } | ||
3670 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3671 | pub struct ImplDef { | ||
3672 | pub(crate) syntax: SyntaxNode, | ||
3673 | } | ||
3674 | impl std::fmt::Display for ImplDef { | ||
3675 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3676 | std::fmt::Display::fmt(self.syntax(), f) | ||
3677 | } | ||
3678 | } | ||
3679 | impl AstNode for ImplDef { | ||
3680 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3681 | match kind { | ||
3682 | IMPL_DEF => true, | ||
3683 | _ => false, | ||
3684 | } | ||
3685 | } | ||
3686 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3687 | if Self::can_cast(syntax.kind()) { | ||
3688 | Some(Self { syntax }) | ||
3689 | } else { | ||
3690 | None | ||
3691 | } | ||
3692 | } | ||
3693 | fn syntax(&self) -> &SyntaxNode { | ||
3694 | &self.syntax | ||
3695 | } | ||
3696 | } | ||
3697 | impl ast::TypeParamsOwner for ImplDef {} | ||
3698 | impl ast::AttrsOwner for ImplDef {} | ||
3699 | impl ImplDef { | ||
3700 | pub fn item_list(&self) -> Option<ItemList> { | ||
3701 | AstChildren::new(&self.syntax).next() | ||
3702 | } | ||
3703 | } | ||
3704 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3705 | pub struct ParenType { | ||
3706 | pub(crate) syntax: SyntaxNode, | ||
3707 | } | ||
3708 | impl std::fmt::Display for ParenType { | ||
3709 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3710 | std::fmt::Display::fmt(self.syntax(), f) | ||
3711 | } | ||
3712 | } | ||
3713 | impl AstNode for ParenType { | ||
3714 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3715 | match kind { | ||
3716 | PAREN_TYPE => true, | ||
3717 | _ => false, | ||
3718 | } | ||
3719 | } | ||
3720 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3721 | if Self::can_cast(syntax.kind()) { | ||
3722 | Some(Self { syntax }) | ||
3723 | } else { | ||
3724 | None | ||
3725 | } | ||
3726 | } | ||
3727 | fn syntax(&self) -> &SyntaxNode { | ||
3728 | &self.syntax | ||
3729 | } | ||
3730 | } | ||
3731 | impl ParenType { | ||
3732 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3733 | AstChildren::new(&self.syntax).next() | ||
3734 | } | ||
3735 | } | ||
3736 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3737 | pub struct TupleType { | ||
3738 | pub(crate) syntax: SyntaxNode, | ||
3739 | } | ||
3740 | impl std::fmt::Display for TupleType { | ||
3741 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3742 | std::fmt::Display::fmt(self.syntax(), f) | ||
3743 | } | ||
3744 | } | ||
3745 | impl AstNode for TupleType { | ||
3746 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3747 | match kind { | ||
3748 | TUPLE_TYPE => true, | ||
3749 | _ => false, | ||
3750 | } | ||
3751 | } | ||
3752 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3753 | if Self::can_cast(syntax.kind()) { | ||
3754 | Some(Self { syntax }) | ||
3755 | } else { | ||
3756 | None | ||
3757 | } | ||
3758 | } | ||
3759 | fn syntax(&self) -> &SyntaxNode { | ||
3760 | &self.syntax | ||
3761 | } | ||
3762 | } | ||
3763 | impl TupleType { | ||
3764 | pub fn fields(&self) -> AstChildren<TypeRef> { | ||
3765 | AstChildren::new(&self.syntax) | ||
3766 | } | ||
3767 | } | ||
3768 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3769 | pub struct NeverType { | ||
3770 | pub(crate) syntax: SyntaxNode, | ||
3771 | } | ||
3772 | impl std::fmt::Display for NeverType { | ||
3773 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3774 | std::fmt::Display::fmt(self.syntax(), f) | ||
3775 | } | ||
3776 | } | ||
3777 | impl AstNode for NeverType { | ||
3778 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3779 | match kind { | ||
3780 | NEVER_TYPE => true, | ||
3781 | _ => false, | ||
3782 | } | ||
3783 | } | ||
3784 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3785 | if Self::can_cast(syntax.kind()) { | ||
3786 | Some(Self { syntax }) | ||
3787 | } else { | ||
3788 | None | ||
3789 | } | ||
3790 | } | ||
3791 | fn syntax(&self) -> &SyntaxNode { | ||
3792 | &self.syntax | ||
3793 | } | ||
3794 | } | ||
3795 | impl NeverType {} | ||
3796 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3797 | pub struct PathType { | ||
3798 | pub(crate) syntax: SyntaxNode, | ||
3799 | } | ||
3800 | impl std::fmt::Display for PathType { | ||
3801 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3802 | std::fmt::Display::fmt(self.syntax(), f) | ||
3803 | } | ||
3804 | } | ||
3805 | impl AstNode for PathType { | ||
3806 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3807 | match kind { | ||
3808 | PATH_TYPE => true, | ||
3809 | _ => false, | ||
3810 | } | ||
3811 | } | ||
3812 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3813 | if Self::can_cast(syntax.kind()) { | ||
3814 | Some(Self { syntax }) | ||
3815 | } else { | ||
3816 | None | ||
3817 | } | ||
3818 | } | ||
3819 | fn syntax(&self) -> &SyntaxNode { | ||
3820 | &self.syntax | ||
3821 | } | ||
3822 | } | ||
3823 | impl PathType { | ||
3824 | pub fn path(&self) -> Option<Path> { | ||
3825 | AstChildren::new(&self.syntax).next() | ||
3826 | } | ||
3827 | } | ||
3828 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3829 | pub struct PointerType { | ||
3830 | pub(crate) syntax: SyntaxNode, | ||
3831 | } | ||
3832 | impl std::fmt::Display for PointerType { | ||
3833 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3834 | std::fmt::Display::fmt(self.syntax(), f) | ||
3835 | } | ||
3836 | } | ||
3837 | impl AstNode for PointerType { | ||
3838 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3839 | match kind { | ||
3840 | POINTER_TYPE => true, | ||
3841 | _ => false, | ||
3842 | } | ||
3843 | } | ||
3844 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3845 | if Self::can_cast(syntax.kind()) { | ||
3846 | Some(Self { syntax }) | ||
3847 | } else { | ||
3848 | None | ||
3849 | } | ||
3850 | } | ||
3851 | fn syntax(&self) -> &SyntaxNode { | ||
3852 | &self.syntax | ||
3853 | } | ||
3854 | } | ||
3855 | impl PointerType { | ||
3856 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3857 | AstChildren::new(&self.syntax).next() | ||
3858 | } | ||
3859 | } | ||
3860 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3861 | pub struct ArrayType { | ||
3862 | pub(crate) syntax: SyntaxNode, | ||
3863 | } | ||
3864 | impl std::fmt::Display for ArrayType { | ||
3865 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3866 | std::fmt::Display::fmt(self.syntax(), f) | ||
3867 | } | ||
3868 | } | ||
3869 | impl AstNode for ArrayType { | ||
3870 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3871 | match kind { | ||
3872 | ARRAY_TYPE => true, | ||
3873 | _ => false, | ||
3874 | } | ||
3875 | } | ||
3876 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3877 | if Self::can_cast(syntax.kind()) { | ||
3878 | Some(Self { syntax }) | ||
3879 | } else { | ||
3880 | None | ||
3881 | } | ||
3882 | } | ||
3883 | fn syntax(&self) -> &SyntaxNode { | ||
3884 | &self.syntax | ||
3885 | } | ||
3886 | } | ||
3887 | impl ArrayType { | ||
3888 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3889 | AstChildren::new(&self.syntax).next() | ||
3890 | } | ||
3891 | pub fn expr(&self) -> Option<Expr> { | ||
3892 | AstChildren::new(&self.syntax).next() | ||
3893 | } | ||
3894 | } | ||
3895 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3896 | pub struct SliceType { | ||
3897 | pub(crate) syntax: SyntaxNode, | ||
3898 | } | ||
3899 | impl std::fmt::Display for SliceType { | ||
3900 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3901 | std::fmt::Display::fmt(self.syntax(), f) | ||
3902 | } | ||
3903 | } | ||
3904 | impl AstNode for SliceType { | ||
3905 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3906 | match kind { | ||
3907 | SLICE_TYPE => true, | ||
3908 | _ => false, | ||
3909 | } | ||
3910 | } | ||
3911 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3912 | if Self::can_cast(syntax.kind()) { | ||
3913 | Some(Self { syntax }) | ||
3914 | } else { | ||
3915 | None | ||
3916 | } | ||
3917 | } | ||
3918 | fn syntax(&self) -> &SyntaxNode { | ||
3919 | &self.syntax | ||
3920 | } | ||
3921 | } | ||
3922 | impl SliceType { | ||
3923 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3924 | AstChildren::new(&self.syntax).next() | ||
3925 | } | ||
3926 | } | ||
3927 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3928 | pub struct ReferenceType { | ||
3929 | pub(crate) syntax: SyntaxNode, | ||
3930 | } | ||
3931 | impl std::fmt::Display for ReferenceType { | ||
3932 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3933 | std::fmt::Display::fmt(self.syntax(), f) | ||
3934 | } | ||
3935 | } | ||
3936 | impl AstNode for ReferenceType { | ||
3937 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3938 | match kind { | ||
3939 | REFERENCE_TYPE => true, | ||
3940 | _ => false, | ||
3941 | } | ||
3942 | } | ||
3943 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3944 | if Self::can_cast(syntax.kind()) { | ||
3945 | Some(Self { syntax }) | ||
3946 | } else { | ||
3947 | None | ||
3948 | } | ||
3949 | } | ||
3950 | fn syntax(&self) -> &SyntaxNode { | ||
3951 | &self.syntax | ||
3952 | } | ||
3953 | } | ||
3954 | impl ReferenceType { | ||
3955 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
3956 | AstChildren::new(&self.syntax).next() | ||
3957 | } | ||
3958 | } | ||
3959 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3960 | pub struct PlaceholderType { | ||
3961 | pub(crate) syntax: SyntaxNode, | ||
3962 | } | ||
3963 | impl std::fmt::Display for PlaceholderType { | ||
3964 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3965 | std::fmt::Display::fmt(self.syntax(), f) | ||
3966 | } | ||
3967 | } | ||
3968 | impl AstNode for PlaceholderType { | ||
3969 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3970 | match kind { | ||
3971 | PLACEHOLDER_TYPE => true, | ||
3972 | _ => false, | ||
3973 | } | ||
3974 | } | ||
3975 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3976 | if Self::can_cast(syntax.kind()) { | ||
3977 | Some(Self { syntax }) | ||
3978 | } else { | ||
3979 | None | ||
3980 | } | ||
3981 | } | ||
3982 | fn syntax(&self) -> &SyntaxNode { | ||
3983 | &self.syntax | ||
3984 | } | ||
3985 | } | ||
3986 | impl PlaceholderType {} | ||
3987 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3988 | pub struct FnPointerType { | ||
3989 | pub(crate) syntax: SyntaxNode, | ||
3990 | } | ||
3991 | impl std::fmt::Display for FnPointerType { | ||
3992 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3993 | std::fmt::Display::fmt(self.syntax(), f) | ||
3994 | } | ||
3995 | } | ||
3996 | impl AstNode for FnPointerType { | ||
3997 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3998 | match kind { | ||
3999 | FN_POINTER_TYPE => true, | ||
4000 | _ => false, | ||
4001 | } | ||
4002 | } | ||
4003 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4004 | if Self::can_cast(syntax.kind()) { | ||
4005 | Some(Self { syntax }) | ||
4006 | } else { | ||
4007 | None | ||
4008 | } | ||
4009 | } | ||
4010 | fn syntax(&self) -> &SyntaxNode { | ||
4011 | &self.syntax | ||
4012 | } | ||
4013 | } | ||
4014 | impl FnPointerType { | ||
4015 | pub fn param_list(&self) -> Option<ParamList> { | ||
4016 | AstChildren::new(&self.syntax).next() | ||
4017 | } | ||
4018 | pub fn ret_type(&self) -> Option<RetType> { | ||
4019 | AstChildren::new(&self.syntax).next() | ||
4020 | } | ||
4021 | } | ||
4022 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4023 | pub struct ForType { | ||
4024 | pub(crate) syntax: SyntaxNode, | ||
4025 | } | ||
4026 | impl std::fmt::Display for ForType { | ||
4027 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4028 | std::fmt::Display::fmt(self.syntax(), f) | ||
4029 | } | ||
4030 | } | ||
4031 | impl AstNode for ForType { | ||
4032 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4033 | match kind { | ||
4034 | FOR_TYPE => true, | ||
4035 | _ => false, | ||
4036 | } | ||
4037 | } | ||
4038 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4039 | if Self::can_cast(syntax.kind()) { | ||
4040 | Some(Self { syntax }) | ||
4041 | } else { | ||
4042 | None | ||
4043 | } | ||
4044 | } | ||
4045 | fn syntax(&self) -> &SyntaxNode { | ||
4046 | &self.syntax | ||
4047 | } | ||
4048 | } | ||
4049 | impl ForType { | ||
4050 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
4051 | AstChildren::new(&self.syntax).next() | ||
4052 | } | ||
4053 | } | ||
4054 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4055 | pub struct ImplTraitType { | ||
4056 | pub(crate) syntax: SyntaxNode, | ||
4057 | } | ||
4058 | impl std::fmt::Display for ImplTraitType { | ||
4059 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4060 | std::fmt::Display::fmt(self.syntax(), f) | ||
4061 | } | ||
4062 | } | ||
4063 | impl AstNode for ImplTraitType { | ||
4064 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4065 | match kind { | ||
4066 | IMPL_TRAIT_TYPE => true, | ||
4067 | _ => false, | ||
4068 | } | ||
4069 | } | ||
4070 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4071 | if Self::can_cast(syntax.kind()) { | ||
4072 | Some(Self { syntax }) | ||
4073 | } else { | ||
4074 | None | ||
4075 | } | ||
4076 | } | ||
4077 | fn syntax(&self) -> &SyntaxNode { | ||
4078 | &self.syntax | ||
4079 | } | ||
4080 | } | ||
4081 | impl ast::TypeBoundsOwner for ImplTraitType {} | ||
4082 | impl ImplTraitType {} | ||
4083 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4084 | pub struct DynTraitType { | ||
4085 | pub(crate) syntax: SyntaxNode, | ||
4086 | } | ||
4087 | impl std::fmt::Display for DynTraitType { | ||
4088 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4089 | std::fmt::Display::fmt(self.syntax(), f) | ||
4090 | } | ||
4091 | } | ||
4092 | impl AstNode for DynTraitType { | ||
4093 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4094 | match kind { | ||
4095 | DYN_TRAIT_TYPE => true, | ||
4096 | _ => false, | ||
4097 | } | ||
4098 | } | ||
4099 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4100 | if Self::can_cast(syntax.kind()) { | ||
4101 | Some(Self { syntax }) | ||
4102 | } else { | ||
4103 | None | ||
4104 | } | ||
4105 | } | ||
4106 | fn syntax(&self) -> &SyntaxNode { | ||
4107 | &self.syntax | ||
4108 | } | ||
4109 | } | ||
4110 | impl ast::TypeBoundsOwner for DynTraitType {} | ||
4111 | impl DynTraitType {} | ||
4112 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4113 | pub struct TupleExpr { | ||
4114 | pub(crate) syntax: SyntaxNode, | ||
4115 | } | ||
4116 | impl std::fmt::Display for TupleExpr { | ||
4117 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4118 | std::fmt::Display::fmt(self.syntax(), f) | ||
4119 | } | ||
4120 | } | ||
4121 | impl AstNode for TupleExpr { | ||
4122 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4123 | match kind { | ||
4124 | TUPLE_EXPR => true, | ||
4125 | _ => false, | ||
4126 | } | ||
4127 | } | ||
4128 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4129 | if Self::can_cast(syntax.kind()) { | ||
4130 | Some(Self { syntax }) | ||
4131 | } else { | ||
4132 | None | ||
4133 | } | ||
4134 | } | ||
4135 | fn syntax(&self) -> &SyntaxNode { | ||
4136 | &self.syntax | ||
4137 | } | ||
4138 | } | ||
4139 | impl TupleExpr { | ||
4140 | pub fn exprs(&self) -> AstChildren<Expr> { | ||
4141 | AstChildren::new(&self.syntax) | ||
4142 | } | ||
4143 | } | ||
4144 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4145 | pub struct ArrayExpr { | ||
4146 | pub(crate) syntax: SyntaxNode, | ||
4147 | } | ||
4148 | impl std::fmt::Display for ArrayExpr { | ||
4149 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4150 | std::fmt::Display::fmt(self.syntax(), f) | ||
4151 | } | ||
4152 | } | ||
4153 | impl AstNode for ArrayExpr { | ||
4154 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4155 | match kind { | ||
4156 | ARRAY_EXPR => true, | ||
4157 | _ => false, | ||
4158 | } | ||
4159 | } | ||
4160 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4161 | if Self::can_cast(syntax.kind()) { | ||
4162 | Some(Self { syntax }) | ||
4163 | } else { | ||
4164 | None | ||
4165 | } | ||
4166 | } | ||
4167 | fn syntax(&self) -> &SyntaxNode { | ||
4168 | &self.syntax | ||
4169 | } | ||
4170 | } | ||
4171 | impl ArrayExpr { | ||
4172 | pub fn exprs(&self) -> AstChildren<Expr> { | ||
4173 | AstChildren::new(&self.syntax) | ||
4174 | } | ||
4175 | } | ||
4176 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4177 | pub struct ParenExpr { | ||
4178 | pub(crate) syntax: SyntaxNode, | ||
4179 | } | ||
4180 | impl std::fmt::Display for ParenExpr { | ||
4181 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4182 | std::fmt::Display::fmt(self.syntax(), f) | ||
4183 | } | ||
4184 | } | ||
4185 | impl AstNode for ParenExpr { | ||
4186 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4187 | match kind { | ||
4188 | PAREN_EXPR => true, | ||
4189 | _ => false, | ||
4190 | } | ||
4191 | } | ||
4192 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4193 | if Self::can_cast(syntax.kind()) { | ||
4194 | Some(Self { syntax }) | ||
4195 | } else { | ||
4196 | None | ||
4197 | } | ||
4198 | } | ||
4199 | fn syntax(&self) -> &SyntaxNode { | ||
4200 | &self.syntax | ||
4201 | } | ||
4202 | } | ||
4203 | impl ParenExpr { | ||
4204 | pub fn expr(&self) -> Option<Expr> { | ||
4205 | AstChildren::new(&self.syntax).next() | ||
4206 | } | ||
4207 | } | ||
4208 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4209 | pub struct PathExpr { | ||
4210 | pub(crate) syntax: SyntaxNode, | ||
4211 | } | ||
4212 | impl std::fmt::Display for PathExpr { | ||
4213 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4214 | std::fmt::Display::fmt(self.syntax(), f) | ||
4215 | } | ||
4216 | } | ||
4217 | impl AstNode for PathExpr { | ||
4218 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4219 | match kind { | ||
4220 | PATH_EXPR => true, | ||
4221 | _ => false, | ||
4222 | } | ||
4223 | } | ||
4224 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4225 | if Self::can_cast(syntax.kind()) { | ||
4226 | Some(Self { syntax }) | ||
4227 | } else { | ||
4228 | None | ||
4229 | } | ||
4230 | } | ||
4231 | fn syntax(&self) -> &SyntaxNode { | ||
4232 | &self.syntax | ||
4233 | } | ||
4234 | } | ||
4235 | impl PathExpr { | ||
4236 | pub fn path(&self) -> Option<Path> { | ||
4237 | AstChildren::new(&self.syntax).next() | ||
4238 | } | ||
4239 | } | ||
4240 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4241 | pub struct LambdaExpr { | ||
4242 | pub(crate) syntax: SyntaxNode, | ||
4243 | } | ||
4244 | impl std::fmt::Display for LambdaExpr { | ||
4245 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4246 | std::fmt::Display::fmt(self.syntax(), f) | ||
4247 | } | ||
4248 | } | ||
4249 | impl AstNode for LambdaExpr { | ||
4250 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4251 | match kind { | ||
4252 | LAMBDA_EXPR => true, | ||
4253 | _ => false, | ||
4254 | } | ||
4255 | } | ||
4256 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4257 | if Self::can_cast(syntax.kind()) { | ||
4258 | Some(Self { syntax }) | ||
4259 | } else { | ||
4260 | None | ||
4261 | } | ||
4262 | } | ||
4263 | fn syntax(&self) -> &SyntaxNode { | ||
4264 | &self.syntax | ||
4265 | } | ||
4266 | } | ||
4267 | impl LambdaExpr { | ||
4268 | pub fn param_list(&self) -> Option<ParamList> { | ||
4269 | AstChildren::new(&self.syntax).next() | ||
4270 | } | ||
4271 | pub fn ret_type(&self) -> Option<RetType> { | ||
4272 | AstChildren::new(&self.syntax).next() | ||
4273 | } | ||
4274 | pub fn body(&self) -> Option<Expr> { | ||
4275 | AstChildren::new(&self.syntax).next() | ||
4276 | } | ||
4277 | } | ||
4278 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4279 | pub struct IfExpr { | ||
4280 | pub(crate) syntax: SyntaxNode, | ||
4281 | } | ||
4282 | impl std::fmt::Display for IfExpr { | ||
4283 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4284 | std::fmt::Display::fmt(self.syntax(), f) | ||
4285 | } | ||
4286 | } | ||
4287 | impl AstNode for IfExpr { | ||
4288 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4289 | match kind { | ||
4290 | IF_EXPR => true, | ||
4291 | _ => false, | ||
4292 | } | ||
4293 | } | ||
4294 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4295 | if Self::can_cast(syntax.kind()) { | ||
4296 | Some(Self { syntax }) | ||
4297 | } else { | ||
4298 | None | ||
4299 | } | ||
4300 | } | ||
4301 | fn syntax(&self) -> &SyntaxNode { | ||
4302 | &self.syntax | ||
4303 | } | ||
4304 | } | ||
4305 | impl IfExpr { | ||
4306 | pub fn condition(&self) -> Option<Condition> { | ||
4307 | AstChildren::new(&self.syntax).next() | ||
4308 | } | ||
4309 | } | ||
4310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4311 | pub struct LoopExpr { | ||
4312 | pub(crate) syntax: SyntaxNode, | ||
4313 | } | ||
4314 | impl std::fmt::Display for LoopExpr { | ||
4315 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4316 | std::fmt::Display::fmt(self.syntax(), f) | ||
4317 | } | ||
4318 | } | ||
4319 | impl AstNode for LoopExpr { | ||
4320 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4321 | match kind { | ||
4322 | LOOP_EXPR => true, | ||
4323 | _ => false, | ||
4324 | } | ||
4325 | } | ||
4326 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4327 | if Self::can_cast(syntax.kind()) { | ||
4328 | Some(Self { syntax }) | ||
4329 | } else { | ||
4330 | None | ||
4331 | } | ||
4332 | } | ||
4333 | fn syntax(&self) -> &SyntaxNode { | ||
4334 | &self.syntax | ||
4335 | } | ||
4336 | } | ||
4337 | impl ast::LoopBodyOwner for LoopExpr {} | ||
4338 | impl LoopExpr {} | ||
4339 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4340 | pub struct TryBlockExpr { | ||
4341 | pub(crate) syntax: SyntaxNode, | ||
4342 | } | ||
4343 | impl std::fmt::Display for TryBlockExpr { | ||
4344 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4345 | std::fmt::Display::fmt(self.syntax(), f) | ||
4346 | } | ||
4347 | } | ||
4348 | impl AstNode for TryBlockExpr { | ||
4349 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4350 | match kind { | ||
4351 | TRY_BLOCK_EXPR => true, | ||
4352 | _ => false, | ||
4353 | } | ||
4354 | } | ||
4355 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4356 | if Self::can_cast(syntax.kind()) { | ||
4357 | Some(Self { syntax }) | ||
4358 | } else { | ||
4359 | None | ||
4360 | } | ||
4361 | } | ||
4362 | fn syntax(&self) -> &SyntaxNode { | ||
4363 | &self.syntax | ||
4364 | } | ||
4365 | } | ||
4366 | impl TryBlockExpr { | ||
4367 | pub fn body(&self) -> Option<BlockExpr> { | ||
4368 | AstChildren::new(&self.syntax).next() | ||
4369 | } | ||
4370 | } | ||
4371 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4372 | pub struct ForExpr { | ||
4373 | pub(crate) syntax: SyntaxNode, | ||
4374 | } | ||
4375 | impl std::fmt::Display for ForExpr { | ||
4376 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4377 | std::fmt::Display::fmt(self.syntax(), f) | ||
4378 | } | ||
4379 | } | ||
4380 | impl AstNode for ForExpr { | ||
4381 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4382 | match kind { | ||
4383 | FOR_EXPR => true, | ||
4384 | _ => false, | ||
4385 | } | ||
4386 | } | ||
4387 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4388 | if Self::can_cast(syntax.kind()) { | ||
4389 | Some(Self { syntax }) | ||
4390 | } else { | ||
4391 | None | ||
4392 | } | ||
4393 | } | ||
4394 | fn syntax(&self) -> &SyntaxNode { | ||
4395 | &self.syntax | ||
4396 | } | ||
4397 | } | ||
4398 | impl ast::LoopBodyOwner for ForExpr {} | ||
4399 | impl ForExpr { | ||
4400 | pub fn pat(&self) -> Option<Pat> { | ||
4401 | AstChildren::new(&self.syntax).next() | ||
4402 | } | ||
4403 | pub fn iterable(&self) -> Option<Expr> { | ||
4404 | AstChildren::new(&self.syntax).next() | ||
4405 | } | ||
4406 | } | ||
4407 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4408 | pub struct WhileExpr { | ||
4409 | pub(crate) syntax: SyntaxNode, | ||
4410 | } | ||
4411 | impl std::fmt::Display for WhileExpr { | ||
4412 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4413 | std::fmt::Display::fmt(self.syntax(), f) | ||
4414 | } | ||
4415 | } | ||
4416 | impl AstNode for WhileExpr { | ||
4417 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4418 | match kind { | ||
4419 | WHILE_EXPR => true, | ||
4420 | _ => false, | ||
4421 | } | ||
4422 | } | ||
4423 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4424 | if Self::can_cast(syntax.kind()) { | ||
4425 | Some(Self { syntax }) | ||
4426 | } else { | ||
4427 | None | ||
4428 | } | ||
4429 | } | ||
4430 | fn syntax(&self) -> &SyntaxNode { | ||
4431 | &self.syntax | ||
4432 | } | ||
4433 | } | ||
4434 | impl ast::LoopBodyOwner for WhileExpr {} | ||
4435 | impl WhileExpr { | ||
4436 | pub fn condition(&self) -> Option<Condition> { | ||
4437 | AstChildren::new(&self.syntax).next() | ||
4438 | } | ||
4439 | } | ||
4440 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4441 | pub struct ContinueExpr { | ||
4442 | pub(crate) syntax: SyntaxNode, | ||
4443 | } | ||
4444 | impl std::fmt::Display for ContinueExpr { | ||
4445 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4446 | std::fmt::Display::fmt(self.syntax(), f) | ||
4447 | } | ||
4448 | } | ||
4449 | impl AstNode for ContinueExpr { | ||
4450 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4451 | match kind { | ||
4452 | CONTINUE_EXPR => true, | ||
4453 | _ => false, | ||
4454 | } | ||
4455 | } | ||
4456 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4457 | if Self::can_cast(syntax.kind()) { | ||
4458 | Some(Self { syntax }) | ||
4459 | } else { | ||
4460 | None | ||
4461 | } | ||
4462 | } | ||
4463 | fn syntax(&self) -> &SyntaxNode { | ||
4464 | &self.syntax | ||
4465 | } | ||
4466 | } | ||
4467 | impl ContinueExpr {} | ||
4468 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4469 | pub struct BreakExpr { | ||
4470 | pub(crate) syntax: SyntaxNode, | ||
4471 | } | ||
4472 | impl std::fmt::Display for BreakExpr { | ||
4473 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4474 | std::fmt::Display::fmt(self.syntax(), f) | ||
4475 | } | ||
4476 | } | ||
4477 | impl AstNode for BreakExpr { | ||
4478 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4479 | match kind { | ||
4480 | BREAK_EXPR => true, | ||
4481 | _ => false, | ||
4482 | } | ||
4483 | } | ||
4484 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4485 | if Self::can_cast(syntax.kind()) { | ||
4486 | Some(Self { syntax }) | ||
4487 | } else { | ||
4488 | None | ||
4489 | } | ||
4490 | } | ||
4491 | fn syntax(&self) -> &SyntaxNode { | ||
4492 | &self.syntax | ||
4493 | } | ||
4494 | } | ||
4495 | impl BreakExpr { | ||
4496 | pub fn expr(&self) -> Option<Expr> { | ||
4497 | AstChildren::new(&self.syntax).next() | ||
4498 | } | ||
4499 | } | ||
4500 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4501 | pub struct Label { | ||
4502 | pub(crate) syntax: SyntaxNode, | ||
4503 | } | ||
4504 | impl std::fmt::Display for Label { | ||
4505 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4506 | std::fmt::Display::fmt(self.syntax(), f) | ||
4507 | } | ||
4508 | } | ||
4509 | impl AstNode for Label { | ||
4510 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4511 | match kind { | ||
4512 | LABEL => true, | ||
4513 | _ => false, | ||
4514 | } | ||
4515 | } | ||
4516 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4517 | if Self::can_cast(syntax.kind()) { | ||
4518 | Some(Self { syntax }) | ||
4519 | } else { | ||
4520 | None | ||
4521 | } | ||
4522 | } | ||
4523 | fn syntax(&self) -> &SyntaxNode { | ||
4524 | &self.syntax | ||
4525 | } | ||
4526 | } | ||
4527 | impl Label {} | ||
4528 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4529 | pub struct BlockExpr { | ||
4530 | pub(crate) syntax: SyntaxNode, | ||
4531 | } | ||
4532 | impl std::fmt::Display for BlockExpr { | ||
4533 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4534 | std::fmt::Display::fmt(self.syntax(), f) | ||
4535 | } | ||
4536 | } | ||
4537 | impl AstNode for BlockExpr { | ||
4538 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4539 | match kind { | ||
4540 | BLOCK_EXPR => true, | ||
4541 | _ => false, | ||
4542 | } | ||
4543 | } | ||
4544 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4545 | if Self::can_cast(syntax.kind()) { | ||
4546 | Some(Self { syntax }) | ||
4547 | } else { | ||
4548 | None | ||
4549 | } | ||
4550 | } | ||
4551 | fn syntax(&self) -> &SyntaxNode { | ||
4552 | &self.syntax | ||
4553 | } | ||
4554 | } | ||
4555 | impl BlockExpr { | ||
4556 | pub fn block(&self) -> Option<Block> { | ||
4557 | AstChildren::new(&self.syntax).next() | ||
4558 | } | ||
4559 | } | ||
4560 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4561 | pub struct ReturnExpr { | ||
4562 | pub(crate) syntax: SyntaxNode, | ||
4563 | } | ||
4564 | impl std::fmt::Display for ReturnExpr { | ||
4565 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4566 | std::fmt::Display::fmt(self.syntax(), f) | ||
4567 | } | ||
4568 | } | ||
4569 | impl AstNode for ReturnExpr { | ||
4570 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4571 | match kind { | ||
4572 | RETURN_EXPR => true, | ||
4573 | _ => false, | ||
4574 | } | ||
4575 | } | ||
4576 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4577 | if Self::can_cast(syntax.kind()) { | ||
4578 | Some(Self { syntax }) | ||
4579 | } else { | ||
4580 | None | ||
4581 | } | ||
4582 | } | ||
4583 | fn syntax(&self) -> &SyntaxNode { | ||
4584 | &self.syntax | ||
4585 | } | ||
4586 | } | ||
4587 | impl ReturnExpr { | ||
4588 | pub fn expr(&self) -> Option<Expr> { | ||
4589 | AstChildren::new(&self.syntax).next() | ||
4590 | } | ||
4591 | } | ||
4592 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4593 | pub struct CallExpr { | ||
4594 | pub(crate) syntax: SyntaxNode, | ||
4595 | } | ||
4596 | impl std::fmt::Display for CallExpr { | ||
4597 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4598 | std::fmt::Display::fmt(self.syntax(), f) | ||
4599 | } | ||
4600 | } | ||
4601 | impl AstNode for CallExpr { | ||
4602 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4603 | match kind { | ||
4604 | CALL_EXPR => true, | ||
4605 | _ => false, | ||
4606 | } | ||
4607 | } | ||
4608 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4609 | if Self::can_cast(syntax.kind()) { | ||
4610 | Some(Self { syntax }) | ||
4611 | } else { | ||
4612 | None | ||
4613 | } | ||
4614 | } | ||
4615 | fn syntax(&self) -> &SyntaxNode { | ||
4616 | &self.syntax | ||
4617 | } | ||
4618 | } | ||
4619 | impl ast::ArgListOwner for CallExpr {} | ||
4620 | impl CallExpr { | ||
4621 | pub fn expr(&self) -> Option<Expr> { | ||
4622 | AstChildren::new(&self.syntax).next() | ||
4623 | } | ||
4624 | } | ||
4625 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4626 | pub struct MethodCallExpr { | ||
4627 | pub(crate) syntax: SyntaxNode, | ||
4628 | } | ||
4629 | impl std::fmt::Display for MethodCallExpr { | ||
4630 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4631 | std::fmt::Display::fmt(self.syntax(), f) | ||
4632 | } | ||
4633 | } | ||
4634 | impl AstNode for MethodCallExpr { | ||
4635 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4636 | match kind { | ||
4637 | METHOD_CALL_EXPR => true, | ||
4638 | _ => false, | ||
4639 | } | ||
4640 | } | ||
4641 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4642 | if Self::can_cast(syntax.kind()) { | ||
4643 | Some(Self { syntax }) | ||
4644 | } else { | ||
4645 | None | ||
4646 | } | ||
4647 | } | ||
4648 | fn syntax(&self) -> &SyntaxNode { | ||
4649 | &self.syntax | ||
4650 | } | ||
4651 | } | ||
4652 | impl ast::ArgListOwner for MethodCallExpr {} | ||
4653 | impl MethodCallExpr { | ||
4654 | pub fn expr(&self) -> Option<Expr> { | ||
4655 | AstChildren::new(&self.syntax).next() | ||
4656 | } | ||
4657 | pub fn name_ref(&self) -> Option<NameRef> { | ||
4658 | AstChildren::new(&self.syntax).next() | ||
4659 | } | ||
4660 | pub fn type_arg_list(&self) -> Option<TypeArgList> { | ||
4661 | AstChildren::new(&self.syntax).next() | ||
4662 | } | ||
4663 | } | ||
4664 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4665 | pub struct IndexExpr { | ||
4666 | pub(crate) syntax: SyntaxNode, | ||
4667 | } | ||
4668 | impl std::fmt::Display for IndexExpr { | ||
4669 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4670 | std::fmt::Display::fmt(self.syntax(), f) | ||
4671 | } | ||
4672 | } | ||
4673 | impl AstNode for IndexExpr { | ||
4674 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4675 | match kind { | ||
4676 | INDEX_EXPR => true, | ||
4677 | _ => false, | ||
4678 | } | ||
4679 | } | ||
4680 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4681 | if Self::can_cast(syntax.kind()) { | ||
4682 | Some(Self { syntax }) | ||
4683 | } else { | ||
4684 | None | ||
4685 | } | ||
4686 | } | ||
4687 | fn syntax(&self) -> &SyntaxNode { | ||
4688 | &self.syntax | ||
4689 | } | ||
4690 | } | ||
4691 | impl IndexExpr {} | ||
4692 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4693 | pub struct FieldExpr { | ||
4694 | pub(crate) syntax: SyntaxNode, | ||
4695 | } | ||
4696 | impl std::fmt::Display for FieldExpr { | ||
4697 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4698 | std::fmt::Display::fmt(self.syntax(), f) | ||
4699 | } | ||
4700 | } | ||
4701 | impl AstNode for FieldExpr { | ||
4702 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4703 | match kind { | ||
4704 | FIELD_EXPR => true, | ||
4705 | _ => false, | ||
4706 | } | ||
4707 | } | ||
4708 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4709 | if Self::can_cast(syntax.kind()) { | ||
4710 | Some(Self { syntax }) | ||
4711 | } else { | ||
4712 | None | ||
4713 | } | ||
4714 | } | ||
4715 | fn syntax(&self) -> &SyntaxNode { | ||
4716 | &self.syntax | ||
4717 | } | ||
4718 | } | ||
4719 | impl FieldExpr { | ||
4720 | pub fn expr(&self) -> Option<Expr> { | ||
4721 | AstChildren::new(&self.syntax).next() | ||
4722 | } | ||
4723 | pub fn name_ref(&self) -> Option<NameRef> { | ||
4724 | AstChildren::new(&self.syntax).next() | ||
4725 | } | ||
4726 | } | ||
4727 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4728 | pub struct AwaitExpr { | ||
4729 | pub(crate) syntax: SyntaxNode, | ||
4730 | } | ||
4731 | impl std::fmt::Display for AwaitExpr { | ||
4732 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4733 | std::fmt::Display::fmt(self.syntax(), f) | ||
4734 | } | ||
4735 | } | ||
4736 | impl AstNode for AwaitExpr { | ||
4737 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4738 | match kind { | ||
4739 | AWAIT_EXPR => true, | ||
4740 | _ => false, | ||
4741 | } | ||
4742 | } | ||
4743 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4744 | if Self::can_cast(syntax.kind()) { | ||
4745 | Some(Self { syntax }) | ||
4746 | } else { | ||
4747 | None | ||
4748 | } | ||
4749 | } | ||
4750 | fn syntax(&self) -> &SyntaxNode { | ||
4751 | &self.syntax | ||
4752 | } | ||
4753 | } | ||
4754 | impl AwaitExpr { | ||
4755 | pub fn expr(&self) -> Option<Expr> { | ||
4756 | AstChildren::new(&self.syntax).next() | ||
4757 | } | ||
4758 | } | ||
4759 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4760 | pub struct TryExpr { | ||
4761 | pub(crate) syntax: SyntaxNode, | ||
4762 | } | ||
4763 | impl std::fmt::Display for TryExpr { | ||
4764 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4765 | std::fmt::Display::fmt(self.syntax(), f) | ||
4766 | } | ||
4767 | } | ||
4768 | impl AstNode for TryExpr { | ||
4769 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4770 | match kind { | ||
4771 | TRY_EXPR => true, | ||
4772 | _ => false, | ||
4773 | } | ||
4774 | } | ||
4775 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4776 | if Self::can_cast(syntax.kind()) { | ||
4777 | Some(Self { syntax }) | ||
4778 | } else { | ||
4779 | None | ||
4780 | } | ||
4781 | } | ||
4782 | fn syntax(&self) -> &SyntaxNode { | ||
4783 | &self.syntax | ||
4784 | } | ||
4785 | } | ||
4786 | impl TryExpr { | ||
4787 | pub fn expr(&self) -> Option<Expr> { | ||
4788 | AstChildren::new(&self.syntax).next() | ||
4789 | } | ||
4790 | } | ||
4791 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4792 | pub struct CastExpr { | ||
4793 | pub(crate) syntax: SyntaxNode, | ||
4794 | } | ||
4795 | impl std::fmt::Display for CastExpr { | ||
4796 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4797 | std::fmt::Display::fmt(self.syntax(), f) | ||
4798 | } | ||
4799 | } | ||
4800 | impl AstNode for CastExpr { | ||
4801 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4802 | match kind { | ||
4803 | CAST_EXPR => true, | ||
4804 | _ => false, | ||
4805 | } | ||
4806 | } | ||
4807 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4808 | if Self::can_cast(syntax.kind()) { | ||
4809 | Some(Self { syntax }) | ||
4810 | } else { | ||
4811 | None | ||
4812 | } | ||
4813 | } | ||
4814 | fn syntax(&self) -> &SyntaxNode { | ||
4815 | &self.syntax | ||
4816 | } | ||
4817 | } | ||
4818 | impl CastExpr { | ||
4819 | pub fn expr(&self) -> Option<Expr> { | ||
4820 | AstChildren::new(&self.syntax).next() | ||
4821 | } | ||
4822 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
4823 | AstChildren::new(&self.syntax).next() | ||
4824 | } | ||
4825 | } | ||
4826 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4827 | pub struct RefExpr { | ||
4828 | pub(crate) syntax: SyntaxNode, | ||
4829 | } | ||
4830 | impl std::fmt::Display for RefExpr { | ||
4831 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4832 | std::fmt::Display::fmt(self.syntax(), f) | ||
4833 | } | ||
4834 | } | ||
4835 | impl AstNode for RefExpr { | ||
4836 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4837 | match kind { | ||
4838 | REF_EXPR => true, | ||
4839 | _ => false, | ||
4840 | } | ||
4841 | } | ||
4842 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4843 | if Self::can_cast(syntax.kind()) { | ||
4844 | Some(Self { syntax }) | ||
4845 | } else { | ||
4846 | None | ||
4847 | } | ||
4848 | } | ||
4849 | fn syntax(&self) -> &SyntaxNode { | ||
4850 | &self.syntax | ||
4851 | } | ||
4852 | } | ||
4853 | impl RefExpr { | ||
4854 | pub fn expr(&self) -> Option<Expr> { | ||
4855 | AstChildren::new(&self.syntax).next() | ||
4856 | } | ||
4857 | } | ||
4858 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4859 | pub struct PrefixExpr { | ||
4860 | pub(crate) syntax: SyntaxNode, | ||
4861 | } | ||
4862 | impl std::fmt::Display for PrefixExpr { | ||
4863 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4864 | std::fmt::Display::fmt(self.syntax(), f) | ||
4865 | } | ||
4866 | } | ||
4867 | impl AstNode for PrefixExpr { | ||
4868 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4869 | match kind { | ||
4870 | PREFIX_EXPR => true, | ||
4871 | _ => false, | ||
4872 | } | ||
4873 | } | ||
4874 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4875 | if Self::can_cast(syntax.kind()) { | ||
4876 | Some(Self { syntax }) | ||
4877 | } else { | ||
4878 | None | ||
4879 | } | ||
4880 | } | ||
4881 | fn syntax(&self) -> &SyntaxNode { | ||
4882 | &self.syntax | ||
4883 | } | ||
4884 | } | ||
4885 | impl PrefixExpr { | ||
4886 | pub fn expr(&self) -> Option<Expr> { | ||
4887 | AstChildren::new(&self.syntax).next() | ||
4888 | } | ||
4889 | } | ||
4890 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4891 | pub struct BoxExpr { | ||
4892 | pub(crate) syntax: SyntaxNode, | ||
4893 | } | ||
4894 | impl std::fmt::Display for BoxExpr { | ||
4895 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4896 | std::fmt::Display::fmt(self.syntax(), f) | ||
4897 | } | ||
4898 | } | ||
4899 | impl AstNode for BoxExpr { | ||
4900 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4901 | match kind { | ||
4902 | BOX_EXPR => true, | ||
4903 | _ => false, | ||
4904 | } | ||
4905 | } | ||
4906 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4907 | if Self::can_cast(syntax.kind()) { | ||
4908 | Some(Self { syntax }) | ||
4909 | } else { | ||
4910 | None | ||
4911 | } | ||
4912 | } | ||
4913 | fn syntax(&self) -> &SyntaxNode { | ||
4914 | &self.syntax | ||
4915 | } | ||
4916 | } | ||
4917 | impl BoxExpr { | ||
4918 | pub fn expr(&self) -> Option<Expr> { | ||
4919 | AstChildren::new(&self.syntax).next() | ||
4920 | } | ||
4921 | } | ||
4922 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4923 | pub struct RangeExpr { | ||
4924 | pub(crate) syntax: SyntaxNode, | ||
4925 | } | ||
4926 | impl std::fmt::Display for RangeExpr { | ||
4927 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4928 | std::fmt::Display::fmt(self.syntax(), f) | ||
4929 | } | ||
4930 | } | ||
4931 | impl AstNode for RangeExpr { | ||
4932 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4933 | match kind { | ||
4934 | RANGE_EXPR => true, | ||
4935 | _ => false, | ||
4936 | } | ||
4937 | } | ||
4938 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4939 | if Self::can_cast(syntax.kind()) { | ||
4940 | Some(Self { syntax }) | ||
4941 | } else { | ||
4942 | None | ||
4943 | } | ||
4944 | } | ||
4945 | fn syntax(&self) -> &SyntaxNode { | ||
4946 | &self.syntax | ||
4947 | } | ||
4948 | } | ||
4949 | impl RangeExpr {} | ||
4950 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4951 | pub struct BinExpr { | ||
4952 | pub(crate) syntax: SyntaxNode, | ||
4953 | } | ||
4954 | impl std::fmt::Display for BinExpr { | ||
4955 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4956 | std::fmt::Display::fmt(self.syntax(), f) | ||
4957 | } | ||
4958 | } | ||
4959 | impl AstNode for BinExpr { | ||
4960 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4961 | match kind { | ||
4962 | BIN_EXPR => true, | ||
4963 | _ => false, | ||
4964 | } | ||
4965 | } | ||
4966 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4967 | if Self::can_cast(syntax.kind()) { | ||
4968 | Some(Self { syntax }) | ||
4969 | } else { | ||
4970 | None | ||
4971 | } | ||
4972 | } | ||
4973 | fn syntax(&self) -> &SyntaxNode { | ||
4974 | &self.syntax | ||
4975 | } | ||
4976 | } | ||
4977 | impl BinExpr {} | ||
4978 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
4979 | pub struct Literal { | ||
4980 | pub(crate) syntax: SyntaxNode, | ||
4981 | } | ||
4982 | impl std::fmt::Display for Literal { | ||
4983 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4984 | std::fmt::Display::fmt(self.syntax(), f) | ||
4985 | } | ||
4986 | } | ||
4987 | impl AstNode for Literal { | ||
4988 | fn can_cast(kind: SyntaxKind) -> bool { | ||
4989 | match kind { | ||
4990 | LITERAL => true, | ||
4991 | _ => false, | ||
4992 | } | ||
4993 | } | ||
4994 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
4995 | if Self::can_cast(syntax.kind()) { | ||
4996 | Some(Self { syntax }) | ||
4997 | } else { | ||
4998 | None | ||
4999 | } | ||
5000 | } | ||
5001 | fn syntax(&self) -> &SyntaxNode { | ||
5002 | &self.syntax | ||
5003 | } | ||
5004 | } | ||
5005 | impl Literal {} | ||
5006 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5007 | pub struct MatchExpr { | ||
5008 | pub(crate) syntax: SyntaxNode, | ||
5009 | } | ||
5010 | impl std::fmt::Display for MatchExpr { | ||
5011 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5012 | std::fmt::Display::fmt(self.syntax(), f) | ||
5013 | } | ||
5014 | } | ||
5015 | impl AstNode for MatchExpr { | ||
5016 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5017 | match kind { | ||
5018 | MATCH_EXPR => true, | ||
5019 | _ => false, | ||
5020 | } | ||
5021 | } | ||
5022 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5023 | if Self::can_cast(syntax.kind()) { | ||
5024 | Some(Self { syntax }) | ||
5025 | } else { | ||
5026 | None | ||
5027 | } | ||
5028 | } | ||
5029 | fn syntax(&self) -> &SyntaxNode { | ||
5030 | &self.syntax | ||
5031 | } | ||
5032 | } | ||
5033 | impl MatchExpr { | ||
5034 | pub fn expr(&self) -> Option<Expr> { | ||
5035 | AstChildren::new(&self.syntax).next() | ||
5036 | } | ||
5037 | pub fn match_arm_list(&self) -> Option<MatchArmList> { | ||
5038 | AstChildren::new(&self.syntax).next() | ||
5039 | } | ||
5040 | } | ||
5041 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5042 | pub struct MatchArmList { | ||
5043 | pub(crate) syntax: SyntaxNode, | ||
5044 | } | ||
5045 | impl std::fmt::Display for MatchArmList { | ||
5046 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5047 | std::fmt::Display::fmt(self.syntax(), f) | ||
5048 | } | ||
5049 | } | ||
5050 | impl AstNode for MatchArmList { | ||
5051 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5052 | match kind { | ||
5053 | MATCH_ARM_LIST => true, | ||
5054 | _ => false, | ||
5055 | } | ||
5056 | } | ||
5057 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5058 | if Self::can_cast(syntax.kind()) { | ||
5059 | Some(Self { syntax }) | ||
5060 | } else { | ||
5061 | None | ||
5062 | } | ||
5063 | } | ||
5064 | fn syntax(&self) -> &SyntaxNode { | ||
5065 | &self.syntax | ||
5066 | } | ||
5067 | } | ||
5068 | impl ast::AttrsOwner for MatchArmList {} | ||
5069 | impl MatchArmList { | ||
5070 | pub fn arms(&self) -> AstChildren<MatchArm> { | ||
5071 | AstChildren::new(&self.syntax) | ||
5072 | } | ||
5073 | } | ||
5074 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5075 | pub struct MatchArm { | ||
5076 | pub(crate) syntax: SyntaxNode, | ||
5077 | } | ||
5078 | impl std::fmt::Display for MatchArm { | ||
5079 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5080 | std::fmt::Display::fmt(self.syntax(), f) | ||
5081 | } | ||
5082 | } | ||
5083 | impl AstNode for MatchArm { | ||
5084 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5085 | match kind { | ||
5086 | MATCH_ARM => true, | ||
5087 | _ => false, | ||
5088 | } | ||
5089 | } | ||
5090 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5091 | if Self::can_cast(syntax.kind()) { | ||
5092 | Some(Self { syntax }) | ||
5093 | } else { | ||
5094 | None | ||
5095 | } | ||
5096 | } | ||
5097 | fn syntax(&self) -> &SyntaxNode { | ||
5098 | &self.syntax | ||
5099 | } | ||
5100 | } | ||
5101 | impl ast::AttrsOwner for MatchArm {} | ||
5102 | impl MatchArm { | ||
5103 | pub fn pat(&self) -> Option<Pat> { | ||
5104 | AstChildren::new(&self.syntax).next() | ||
5105 | } | ||
5106 | pub fn guard(&self) -> Option<MatchGuard> { | ||
5107 | AstChildren::new(&self.syntax).next() | ||
5108 | } | ||
5109 | pub fn expr(&self) -> Option<Expr> { | ||
5110 | AstChildren::new(&self.syntax).next() | ||
5111 | } | ||
5112 | } | ||
5113 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5114 | pub struct MatchGuard { | ||
5115 | pub(crate) syntax: SyntaxNode, | ||
5116 | } | ||
5117 | impl std::fmt::Display for MatchGuard { | ||
5118 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5119 | std::fmt::Display::fmt(self.syntax(), f) | ||
5120 | } | ||
5121 | } | ||
5122 | impl AstNode for MatchGuard { | ||
5123 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5124 | match kind { | ||
5125 | MATCH_GUARD => true, | ||
5126 | _ => false, | ||
5127 | } | ||
5128 | } | ||
5129 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5130 | if Self::can_cast(syntax.kind()) { | ||
5131 | Some(Self { syntax }) | ||
5132 | } else { | ||
5133 | None | ||
5134 | } | ||
5135 | } | ||
5136 | fn syntax(&self) -> &SyntaxNode { | ||
5137 | &self.syntax | ||
5138 | } | ||
5139 | } | ||
5140 | impl MatchGuard { | ||
5141 | pub fn expr(&self) -> Option<Expr> { | ||
5142 | AstChildren::new(&self.syntax).next() | ||
5143 | } | ||
5144 | } | ||
5145 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5146 | pub struct RecordLit { | ||
5147 | pub(crate) syntax: SyntaxNode, | ||
5148 | } | ||
5149 | impl std::fmt::Display for RecordLit { | ||
5150 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5151 | std::fmt::Display::fmt(self.syntax(), f) | ||
5152 | } | ||
5153 | } | ||
5154 | impl AstNode for RecordLit { | ||
5155 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5156 | match kind { | ||
5157 | RECORD_LIT => true, | ||
5158 | _ => false, | ||
5159 | } | ||
5160 | } | ||
5161 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5162 | if Self::can_cast(syntax.kind()) { | ||
5163 | Some(Self { syntax }) | ||
5164 | } else { | ||
5165 | None | ||
5166 | } | ||
5167 | } | ||
5168 | fn syntax(&self) -> &SyntaxNode { | ||
5169 | &self.syntax | ||
5170 | } | ||
5171 | } | ||
5172 | impl RecordLit { | ||
5173 | pub fn path(&self) -> Option<Path> { | ||
5174 | AstChildren::new(&self.syntax).next() | ||
5175 | } | ||
5176 | pub fn record_field_list(&self) -> Option<RecordFieldList> { | ||
5177 | AstChildren::new(&self.syntax).next() | ||
5178 | } | ||
5179 | } | ||
5180 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5181 | pub struct RecordFieldList { | ||
5182 | pub(crate) syntax: SyntaxNode, | ||
5183 | } | ||
5184 | impl std::fmt::Display for RecordFieldList { | ||
5185 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5186 | std::fmt::Display::fmt(self.syntax(), f) | ||
5187 | } | ||
5188 | } | ||
5189 | impl AstNode for RecordFieldList { | ||
5190 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5191 | match kind { | ||
5192 | RECORD_FIELD_LIST => true, | ||
5193 | _ => false, | ||
5194 | } | ||
5195 | } | ||
5196 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5197 | if Self::can_cast(syntax.kind()) { | ||
5198 | Some(Self { syntax }) | ||
5199 | } else { | ||
5200 | None | ||
5201 | } | ||
5202 | } | ||
5203 | fn syntax(&self) -> &SyntaxNode { | ||
5204 | &self.syntax | ||
5205 | } | ||
5206 | } | ||
5207 | impl RecordFieldList { | ||
5208 | pub fn fields(&self) -> AstChildren<RecordField> { | ||
5209 | AstChildren::new(&self.syntax) | ||
5210 | } | ||
5211 | pub fn spread(&self) -> Option<Expr> { | ||
5212 | AstChildren::new(&self.syntax).next() | ||
5213 | } | ||
5214 | } | ||
5215 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5216 | pub struct RecordField { | ||
5217 | pub(crate) syntax: SyntaxNode, | ||
5218 | } | ||
5219 | impl ast::AttrsOwner for RecordField {} | ||
5220 | impl std::fmt::Display for RecordField { | ||
5221 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5222 | std::fmt::Display::fmt(self.syntax(), f) | ||
5223 | } | ||
5224 | } | ||
5225 | impl AstNode for RecordField { | ||
5226 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5227 | match kind { | ||
5228 | RECORD_FIELD => true, | ||
5229 | _ => false, | ||
5230 | } | ||
5231 | } | ||
5232 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5233 | if Self::can_cast(syntax.kind()) { | ||
5234 | Some(Self { syntax }) | ||
5235 | } else { | ||
5236 | None | ||
5237 | } | ||
5238 | } | ||
5239 | fn syntax(&self) -> &SyntaxNode { | ||
5240 | &self.syntax | ||
5241 | } | ||
5242 | } | ||
5243 | impl RecordField { | ||
5244 | pub fn name_ref(&self) -> Option<NameRef> { | ||
5245 | AstChildren::new(&self.syntax).next() | ||
5246 | } | ||
5247 | pub fn expr(&self) -> Option<Expr> { | ||
5248 | AstChildren::new(&self.syntax).next() | ||
5249 | } | ||
5250 | } | ||
5251 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5252 | pub struct OrPat { | ||
5253 | pub(crate) syntax: SyntaxNode, | ||
5254 | } | ||
5255 | impl std::fmt::Display for OrPat { | ||
5256 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5257 | std::fmt::Display::fmt(self.syntax(), f) | ||
5258 | } | ||
5259 | } | ||
5260 | impl AstNode for OrPat { | ||
5261 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5262 | match kind { | ||
5263 | OR_PAT => true, | ||
5264 | _ => false, | ||
5265 | } | ||
5266 | } | ||
5267 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5268 | if Self::can_cast(syntax.kind()) { | ||
5269 | Some(Self { syntax }) | ||
5270 | } else { | ||
5271 | None | ||
5272 | } | ||
5273 | } | ||
5274 | fn syntax(&self) -> &SyntaxNode { | ||
5275 | &self.syntax | ||
5276 | } | ||
5277 | } | ||
5278 | impl OrPat { | ||
5279 | pub fn pats(&self) -> AstChildren<Pat> { | ||
5280 | AstChildren::new(&self.syntax) | ||
5281 | } | ||
5282 | } | ||
5283 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5284 | pub struct ParenPat { | ||
5285 | pub(crate) syntax: SyntaxNode, | ||
5286 | } | ||
5287 | impl std::fmt::Display for ParenPat { | ||
5288 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5289 | std::fmt::Display::fmt(self.syntax(), f) | ||
5290 | } | ||
5291 | } | ||
5292 | impl AstNode for ParenPat { | ||
5293 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5294 | match kind { | ||
5295 | PAREN_PAT => true, | ||
5296 | _ => false, | ||
5297 | } | ||
5298 | } | ||
5299 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5300 | if Self::can_cast(syntax.kind()) { | ||
5301 | Some(Self { syntax }) | ||
5302 | } else { | ||
5303 | None | ||
5304 | } | ||
5305 | } | ||
5306 | fn syntax(&self) -> &SyntaxNode { | ||
5307 | &self.syntax | ||
5308 | } | ||
5309 | } | ||
5310 | impl ParenPat { | ||
5311 | pub fn pat(&self) -> Option<Pat> { | ||
5312 | AstChildren::new(&self.syntax).next() | ||
5313 | } | ||
5314 | } | ||
5315 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5316 | pub struct RefPat { | ||
5317 | pub(crate) syntax: SyntaxNode, | ||
5318 | } | ||
5319 | impl std::fmt::Display for RefPat { | ||
5320 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5321 | std::fmt::Display::fmt(self.syntax(), f) | ||
5322 | } | ||
5323 | } | ||
5324 | impl AstNode for RefPat { | ||
5325 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5326 | match kind { | ||
5327 | REF_PAT => true, | ||
5328 | _ => false, | ||
5329 | } | ||
5330 | } | ||
5331 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5332 | if Self::can_cast(syntax.kind()) { | ||
5333 | Some(Self { syntax }) | ||
5334 | } else { | ||
5335 | None | ||
5336 | } | ||
5337 | } | ||
5338 | fn syntax(&self) -> &SyntaxNode { | ||
5339 | &self.syntax | ||
5340 | } | ||
5341 | } | ||
5342 | impl RefPat { | ||
5343 | pub fn pat(&self) -> Option<Pat> { | ||
5344 | AstChildren::new(&self.syntax).next() | ||
5345 | } | ||
5346 | } | ||
5347 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5348 | pub struct BoxPat { | ||
5349 | pub(crate) syntax: SyntaxNode, | ||
5350 | } | ||
5351 | impl std::fmt::Display for BoxPat { | ||
5352 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5353 | std::fmt::Display::fmt(self.syntax(), f) | ||
5354 | } | ||
5355 | } | ||
5356 | impl AstNode for BoxPat { | ||
5357 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5358 | match kind { | ||
5359 | BOX_PAT => true, | ||
5360 | _ => false, | ||
5361 | } | ||
5362 | } | ||
5363 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5364 | if Self::can_cast(syntax.kind()) { | ||
5365 | Some(Self { syntax }) | ||
5366 | } else { | ||
5367 | None | ||
5368 | } | ||
5369 | } | ||
5370 | fn syntax(&self) -> &SyntaxNode { | ||
5371 | &self.syntax | ||
5372 | } | ||
5373 | } | ||
5374 | impl BoxPat { | ||
5375 | pub fn pat(&self) -> Option<Pat> { | ||
5376 | AstChildren::new(&self.syntax).next() | ||
5377 | } | ||
5378 | } | ||
5379 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5380 | pub struct BindPat { | ||
5381 | pub(crate) syntax: SyntaxNode, | ||
5382 | } | ||
5383 | impl std::fmt::Display for BindPat { | ||
5384 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5385 | std::fmt::Display::fmt(self.syntax(), f) | ||
5386 | } | ||
5387 | } | ||
5388 | impl AstNode for BindPat { | ||
5389 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5390 | match kind { | ||
5391 | BIND_PAT => true, | ||
5392 | _ => false, | ||
5393 | } | ||
5394 | } | ||
5395 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5396 | if Self::can_cast(syntax.kind()) { | ||
5397 | Some(Self { syntax }) | ||
5398 | } else { | ||
5399 | None | ||
5400 | } | ||
5401 | } | ||
5402 | fn syntax(&self) -> &SyntaxNode { | ||
5403 | &self.syntax | ||
5404 | } | ||
5405 | } | ||
5406 | impl ast::NameOwner for BindPat {} | ||
5407 | impl BindPat { | ||
5408 | pub fn pat(&self) -> Option<Pat> { | ||
5409 | AstChildren::new(&self.syntax).next() | ||
5410 | } | ||
5411 | } | ||
5412 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5413 | pub struct PlaceholderPat { | ||
5414 | pub(crate) syntax: SyntaxNode, | ||
5415 | } | ||
5416 | impl std::fmt::Display for PlaceholderPat { | ||
5417 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5418 | std::fmt::Display::fmt(self.syntax(), f) | ||
5419 | } | ||
5420 | } | ||
5421 | impl AstNode for PlaceholderPat { | ||
5422 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5423 | match kind { | ||
5424 | PLACEHOLDER_PAT => true, | ||
5425 | _ => false, | ||
5426 | } | ||
5427 | } | ||
5428 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5429 | if Self::can_cast(syntax.kind()) { | ||
5430 | Some(Self { syntax }) | ||
5431 | } else { | ||
5432 | None | ||
5433 | } | ||
5434 | } | ||
5435 | fn syntax(&self) -> &SyntaxNode { | ||
5436 | &self.syntax | ||
5437 | } | ||
5438 | } | ||
5439 | impl PlaceholderPat {} | ||
5440 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5441 | pub struct DotDotPat { | ||
5442 | pub(crate) syntax: SyntaxNode, | ||
5443 | } | ||
5444 | impl std::fmt::Display for DotDotPat { | ||
5445 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5446 | std::fmt::Display::fmt(self.syntax(), f) | ||
5447 | } | ||
5448 | } | ||
5449 | impl AstNode for DotDotPat { | ||
5450 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5451 | match kind { | ||
5452 | DOT_DOT_PAT => true, | ||
5453 | _ => false, | ||
5454 | } | ||
5455 | } | ||
5456 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5457 | if Self::can_cast(syntax.kind()) { | ||
5458 | Some(Self { syntax }) | ||
5459 | } else { | ||
5460 | None | ||
5461 | } | ||
5462 | } | ||
5463 | fn syntax(&self) -> &SyntaxNode { | ||
5464 | &self.syntax | ||
5465 | } | ||
5466 | } | ||
5467 | impl DotDotPat {} | ||
5468 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5469 | pub struct PathPat { | ||
5470 | pub(crate) syntax: SyntaxNode, | ||
5471 | } | ||
5472 | impl std::fmt::Display for PathPat { | ||
5473 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5474 | std::fmt::Display::fmt(self.syntax(), f) | ||
5475 | } | ||
5476 | } | ||
5477 | impl AstNode for PathPat { | ||
5478 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5479 | match kind { | ||
5480 | PATH_PAT => true, | ||
5481 | _ => false, | ||
5482 | } | ||
5483 | } | ||
5484 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5485 | if Self::can_cast(syntax.kind()) { | ||
5486 | Some(Self { syntax }) | ||
5487 | } else { | ||
5488 | None | ||
5489 | } | ||
5490 | } | ||
5491 | fn syntax(&self) -> &SyntaxNode { | ||
5492 | &self.syntax | ||
5493 | } | ||
5494 | } | ||
5495 | impl PathPat { | ||
5496 | pub fn path(&self) -> Option<Path> { | ||
5497 | AstChildren::new(&self.syntax).next() | ||
5498 | } | ||
5499 | } | ||
5500 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5501 | pub struct SlicePat { | ||
5502 | pub(crate) syntax: SyntaxNode, | ||
5503 | } | ||
5504 | impl std::fmt::Display for SlicePat { | ||
5505 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5506 | std::fmt::Display::fmt(self.syntax(), f) | ||
5507 | } | ||
5508 | } | ||
5509 | impl AstNode for SlicePat { | ||
5510 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5511 | match kind { | ||
5512 | SLICE_PAT => true, | ||
5513 | _ => false, | ||
5514 | } | ||
5515 | } | ||
5516 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5517 | if Self::can_cast(syntax.kind()) { | ||
5518 | Some(Self { syntax }) | ||
5519 | } else { | ||
5520 | None | ||
5521 | } | ||
5522 | } | ||
5523 | fn syntax(&self) -> &SyntaxNode { | ||
5524 | &self.syntax | ||
5525 | } | ||
5526 | } | ||
5527 | impl SlicePat { | ||
5528 | pub fn args(&self) -> AstChildren<Pat> { | ||
5529 | AstChildren::new(&self.syntax) | ||
5530 | } | ||
5531 | } | ||
5532 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5533 | pub struct RangePat { | ||
5534 | pub(crate) syntax: SyntaxNode, | ||
5535 | } | ||
5536 | impl std::fmt::Display for RangePat { | ||
5537 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5538 | std::fmt::Display::fmt(self.syntax(), f) | ||
5539 | } | ||
5540 | } | ||
5541 | impl AstNode for RangePat { | ||
5542 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5543 | match kind { | ||
5544 | RANGE_PAT => true, | ||
5545 | _ => false, | ||
5546 | } | ||
5547 | } | ||
5548 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5549 | if Self::can_cast(syntax.kind()) { | ||
5550 | Some(Self { syntax }) | ||
5551 | } else { | ||
5552 | None | ||
5553 | } | ||
5554 | } | ||
5555 | fn syntax(&self) -> &SyntaxNode { | ||
5556 | &self.syntax | ||
5557 | } | ||
5558 | } | ||
5559 | impl RangePat {} | ||
5560 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5561 | pub struct LiteralPat { | ||
5562 | pub(crate) syntax: SyntaxNode, | ||
5563 | } | ||
5564 | impl std::fmt::Display for LiteralPat { | ||
5565 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5566 | std::fmt::Display::fmt(self.syntax(), f) | ||
5567 | } | ||
5568 | } | ||
5569 | impl AstNode for LiteralPat { | ||
5570 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5571 | match kind { | ||
5572 | LITERAL_PAT => true, | ||
5573 | _ => false, | ||
5574 | } | ||
5575 | } | ||
5576 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5577 | if Self::can_cast(syntax.kind()) { | ||
5578 | Some(Self { syntax }) | ||
5579 | } else { | ||
5580 | None | ||
5581 | } | ||
5582 | } | ||
5583 | fn syntax(&self) -> &SyntaxNode { | ||
5584 | &self.syntax | ||
5585 | } | ||
5586 | } | ||
5587 | impl LiteralPat { | ||
5588 | pub fn literal(&self) -> Option<Literal> { | ||
5589 | AstChildren::new(&self.syntax).next() | ||
5590 | } | ||
5591 | } | ||
5592 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5593 | pub struct MacroPat { | ||
5594 | pub(crate) syntax: SyntaxNode, | ||
5595 | } | ||
5596 | impl std::fmt::Display for MacroPat { | ||
5597 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5598 | std::fmt::Display::fmt(self.syntax(), f) | ||
5599 | } | ||
5600 | } | ||
5601 | impl AstNode for MacroPat { | ||
5602 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5603 | match kind { | ||
5604 | MACRO_PAT => true, | ||
5605 | _ => false, | ||
5606 | } | ||
5607 | } | ||
5608 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5609 | if Self::can_cast(syntax.kind()) { | ||
5610 | Some(Self { syntax }) | ||
5611 | } else { | ||
5612 | None | ||
5613 | } | ||
5614 | } | ||
5615 | fn syntax(&self) -> &SyntaxNode { | ||
5616 | &self.syntax | ||
5617 | } | ||
5618 | } | ||
5619 | impl MacroPat { | ||
5620 | pub fn macro_call(&self) -> Option<MacroCall> { | ||
5621 | AstChildren::new(&self.syntax).next() | ||
5622 | } | ||
5623 | } | ||
5624 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5625 | pub struct RecordPat { | ||
5626 | pub(crate) syntax: SyntaxNode, | ||
5627 | } | ||
5628 | impl std::fmt::Display for RecordPat { | ||
5629 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5630 | std::fmt::Display::fmt(self.syntax(), f) | ||
5631 | } | ||
5632 | } | ||
5633 | impl AstNode for RecordPat { | ||
5634 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5635 | match kind { | ||
5636 | RECORD_PAT => true, | ||
5637 | _ => false, | ||
5638 | } | ||
5639 | } | ||
5640 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5641 | if Self::can_cast(syntax.kind()) { | ||
5642 | Some(Self { syntax }) | ||
5643 | } else { | ||
5644 | None | ||
5645 | } | ||
5646 | } | ||
5647 | fn syntax(&self) -> &SyntaxNode { | ||
5648 | &self.syntax | ||
5649 | } | ||
5650 | } | ||
5651 | impl RecordPat { | ||
5652 | pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { | ||
5653 | AstChildren::new(&self.syntax).next() | ||
5654 | } | ||
5655 | pub fn path(&self) -> Option<Path> { | ||
5656 | AstChildren::new(&self.syntax).next() | ||
5657 | } | ||
5658 | } | ||
5659 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5660 | pub struct RecordFieldPatList { | ||
5661 | pub(crate) syntax: SyntaxNode, | ||
5662 | } | ||
5663 | impl std::fmt::Display for RecordFieldPatList { | ||
5664 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5665 | std::fmt::Display::fmt(self.syntax(), f) | ||
5666 | } | ||
5667 | } | ||
5668 | impl AstNode for RecordFieldPatList { | ||
5669 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5670 | match kind { | ||
5671 | RECORD_FIELD_PAT_LIST => true, | ||
5672 | _ => false, | ||
5673 | } | ||
5674 | } | ||
5675 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5676 | if Self::can_cast(syntax.kind()) { | ||
5677 | Some(Self { syntax }) | ||
5678 | } else { | ||
5679 | None | ||
5680 | } | ||
5681 | } | ||
5682 | fn syntax(&self) -> &SyntaxNode { | ||
5683 | &self.syntax | ||
5684 | } | ||
5685 | } | ||
5686 | impl RecordFieldPatList { | ||
5687 | pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { | ||
5688 | AstChildren::new(&self.syntax) | ||
5689 | } | ||
5690 | pub fn bind_pats(&self) -> AstChildren<BindPat> { | ||
5691 | AstChildren::new(&self.syntax) | ||
5692 | } | ||
5693 | } | ||
5694 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5695 | pub struct RecordFieldPat { | ||
5696 | pub(crate) syntax: SyntaxNode, | ||
5697 | } | ||
5698 | impl std::fmt::Display for RecordFieldPat { | ||
5699 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5700 | std::fmt::Display::fmt(self.syntax(), f) | ||
5701 | } | ||
5702 | } | ||
5703 | impl AstNode for RecordFieldPat { | ||
5704 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5705 | match kind { | ||
5706 | RECORD_FIELD_PAT => true, | ||
5707 | _ => false, | ||
5708 | } | ||
5709 | } | ||
5710 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5711 | if Self::can_cast(syntax.kind()) { | ||
5712 | Some(Self { syntax }) | ||
5713 | } else { | ||
5714 | None | ||
5715 | } | ||
5716 | } | ||
5717 | fn syntax(&self) -> &SyntaxNode { | ||
5718 | &self.syntax | ||
5719 | } | ||
5720 | } | ||
5721 | impl ast::NameOwner for RecordFieldPat {} | ||
5722 | impl RecordFieldPat { | ||
5723 | pub fn pat(&self) -> Option<Pat> { | ||
5724 | AstChildren::new(&self.syntax).next() | ||
5725 | } | ||
5726 | } | ||
5727 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5728 | pub struct TupleStructPat { | ||
5729 | pub(crate) syntax: SyntaxNode, | ||
5730 | } | ||
5731 | impl std::fmt::Display for TupleStructPat { | ||
5732 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5733 | std::fmt::Display::fmt(self.syntax(), f) | ||
5734 | } | ||
5735 | } | ||
5736 | impl AstNode for TupleStructPat { | ||
5737 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5738 | match kind { | ||
5739 | TUPLE_STRUCT_PAT => true, | ||
5740 | _ => false, | ||
5741 | } | ||
5742 | } | ||
5743 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5744 | if Self::can_cast(syntax.kind()) { | ||
5745 | Some(Self { syntax }) | ||
5746 | } else { | ||
5747 | None | ||
5748 | } | ||
5749 | } | ||
5750 | fn syntax(&self) -> &SyntaxNode { | ||
5751 | &self.syntax | ||
5752 | } | ||
5753 | } | ||
5754 | impl TupleStructPat { | ||
5755 | pub fn path(&self) -> Option<Path> { | ||
5756 | AstChildren::new(&self.syntax).next() | ||
5757 | } | ||
5758 | pub fn args(&self) -> AstChildren<Pat> { | ||
5759 | AstChildren::new(&self.syntax) | ||
5760 | } | ||
5761 | } | ||
5762 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5763 | pub struct TuplePat { | ||
5764 | pub(crate) syntax: SyntaxNode, | ||
5765 | } | ||
5766 | impl std::fmt::Display for TuplePat { | ||
5767 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5768 | std::fmt::Display::fmt(self.syntax(), f) | ||
5769 | } | ||
5770 | } | ||
5771 | impl AstNode for TuplePat { | ||
5772 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5773 | match kind { | ||
5774 | TUPLE_PAT => true, | ||
5775 | _ => false, | ||
5776 | } | ||
5777 | } | ||
5778 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5779 | if Self::can_cast(syntax.kind()) { | ||
5780 | Some(Self { syntax }) | ||
5781 | } else { | ||
5782 | None | ||
5783 | } | ||
5784 | } | ||
5785 | fn syntax(&self) -> &SyntaxNode { | ||
5786 | &self.syntax | ||
5787 | } | ||
5788 | } | ||
5789 | impl TuplePat { | ||
5790 | pub fn args(&self) -> AstChildren<Pat> { | ||
5791 | AstChildren::new(&self.syntax) | ||
5792 | } | ||
5793 | } | ||
5794 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5795 | pub struct Visibility { | ||
5796 | pub(crate) syntax: SyntaxNode, | ||
5797 | } | ||
5798 | impl std::fmt::Display for Visibility { | ||
5799 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5800 | std::fmt::Display::fmt(self.syntax(), f) | ||
5801 | } | ||
5802 | } | ||
5803 | impl AstNode for Visibility { | ||
5804 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5805 | match kind { | ||
5806 | VISIBILITY => true, | ||
5807 | _ => false, | ||
5808 | } | ||
5809 | } | ||
5810 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5811 | if Self::can_cast(syntax.kind()) { | ||
5812 | Some(Self { syntax }) | ||
5813 | } else { | ||
5814 | None | ||
5815 | } | ||
5816 | } | ||
5817 | fn syntax(&self) -> &SyntaxNode { | ||
5818 | &self.syntax | ||
5819 | } | ||
5820 | } | ||
5821 | impl Visibility {} | ||
5822 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5823 | pub struct Name { | ||
5824 | pub(crate) syntax: SyntaxNode, | ||
5825 | } | ||
5826 | impl std::fmt::Display for Name { | ||
5827 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5828 | std::fmt::Display::fmt(self.syntax(), f) | ||
5829 | } | ||
5830 | } | ||
5831 | impl AstNode for Name { | ||
5832 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5833 | match kind { | ||
5834 | NAME => true, | ||
5835 | _ => false, | ||
5836 | } | ||
5837 | } | ||
5838 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5839 | if Self::can_cast(syntax.kind()) { | ||
5840 | Some(Self { syntax }) | ||
5841 | } else { | ||
5842 | None | ||
5843 | } | ||
5844 | } | ||
5845 | fn syntax(&self) -> &SyntaxNode { | ||
5846 | &self.syntax | ||
5847 | } | ||
5848 | } | ||
5849 | impl Name {} | ||
5850 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5851 | pub struct NameRef { | ||
5852 | pub(crate) syntax: SyntaxNode, | ||
5853 | } | ||
5854 | impl std::fmt::Display for NameRef { | ||
5855 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5856 | std::fmt::Display::fmt(self.syntax(), f) | ||
5857 | } | ||
5858 | } | ||
5859 | impl AstNode for NameRef { | ||
5860 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5861 | match kind { | ||
5862 | NAME_REF => true, | ||
5863 | _ => false, | ||
5864 | } | ||
5865 | } | ||
5866 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5867 | if Self::can_cast(syntax.kind()) { | ||
5868 | Some(Self { syntax }) | ||
5869 | } else { | ||
5870 | None | ||
5871 | } | ||
5872 | } | ||
5873 | fn syntax(&self) -> &SyntaxNode { | ||
5874 | &self.syntax | ||
5875 | } | ||
5876 | } | ||
5877 | impl NameRef {} | ||
5878 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5879 | pub struct MacroCall { | ||
5880 | pub(crate) syntax: SyntaxNode, | ||
5881 | } | ||
5882 | impl std::fmt::Display for MacroCall { | ||
5883 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5884 | std::fmt::Display::fmt(self.syntax(), f) | ||
5885 | } | ||
5886 | } | ||
5887 | impl AstNode for MacroCall { | ||
5888 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5889 | match kind { | ||
5890 | MACRO_CALL => true, | ||
5891 | _ => false, | ||
5892 | } | ||
5893 | } | ||
5894 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5895 | if Self::can_cast(syntax.kind()) { | ||
5896 | Some(Self { syntax }) | ||
5897 | } else { | ||
5898 | None | ||
5899 | } | ||
5900 | } | ||
5901 | fn syntax(&self) -> &SyntaxNode { | ||
5902 | &self.syntax | ||
5903 | } | ||
5904 | } | ||
5905 | impl ast::NameOwner for MacroCall {} | ||
5906 | impl ast::AttrsOwner for MacroCall {} | ||
5907 | impl ast::DocCommentsOwner for MacroCall {} | ||
5908 | impl MacroCall { | ||
5909 | pub fn token_tree(&self) -> Option<TokenTree> { | ||
5910 | AstChildren::new(&self.syntax).next() | ||
5911 | } | ||
5912 | pub fn path(&self) -> Option<Path> { | ||
5913 | AstChildren::new(&self.syntax).next() | ||
5914 | } | ||
5915 | } | ||
5916 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5917 | pub struct Attr { | ||
5918 | pub(crate) syntax: SyntaxNode, | ||
5919 | } | ||
5920 | impl std::fmt::Display for Attr { | ||
5921 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5922 | std::fmt::Display::fmt(self.syntax(), f) | ||
5923 | } | ||
5924 | } | ||
5925 | impl AstNode for Attr { | ||
5926 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5927 | match kind { | ||
5928 | ATTR => true, | ||
5929 | _ => false, | ||
5930 | } | ||
5931 | } | ||
5932 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5933 | if Self::can_cast(syntax.kind()) { | ||
5934 | Some(Self { syntax }) | ||
5935 | } else { | ||
5936 | None | ||
5937 | } | ||
5938 | } | ||
5939 | fn syntax(&self) -> &SyntaxNode { | ||
5940 | &self.syntax | ||
5941 | } | ||
5942 | } | ||
5943 | impl Attr { | ||
5944 | pub fn path(&self) -> Option<Path> { | ||
5945 | AstChildren::new(&self.syntax).next() | ||
5946 | } | ||
5947 | pub fn input(&self) -> Option<AttrInput> { | ||
5948 | AstChildren::new(&self.syntax).next() | ||
5949 | } | ||
5950 | } | ||
5951 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5952 | pub struct TokenTree { | ||
5953 | pub(crate) syntax: SyntaxNode, | ||
5954 | } | ||
5955 | impl std::fmt::Display for TokenTree { | ||
5956 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5957 | std::fmt::Display::fmt(self.syntax(), f) | ||
5958 | } | ||
5959 | } | ||
5960 | impl AstNode for TokenTree { | ||
5961 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5962 | match kind { | ||
5963 | TOKEN_TREE => true, | ||
5964 | _ => false, | ||
5965 | } | ||
5966 | } | ||
5967 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5968 | if Self::can_cast(syntax.kind()) { | ||
5969 | Some(Self { syntax }) | ||
5970 | } else { | ||
5971 | None | ||
5972 | } | ||
5973 | } | ||
5974 | fn syntax(&self) -> &SyntaxNode { | ||
5975 | &self.syntax | ||
5976 | } | ||
5977 | } | ||
5978 | impl TokenTree {} | ||
5979 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
5980 | pub struct TypeParamList { | ||
5981 | pub(crate) syntax: SyntaxNode, | ||
5982 | } | ||
5983 | impl std::fmt::Display for TypeParamList { | ||
5984 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
5985 | std::fmt::Display::fmt(self.syntax(), f) | ||
5986 | } | ||
5987 | } | ||
5988 | impl AstNode for TypeParamList { | ||
5989 | fn can_cast(kind: SyntaxKind) -> bool { | ||
5990 | match kind { | ||
5991 | TYPE_PARAM_LIST => true, | ||
5992 | _ => false, | ||
5993 | } | ||
5994 | } | ||
5995 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
5996 | if Self::can_cast(syntax.kind()) { | ||
5997 | Some(Self { syntax }) | ||
5998 | } else { | ||
5999 | None | ||
6000 | } | ||
6001 | } | ||
6002 | fn syntax(&self) -> &SyntaxNode { | ||
6003 | &self.syntax | ||
6004 | } | ||
6005 | } | ||
6006 | impl TypeParamList { | ||
6007 | pub fn type_params(&self) -> AstChildren<TypeParam> { | ||
6008 | AstChildren::new(&self.syntax) | ||
6009 | } | ||
6010 | pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { | ||
6011 | AstChildren::new(&self.syntax) | ||
6012 | } | ||
6013 | } | ||
6014 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6015 | pub struct TypeParam { | ||
6016 | pub(crate) syntax: SyntaxNode, | ||
6017 | } | ||
6018 | impl std::fmt::Display for TypeParam { | ||
6019 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6020 | std::fmt::Display::fmt(self.syntax(), f) | ||
6021 | } | ||
6022 | } | ||
6023 | impl AstNode for TypeParam { | ||
6024 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6025 | match kind { | ||
6026 | TYPE_PARAM => true, | ||
6027 | _ => false, | ||
6028 | } | ||
6029 | } | ||
6030 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6031 | if Self::can_cast(syntax.kind()) { | ||
6032 | Some(Self { syntax }) | ||
6033 | } else { | ||
6034 | None | ||
6035 | } | ||
6036 | } | ||
6037 | fn syntax(&self) -> &SyntaxNode { | ||
6038 | &self.syntax | ||
6039 | } | ||
6040 | } | ||
6041 | impl ast::NameOwner for TypeParam {} | ||
6042 | impl ast::AttrsOwner for TypeParam {} | ||
6043 | impl ast::TypeBoundsOwner for TypeParam {} | ||
6044 | impl TypeParam { | ||
6045 | pub fn default_type(&self) -> Option<TypeRef> { | ||
6046 | AstChildren::new(&self.syntax).next() | ||
6047 | } | ||
6048 | } | ||
6049 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6050 | pub struct ConstParam { | ||
6051 | pub(crate) syntax: SyntaxNode, | ||
6052 | } | ||
6053 | impl std::fmt::Display for ConstParam { | ||
6054 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6055 | std::fmt::Display::fmt(self.syntax(), f) | ||
6056 | } | ||
6057 | } | ||
6058 | impl AstNode for ConstParam { | ||
6059 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6060 | match kind { | ||
6061 | CONST_PARAM => true, | ||
6062 | _ => false, | ||
6063 | } | ||
6064 | } | ||
6065 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6066 | if Self::can_cast(syntax.kind()) { | ||
6067 | Some(Self { syntax }) | ||
6068 | } else { | ||
6069 | None | ||
6070 | } | ||
6071 | } | ||
6072 | fn syntax(&self) -> &SyntaxNode { | ||
6073 | &self.syntax | ||
6074 | } | ||
6075 | } | ||
6076 | impl ast::NameOwner for ConstParam {} | ||
6077 | impl ast::AttrsOwner for ConstParam {} | ||
6078 | impl ast::TypeAscriptionOwner for ConstParam {} | ||
6079 | impl ConstParam { | ||
6080 | pub fn default_val(&self) -> Option<Expr> { | ||
6081 | AstChildren::new(&self.syntax).next() | ||
6082 | } | ||
6083 | } | ||
6084 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6085 | pub struct LifetimeParam { | ||
6086 | pub(crate) syntax: SyntaxNode, | ||
6087 | } | ||
6088 | impl std::fmt::Display for LifetimeParam { | ||
6089 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6090 | std::fmt::Display::fmt(self.syntax(), f) | ||
6091 | } | ||
6092 | } | ||
6093 | impl AstNode for LifetimeParam { | ||
6094 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6095 | match kind { | ||
6096 | LIFETIME_PARAM => true, | ||
6097 | _ => false, | ||
6098 | } | ||
6099 | } | ||
6100 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6101 | if Self::can_cast(syntax.kind()) { | ||
6102 | Some(Self { syntax }) | ||
6103 | } else { | ||
6104 | None | ||
6105 | } | ||
6106 | } | ||
6107 | fn syntax(&self) -> &SyntaxNode { | ||
6108 | &self.syntax | ||
6109 | } | ||
6110 | } | ||
6111 | impl ast::AttrsOwner for LifetimeParam {} | ||
6112 | impl LifetimeParam {} | ||
6113 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6114 | pub struct TypeBound { | ||
6115 | pub(crate) syntax: SyntaxNode, | ||
6116 | } | ||
6117 | impl std::fmt::Display for TypeBound { | ||
6118 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6119 | std::fmt::Display::fmt(self.syntax(), f) | ||
6120 | } | ||
6121 | } | ||
6122 | impl AstNode for TypeBound { | ||
6123 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6124 | match kind { | ||
6125 | TYPE_BOUND => true, | ||
6126 | _ => false, | ||
6127 | } | ||
6128 | } | ||
6129 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6130 | if Self::can_cast(syntax.kind()) { | ||
6131 | Some(Self { syntax }) | ||
6132 | } else { | ||
6133 | None | ||
6134 | } | ||
6135 | } | ||
6136 | fn syntax(&self) -> &SyntaxNode { | ||
6137 | &self.syntax | ||
6138 | } | ||
6139 | } | ||
6140 | impl TypeBound { | ||
6141 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
6142 | AstChildren::new(&self.syntax).next() | ||
6143 | } | ||
6144 | } | ||
6145 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6146 | pub struct TypeBoundList { | ||
6147 | pub(crate) syntax: SyntaxNode, | ||
6148 | } | ||
6149 | impl std::fmt::Display for TypeBoundList { | ||
6150 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6151 | std::fmt::Display::fmt(self.syntax(), f) | ||
6152 | } | ||
6153 | } | ||
6154 | impl AstNode for TypeBoundList { | ||
6155 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6156 | match kind { | ||
6157 | TYPE_BOUND_LIST => true, | ||
6158 | _ => false, | ||
6159 | } | ||
6160 | } | ||
6161 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6162 | if Self::can_cast(syntax.kind()) { | ||
6163 | Some(Self { syntax }) | ||
6164 | } else { | ||
6165 | None | ||
6166 | } | ||
6167 | } | ||
6168 | fn syntax(&self) -> &SyntaxNode { | ||
6169 | &self.syntax | ||
6170 | } | ||
6171 | } | ||
6172 | impl TypeBoundList { | ||
6173 | pub fn bounds(&self) -> AstChildren<TypeBound> { | ||
6174 | AstChildren::new(&self.syntax) | ||
6175 | } | ||
6176 | } | ||
6177 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6178 | pub struct WherePred { | ||
6179 | pub(crate) syntax: SyntaxNode, | ||
6180 | } | ||
6181 | impl std::fmt::Display for WherePred { | ||
6182 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6183 | std::fmt::Display::fmt(self.syntax(), f) | ||
6184 | } | ||
6185 | } | ||
6186 | impl AstNode for WherePred { | ||
6187 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6188 | match kind { | ||
6189 | WHERE_PRED => true, | ||
6190 | _ => false, | ||
6191 | } | ||
6192 | } | ||
6193 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6194 | if Self::can_cast(syntax.kind()) { | ||
6195 | Some(Self { syntax }) | ||
6196 | } else { | ||
6197 | None | ||
6198 | } | ||
6199 | } | ||
6200 | fn syntax(&self) -> &SyntaxNode { | ||
6201 | &self.syntax | ||
6202 | } | ||
6203 | } | ||
6204 | impl ast::TypeBoundsOwner for WherePred {} | ||
6205 | impl WherePred { | ||
6206 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
6207 | AstChildren::new(&self.syntax).next() | ||
6208 | } | ||
6209 | } | ||
6210 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6211 | pub struct WhereClause { | ||
6212 | pub(crate) syntax: SyntaxNode, | ||
6213 | } | ||
6214 | impl std::fmt::Display for WhereClause { | ||
6215 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6216 | std::fmt::Display::fmt(self.syntax(), f) | ||
6217 | } | ||
6218 | } | ||
6219 | impl AstNode for WhereClause { | ||
6220 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6221 | match kind { | ||
6222 | WHERE_CLAUSE => true, | ||
6223 | _ => false, | ||
6224 | } | ||
6225 | } | ||
6226 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6227 | if Self::can_cast(syntax.kind()) { | ||
6228 | Some(Self { syntax }) | ||
6229 | } else { | ||
6230 | None | ||
6231 | } | ||
6232 | } | ||
6233 | fn syntax(&self) -> &SyntaxNode { | ||
6234 | &self.syntax | ||
6235 | } | ||
6236 | } | ||
6237 | impl WhereClause { | ||
6238 | pub fn predicates(&self) -> AstChildren<WherePred> { | ||
6239 | AstChildren::new(&self.syntax) | ||
6240 | } | ||
6241 | } | ||
6242 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6243 | pub struct ExprStmt { | ||
6244 | pub(crate) syntax: SyntaxNode, | ||
6245 | } | ||
6246 | impl std::fmt::Display for ExprStmt { | ||
6247 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6248 | std::fmt::Display::fmt(self.syntax(), f) | ||
6249 | } | ||
6250 | } | ||
6251 | impl AstNode for ExprStmt { | ||
6252 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6253 | match kind { | ||
6254 | EXPR_STMT => true, | ||
6255 | _ => false, | ||
6256 | } | ||
6257 | } | ||
6258 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6259 | if Self::can_cast(syntax.kind()) { | ||
6260 | Some(Self { syntax }) | ||
6261 | } else { | ||
6262 | None | ||
6263 | } | ||
6264 | } | ||
6265 | fn syntax(&self) -> &SyntaxNode { | ||
6266 | &self.syntax | ||
6267 | } | ||
6268 | } | ||
6269 | impl ExprStmt { | ||
6270 | pub fn expr(&self) -> Option<Expr> { | ||
6271 | AstChildren::new(&self.syntax).next() | ||
6272 | } | ||
6273 | } | ||
6274 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6275 | pub struct LetStmt { | ||
6276 | pub(crate) syntax: SyntaxNode, | ||
6277 | } | ||
6278 | impl std::fmt::Display for LetStmt { | ||
6279 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6280 | std::fmt::Display::fmt(self.syntax(), f) | ||
6281 | } | ||
6282 | } | ||
6283 | impl AstNode for LetStmt { | ||
6284 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6285 | match kind { | ||
6286 | LET_STMT => true, | ||
6287 | _ => false, | ||
6288 | } | ||
6289 | } | ||
6290 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6291 | if Self::can_cast(syntax.kind()) { | ||
6292 | Some(Self { syntax }) | ||
6293 | } else { | ||
6294 | None | ||
6295 | } | ||
6296 | } | ||
6297 | fn syntax(&self) -> &SyntaxNode { | ||
6298 | &self.syntax | ||
6299 | } | ||
6300 | } | ||
6301 | impl ast::TypeAscriptionOwner for LetStmt {} | ||
6302 | impl LetStmt { | ||
6303 | pub fn pat(&self) -> Option<Pat> { | ||
6304 | AstChildren::new(&self.syntax).next() | ||
6305 | } | ||
6306 | pub fn initializer(&self) -> Option<Expr> { | ||
6307 | AstChildren::new(&self.syntax).next() | ||
6308 | } | ||
6309 | } | ||
6310 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6311 | pub struct Condition { | ||
6312 | pub(crate) syntax: SyntaxNode, | ||
6313 | } | ||
6314 | impl std::fmt::Display for Condition { | ||
6315 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6316 | std::fmt::Display::fmt(self.syntax(), f) | ||
6317 | } | ||
6318 | } | ||
6319 | impl AstNode for Condition { | ||
6320 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6321 | match kind { | ||
6322 | CONDITION => true, | ||
6323 | _ => false, | ||
6324 | } | ||
6325 | } | ||
6326 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6327 | if Self::can_cast(syntax.kind()) { | ||
6328 | Some(Self { syntax }) | ||
6329 | } else { | ||
6330 | None | ||
6331 | } | ||
6332 | } | ||
6333 | fn syntax(&self) -> &SyntaxNode { | ||
6334 | &self.syntax | ||
6335 | } | ||
6336 | } | ||
6337 | impl Condition { | ||
6338 | pub fn pat(&self) -> Option<Pat> { | ||
6339 | AstChildren::new(&self.syntax).next() | ||
6340 | } | ||
6341 | pub fn expr(&self) -> Option<Expr> { | ||
6342 | AstChildren::new(&self.syntax).next() | ||
6343 | } | ||
6344 | } | ||
6345 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6346 | pub struct Block { | ||
6347 | pub(crate) syntax: SyntaxNode, | ||
6348 | } | ||
6349 | impl std::fmt::Display for Block { | ||
6350 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6351 | std::fmt::Display::fmt(self.syntax(), f) | ||
6352 | } | ||
6353 | } | ||
6354 | impl AstNode for Block { | ||
6355 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6356 | match kind { | ||
6357 | BLOCK => true, | ||
6358 | _ => false, | ||
6359 | } | ||
6360 | } | ||
6361 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6362 | if Self::can_cast(syntax.kind()) { | ||
6363 | Some(Self { syntax }) | ||
6364 | } else { | ||
6365 | None | ||
6366 | } | ||
6367 | } | ||
6368 | fn syntax(&self) -> &SyntaxNode { | ||
6369 | &self.syntax | ||
6370 | } | ||
6371 | } | ||
6372 | impl ast::AttrsOwner for Block {} | ||
6373 | impl ast::ModuleItemOwner for Block {} | ||
6374 | impl Block { | ||
6375 | pub fn statements(&self) -> AstChildren<Stmt> { | ||
6376 | AstChildren::new(&self.syntax) | ||
6377 | } | ||
6378 | pub fn expr(&self) -> Option<Expr> { | ||
6379 | AstChildren::new(&self.syntax).next() | ||
6380 | } | ||
6381 | } | ||
6382 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6383 | pub struct ParamList { | ||
6384 | pub(crate) syntax: SyntaxNode, | ||
6385 | } | ||
6386 | impl std::fmt::Display for ParamList { | ||
6387 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6388 | std::fmt::Display::fmt(self.syntax(), f) | ||
6389 | } | ||
6390 | } | ||
6391 | impl AstNode for ParamList { | ||
6392 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6393 | match kind { | ||
6394 | PARAM_LIST => true, | ||
6395 | _ => false, | ||
6396 | } | ||
6397 | } | ||
6398 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6399 | if Self::can_cast(syntax.kind()) { | ||
6400 | Some(Self { syntax }) | ||
6401 | } else { | ||
6402 | None | ||
6403 | } | ||
6404 | } | ||
6405 | fn syntax(&self) -> &SyntaxNode { | ||
6406 | &self.syntax | ||
6407 | } | ||
6408 | } | ||
6409 | impl ParamList { | ||
6410 | pub fn self_param(&self) -> Option<SelfParam> { | ||
6411 | AstChildren::new(&self.syntax).next() | ||
6412 | } | ||
6413 | pub fn params(&self) -> AstChildren<Param> { | ||
6414 | AstChildren::new(&self.syntax) | ||
6415 | } | ||
6416 | } | ||
6417 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6418 | pub struct SelfParam { | ||
6419 | pub(crate) syntax: SyntaxNode, | ||
6420 | } | ||
6421 | impl std::fmt::Display for SelfParam { | ||
6422 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6423 | std::fmt::Display::fmt(self.syntax(), f) | ||
6424 | } | ||
6425 | } | ||
6426 | impl AstNode for SelfParam { | ||
6427 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6428 | match kind { | ||
6429 | SELF_PARAM => true, | ||
6430 | _ => false, | ||
6431 | } | ||
6432 | } | ||
6433 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6434 | if Self::can_cast(syntax.kind()) { | ||
6435 | Some(Self { syntax }) | ||
6436 | } else { | ||
6437 | None | ||
6438 | } | ||
6439 | } | ||
6440 | fn syntax(&self) -> &SyntaxNode { | ||
6441 | &self.syntax | ||
6442 | } | ||
6443 | } | ||
6444 | impl ast::TypeAscriptionOwner for SelfParam {} | ||
6445 | impl ast::AttrsOwner for SelfParam {} | ||
6446 | impl SelfParam {} | ||
6447 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6448 | pub struct Param { | ||
6449 | pub(crate) syntax: SyntaxNode, | ||
6450 | } | ||
6451 | impl std::fmt::Display for Param { | ||
6452 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6453 | std::fmt::Display::fmt(self.syntax(), f) | ||
6454 | } | ||
6455 | } | ||
6456 | impl AstNode for Param { | ||
6457 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6458 | match kind { | ||
6459 | PARAM => true, | ||
6460 | _ => false, | ||
6461 | } | ||
6462 | } | ||
6463 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6464 | if Self::can_cast(syntax.kind()) { | ||
6465 | Some(Self { syntax }) | ||
6466 | } else { | ||
6467 | None | ||
6468 | } | ||
6469 | } | ||
6470 | fn syntax(&self) -> &SyntaxNode { | ||
6471 | &self.syntax | ||
6472 | } | ||
6473 | } | ||
6474 | impl ast::TypeAscriptionOwner for Param {} | ||
6475 | impl ast::AttrsOwner for Param {} | ||
6476 | impl Param { | ||
6477 | pub fn pat(&self) -> Option<Pat> { | ||
6478 | AstChildren::new(&self.syntax).next() | ||
6479 | } | ||
6480 | } | ||
6481 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6482 | pub struct UseItem { | ||
6483 | pub(crate) syntax: SyntaxNode, | ||
6484 | } | ||
6485 | impl std::fmt::Display for UseItem { | ||
6486 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6487 | std::fmt::Display::fmt(self.syntax(), f) | ||
6488 | } | ||
6489 | } | ||
6490 | impl AstNode for UseItem { | ||
6491 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6492 | match kind { | ||
6493 | USE_ITEM => true, | ||
6494 | _ => false, | ||
6495 | } | ||
6496 | } | ||
6497 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6498 | if Self::can_cast(syntax.kind()) { | ||
6499 | Some(Self { syntax }) | ||
6500 | } else { | ||
6501 | None | ||
6502 | } | ||
6503 | } | ||
6504 | fn syntax(&self) -> &SyntaxNode { | ||
6505 | &self.syntax | ||
6506 | } | ||
6507 | } | ||
6508 | impl ast::AttrsOwner for UseItem {} | ||
6509 | impl ast::VisibilityOwner for UseItem {} | ||
6510 | impl UseItem { | ||
6511 | pub fn use_tree(&self) -> Option<UseTree> { | ||
6512 | AstChildren::new(&self.syntax).next() | ||
6513 | } | ||
6514 | } | ||
6515 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6516 | pub struct UseTree { | ||
6517 | pub(crate) syntax: SyntaxNode, | ||
6518 | } | ||
6519 | impl std::fmt::Display for UseTree { | ||
6520 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6521 | std::fmt::Display::fmt(self.syntax(), f) | ||
6522 | } | ||
6523 | } | ||
6524 | impl AstNode for UseTree { | ||
6525 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6526 | match kind { | ||
6527 | USE_TREE => true, | ||
6528 | _ => false, | ||
6529 | } | ||
6530 | } | ||
6531 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6532 | if Self::can_cast(syntax.kind()) { | ||
6533 | Some(Self { syntax }) | ||
6534 | } else { | ||
6535 | None | ||
6536 | } | ||
6537 | } | ||
6538 | fn syntax(&self) -> &SyntaxNode { | ||
6539 | &self.syntax | ||
6540 | } | ||
6541 | } | ||
6542 | impl UseTree { | ||
6543 | pub fn path(&self) -> Option<Path> { | ||
6544 | AstChildren::new(&self.syntax).next() | ||
6545 | } | ||
6546 | pub fn use_tree_list(&self) -> Option<UseTreeList> { | ||
6547 | AstChildren::new(&self.syntax).next() | ||
6548 | } | ||
6549 | pub fn alias(&self) -> Option<Alias> { | ||
6550 | AstChildren::new(&self.syntax).next() | ||
6551 | } | ||
6552 | } | ||
6553 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6554 | pub struct Alias { | ||
6555 | pub(crate) syntax: SyntaxNode, | ||
6556 | } | ||
6557 | impl std::fmt::Display for Alias { | ||
6558 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6559 | std::fmt::Display::fmt(self.syntax(), f) | ||
6560 | } | ||
6561 | } | ||
6562 | impl AstNode for Alias { | ||
6563 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6564 | match kind { | ||
6565 | ALIAS => true, | ||
6566 | _ => false, | ||
6567 | } | ||
6568 | } | ||
6569 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6570 | if Self::can_cast(syntax.kind()) { | ||
6571 | Some(Self { syntax }) | ||
6572 | } else { | ||
6573 | None | ||
6574 | } | ||
6575 | } | ||
6576 | fn syntax(&self) -> &SyntaxNode { | ||
6577 | &self.syntax | ||
6578 | } | ||
6579 | } | ||
6580 | impl ast::NameOwner for Alias {} | ||
6581 | impl Alias {} | ||
6582 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6583 | pub struct UseTreeList { | ||
6584 | pub(crate) syntax: SyntaxNode, | ||
6585 | } | ||
6586 | impl std::fmt::Display for UseTreeList { | ||
6587 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6588 | std::fmt::Display::fmt(self.syntax(), f) | ||
6589 | } | ||
6590 | } | ||
6591 | impl AstNode for UseTreeList { | ||
6592 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6593 | match kind { | ||
6594 | USE_TREE_LIST => true, | ||
6595 | _ => false, | ||
6596 | } | ||
6597 | } | ||
6598 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6599 | if Self::can_cast(syntax.kind()) { | ||
6600 | Some(Self { syntax }) | ||
6601 | } else { | ||
6602 | None | ||
6603 | } | ||
6604 | } | ||
6605 | fn syntax(&self) -> &SyntaxNode { | ||
6606 | &self.syntax | ||
6607 | } | ||
6608 | } | ||
6609 | impl UseTreeList { | ||
6610 | pub fn use_trees(&self) -> AstChildren<UseTree> { | ||
6611 | AstChildren::new(&self.syntax) | ||
6612 | } | ||
6613 | } | ||
6614 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6615 | pub struct ExternCrateItem { | ||
6616 | pub(crate) syntax: SyntaxNode, | ||
6617 | } | ||
6618 | impl std::fmt::Display for ExternCrateItem { | ||
6619 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6620 | std::fmt::Display::fmt(self.syntax(), f) | ||
6621 | } | ||
6622 | } | ||
6623 | impl AstNode for ExternCrateItem { | ||
6624 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6625 | match kind { | ||
6626 | EXTERN_CRATE_ITEM => true, | ||
6627 | _ => false, | ||
6628 | } | ||
6629 | } | ||
6630 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6631 | if Self::can_cast(syntax.kind()) { | ||
6632 | Some(Self { syntax }) | ||
6633 | } else { | ||
6634 | None | ||
6635 | } | ||
6636 | } | ||
6637 | fn syntax(&self) -> &SyntaxNode { | ||
6638 | &self.syntax | ||
6639 | } | ||
6640 | } | ||
6641 | impl ast::AttrsOwner for ExternCrateItem {} | ||
6642 | impl ast::VisibilityOwner for ExternCrateItem {} | ||
6643 | impl ExternCrateItem { | ||
6644 | pub fn name_ref(&self) -> Option<NameRef> { | ||
6645 | AstChildren::new(&self.syntax).next() | ||
6646 | } | ||
6647 | pub fn alias(&self) -> Option<Alias> { | ||
6648 | AstChildren::new(&self.syntax).next() | ||
6649 | } | ||
6650 | } | ||
6651 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6652 | pub struct ArgList { | ||
6653 | pub(crate) syntax: SyntaxNode, | ||
6654 | } | ||
6655 | impl std::fmt::Display for ArgList { | ||
6656 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6657 | std::fmt::Display::fmt(self.syntax(), f) | ||
6658 | } | ||
6659 | } | ||
6660 | impl AstNode for ArgList { | ||
6661 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6662 | match kind { | ||
6663 | ARG_LIST => true, | ||
6664 | _ => false, | ||
6665 | } | ||
6666 | } | ||
6667 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6668 | if Self::can_cast(syntax.kind()) { | ||
6669 | Some(Self { syntax }) | ||
6670 | } else { | ||
6671 | None | ||
6672 | } | ||
6673 | } | ||
6674 | fn syntax(&self) -> &SyntaxNode { | ||
6675 | &self.syntax | ||
6676 | } | ||
6677 | } | ||
6678 | impl ArgList { | ||
6679 | pub fn args(&self) -> AstChildren<Expr> { | ||
6680 | AstChildren::new(&self.syntax) | ||
6681 | } | ||
6682 | } | ||
6683 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6684 | pub struct Path { | ||
6685 | pub(crate) syntax: SyntaxNode, | ||
6686 | } | ||
6687 | impl std::fmt::Display for Path { | ||
6688 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6689 | std::fmt::Display::fmt(self.syntax(), f) | ||
6690 | } | ||
6691 | } | ||
6692 | impl AstNode for Path { | ||
6693 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6694 | match kind { | ||
6695 | PATH => true, | ||
6696 | _ => false, | ||
6697 | } | ||
6698 | } | ||
6699 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6700 | if Self::can_cast(syntax.kind()) { | ||
6701 | Some(Self { syntax }) | ||
6702 | } else { | ||
6703 | None | ||
6704 | } | ||
6705 | } | ||
6706 | fn syntax(&self) -> &SyntaxNode { | ||
6707 | &self.syntax | ||
6708 | } | ||
6709 | } | ||
6710 | impl Path { | ||
6711 | pub fn segment(&self) -> Option<PathSegment> { | ||
6712 | AstChildren::new(&self.syntax).next() | ||
6713 | } | ||
6714 | pub fn qualifier(&self) -> Option<Path> { | ||
6715 | AstChildren::new(&self.syntax).next() | ||
6716 | } | ||
6717 | } | ||
6718 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6719 | pub struct PathSegment { | ||
6720 | pub(crate) syntax: SyntaxNode, | ||
6721 | } | ||
6722 | impl std::fmt::Display for PathSegment { | ||
6723 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6724 | std::fmt::Display::fmt(self.syntax(), f) | ||
6725 | } | ||
6726 | } | ||
6727 | impl AstNode for PathSegment { | ||
6728 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6729 | match kind { | ||
6730 | PATH_SEGMENT => true, | ||
6731 | _ => false, | ||
6732 | } | ||
6733 | } | ||
6734 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6735 | if Self::can_cast(syntax.kind()) { | ||
6736 | Some(Self { syntax }) | ||
6737 | } else { | ||
6738 | None | ||
6739 | } | ||
6740 | } | ||
6741 | fn syntax(&self) -> &SyntaxNode { | ||
6742 | &self.syntax | ||
6743 | } | ||
6744 | } | ||
6745 | impl PathSegment { | ||
6746 | pub fn name_ref(&self) -> Option<NameRef> { | ||
6747 | AstChildren::new(&self.syntax).next() | ||
6748 | } | ||
6749 | pub fn type_arg_list(&self) -> Option<TypeArgList> { | ||
6750 | AstChildren::new(&self.syntax).next() | ||
6751 | } | ||
6752 | pub fn param_list(&self) -> Option<ParamList> { | ||
6753 | AstChildren::new(&self.syntax).next() | ||
6754 | } | ||
6755 | pub fn ret_type(&self) -> Option<RetType> { | ||
6756 | AstChildren::new(&self.syntax).next() | ||
6757 | } | ||
6758 | pub fn path_type(&self) -> Option<PathType> { | ||
6759 | AstChildren::new(&self.syntax).next() | ||
6760 | } | ||
6761 | } | ||
6762 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6763 | pub struct TypeArgList { | ||
6764 | pub(crate) syntax: SyntaxNode, | ||
6765 | } | ||
6766 | impl std::fmt::Display for TypeArgList { | ||
6767 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6768 | std::fmt::Display::fmt(self.syntax(), f) | ||
6769 | } | ||
6770 | } | ||
6771 | impl AstNode for TypeArgList { | ||
6772 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6773 | match kind { | ||
6774 | TYPE_ARG_LIST => true, | ||
6775 | _ => false, | ||
6776 | } | ||
6777 | } | ||
6778 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6779 | if Self::can_cast(syntax.kind()) { | ||
6780 | Some(Self { syntax }) | ||
6781 | } else { | ||
6782 | None | ||
6783 | } | ||
6784 | } | ||
6785 | fn syntax(&self) -> &SyntaxNode { | ||
6786 | &self.syntax | ||
6787 | } | ||
6788 | } | ||
6789 | impl TypeArgList { | ||
6790 | pub fn type_args(&self) -> AstChildren<TypeArg> { | ||
6791 | AstChildren::new(&self.syntax) | ||
6792 | } | ||
6793 | pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { | ||
6794 | AstChildren::new(&self.syntax) | ||
6795 | } | ||
6796 | pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { | ||
6797 | AstChildren::new(&self.syntax) | ||
6798 | } | ||
6799 | pub fn const_arg(&self) -> AstChildren<ConstArg> { | ||
6800 | AstChildren::new(&self.syntax) | ||
6801 | } | ||
6802 | } | ||
6803 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6804 | pub struct TypeArg { | ||
6805 | pub(crate) syntax: SyntaxNode, | ||
6806 | } | ||
6807 | impl std::fmt::Display for TypeArg { | ||
6808 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6809 | std::fmt::Display::fmt(self.syntax(), f) | ||
6810 | } | ||
6811 | } | ||
6812 | impl AstNode for TypeArg { | ||
6813 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6814 | match kind { | ||
6815 | TYPE_ARG => true, | ||
6816 | _ => false, | ||
6817 | } | ||
6818 | } | ||
6819 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6820 | if Self::can_cast(syntax.kind()) { | ||
6821 | Some(Self { syntax }) | ||
6822 | } else { | ||
6823 | None | ||
6824 | } | ||
6825 | } | ||
6826 | fn syntax(&self) -> &SyntaxNode { | ||
6827 | &self.syntax | ||
6828 | } | ||
6829 | } | ||
6830 | impl TypeArg { | ||
6831 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
6832 | AstChildren::new(&self.syntax).next() | ||
6833 | } | ||
6834 | } | ||
6835 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6836 | pub struct AssocTypeArg { | ||
6837 | pub(crate) syntax: SyntaxNode, | ||
6838 | } | ||
6839 | impl std::fmt::Display for AssocTypeArg { | ||
6840 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6841 | std::fmt::Display::fmt(self.syntax(), f) | ||
6842 | } | ||
6843 | } | ||
6844 | impl AstNode for AssocTypeArg { | ||
6845 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6846 | match kind { | ||
6847 | ASSOC_TYPE_ARG => true, | ||
6848 | _ => false, | ||
6849 | } | ||
6850 | } | ||
6851 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6852 | if Self::can_cast(syntax.kind()) { | ||
6853 | Some(Self { syntax }) | ||
6854 | } else { | ||
6855 | None | ||
6856 | } | ||
6857 | } | ||
6858 | fn syntax(&self) -> &SyntaxNode { | ||
6859 | &self.syntax | ||
6860 | } | ||
6861 | } | ||
6862 | impl AssocTypeArg { | ||
6863 | pub fn name_ref(&self) -> Option<NameRef> { | ||
6864 | AstChildren::new(&self.syntax).next() | ||
6865 | } | ||
6866 | pub fn type_ref(&self) -> Option<TypeRef> { | ||
6867 | AstChildren::new(&self.syntax).next() | ||
6868 | } | ||
6869 | } | ||
6870 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6871 | pub struct LifetimeArg { | ||
6872 | pub(crate) syntax: SyntaxNode, | ||
6873 | } | ||
6874 | impl std::fmt::Display for LifetimeArg { | ||
6875 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6876 | std::fmt::Display::fmt(self.syntax(), f) | ||
6877 | } | ||
6878 | } | ||
6879 | impl AstNode for LifetimeArg { | ||
6880 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6881 | match kind { | ||
6882 | LIFETIME_ARG => true, | ||
6883 | _ => false, | ||
6884 | } | ||
6885 | } | ||
6886 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6887 | if Self::can_cast(syntax.kind()) { | ||
6888 | Some(Self { syntax }) | ||
6889 | } else { | ||
6890 | None | ||
6891 | } | ||
6892 | } | ||
6893 | fn syntax(&self) -> &SyntaxNode { | ||
6894 | &self.syntax | ||
6895 | } | ||
6896 | } | ||
6897 | impl LifetimeArg {} | ||
6898 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6899 | pub struct ConstArg { | ||
6900 | pub(crate) syntax: SyntaxNode, | ||
6901 | } | ||
6902 | impl std::fmt::Display for ConstArg { | ||
6903 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6904 | std::fmt::Display::fmt(self.syntax(), f) | ||
6905 | } | ||
6906 | } | ||
6907 | impl AstNode for ConstArg { | ||
6908 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6909 | match kind { | ||
6910 | CONST_ARG => true, | ||
6911 | _ => false, | ||
6912 | } | ||
6913 | } | ||
6914 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6915 | if Self::can_cast(syntax.kind()) { | ||
6916 | Some(Self { syntax }) | ||
6917 | } else { | ||
6918 | None | ||
6919 | } | ||
6920 | } | ||
6921 | fn syntax(&self) -> &SyntaxNode { | ||
6922 | &self.syntax | ||
6923 | } | ||
6924 | } | ||
6925 | impl ConstArg { | ||
6926 | pub fn literal(&self) -> Option<Literal> { | ||
6927 | AstChildren::new(&self.syntax).next() | ||
6928 | } | ||
6929 | pub fn block_expr(&self) -> Option<BlockExpr> { | ||
6930 | AstChildren::new(&self.syntax).next() | ||
6931 | } | ||
6932 | } | ||
6933 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6934 | pub struct MacroItems { | ||
6935 | pub(crate) syntax: SyntaxNode, | ||
6936 | } | ||
6937 | impl std::fmt::Display for MacroItems { | ||
6938 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6939 | std::fmt::Display::fmt(self.syntax(), f) | ||
6940 | } | ||
6941 | } | ||
6942 | impl AstNode for MacroItems { | ||
6943 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6944 | match kind { | ||
6945 | MACRO_ITEMS => true, | ||
6946 | _ => false, | ||
6947 | } | ||
6948 | } | ||
6949 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6950 | if Self::can_cast(syntax.kind()) { | ||
6951 | Some(Self { syntax }) | ||
6952 | } else { | ||
6953 | None | ||
6954 | } | ||
6955 | } | ||
6956 | fn syntax(&self) -> &SyntaxNode { | ||
6957 | &self.syntax | ||
6958 | } | ||
6959 | } | ||
6960 | impl ast::ModuleItemOwner for MacroItems {} | ||
6961 | impl ast::FnDefOwner for MacroItems {} | ||
6962 | impl MacroItems {} | ||
6963 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6964 | pub struct MacroStmts { | ||
6965 | pub(crate) syntax: SyntaxNode, | ||
6966 | } | ||
6967 | impl std::fmt::Display for MacroStmts { | ||
6968 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
6969 | std::fmt::Display::fmt(self.syntax(), f) | ||
6970 | } | ||
6971 | } | ||
6972 | impl AstNode for MacroStmts { | ||
6973 | fn can_cast(kind: SyntaxKind) -> bool { | ||
6974 | match kind { | ||
6975 | MACRO_STMTS => true, | ||
6976 | _ => false, | ||
6977 | } | ||
6978 | } | ||
6979 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
6980 | if Self::can_cast(syntax.kind()) { | ||
6981 | Some(Self { syntax }) | ||
6982 | } else { | ||
6983 | None | ||
6984 | } | ||
6985 | } | ||
6986 | fn syntax(&self) -> &SyntaxNode { | ||
6987 | &self.syntax | ||
6988 | } | ||
6989 | } | ||
6990 | impl MacroStmts { | ||
6991 | pub fn statements(&self) -> AstChildren<Stmt> { | ||
6992 | AstChildren::new(&self.syntax) | ||
6993 | } | ||
6994 | pub fn expr(&self) -> Option<Expr> { | ||
6995 | AstChildren::new(&self.syntax).next() | ||
6996 | } | ||
6997 | } | ||
6998 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
6999 | pub enum NominalDef { | ||
7000 | StructDef(StructDef), | ||
7001 | EnumDef(EnumDef), | ||
7002 | UnionDef(UnionDef), | ||
7003 | } | ||
7004 | impl From<StructDef> for NominalDef { | ||
7005 | fn from(node: StructDef) -> NominalDef { | ||
7006 | NominalDef::StructDef(node) | ||
7007 | } | ||
7008 | } | ||
7009 | impl From<EnumDef> for NominalDef { | ||
7010 | fn from(node: EnumDef) -> NominalDef { | ||
7011 | NominalDef::EnumDef(node) | ||
7012 | } | ||
7013 | } | ||
7014 | impl From<UnionDef> for NominalDef { | ||
7015 | fn from(node: UnionDef) -> NominalDef { | ||
7016 | NominalDef::UnionDef(node) | ||
7017 | } | ||
7018 | } | ||
7019 | impl std::fmt::Display for NominalDef { | ||
7020 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7021 | std::fmt::Display::fmt(self.syntax(), f) | ||
7022 | } | ||
7023 | } | ||
7024 | impl AstNode for NominalDef { | ||
7025 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7026 | match kind { | ||
7027 | STRUCT_DEF | ENUM_DEF | UNION_DEF => true, | ||
7028 | _ => false, | ||
7029 | } | ||
7030 | } | ||
7031 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7032 | let res = match syntax.kind() { | ||
7033 | STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }), | ||
7034 | ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }), | ||
7035 | UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }), | ||
7036 | _ => return None, | ||
7037 | }; | ||
7038 | Some(res) | ||
7039 | } | ||
7040 | fn syntax(&self) -> &SyntaxNode { | ||
7041 | match self { | ||
7042 | NominalDef::StructDef(it) => &it.syntax, | ||
7043 | NominalDef::EnumDef(it) => &it.syntax, | ||
7044 | NominalDef::UnionDef(it) => &it.syntax, | ||
7045 | } | ||
7046 | } | ||
7047 | } | ||
7048 | impl ast::NameOwner for NominalDef {} | ||
7049 | impl ast::TypeParamsOwner for NominalDef {} | ||
7050 | impl ast::AttrsOwner for NominalDef {} | ||
7051 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7052 | pub enum TypeRef { | ||
7053 | ParenType(ParenType), | ||
7054 | TupleType(TupleType), | ||
7055 | NeverType(NeverType), | ||
7056 | PathType(PathType), | ||
7057 | PointerType(PointerType), | ||
7058 | ArrayType(ArrayType), | ||
7059 | SliceType(SliceType), | ||
7060 | ReferenceType(ReferenceType), | ||
7061 | PlaceholderType(PlaceholderType), | ||
7062 | FnPointerType(FnPointerType), | ||
7063 | ForType(ForType), | ||
7064 | ImplTraitType(ImplTraitType), | ||
7065 | DynTraitType(DynTraitType), | ||
7066 | } | ||
7067 | impl From<ParenType> for TypeRef { | ||
7068 | fn from(node: ParenType) -> TypeRef { | ||
7069 | TypeRef::ParenType(node) | ||
7070 | } | ||
7071 | } | ||
7072 | impl From<TupleType> for TypeRef { | ||
7073 | fn from(node: TupleType) -> TypeRef { | ||
7074 | TypeRef::TupleType(node) | ||
7075 | } | ||
7076 | } | ||
7077 | impl From<NeverType> for TypeRef { | ||
7078 | fn from(node: NeverType) -> TypeRef { | ||
7079 | TypeRef::NeverType(node) | ||
7080 | } | ||
7081 | } | ||
7082 | impl From<PathType> for TypeRef { | ||
7083 | fn from(node: PathType) -> TypeRef { | ||
7084 | TypeRef::PathType(node) | ||
7085 | } | ||
7086 | } | ||
7087 | impl From<PointerType> for TypeRef { | ||
7088 | fn from(node: PointerType) -> TypeRef { | ||
7089 | TypeRef::PointerType(node) | ||
7090 | } | ||
7091 | } | ||
7092 | impl From<ArrayType> for TypeRef { | ||
7093 | fn from(node: ArrayType) -> TypeRef { | ||
7094 | TypeRef::ArrayType(node) | ||
7095 | } | ||
7096 | } | ||
7097 | impl From<SliceType> for TypeRef { | ||
7098 | fn from(node: SliceType) -> TypeRef { | ||
7099 | TypeRef::SliceType(node) | ||
7100 | } | ||
7101 | } | ||
7102 | impl From<ReferenceType> for TypeRef { | ||
7103 | fn from(node: ReferenceType) -> TypeRef { | ||
7104 | TypeRef::ReferenceType(node) | ||
7105 | } | ||
7106 | } | ||
7107 | impl From<PlaceholderType> for TypeRef { | ||
7108 | fn from(node: PlaceholderType) -> TypeRef { | ||
7109 | TypeRef::PlaceholderType(node) | ||
7110 | } | ||
7111 | } | ||
7112 | impl From<FnPointerType> for TypeRef { | ||
7113 | fn from(node: FnPointerType) -> TypeRef { | ||
7114 | TypeRef::FnPointerType(node) | ||
7115 | } | ||
7116 | } | ||
7117 | impl From<ForType> for TypeRef { | ||
7118 | fn from(node: ForType) -> TypeRef { | ||
7119 | TypeRef::ForType(node) | ||
7120 | } | ||
7121 | } | ||
7122 | impl From<ImplTraitType> for TypeRef { | ||
7123 | fn from(node: ImplTraitType) -> TypeRef { | ||
7124 | TypeRef::ImplTraitType(node) | ||
7125 | } | ||
7126 | } | ||
7127 | impl From<DynTraitType> for TypeRef { | ||
7128 | fn from(node: DynTraitType) -> TypeRef { | ||
7129 | TypeRef::DynTraitType(node) | ||
7130 | } | ||
7131 | } | ||
7132 | impl std::fmt::Display for TypeRef { | ||
7133 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7134 | std::fmt::Display::fmt(self.syntax(), f) | ||
7135 | } | ||
7136 | } | ||
7137 | impl AstNode for TypeRef { | ||
7138 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7139 | match kind { | ||
7140 | PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE | ||
7141 | | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE | ||
7142 | | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true, | ||
7143 | _ => false, | ||
7144 | } | ||
7145 | } | ||
7146 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7147 | let res = match syntax.kind() { | ||
7148 | PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }), | ||
7149 | TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }), | ||
7150 | NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }), | ||
7151 | PATH_TYPE => TypeRef::PathType(PathType { syntax }), | ||
7152 | POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }), | ||
7153 | ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }), | ||
7154 | SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }), | ||
7155 | REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }), | ||
7156 | PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }), | ||
7157 | FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }), | ||
7158 | FOR_TYPE => TypeRef::ForType(ForType { syntax }), | ||
7159 | IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }), | ||
7160 | DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }), | ||
7161 | _ => return None, | ||
7162 | }; | ||
7163 | Some(res) | ||
7164 | } | ||
7165 | fn syntax(&self) -> &SyntaxNode { | ||
7166 | match self { | ||
7167 | TypeRef::ParenType(it) => &it.syntax, | ||
7168 | TypeRef::TupleType(it) => &it.syntax, | ||
7169 | TypeRef::NeverType(it) => &it.syntax, | ||
7170 | TypeRef::PathType(it) => &it.syntax, | ||
7171 | TypeRef::PointerType(it) => &it.syntax, | ||
7172 | TypeRef::ArrayType(it) => &it.syntax, | ||
7173 | TypeRef::SliceType(it) => &it.syntax, | ||
7174 | TypeRef::ReferenceType(it) => &it.syntax, | ||
7175 | TypeRef::PlaceholderType(it) => &it.syntax, | ||
7176 | TypeRef::FnPointerType(it) => &it.syntax, | ||
7177 | TypeRef::ForType(it) => &it.syntax, | ||
7178 | TypeRef::ImplTraitType(it) => &it.syntax, | ||
7179 | TypeRef::DynTraitType(it) => &it.syntax, | ||
7180 | } | ||
7181 | } | ||
7182 | } | ||
7183 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7184 | pub enum ModuleItem { | ||
7185 | StructDef(StructDef), | ||
7186 | UnionDef(UnionDef), | ||
7187 | EnumDef(EnumDef), | ||
7188 | FnDef(FnDef), | ||
7189 | TraitDef(TraitDef), | ||
7190 | TypeAliasDef(TypeAliasDef), | ||
7191 | ImplDef(ImplDef), | ||
7192 | UseItem(UseItem), | ||
7193 | ExternCrateItem(ExternCrateItem), | ||
7194 | ConstDef(ConstDef), | ||
7195 | StaticDef(StaticDef), | ||
7196 | Module(Module), | ||
7197 | MacroCall(MacroCall), | ||
7198 | } | ||
7199 | impl From<StructDef> for ModuleItem { | ||
7200 | fn from(node: StructDef) -> ModuleItem { | ||
7201 | ModuleItem::StructDef(node) | ||
7202 | } | ||
7203 | } | ||
7204 | impl From<UnionDef> for ModuleItem { | ||
7205 | fn from(node: UnionDef) -> ModuleItem { | ||
7206 | ModuleItem::UnionDef(node) | ||
7207 | } | ||
7208 | } | ||
7209 | impl From<EnumDef> for ModuleItem { | ||
7210 | fn from(node: EnumDef) -> ModuleItem { | ||
7211 | ModuleItem::EnumDef(node) | ||
7212 | } | ||
7213 | } | ||
7214 | impl From<FnDef> for ModuleItem { | ||
7215 | fn from(node: FnDef) -> ModuleItem { | ||
7216 | ModuleItem::FnDef(node) | ||
7217 | } | ||
7218 | } | ||
7219 | impl From<TraitDef> for ModuleItem { | ||
7220 | fn from(node: TraitDef) -> ModuleItem { | ||
7221 | ModuleItem::TraitDef(node) | ||
7222 | } | ||
7223 | } | ||
7224 | impl From<TypeAliasDef> for ModuleItem { | ||
7225 | fn from(node: TypeAliasDef) -> ModuleItem { | ||
7226 | ModuleItem::TypeAliasDef(node) | ||
7227 | } | ||
7228 | } | ||
7229 | impl From<ImplDef> for ModuleItem { | ||
7230 | fn from(node: ImplDef) -> ModuleItem { | ||
7231 | ModuleItem::ImplDef(node) | ||
7232 | } | ||
7233 | } | ||
7234 | impl From<UseItem> for ModuleItem { | ||
7235 | fn from(node: UseItem) -> ModuleItem { | ||
7236 | ModuleItem::UseItem(node) | ||
7237 | } | ||
7238 | } | ||
7239 | impl From<ExternCrateItem> for ModuleItem { | ||
7240 | fn from(node: ExternCrateItem) -> ModuleItem { | ||
7241 | ModuleItem::ExternCrateItem(node) | ||
7242 | } | ||
7243 | } | ||
7244 | impl From<ConstDef> for ModuleItem { | ||
7245 | fn from(node: ConstDef) -> ModuleItem { | ||
7246 | ModuleItem::ConstDef(node) | ||
7247 | } | ||
7248 | } | ||
7249 | impl From<StaticDef> for ModuleItem { | ||
7250 | fn from(node: StaticDef) -> ModuleItem { | ||
7251 | ModuleItem::StaticDef(node) | ||
7252 | } | ||
7253 | } | ||
7254 | impl From<Module> for ModuleItem { | ||
7255 | fn from(node: Module) -> ModuleItem { | ||
7256 | ModuleItem::Module(node) | ||
7257 | } | ||
7258 | } | ||
7259 | impl From<MacroCall> for ModuleItem { | ||
7260 | fn from(node: MacroCall) -> ModuleItem { | ||
7261 | ModuleItem::MacroCall(node) | ||
7262 | } | ||
7263 | } | ||
7264 | impl std::fmt::Display for ModuleItem { | ||
7265 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7266 | std::fmt::Display::fmt(self.syntax(), f) | ||
7267 | } | ||
7268 | } | ||
7269 | impl AstNode for ModuleItem { | ||
7270 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7271 | match kind { | ||
7272 | STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF | ||
7273 | | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL => true, | ||
7274 | _ => false, | ||
7275 | } | ||
7276 | } | ||
7277 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7278 | let res = match syntax.kind() { | ||
7279 | STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }), | ||
7280 | UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }), | ||
7281 | ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }), | ||
7282 | FN_DEF => ModuleItem::FnDef(FnDef { syntax }), | ||
7283 | TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), | ||
7284 | TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), | ||
7285 | IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }), | ||
7286 | USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), | ||
7287 | EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), | ||
7288 | CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), | ||
7289 | STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }), | ||
7290 | MODULE => ModuleItem::Module(Module { syntax }), | ||
7291 | MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }), | ||
7292 | _ => return None, | ||
7293 | }; | ||
7294 | Some(res) | ||
7295 | } | ||
7296 | fn syntax(&self) -> &SyntaxNode { | ||
7297 | match self { | ||
7298 | ModuleItem::StructDef(it) => &it.syntax, | ||
7299 | ModuleItem::UnionDef(it) => &it.syntax, | ||
7300 | ModuleItem::EnumDef(it) => &it.syntax, | ||
7301 | ModuleItem::FnDef(it) => &it.syntax, | ||
7302 | ModuleItem::TraitDef(it) => &it.syntax, | ||
7303 | ModuleItem::TypeAliasDef(it) => &it.syntax, | ||
7304 | ModuleItem::ImplDef(it) => &it.syntax, | ||
7305 | ModuleItem::UseItem(it) => &it.syntax, | ||
7306 | ModuleItem::ExternCrateItem(it) => &it.syntax, | ||
7307 | ModuleItem::ConstDef(it) => &it.syntax, | ||
7308 | ModuleItem::StaticDef(it) => &it.syntax, | ||
7309 | ModuleItem::Module(it) => &it.syntax, | ||
7310 | ModuleItem::MacroCall(it) => &it.syntax, | ||
7311 | } | ||
7312 | } | ||
7313 | } | ||
7314 | impl ast::AttrsOwner for ModuleItem {} | ||
7315 | impl ast::VisibilityOwner for ModuleItem {} | ||
7316 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7317 | pub enum ImplItem { | ||
7318 | FnDef(FnDef), | ||
7319 | TypeAliasDef(TypeAliasDef), | ||
7320 | ConstDef(ConstDef), | ||
7321 | } | ||
7322 | impl From<FnDef> for ImplItem { | ||
7323 | fn from(node: FnDef) -> ImplItem { | ||
7324 | ImplItem::FnDef(node) | ||
7325 | } | ||
7326 | } | ||
7327 | impl From<TypeAliasDef> for ImplItem { | ||
7328 | fn from(node: TypeAliasDef) -> ImplItem { | ||
7329 | ImplItem::TypeAliasDef(node) | ||
7330 | } | ||
7331 | } | ||
7332 | impl From<ConstDef> for ImplItem { | ||
7333 | fn from(node: ConstDef) -> ImplItem { | ||
7334 | ImplItem::ConstDef(node) | ||
7335 | } | ||
7336 | } | ||
7337 | impl std::fmt::Display for ImplItem { | ||
7338 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7339 | std::fmt::Display::fmt(self.syntax(), f) | ||
7340 | } | ||
7341 | } | ||
7342 | impl AstNode for ImplItem { | ||
7343 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7344 | match kind { | ||
7345 | FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true, | ||
7346 | _ => false, | ||
7347 | } | ||
7348 | } | ||
7349 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7350 | let res = match syntax.kind() { | ||
7351 | FN_DEF => ImplItem::FnDef(FnDef { syntax }), | ||
7352 | TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }), | ||
7353 | CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }), | ||
7354 | _ => return None, | ||
7355 | }; | ||
7356 | Some(res) | ||
7357 | } | ||
7358 | fn syntax(&self) -> &SyntaxNode { | ||
7359 | match self { | ||
7360 | ImplItem::FnDef(it) => &it.syntax, | ||
7361 | ImplItem::TypeAliasDef(it) => &it.syntax, | ||
7362 | ImplItem::ConstDef(it) => &it.syntax, | ||
7363 | } | ||
7364 | } | ||
7365 | } | ||
7366 | impl ast::AttrsOwner for ImplItem {} | ||
7367 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7368 | pub enum Expr { | ||
7369 | TupleExpr(TupleExpr), | ||
7370 | ArrayExpr(ArrayExpr), | ||
7371 | ParenExpr(ParenExpr), | ||
7372 | PathExpr(PathExpr), | ||
7373 | LambdaExpr(LambdaExpr), | ||
7374 | IfExpr(IfExpr), | ||
7375 | LoopExpr(LoopExpr), | ||
7376 | ForExpr(ForExpr), | ||
7377 | WhileExpr(WhileExpr), | ||
7378 | ContinueExpr(ContinueExpr), | ||
7379 | BreakExpr(BreakExpr), | ||
7380 | Label(Label), | ||
7381 | BlockExpr(BlockExpr), | ||
7382 | ReturnExpr(ReturnExpr), | ||
7383 | MatchExpr(MatchExpr), | ||
7384 | RecordLit(RecordLit), | ||
7385 | CallExpr(CallExpr), | ||
7386 | IndexExpr(IndexExpr), | ||
7387 | MethodCallExpr(MethodCallExpr), | ||
7388 | FieldExpr(FieldExpr), | ||
7389 | AwaitExpr(AwaitExpr), | ||
7390 | TryExpr(TryExpr), | ||
7391 | TryBlockExpr(TryBlockExpr), | ||
7392 | CastExpr(CastExpr), | ||
7393 | RefExpr(RefExpr), | ||
7394 | PrefixExpr(PrefixExpr), | ||
7395 | RangeExpr(RangeExpr), | ||
7396 | BinExpr(BinExpr), | ||
7397 | Literal(Literal), | ||
7398 | MacroCall(MacroCall), | ||
7399 | BoxExpr(BoxExpr), | ||
7400 | } | ||
7401 | impl From<TupleExpr> for Expr { | ||
7402 | fn from(node: TupleExpr) -> Expr { | ||
7403 | Expr::TupleExpr(node) | ||
7404 | } | ||
7405 | } | ||
7406 | impl From<ArrayExpr> for Expr { | ||
7407 | fn from(node: ArrayExpr) -> Expr { | ||
7408 | Expr::ArrayExpr(node) | ||
7409 | } | ||
7410 | } | ||
7411 | impl From<ParenExpr> for Expr { | ||
7412 | fn from(node: ParenExpr) -> Expr { | ||
7413 | Expr::ParenExpr(node) | ||
7414 | } | ||
7415 | } | ||
7416 | impl From<PathExpr> for Expr { | ||
7417 | fn from(node: PathExpr) -> Expr { | ||
7418 | Expr::PathExpr(node) | ||
7419 | } | ||
7420 | } | ||
7421 | impl From<LambdaExpr> for Expr { | ||
7422 | fn from(node: LambdaExpr) -> Expr { | ||
7423 | Expr::LambdaExpr(node) | ||
7424 | } | ||
7425 | } | ||
7426 | impl From<IfExpr> for Expr { | ||
7427 | fn from(node: IfExpr) -> Expr { | ||
7428 | Expr::IfExpr(node) | ||
7429 | } | ||
7430 | } | ||
7431 | impl From<LoopExpr> for Expr { | ||
7432 | fn from(node: LoopExpr) -> Expr { | ||
7433 | Expr::LoopExpr(node) | ||
7434 | } | ||
7435 | } | ||
7436 | impl From<ForExpr> for Expr { | ||
7437 | fn from(node: ForExpr) -> Expr { | ||
7438 | Expr::ForExpr(node) | ||
7439 | } | ||
7440 | } | ||
7441 | impl From<WhileExpr> for Expr { | ||
7442 | fn from(node: WhileExpr) -> Expr { | ||
7443 | Expr::WhileExpr(node) | ||
7444 | } | ||
7445 | } | ||
7446 | impl From<ContinueExpr> for Expr { | ||
7447 | fn from(node: ContinueExpr) -> Expr { | ||
7448 | Expr::ContinueExpr(node) | ||
7449 | } | ||
7450 | } | ||
7451 | impl From<BreakExpr> for Expr { | ||
7452 | fn from(node: BreakExpr) -> Expr { | ||
7453 | Expr::BreakExpr(node) | ||
7454 | } | ||
7455 | } | ||
7456 | impl From<Label> for Expr { | ||
7457 | fn from(node: Label) -> Expr { | ||
7458 | Expr::Label(node) | ||
7459 | } | ||
7460 | } | ||
7461 | impl From<BlockExpr> for Expr { | ||
7462 | fn from(node: BlockExpr) -> Expr { | ||
7463 | Expr::BlockExpr(node) | ||
7464 | } | ||
7465 | } | ||
7466 | impl From<ReturnExpr> for Expr { | ||
7467 | fn from(node: ReturnExpr) -> Expr { | ||
7468 | Expr::ReturnExpr(node) | ||
7469 | } | ||
7470 | } | ||
7471 | impl From<MatchExpr> for Expr { | ||
7472 | fn from(node: MatchExpr) -> Expr { | ||
7473 | Expr::MatchExpr(node) | ||
7474 | } | ||
7475 | } | ||
7476 | impl From<RecordLit> for Expr { | ||
7477 | fn from(node: RecordLit) -> Expr { | ||
7478 | Expr::RecordLit(node) | ||
7479 | } | ||
7480 | } | ||
7481 | impl From<CallExpr> for Expr { | ||
7482 | fn from(node: CallExpr) -> Expr { | ||
7483 | Expr::CallExpr(node) | ||
7484 | } | ||
7485 | } | ||
7486 | impl From<IndexExpr> for Expr { | ||
7487 | fn from(node: IndexExpr) -> Expr { | ||
7488 | Expr::IndexExpr(node) | ||
7489 | } | ||
7490 | } | ||
7491 | impl From<MethodCallExpr> for Expr { | ||
7492 | fn from(node: MethodCallExpr) -> Expr { | ||
7493 | Expr::MethodCallExpr(node) | ||
7494 | } | ||
7495 | } | ||
7496 | impl From<FieldExpr> for Expr { | ||
7497 | fn from(node: FieldExpr) -> Expr { | ||
7498 | Expr::FieldExpr(node) | ||
7499 | } | ||
7500 | } | ||
7501 | impl From<AwaitExpr> for Expr { | ||
7502 | fn from(node: AwaitExpr) -> Expr { | ||
7503 | Expr::AwaitExpr(node) | ||
7504 | } | ||
7505 | } | ||
7506 | impl From<TryExpr> for Expr { | ||
7507 | fn from(node: TryExpr) -> Expr { | ||
7508 | Expr::TryExpr(node) | ||
7509 | } | ||
7510 | } | ||
7511 | impl From<TryBlockExpr> for Expr { | ||
7512 | fn from(node: TryBlockExpr) -> Expr { | ||
7513 | Expr::TryBlockExpr(node) | ||
7514 | } | ||
7515 | } | ||
7516 | impl From<CastExpr> for Expr { | ||
7517 | fn from(node: CastExpr) -> Expr { | ||
7518 | Expr::CastExpr(node) | ||
7519 | } | ||
7520 | } | ||
7521 | impl From<RefExpr> for Expr { | ||
7522 | fn from(node: RefExpr) -> Expr { | ||
7523 | Expr::RefExpr(node) | ||
7524 | } | ||
7525 | } | ||
7526 | impl From<PrefixExpr> for Expr { | ||
7527 | fn from(node: PrefixExpr) -> Expr { | ||
7528 | Expr::PrefixExpr(node) | ||
7529 | } | ||
7530 | } | ||
7531 | impl From<RangeExpr> for Expr { | ||
7532 | fn from(node: RangeExpr) -> Expr { | ||
7533 | Expr::RangeExpr(node) | ||
7534 | } | ||
7535 | } | ||
7536 | impl From<BinExpr> for Expr { | ||
7537 | fn from(node: BinExpr) -> Expr { | ||
7538 | Expr::BinExpr(node) | ||
7539 | } | ||
7540 | } | ||
7541 | impl From<Literal> for Expr { | ||
7542 | fn from(node: Literal) -> Expr { | ||
7543 | Expr::Literal(node) | ||
7544 | } | ||
7545 | } | ||
7546 | impl From<MacroCall> for Expr { | ||
7547 | fn from(node: MacroCall) -> Expr { | ||
7548 | Expr::MacroCall(node) | ||
7549 | } | ||
7550 | } | ||
7551 | impl From<BoxExpr> for Expr { | ||
7552 | fn from(node: BoxExpr) -> Expr { | ||
7553 | Expr::BoxExpr(node) | ||
7554 | } | ||
7555 | } | ||
7556 | impl std::fmt::Display for Expr { | ||
7557 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7558 | std::fmt::Display::fmt(self.syntax(), f) | ||
7559 | } | ||
7560 | } | ||
7561 | impl AstNode for Expr { | ||
7562 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7563 | match kind { | ||
7564 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | ||
7565 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | ||
7566 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR | ||
7567 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR | ||
7568 | | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | ||
7569 | | BOX_EXPR => true, | ||
7570 | _ => false, | ||
7571 | } | ||
7572 | } | ||
7573 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7574 | let res = match syntax.kind() { | ||
7575 | TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), | ||
7576 | ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }), | ||
7577 | PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }), | ||
7578 | PATH_EXPR => Expr::PathExpr(PathExpr { syntax }), | ||
7579 | LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }), | ||
7580 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), | ||
7581 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), | ||
7582 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), | ||
7583 | WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), | ||
7584 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), | ||
7585 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), | ||
7586 | LABEL => Expr::Label(Label { syntax }), | ||
7587 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | ||
7588 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | ||
7589 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | ||
7590 | RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), | ||
7591 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | ||
7592 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | ||
7593 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | ||
7594 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), | ||
7595 | AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }), | ||
7596 | TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), | ||
7597 | TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }), | ||
7598 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), | ||
7599 | REF_EXPR => Expr::RefExpr(RefExpr { syntax }), | ||
7600 | PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }), | ||
7601 | RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }), | ||
7602 | BIN_EXPR => Expr::BinExpr(BinExpr { syntax }), | ||
7603 | LITERAL => Expr::Literal(Literal { syntax }), | ||
7604 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), | ||
7605 | BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }), | ||
7606 | _ => return None, | ||
7607 | }; | ||
7608 | Some(res) | ||
7609 | } | ||
7610 | fn syntax(&self) -> &SyntaxNode { | ||
7611 | match self { | ||
7612 | Expr::TupleExpr(it) => &it.syntax, | ||
7613 | Expr::ArrayExpr(it) => &it.syntax, | ||
7614 | Expr::ParenExpr(it) => &it.syntax, | ||
7615 | Expr::PathExpr(it) => &it.syntax, | ||
7616 | Expr::LambdaExpr(it) => &it.syntax, | ||
7617 | Expr::IfExpr(it) => &it.syntax, | ||
7618 | Expr::LoopExpr(it) => &it.syntax, | ||
7619 | Expr::ForExpr(it) => &it.syntax, | ||
7620 | Expr::WhileExpr(it) => &it.syntax, | ||
7621 | Expr::ContinueExpr(it) => &it.syntax, | ||
7622 | Expr::BreakExpr(it) => &it.syntax, | ||
7623 | Expr::Label(it) => &it.syntax, | ||
7624 | Expr::BlockExpr(it) => &it.syntax, | ||
7625 | Expr::ReturnExpr(it) => &it.syntax, | ||
7626 | Expr::MatchExpr(it) => &it.syntax, | ||
7627 | Expr::RecordLit(it) => &it.syntax, | ||
7628 | Expr::CallExpr(it) => &it.syntax, | ||
7629 | Expr::IndexExpr(it) => &it.syntax, | ||
7630 | Expr::MethodCallExpr(it) => &it.syntax, | ||
7631 | Expr::FieldExpr(it) => &it.syntax, | ||
7632 | Expr::AwaitExpr(it) => &it.syntax, | ||
7633 | Expr::TryExpr(it) => &it.syntax, | ||
7634 | Expr::TryBlockExpr(it) => &it.syntax, | ||
7635 | Expr::CastExpr(it) => &it.syntax, | ||
7636 | Expr::RefExpr(it) => &it.syntax, | ||
7637 | Expr::PrefixExpr(it) => &it.syntax, | ||
7638 | Expr::RangeExpr(it) => &it.syntax, | ||
7639 | Expr::BinExpr(it) => &it.syntax, | ||
7640 | Expr::Literal(it) => &it.syntax, | ||
7641 | Expr::MacroCall(it) => &it.syntax, | ||
7642 | Expr::BoxExpr(it) => &it.syntax, | ||
7643 | } | ||
7644 | } | ||
7645 | } | ||
7646 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7647 | pub enum Pat { | ||
7648 | OrPat(OrPat), | ||
7649 | ParenPat(ParenPat), | ||
7650 | RefPat(RefPat), | ||
7651 | BoxPat(BoxPat), | ||
7652 | BindPat(BindPat), | ||
7653 | PlaceholderPat(PlaceholderPat), | ||
7654 | DotDotPat(DotDotPat), | ||
7655 | PathPat(PathPat), | ||
7656 | RecordPat(RecordPat), | ||
7657 | TupleStructPat(TupleStructPat), | ||
7658 | TuplePat(TuplePat), | ||
7659 | SlicePat(SlicePat), | ||
7660 | RangePat(RangePat), | ||
7661 | LiteralPat(LiteralPat), | ||
7662 | MacroPat(MacroPat), | ||
7663 | } | ||
7664 | impl From<OrPat> for Pat { | ||
7665 | fn from(node: OrPat) -> Pat { | ||
7666 | Pat::OrPat(node) | ||
7667 | } | ||
7668 | } | ||
7669 | impl From<ParenPat> for Pat { | ||
7670 | fn from(node: ParenPat) -> Pat { | ||
7671 | Pat::ParenPat(node) | ||
7672 | } | ||
7673 | } | ||
7674 | impl From<RefPat> for Pat { | ||
7675 | fn from(node: RefPat) -> Pat { | ||
7676 | Pat::RefPat(node) | ||
7677 | } | ||
7678 | } | ||
7679 | impl From<BoxPat> for Pat { | ||
7680 | fn from(node: BoxPat) -> Pat { | ||
7681 | Pat::BoxPat(node) | ||
7682 | } | ||
7683 | } | ||
7684 | impl From<BindPat> for Pat { | ||
7685 | fn from(node: BindPat) -> Pat { | ||
7686 | Pat::BindPat(node) | ||
7687 | } | ||
7688 | } | ||
7689 | impl From<PlaceholderPat> for Pat { | ||
7690 | fn from(node: PlaceholderPat) -> Pat { | ||
7691 | Pat::PlaceholderPat(node) | ||
7692 | } | ||
7693 | } | ||
7694 | impl From<DotDotPat> for Pat { | ||
7695 | fn from(node: DotDotPat) -> Pat { | ||
7696 | Pat::DotDotPat(node) | ||
7697 | } | ||
7698 | } | ||
7699 | impl From<PathPat> for Pat { | ||
7700 | fn from(node: PathPat) -> Pat { | ||
7701 | Pat::PathPat(node) | ||
7702 | } | ||
7703 | } | ||
7704 | impl From<RecordPat> for Pat { | ||
7705 | fn from(node: RecordPat) -> Pat { | ||
7706 | Pat::RecordPat(node) | ||
7707 | } | ||
7708 | } | ||
7709 | impl From<TupleStructPat> for Pat { | ||
7710 | fn from(node: TupleStructPat) -> Pat { | ||
7711 | Pat::TupleStructPat(node) | ||
7712 | } | ||
7713 | } | ||
7714 | impl From<TuplePat> for Pat { | ||
7715 | fn from(node: TuplePat) -> Pat { | ||
7716 | Pat::TuplePat(node) | ||
7717 | } | ||
7718 | } | ||
7719 | impl From<SlicePat> for Pat { | ||
7720 | fn from(node: SlicePat) -> Pat { | ||
7721 | Pat::SlicePat(node) | ||
7722 | } | ||
7723 | } | ||
7724 | impl From<RangePat> for Pat { | ||
7725 | fn from(node: RangePat) -> Pat { | ||
7726 | Pat::RangePat(node) | ||
7727 | } | ||
7728 | } | ||
7729 | impl From<LiteralPat> for Pat { | ||
7730 | fn from(node: LiteralPat) -> Pat { | ||
7731 | Pat::LiteralPat(node) | ||
7732 | } | ||
7733 | } | ||
7734 | impl From<MacroPat> for Pat { | ||
7735 | fn from(node: MacroPat) -> Pat { | ||
7736 | Pat::MacroPat(node) | ||
7737 | } | ||
7738 | } | ||
7739 | impl std::fmt::Display for Pat { | ||
7740 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7741 | std::fmt::Display::fmt(self.syntax(), f) | ||
7742 | } | ||
7743 | } | ||
7744 | impl AstNode for Pat { | ||
7745 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7746 | match kind { | ||
7747 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
7748 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
7749 | | LITERAL_PAT | MACRO_PAT => true, | ||
7750 | _ => false, | ||
7751 | } | ||
7752 | } | ||
7753 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7754 | let res = match syntax.kind() { | ||
7755 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
7756 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
7757 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
7758 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
7759 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
7760 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
7761 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
7762 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
7763 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
7764 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
7765 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
7766 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
7767 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
7768 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
7769 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
7770 | _ => return None, | ||
7771 | }; | ||
7772 | Some(res) | ||
7773 | } | ||
7774 | fn syntax(&self) -> &SyntaxNode { | ||
7775 | match self { | ||
7776 | Pat::OrPat(it) => &it.syntax, | ||
7777 | Pat::ParenPat(it) => &it.syntax, | ||
7778 | Pat::RefPat(it) => &it.syntax, | ||
7779 | Pat::BoxPat(it) => &it.syntax, | ||
7780 | Pat::BindPat(it) => &it.syntax, | ||
7781 | Pat::PlaceholderPat(it) => &it.syntax, | ||
7782 | Pat::DotDotPat(it) => &it.syntax, | ||
7783 | Pat::PathPat(it) => &it.syntax, | ||
7784 | Pat::RecordPat(it) => &it.syntax, | ||
7785 | Pat::TupleStructPat(it) => &it.syntax, | ||
7786 | Pat::TuplePat(it) => &it.syntax, | ||
7787 | Pat::SlicePat(it) => &it.syntax, | ||
7788 | Pat::RangePat(it) => &it.syntax, | ||
7789 | Pat::LiteralPat(it) => &it.syntax, | ||
7790 | Pat::MacroPat(it) => &it.syntax, | ||
7791 | } | ||
7792 | } | ||
7793 | } | ||
7794 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7795 | pub enum AttrInput { | ||
7796 | Literal(Literal), | ||
7797 | TokenTree(TokenTree), | ||
7798 | } | ||
7799 | impl From<Literal> for AttrInput { | ||
7800 | fn from(node: Literal) -> AttrInput { | ||
7801 | AttrInput::Literal(node) | ||
7802 | } | ||
7803 | } | ||
7804 | impl From<TokenTree> for AttrInput { | ||
7805 | fn from(node: TokenTree) -> AttrInput { | ||
7806 | AttrInput::TokenTree(node) | ||
7807 | } | ||
7808 | } | ||
7809 | impl std::fmt::Display for AttrInput { | ||
7810 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7811 | std::fmt::Display::fmt(self.syntax(), f) | ||
7812 | } | ||
7813 | } | ||
7814 | impl AstNode for AttrInput { | ||
7815 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7816 | match kind { | ||
7817 | LITERAL | TOKEN_TREE => true, | ||
7818 | _ => false, | ||
7819 | } | ||
7820 | } | ||
7821 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7822 | let res = match syntax.kind() { | ||
7823 | LITERAL => AttrInput::Literal(Literal { syntax }), | ||
7824 | TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), | ||
7825 | _ => return None, | ||
7826 | }; | ||
7827 | Some(res) | ||
7828 | } | ||
7829 | fn syntax(&self) -> &SyntaxNode { | ||
7830 | match self { | ||
7831 | AttrInput::Literal(it) => &it.syntax, | ||
7832 | AttrInput::TokenTree(it) => &it.syntax, | ||
7833 | } | ||
7834 | } | ||
7835 | } | ||
7836 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
7837 | pub enum Stmt { | ||
7838 | ExprStmt(ExprStmt), | ||
7839 | LetStmt(LetStmt), | ||
7840 | } | ||
7841 | impl From<ExprStmt> for Stmt { | ||
7842 | fn from(node: ExprStmt) -> Stmt { | ||
7843 | Stmt::ExprStmt(node) | ||
7844 | } | ||
7845 | } | ||
7846 | impl From<LetStmt> for Stmt { | ||
7847 | fn from(node: LetStmt) -> Stmt { | ||
7848 | Stmt::LetStmt(node) | ||
7849 | } | ||
7850 | } | ||
7851 | impl std::fmt::Display for Stmt { | ||
7852 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
7853 | std::fmt::Display::fmt(self.syntax(), f) | ||
7854 | } | ||
7855 | } | ||
7856 | impl AstNode for Stmt { | ||
7857 | fn can_cast(kind: SyntaxKind) -> bool { | ||
7858 | match kind { | ||
7859 | EXPR_STMT | LET_STMT => true, | ||
7860 | _ => false, | ||
7861 | } | ||
7862 | } | ||
7863 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
7864 | let res = match syntax.kind() { | ||
7865 | EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), | ||
7866 | LET_STMT => Stmt::LetStmt(LetStmt { syntax }), | ||
7867 | _ => return None, | ||
7868 | }; | ||
7869 | Some(res) | ||
7870 | } | ||
7871 | fn syntax(&self) -> &SyntaxNode { | ||
7872 | match self { | ||
7873 | Stmt::ExprStmt(it) => &it.syntax, | ||
7874 | Stmt::LetStmt(it) => &it.syntax, | ||
7875 | } | ||
7876 | } | ||
7877 | } | ||
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs new file mode 100644 index 000000000..8b348ad6e --- /dev/null +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -0,0 +1,4177 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` | ||
2 | |||
3 | use super::tokens::*; | ||
4 | use crate::{ | ||
5 | ast::{self, support, AstChildren, AstNode}, | ||
6 | SyntaxKind::{self, *}, | ||
7 | SyntaxNode, | ||
8 | }; | ||
9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
10 | pub struct SourceFile { | ||
11 | pub(crate) syntax: SyntaxNode, | ||
12 | } | ||
13 | impl AstNode for SourceFile { | ||
14 | fn can_cast(kind: SyntaxKind) -> bool { kind == SOURCE_FILE } | ||
15 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
16 | if Self::can_cast(syntax.kind()) { | ||
17 | Some(Self { syntax }) | ||
18 | } else { | ||
19 | None | ||
20 | } | ||
21 | } | ||
22 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
23 | } | ||
24 | impl ast::ModuleItemOwner for SourceFile {} | ||
25 | impl ast::FnDefOwner for SourceFile {} | ||
26 | impl ast::AttrsOwner for SourceFile {} | ||
27 | impl SourceFile { | ||
28 | pub fn modules(&self) -> AstChildren<Module> { support::children(&self.syntax) } | ||
29 | } | ||
30 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
31 | pub struct FnDef { | ||
32 | pub(crate) syntax: SyntaxNode, | ||
33 | } | ||
34 | impl AstNode for FnDef { | ||
35 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_DEF } | ||
36 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
37 | if Self::can_cast(syntax.kind()) { | ||
38 | Some(Self { syntax }) | ||
39 | } else { | ||
40 | None | ||
41 | } | ||
42 | } | ||
43 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
44 | } | ||
45 | impl ast::VisibilityOwner for FnDef {} | ||
46 | impl ast::NameOwner for FnDef {} | ||
47 | impl ast::TypeParamsOwner for FnDef {} | ||
48 | impl ast::DocCommentsOwner for FnDef {} | ||
49 | impl ast::AttrsOwner for FnDef {} | ||
50 | impl FnDef { | ||
51 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
52 | pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } | ||
53 | pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | ||
54 | pub fn async_kw(&self) -> Option<AsyncKw> { support::token(&self.syntax) } | ||
55 | pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | ||
56 | pub fn fn_kw(&self) -> Option<FnKw> { support::token(&self.syntax) } | ||
57 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
58 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
59 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
60 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
61 | } | ||
62 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
63 | pub struct RetType { | ||
64 | pub(crate) syntax: SyntaxNode, | ||
65 | } | ||
66 | impl AstNode for RetType { | ||
67 | fn can_cast(kind: SyntaxKind) -> bool { kind == RET_TYPE } | ||
68 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
69 | if Self::can_cast(syntax.kind()) { | ||
70 | Some(Self { syntax }) | ||
71 | } else { | ||
72 | None | ||
73 | } | ||
74 | } | ||
75 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
76 | } | ||
77 | impl RetType { | ||
78 | pub fn thin_arrow(&self) -> Option<ThinArrow> { support::token(&self.syntax) } | ||
79 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
80 | } | ||
81 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
82 | pub struct StructDef { | ||
83 | pub(crate) syntax: SyntaxNode, | ||
84 | } | ||
85 | impl AstNode for StructDef { | ||
86 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_DEF } | ||
87 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
88 | if Self::can_cast(syntax.kind()) { | ||
89 | Some(Self { syntax }) | ||
90 | } else { | ||
91 | None | ||
92 | } | ||
93 | } | ||
94 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
95 | } | ||
96 | impl ast::VisibilityOwner for StructDef {} | ||
97 | impl ast::NameOwner for StructDef {} | ||
98 | impl ast::TypeParamsOwner for StructDef {} | ||
99 | impl ast::AttrsOwner for StructDef {} | ||
100 | impl ast::DocCommentsOwner for StructDef {} | ||
101 | impl StructDef { | ||
102 | pub fn struct_kw(&self) -> Option<StructKw> { support::token(&self.syntax) } | ||
103 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | ||
104 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
105 | } | ||
106 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
107 | pub struct UnionDef { | ||
108 | pub(crate) syntax: SyntaxNode, | ||
109 | } | ||
110 | impl AstNode for UnionDef { | ||
111 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_DEF } | ||
112 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
113 | if Self::can_cast(syntax.kind()) { | ||
114 | Some(Self { syntax }) | ||
115 | } else { | ||
116 | None | ||
117 | } | ||
118 | } | ||
119 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
120 | } | ||
121 | impl ast::VisibilityOwner for UnionDef {} | ||
122 | impl ast::NameOwner for UnionDef {} | ||
123 | impl ast::TypeParamsOwner for UnionDef {} | ||
124 | impl ast::AttrsOwner for UnionDef {} | ||
125 | impl ast::DocCommentsOwner for UnionDef {} | ||
126 | impl UnionDef { | ||
127 | pub fn union_kw(&self) -> Option<UnionKw> { support::token(&self.syntax) } | ||
128 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { | ||
129 | support::child(&self.syntax) | ||
130 | } | ||
131 | } | ||
132 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
133 | pub struct RecordFieldDefList { | ||
134 | pub(crate) syntax: SyntaxNode, | ||
135 | } | ||
136 | impl AstNode for RecordFieldDefList { | ||
137 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF_LIST } | ||
138 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
139 | if Self::can_cast(syntax.kind()) { | ||
140 | Some(Self { syntax }) | ||
141 | } else { | ||
142 | None | ||
143 | } | ||
144 | } | ||
145 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
146 | } | ||
147 | impl RecordFieldDefList { | ||
148 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
149 | pub fn fields(&self) -> AstChildren<RecordFieldDef> { support::children(&self.syntax) } | ||
150 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
151 | } | ||
152 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
153 | pub struct RecordFieldDef { | ||
154 | pub(crate) syntax: SyntaxNode, | ||
155 | } | ||
156 | impl AstNode for RecordFieldDef { | ||
157 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_DEF } | ||
158 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
159 | if Self::can_cast(syntax.kind()) { | ||
160 | Some(Self { syntax }) | ||
161 | } else { | ||
162 | None | ||
163 | } | ||
164 | } | ||
165 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
166 | } | ||
167 | impl ast::VisibilityOwner for RecordFieldDef {} | ||
168 | impl ast::NameOwner for RecordFieldDef {} | ||
169 | impl ast::AttrsOwner for RecordFieldDef {} | ||
170 | impl ast::DocCommentsOwner for RecordFieldDef {} | ||
171 | impl ast::TypeAscriptionOwner for RecordFieldDef {} | ||
172 | impl RecordFieldDef {} | ||
173 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
174 | pub struct TupleFieldDefList { | ||
175 | pub(crate) syntax: SyntaxNode, | ||
176 | } | ||
177 | impl AstNode for TupleFieldDefList { | ||
178 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF_LIST } | ||
179 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
180 | if Self::can_cast(syntax.kind()) { | ||
181 | Some(Self { syntax }) | ||
182 | } else { | ||
183 | None | ||
184 | } | ||
185 | } | ||
186 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
187 | } | ||
188 | impl TupleFieldDefList { | ||
189 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
190 | pub fn fields(&self) -> AstChildren<TupleFieldDef> { support::children(&self.syntax) } | ||
191 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
192 | } | ||
193 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
194 | pub struct TupleFieldDef { | ||
195 | pub(crate) syntax: SyntaxNode, | ||
196 | } | ||
197 | impl AstNode for TupleFieldDef { | ||
198 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_FIELD_DEF } | ||
199 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
200 | if Self::can_cast(syntax.kind()) { | ||
201 | Some(Self { syntax }) | ||
202 | } else { | ||
203 | None | ||
204 | } | ||
205 | } | ||
206 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
207 | } | ||
208 | impl ast::VisibilityOwner for TupleFieldDef {} | ||
209 | impl ast::AttrsOwner for TupleFieldDef {} | ||
210 | impl TupleFieldDef { | ||
211 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
212 | } | ||
213 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
214 | pub struct EnumDef { | ||
215 | pub(crate) syntax: SyntaxNode, | ||
216 | } | ||
217 | impl AstNode for EnumDef { | ||
218 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_DEF } | ||
219 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
220 | if Self::can_cast(syntax.kind()) { | ||
221 | Some(Self { syntax }) | ||
222 | } else { | ||
223 | None | ||
224 | } | ||
225 | } | ||
226 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
227 | } | ||
228 | impl ast::VisibilityOwner for EnumDef {} | ||
229 | impl ast::NameOwner for EnumDef {} | ||
230 | impl ast::TypeParamsOwner for EnumDef {} | ||
231 | impl ast::AttrsOwner for EnumDef {} | ||
232 | impl ast::DocCommentsOwner for EnumDef {} | ||
233 | impl EnumDef { | ||
234 | pub fn enum_kw(&self) -> Option<EnumKw> { support::token(&self.syntax) } | ||
235 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } | ||
236 | } | ||
237 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
238 | pub struct EnumVariantList { | ||
239 | pub(crate) syntax: SyntaxNode, | ||
240 | } | ||
241 | impl AstNode for EnumVariantList { | ||
242 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT_LIST } | ||
243 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
244 | if Self::can_cast(syntax.kind()) { | ||
245 | Some(Self { syntax }) | ||
246 | } else { | ||
247 | None | ||
248 | } | ||
249 | } | ||
250 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
251 | } | ||
252 | impl EnumVariantList { | ||
253 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
254 | pub fn variants(&self) -> AstChildren<EnumVariant> { support::children(&self.syntax) } | ||
255 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
256 | } | ||
257 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
258 | pub struct EnumVariant { | ||
259 | pub(crate) syntax: SyntaxNode, | ||
260 | } | ||
261 | impl AstNode for EnumVariant { | ||
262 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_VARIANT } | ||
263 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
264 | if Self::can_cast(syntax.kind()) { | ||
265 | Some(Self { syntax }) | ||
266 | } else { | ||
267 | None | ||
268 | } | ||
269 | } | ||
270 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
271 | } | ||
272 | impl ast::VisibilityOwner for EnumVariant {} | ||
273 | impl ast::NameOwner for EnumVariant {} | ||
274 | impl ast::DocCommentsOwner for EnumVariant {} | ||
275 | impl ast::AttrsOwner for EnumVariant {} | ||
276 | impl EnumVariant { | ||
277 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | ||
278 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
279 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
280 | } | ||
281 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
282 | pub struct TraitDef { | ||
283 | pub(crate) syntax: SyntaxNode, | ||
284 | } | ||
285 | impl AstNode for TraitDef { | ||
286 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_DEF } | ||
287 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
288 | if Self::can_cast(syntax.kind()) { | ||
289 | Some(Self { syntax }) | ||
290 | } else { | ||
291 | None | ||
292 | } | ||
293 | } | ||
294 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
295 | } | ||
296 | impl ast::VisibilityOwner for TraitDef {} | ||
297 | impl ast::NameOwner for TraitDef {} | ||
298 | impl ast::AttrsOwner for TraitDef {} | ||
299 | impl ast::DocCommentsOwner for TraitDef {} | ||
300 | impl ast::TypeParamsOwner for TraitDef {} | ||
301 | impl ast::TypeBoundsOwner for TraitDef {} | ||
302 | impl TraitDef { | ||
303 | pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | ||
304 | pub fn auto_kw(&self) -> Option<AutoKw> { support::token(&self.syntax) } | ||
305 | pub fn trait_kw(&self) -> Option<TraitKw> { support::token(&self.syntax) } | ||
306 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
307 | } | ||
308 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
309 | pub struct Module { | ||
310 | pub(crate) syntax: SyntaxNode, | ||
311 | } | ||
312 | impl AstNode for Module { | ||
313 | fn can_cast(kind: SyntaxKind) -> bool { kind == MODULE } | ||
314 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
315 | if Self::can_cast(syntax.kind()) { | ||
316 | Some(Self { syntax }) | ||
317 | } else { | ||
318 | None | ||
319 | } | ||
320 | } | ||
321 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
322 | } | ||
323 | impl ast::VisibilityOwner for Module {} | ||
324 | impl ast::NameOwner for Module {} | ||
325 | impl ast::AttrsOwner for Module {} | ||
326 | impl ast::DocCommentsOwner for Module {} | ||
327 | impl Module { | ||
328 | pub fn mod_kw(&self) -> Option<ModKw> { support::token(&self.syntax) } | ||
329 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
330 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
331 | } | ||
332 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
333 | pub struct ItemList { | ||
334 | pub(crate) syntax: SyntaxNode, | ||
335 | } | ||
336 | impl AstNode for ItemList { | ||
337 | fn can_cast(kind: SyntaxKind) -> bool { kind == ITEM_LIST } | ||
338 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
339 | if Self::can_cast(syntax.kind()) { | ||
340 | Some(Self { syntax }) | ||
341 | } else { | ||
342 | None | ||
343 | } | ||
344 | } | ||
345 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
346 | } | ||
347 | impl ast::FnDefOwner for ItemList {} | ||
348 | impl ast::ModuleItemOwner for ItemList {} | ||
349 | impl ItemList { | ||
350 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
351 | pub fn impl_items(&self) -> AstChildren<ImplItem> { support::children(&self.syntax) } | ||
352 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
353 | } | ||
354 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
355 | pub struct ConstDef { | ||
356 | pub(crate) syntax: SyntaxNode, | ||
357 | } | ||
358 | impl AstNode for ConstDef { | ||
359 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_DEF } | ||
360 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
361 | if Self::can_cast(syntax.kind()) { | ||
362 | Some(Self { syntax }) | ||
363 | } else { | ||
364 | None | ||
365 | } | ||
366 | } | ||
367 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
368 | } | ||
369 | impl ast::VisibilityOwner for ConstDef {} | ||
370 | impl ast::NameOwner for ConstDef {} | ||
371 | impl ast::TypeParamsOwner for ConstDef {} | ||
372 | impl ast::AttrsOwner for ConstDef {} | ||
373 | impl ast::DocCommentsOwner for ConstDef {} | ||
374 | impl ast::TypeAscriptionOwner for ConstDef {} | ||
375 | impl ConstDef { | ||
376 | pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | ||
377 | pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } | ||
378 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
379 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
380 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
381 | } | ||
382 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
383 | pub struct StaticDef { | ||
384 | pub(crate) syntax: SyntaxNode, | ||
385 | } | ||
386 | impl AstNode for StaticDef { | ||
387 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_DEF } | ||
388 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
389 | if Self::can_cast(syntax.kind()) { | ||
390 | Some(Self { syntax }) | ||
391 | } else { | ||
392 | None | ||
393 | } | ||
394 | } | ||
395 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
396 | } | ||
397 | impl ast::VisibilityOwner for StaticDef {} | ||
398 | impl ast::NameOwner for StaticDef {} | ||
399 | impl ast::TypeParamsOwner for StaticDef {} | ||
400 | impl ast::AttrsOwner for StaticDef {} | ||
401 | impl ast::DocCommentsOwner for StaticDef {} | ||
402 | impl ast::TypeAscriptionOwner for StaticDef {} | ||
403 | impl StaticDef { | ||
404 | pub fn static_kw(&self) -> Option<StaticKw> { support::token(&self.syntax) } | ||
405 | pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } | ||
406 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
407 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
408 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
409 | } | ||
410 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
411 | pub struct TypeAliasDef { | ||
412 | pub(crate) syntax: SyntaxNode, | ||
413 | } | ||
414 | impl AstNode for TypeAliasDef { | ||
415 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ALIAS_DEF } | ||
416 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
417 | if Self::can_cast(syntax.kind()) { | ||
418 | Some(Self { syntax }) | ||
419 | } else { | ||
420 | None | ||
421 | } | ||
422 | } | ||
423 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
424 | } | ||
425 | impl ast::VisibilityOwner for TypeAliasDef {} | ||
426 | impl ast::NameOwner for TypeAliasDef {} | ||
427 | impl ast::TypeParamsOwner for TypeAliasDef {} | ||
428 | impl ast::AttrsOwner for TypeAliasDef {} | ||
429 | impl ast::DocCommentsOwner for TypeAliasDef {} | ||
430 | impl ast::TypeBoundsOwner for TypeAliasDef {} | ||
431 | impl TypeAliasDef { | ||
432 | pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | ||
433 | pub fn type_kw(&self) -> Option<TypeKw> { support::token(&self.syntax) } | ||
434 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
435 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
436 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
437 | } | ||
438 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
439 | pub struct ImplDef { | ||
440 | pub(crate) syntax: SyntaxNode, | ||
441 | } | ||
442 | impl AstNode for ImplDef { | ||
443 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_DEF } | ||
444 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
445 | if Self::can_cast(syntax.kind()) { | ||
446 | Some(Self { syntax }) | ||
447 | } else { | ||
448 | None | ||
449 | } | ||
450 | } | ||
451 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
452 | } | ||
453 | impl ast::TypeParamsOwner for ImplDef {} | ||
454 | impl ast::AttrsOwner for ImplDef {} | ||
455 | impl ImplDef { | ||
456 | pub fn default_kw(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | ||
457 | pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } | ||
458 | pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | ||
459 | pub fn impl_kw(&self) -> Option<ImplKw> { support::token(&self.syntax) } | ||
460 | pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } | ||
461 | pub fn for_kw(&self) -> Option<ForKw> { support::token(&self.syntax) } | ||
462 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | ||
463 | } | ||
464 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
465 | pub struct ParenType { | ||
466 | pub(crate) syntax: SyntaxNode, | ||
467 | } | ||
468 | impl AstNode for ParenType { | ||
469 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_TYPE } | ||
470 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
471 | if Self::can_cast(syntax.kind()) { | ||
472 | Some(Self { syntax }) | ||
473 | } else { | ||
474 | None | ||
475 | } | ||
476 | } | ||
477 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
478 | } | ||
479 | impl ParenType { | ||
480 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
481 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
482 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
483 | } | ||
484 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
485 | pub struct TupleType { | ||
486 | pub(crate) syntax: SyntaxNode, | ||
487 | } | ||
488 | impl AstNode for TupleType { | ||
489 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_TYPE } | ||
490 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
491 | if Self::can_cast(syntax.kind()) { | ||
492 | Some(Self { syntax }) | ||
493 | } else { | ||
494 | None | ||
495 | } | ||
496 | } | ||
497 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
498 | } | ||
499 | impl TupleType { | ||
500 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
501 | pub fn fields(&self) -> AstChildren<TypeRef> { support::children(&self.syntax) } | ||
502 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
503 | } | ||
504 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
505 | pub struct NeverType { | ||
506 | pub(crate) syntax: SyntaxNode, | ||
507 | } | ||
508 | impl AstNode for NeverType { | ||
509 | fn can_cast(kind: SyntaxKind) -> bool { kind == NEVER_TYPE } | ||
510 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
511 | if Self::can_cast(syntax.kind()) { | ||
512 | Some(Self { syntax }) | ||
513 | } else { | ||
514 | None | ||
515 | } | ||
516 | } | ||
517 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
518 | } | ||
519 | impl NeverType { | ||
520 | pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } | ||
521 | } | ||
522 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
523 | pub struct PathType { | ||
524 | pub(crate) syntax: SyntaxNode, | ||
525 | } | ||
526 | impl AstNode for PathType { | ||
527 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_TYPE } | ||
528 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
529 | if Self::can_cast(syntax.kind()) { | ||
530 | Some(Self { syntax }) | ||
531 | } else { | ||
532 | None | ||
533 | } | ||
534 | } | ||
535 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
536 | } | ||
537 | impl PathType { | ||
538 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
539 | } | ||
540 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
541 | pub struct PointerType { | ||
542 | pub(crate) syntax: SyntaxNode, | ||
543 | } | ||
544 | impl AstNode for PointerType { | ||
545 | fn can_cast(kind: SyntaxKind) -> bool { kind == POINTER_TYPE } | ||
546 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
547 | if Self::can_cast(syntax.kind()) { | ||
548 | Some(Self { syntax }) | ||
549 | } else { | ||
550 | None | ||
551 | } | ||
552 | } | ||
553 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
554 | } | ||
555 | impl PointerType { | ||
556 | pub fn star(&self) -> Option<Star> { support::token(&self.syntax) } | ||
557 | pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } | ||
558 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
559 | } | ||
560 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
561 | pub struct ArrayType { | ||
562 | pub(crate) syntax: SyntaxNode, | ||
563 | } | ||
564 | impl AstNode for ArrayType { | ||
565 | fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_TYPE } | ||
566 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
567 | if Self::can_cast(syntax.kind()) { | ||
568 | Some(Self { syntax }) | ||
569 | } else { | ||
570 | None | ||
571 | } | ||
572 | } | ||
573 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
574 | } | ||
575 | impl ArrayType { | ||
576 | pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } | ||
577 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
578 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
579 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
580 | pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } | ||
581 | } | ||
582 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
583 | pub struct SliceType { | ||
584 | pub(crate) syntax: SyntaxNode, | ||
585 | } | ||
586 | impl AstNode for SliceType { | ||
587 | fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_TYPE } | ||
588 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
589 | if Self::can_cast(syntax.kind()) { | ||
590 | Some(Self { syntax }) | ||
591 | } else { | ||
592 | None | ||
593 | } | ||
594 | } | ||
595 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
596 | } | ||
597 | impl SliceType { | ||
598 | pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } | ||
599 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
600 | pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } | ||
601 | } | ||
602 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
603 | pub struct ReferenceType { | ||
604 | pub(crate) syntax: SyntaxNode, | ||
605 | } | ||
606 | impl AstNode for ReferenceType { | ||
607 | fn can_cast(kind: SyntaxKind) -> bool { kind == REFERENCE_TYPE } | ||
608 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
609 | if Self::can_cast(syntax.kind()) { | ||
610 | Some(Self { syntax }) | ||
611 | } else { | ||
612 | None | ||
613 | } | ||
614 | } | ||
615 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
616 | } | ||
617 | impl ReferenceType { | ||
618 | pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } | ||
619 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
620 | pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } | ||
621 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
622 | } | ||
623 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
624 | pub struct PlaceholderType { | ||
625 | pub(crate) syntax: SyntaxNode, | ||
626 | } | ||
627 | impl AstNode for PlaceholderType { | ||
628 | fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_TYPE } | ||
629 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
630 | if Self::can_cast(syntax.kind()) { | ||
631 | Some(Self { syntax }) | ||
632 | } else { | ||
633 | None | ||
634 | } | ||
635 | } | ||
636 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
637 | } | ||
638 | impl PlaceholderType { | ||
639 | pub fn underscore(&self) -> Option<Underscore> { support::token(&self.syntax) } | ||
640 | } | ||
641 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
642 | pub struct FnPointerType { | ||
643 | pub(crate) syntax: SyntaxNode, | ||
644 | } | ||
645 | impl AstNode for FnPointerType { | ||
646 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_POINTER_TYPE } | ||
647 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
648 | if Self::can_cast(syntax.kind()) { | ||
649 | Some(Self { syntax }) | ||
650 | } else { | ||
651 | None | ||
652 | } | ||
653 | } | ||
654 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
655 | } | ||
656 | impl FnPointerType { | ||
657 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
658 | pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | ||
659 | pub fn fn_kw(&self) -> Option<FnKw> { support::token(&self.syntax) } | ||
660 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
661 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
662 | } | ||
663 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
664 | pub struct ForType { | ||
665 | pub(crate) syntax: SyntaxNode, | ||
666 | } | ||
667 | impl AstNode for ForType { | ||
668 | fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_TYPE } | ||
669 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
670 | if Self::can_cast(syntax.kind()) { | ||
671 | Some(Self { syntax }) | ||
672 | } else { | ||
673 | None | ||
674 | } | ||
675 | } | ||
676 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
677 | } | ||
678 | impl ForType { | ||
679 | pub fn for_kw(&self) -> Option<ForKw> { support::token(&self.syntax) } | ||
680 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | ||
681 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
682 | } | ||
683 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
684 | pub struct ImplTraitType { | ||
685 | pub(crate) syntax: SyntaxNode, | ||
686 | } | ||
687 | impl AstNode for ImplTraitType { | ||
688 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_TRAIT_TYPE } | ||
689 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
690 | if Self::can_cast(syntax.kind()) { | ||
691 | Some(Self { syntax }) | ||
692 | } else { | ||
693 | None | ||
694 | } | ||
695 | } | ||
696 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
697 | } | ||
698 | impl ast::TypeBoundsOwner for ImplTraitType {} | ||
699 | impl ImplTraitType { | ||
700 | pub fn impl_kw(&self) -> Option<ImplKw> { support::token(&self.syntax) } | ||
701 | } | ||
702 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
703 | pub struct DynTraitType { | ||
704 | pub(crate) syntax: SyntaxNode, | ||
705 | } | ||
706 | impl AstNode for DynTraitType { | ||
707 | fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_TRAIT_TYPE } | ||
708 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
709 | if Self::can_cast(syntax.kind()) { | ||
710 | Some(Self { syntax }) | ||
711 | } else { | ||
712 | None | ||
713 | } | ||
714 | } | ||
715 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
716 | } | ||
717 | impl ast::TypeBoundsOwner for DynTraitType {} | ||
718 | impl DynTraitType { | ||
719 | pub fn dyn_kw(&self) -> Option<DynKw> { support::token(&self.syntax) } | ||
720 | } | ||
721 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
722 | pub struct TupleExpr { | ||
723 | pub(crate) syntax: SyntaxNode, | ||
724 | } | ||
725 | impl AstNode for TupleExpr { | ||
726 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_EXPR } | ||
727 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
728 | if Self::can_cast(syntax.kind()) { | ||
729 | Some(Self { syntax }) | ||
730 | } else { | ||
731 | None | ||
732 | } | ||
733 | } | ||
734 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
735 | } | ||
736 | impl ast::AttrsOwner for TupleExpr {} | ||
737 | impl TupleExpr { | ||
738 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
739 | pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } | ||
740 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
741 | } | ||
742 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
743 | pub struct ArrayExpr { | ||
744 | pub(crate) syntax: SyntaxNode, | ||
745 | } | ||
746 | impl AstNode for ArrayExpr { | ||
747 | fn can_cast(kind: SyntaxKind) -> bool { kind == ARRAY_EXPR } | ||
748 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
749 | if Self::can_cast(syntax.kind()) { | ||
750 | Some(Self { syntax }) | ||
751 | } else { | ||
752 | None | ||
753 | } | ||
754 | } | ||
755 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
756 | } | ||
757 | impl ast::AttrsOwner for ArrayExpr {} | ||
758 | impl ArrayExpr { | ||
759 | pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } | ||
760 | pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) } | ||
761 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
762 | pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } | ||
763 | } | ||
764 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
765 | pub struct ParenExpr { | ||
766 | pub(crate) syntax: SyntaxNode, | ||
767 | } | ||
768 | impl AstNode for ParenExpr { | ||
769 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_EXPR } | ||
770 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
771 | if Self::can_cast(syntax.kind()) { | ||
772 | Some(Self { syntax }) | ||
773 | } else { | ||
774 | None | ||
775 | } | ||
776 | } | ||
777 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
778 | } | ||
779 | impl ast::AttrsOwner for ParenExpr {} | ||
780 | impl ParenExpr { | ||
781 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
782 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
783 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
784 | } | ||
785 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
786 | pub struct PathExpr { | ||
787 | pub(crate) syntax: SyntaxNode, | ||
788 | } | ||
789 | impl AstNode for PathExpr { | ||
790 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_EXPR } | ||
791 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
792 | if Self::can_cast(syntax.kind()) { | ||
793 | Some(Self { syntax }) | ||
794 | } else { | ||
795 | None | ||
796 | } | ||
797 | } | ||
798 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
799 | } | ||
800 | impl PathExpr { | ||
801 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
802 | } | ||
803 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
804 | pub struct LambdaExpr { | ||
805 | pub(crate) syntax: SyntaxNode, | ||
806 | } | ||
807 | impl AstNode for LambdaExpr { | ||
808 | fn can_cast(kind: SyntaxKind) -> bool { kind == LAMBDA_EXPR } | ||
809 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
810 | if Self::can_cast(syntax.kind()) { | ||
811 | Some(Self { syntax }) | ||
812 | } else { | ||
813 | None | ||
814 | } | ||
815 | } | ||
816 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
817 | } | ||
818 | impl ast::AttrsOwner for LambdaExpr {} | ||
819 | impl LambdaExpr { | ||
820 | pub fn static_kw(&self) -> Option<StaticKw> { support::token(&self.syntax) } | ||
821 | pub fn async_kw(&self) -> Option<AsyncKw> { support::token(&self.syntax) } | ||
822 | pub fn move_kw(&self) -> Option<MoveKw> { support::token(&self.syntax) } | ||
823 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
824 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
825 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
826 | } | ||
827 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
828 | pub struct IfExpr { | ||
829 | pub(crate) syntax: SyntaxNode, | ||
830 | } | ||
831 | impl AstNode for IfExpr { | ||
832 | fn can_cast(kind: SyntaxKind) -> bool { kind == IF_EXPR } | ||
833 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
834 | if Self::can_cast(syntax.kind()) { | ||
835 | Some(Self { syntax }) | ||
836 | } else { | ||
837 | None | ||
838 | } | ||
839 | } | ||
840 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
841 | } | ||
842 | impl ast::AttrsOwner for IfExpr {} | ||
843 | impl IfExpr { | ||
844 | pub fn if_kw(&self) -> Option<IfKw> { support::token(&self.syntax) } | ||
845 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | ||
846 | } | ||
847 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
848 | pub struct LoopExpr { | ||
849 | pub(crate) syntax: SyntaxNode, | ||
850 | } | ||
851 | impl AstNode for LoopExpr { | ||
852 | fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_EXPR } | ||
853 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
854 | if Self::can_cast(syntax.kind()) { | ||
855 | Some(Self { syntax }) | ||
856 | } else { | ||
857 | None | ||
858 | } | ||
859 | } | ||
860 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
861 | } | ||
862 | impl ast::AttrsOwner for LoopExpr {} | ||
863 | impl ast::LoopBodyOwner for LoopExpr {} | ||
864 | impl LoopExpr { | ||
865 | pub fn loop_kw(&self) -> Option<LoopKw> { support::token(&self.syntax) } | ||
866 | } | ||
867 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
868 | pub struct TryBlockExpr { | ||
869 | pub(crate) syntax: SyntaxNode, | ||
870 | } | ||
871 | impl AstNode for TryBlockExpr { | ||
872 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_BLOCK_EXPR } | ||
873 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
874 | if Self::can_cast(syntax.kind()) { | ||
875 | Some(Self { syntax }) | ||
876 | } else { | ||
877 | None | ||
878 | } | ||
879 | } | ||
880 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
881 | } | ||
882 | impl ast::AttrsOwner for TryBlockExpr {} | ||
883 | impl TryBlockExpr { | ||
884 | pub fn try_kw(&self) -> Option<TryKw> { support::token(&self.syntax) } | ||
885 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
886 | } | ||
887 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
888 | pub struct ForExpr { | ||
889 | pub(crate) syntax: SyntaxNode, | ||
890 | } | ||
891 | impl AstNode for ForExpr { | ||
892 | fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_EXPR } | ||
893 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
894 | if Self::can_cast(syntax.kind()) { | ||
895 | Some(Self { syntax }) | ||
896 | } else { | ||
897 | None | ||
898 | } | ||
899 | } | ||
900 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
901 | } | ||
902 | impl ast::AttrsOwner for ForExpr {} | ||
903 | impl ast::LoopBodyOwner for ForExpr {} | ||
904 | impl ForExpr { | ||
905 | pub fn for_kw(&self) -> Option<ForKw> { support::token(&self.syntax) } | ||
906 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
907 | pub fn in_kw(&self) -> Option<InKw> { support::token(&self.syntax) } | ||
908 | pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
909 | } | ||
910 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
911 | pub struct WhileExpr { | ||
912 | pub(crate) syntax: SyntaxNode, | ||
913 | } | ||
914 | impl AstNode for WhileExpr { | ||
915 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_EXPR } | ||
916 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
917 | if Self::can_cast(syntax.kind()) { | ||
918 | Some(Self { syntax }) | ||
919 | } else { | ||
920 | None | ||
921 | } | ||
922 | } | ||
923 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
924 | } | ||
925 | impl ast::AttrsOwner for WhileExpr {} | ||
926 | impl ast::LoopBodyOwner for WhileExpr {} | ||
927 | impl WhileExpr { | ||
928 | pub fn while_kw(&self) -> Option<WhileKw> { support::token(&self.syntax) } | ||
929 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | ||
930 | } | ||
931 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
932 | pub struct ContinueExpr { | ||
933 | pub(crate) syntax: SyntaxNode, | ||
934 | } | ||
935 | impl AstNode for ContinueExpr { | ||
936 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_EXPR } | ||
937 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
938 | if Self::can_cast(syntax.kind()) { | ||
939 | Some(Self { syntax }) | ||
940 | } else { | ||
941 | None | ||
942 | } | ||
943 | } | ||
944 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
945 | } | ||
946 | impl ast::AttrsOwner for ContinueExpr {} | ||
947 | impl ContinueExpr { | ||
948 | pub fn continue_kw(&self) -> Option<ContinueKw> { support::token(&self.syntax) } | ||
949 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
950 | } | ||
951 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
952 | pub struct BreakExpr { | ||
953 | pub(crate) syntax: SyntaxNode, | ||
954 | } | ||
955 | impl AstNode for BreakExpr { | ||
956 | fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_EXPR } | ||
957 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
958 | if Self::can_cast(syntax.kind()) { | ||
959 | Some(Self { syntax }) | ||
960 | } else { | ||
961 | None | ||
962 | } | ||
963 | } | ||
964 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
965 | } | ||
966 | impl ast::AttrsOwner for BreakExpr {} | ||
967 | impl BreakExpr { | ||
968 | pub fn break_kw(&self) -> Option<BreakKw> { support::token(&self.syntax) } | ||
969 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
970 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
971 | } | ||
972 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
973 | pub struct Label { | ||
974 | pub(crate) syntax: SyntaxNode, | ||
975 | } | ||
976 | impl AstNode for Label { | ||
977 | fn can_cast(kind: SyntaxKind) -> bool { kind == LABEL } | ||
978 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
979 | if Self::can_cast(syntax.kind()) { | ||
980 | Some(Self { syntax }) | ||
981 | } else { | ||
982 | None | ||
983 | } | ||
984 | } | ||
985 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
986 | } | ||
987 | impl Label { | ||
988 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
989 | } | ||
990 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
991 | pub struct BlockExpr { | ||
992 | pub(crate) syntax: SyntaxNode, | ||
993 | } | ||
994 | impl AstNode for BlockExpr { | ||
995 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK_EXPR } | ||
996 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
997 | if Self::can_cast(syntax.kind()) { | ||
998 | Some(Self { syntax }) | ||
999 | } else { | ||
1000 | None | ||
1001 | } | ||
1002 | } | ||
1003 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1004 | } | ||
1005 | impl ast::AttrsOwner for BlockExpr {} | ||
1006 | impl BlockExpr { | ||
1007 | pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } | ||
1008 | pub fn unsafe_kw(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | ||
1009 | pub fn block(&self) -> Option<Block> { support::child(&self.syntax) } | ||
1010 | } | ||
1011 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1012 | pub struct ReturnExpr { | ||
1013 | pub(crate) syntax: SyntaxNode, | ||
1014 | } | ||
1015 | impl AstNode for ReturnExpr { | ||
1016 | fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_EXPR } | ||
1017 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1018 | if Self::can_cast(syntax.kind()) { | ||
1019 | Some(Self { syntax }) | ||
1020 | } else { | ||
1021 | None | ||
1022 | } | ||
1023 | } | ||
1024 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1025 | } | ||
1026 | impl ast::AttrsOwner for ReturnExpr {} | ||
1027 | impl ReturnExpr { | ||
1028 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1029 | } | ||
1030 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1031 | pub struct CallExpr { | ||
1032 | pub(crate) syntax: SyntaxNode, | ||
1033 | } | ||
1034 | impl AstNode for CallExpr { | ||
1035 | fn can_cast(kind: SyntaxKind) -> bool { kind == CALL_EXPR } | ||
1036 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1037 | if Self::can_cast(syntax.kind()) { | ||
1038 | Some(Self { syntax }) | ||
1039 | } else { | ||
1040 | None | ||
1041 | } | ||
1042 | } | ||
1043 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1044 | } | ||
1045 | impl ast::ArgListOwner for CallExpr {} | ||
1046 | impl CallExpr { | ||
1047 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1048 | } | ||
1049 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1050 | pub struct MethodCallExpr { | ||
1051 | pub(crate) syntax: SyntaxNode, | ||
1052 | } | ||
1053 | impl AstNode for MethodCallExpr { | ||
1054 | fn can_cast(kind: SyntaxKind) -> bool { kind == METHOD_CALL_EXPR } | ||
1055 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1056 | if Self::can_cast(syntax.kind()) { | ||
1057 | Some(Self { syntax }) | ||
1058 | } else { | ||
1059 | None | ||
1060 | } | ||
1061 | } | ||
1062 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1063 | } | ||
1064 | impl ast::AttrsOwner for MethodCallExpr {} | ||
1065 | impl ast::ArgListOwner for MethodCallExpr {} | ||
1066 | impl MethodCallExpr { | ||
1067 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1068 | pub fn dot(&self) -> Option<Dot> { support::token(&self.syntax) } | ||
1069 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1070 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | ||
1071 | } | ||
1072 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1073 | pub struct IndexExpr { | ||
1074 | pub(crate) syntax: SyntaxNode, | ||
1075 | } | ||
1076 | impl AstNode for IndexExpr { | ||
1077 | fn can_cast(kind: SyntaxKind) -> bool { kind == INDEX_EXPR } | ||
1078 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1079 | if Self::can_cast(syntax.kind()) { | ||
1080 | Some(Self { syntax }) | ||
1081 | } else { | ||
1082 | None | ||
1083 | } | ||
1084 | } | ||
1085 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1086 | } | ||
1087 | impl ast::AttrsOwner for IndexExpr {} | ||
1088 | impl IndexExpr { | ||
1089 | pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } | ||
1090 | pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } | ||
1091 | } | ||
1092 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1093 | pub struct FieldExpr { | ||
1094 | pub(crate) syntax: SyntaxNode, | ||
1095 | } | ||
1096 | impl AstNode for FieldExpr { | ||
1097 | fn can_cast(kind: SyntaxKind) -> bool { kind == FIELD_EXPR } | ||
1098 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1099 | if Self::can_cast(syntax.kind()) { | ||
1100 | Some(Self { syntax }) | ||
1101 | } else { | ||
1102 | None | ||
1103 | } | ||
1104 | } | ||
1105 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1106 | } | ||
1107 | impl ast::AttrsOwner for FieldExpr {} | ||
1108 | impl FieldExpr { | ||
1109 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1110 | pub fn dot(&self) -> Option<Dot> { support::token(&self.syntax) } | ||
1111 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1112 | } | ||
1113 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1114 | pub struct AwaitExpr { | ||
1115 | pub(crate) syntax: SyntaxNode, | ||
1116 | } | ||
1117 | impl AstNode for AwaitExpr { | ||
1118 | fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_EXPR } | ||
1119 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1120 | if Self::can_cast(syntax.kind()) { | ||
1121 | Some(Self { syntax }) | ||
1122 | } else { | ||
1123 | None | ||
1124 | } | ||
1125 | } | ||
1126 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1127 | } | ||
1128 | impl ast::AttrsOwner for AwaitExpr {} | ||
1129 | impl AwaitExpr { | ||
1130 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1131 | pub fn dot(&self) -> Option<Dot> { support::token(&self.syntax) } | ||
1132 | pub fn await_kw(&self) -> Option<AwaitKw> { support::token(&self.syntax) } | ||
1133 | } | ||
1134 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1135 | pub struct TryExpr { | ||
1136 | pub(crate) syntax: SyntaxNode, | ||
1137 | } | ||
1138 | impl AstNode for TryExpr { | ||
1139 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_EXPR } | ||
1140 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1141 | if Self::can_cast(syntax.kind()) { | ||
1142 | Some(Self { syntax }) | ||
1143 | } else { | ||
1144 | None | ||
1145 | } | ||
1146 | } | ||
1147 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1148 | } | ||
1149 | impl ast::AttrsOwner for TryExpr {} | ||
1150 | impl TryExpr { | ||
1151 | pub fn try_kw(&self) -> Option<TryKw> { support::token(&self.syntax) } | ||
1152 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1153 | } | ||
1154 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1155 | pub struct CastExpr { | ||
1156 | pub(crate) syntax: SyntaxNode, | ||
1157 | } | ||
1158 | impl AstNode for CastExpr { | ||
1159 | fn can_cast(kind: SyntaxKind) -> bool { kind == CAST_EXPR } | ||
1160 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1161 | if Self::can_cast(syntax.kind()) { | ||
1162 | Some(Self { syntax }) | ||
1163 | } else { | ||
1164 | None | ||
1165 | } | ||
1166 | } | ||
1167 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1168 | } | ||
1169 | impl ast::AttrsOwner for CastExpr {} | ||
1170 | impl CastExpr { | ||
1171 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1172 | pub fn as_kw(&self) -> Option<AsKw> { support::token(&self.syntax) } | ||
1173 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
1174 | } | ||
1175 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1176 | pub struct RefExpr { | ||
1177 | pub(crate) syntax: SyntaxNode, | ||
1178 | } | ||
1179 | impl AstNode for RefExpr { | ||
1180 | fn can_cast(kind: SyntaxKind) -> bool { kind == REF_EXPR } | ||
1181 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1182 | if Self::can_cast(syntax.kind()) { | ||
1183 | Some(Self { syntax }) | ||
1184 | } else { | ||
1185 | None | ||
1186 | } | ||
1187 | } | ||
1188 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1189 | } | ||
1190 | impl ast::AttrsOwner for RefExpr {} | ||
1191 | impl RefExpr { | ||
1192 | pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } | ||
1193 | pub fn raw_kw(&self) -> Option<RawKw> { support::token(&self.syntax) } | ||
1194 | pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } | ||
1195 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1196 | } | ||
1197 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1198 | pub struct PrefixExpr { | ||
1199 | pub(crate) syntax: SyntaxNode, | ||
1200 | } | ||
1201 | impl AstNode for PrefixExpr { | ||
1202 | fn can_cast(kind: SyntaxKind) -> bool { kind == PREFIX_EXPR } | ||
1203 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1204 | if Self::can_cast(syntax.kind()) { | ||
1205 | Some(Self { syntax }) | ||
1206 | } else { | ||
1207 | None | ||
1208 | } | ||
1209 | } | ||
1210 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1211 | } | ||
1212 | impl ast::AttrsOwner for PrefixExpr {} | ||
1213 | impl PrefixExpr { | ||
1214 | pub fn prefix_op(&self) -> Option<PrefixOp> { support::token(&self.syntax) } | ||
1215 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1216 | } | ||
1217 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1218 | pub struct BoxExpr { | ||
1219 | pub(crate) syntax: SyntaxNode, | ||
1220 | } | ||
1221 | impl AstNode for BoxExpr { | ||
1222 | fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_EXPR } | ||
1223 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1224 | if Self::can_cast(syntax.kind()) { | ||
1225 | Some(Self { syntax }) | ||
1226 | } else { | ||
1227 | None | ||
1228 | } | ||
1229 | } | ||
1230 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1231 | } | ||
1232 | impl ast::AttrsOwner for BoxExpr {} | ||
1233 | impl BoxExpr { | ||
1234 | pub fn box_kw(&self) -> Option<BoxKw> { support::token(&self.syntax) } | ||
1235 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1236 | } | ||
1237 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1238 | pub struct RangeExpr { | ||
1239 | pub(crate) syntax: SyntaxNode, | ||
1240 | } | ||
1241 | impl AstNode for RangeExpr { | ||
1242 | fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_EXPR } | ||
1243 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1244 | if Self::can_cast(syntax.kind()) { | ||
1245 | Some(Self { syntax }) | ||
1246 | } else { | ||
1247 | None | ||
1248 | } | ||
1249 | } | ||
1250 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1251 | } | ||
1252 | impl ast::AttrsOwner for RangeExpr {} | ||
1253 | impl RangeExpr { | ||
1254 | pub fn range_op(&self) -> Option<RangeOp> { support::token(&self.syntax) } | ||
1255 | } | ||
1256 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1257 | pub struct BinExpr { | ||
1258 | pub(crate) syntax: SyntaxNode, | ||
1259 | } | ||
1260 | impl AstNode for BinExpr { | ||
1261 | fn can_cast(kind: SyntaxKind) -> bool { kind == BIN_EXPR } | ||
1262 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1263 | if Self::can_cast(syntax.kind()) { | ||
1264 | Some(Self { syntax }) | ||
1265 | } else { | ||
1266 | None | ||
1267 | } | ||
1268 | } | ||
1269 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1270 | } | ||
1271 | impl ast::AttrsOwner for BinExpr {} | ||
1272 | impl BinExpr { | ||
1273 | pub fn bin_op(&self) -> Option<BinOp> { support::token(&self.syntax) } | ||
1274 | } | ||
1275 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1276 | pub struct Literal { | ||
1277 | pub(crate) syntax: SyntaxNode, | ||
1278 | } | ||
1279 | impl AstNode for Literal { | ||
1280 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL } | ||
1281 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1282 | if Self::can_cast(syntax.kind()) { | ||
1283 | Some(Self { syntax }) | ||
1284 | } else { | ||
1285 | None | ||
1286 | } | ||
1287 | } | ||
1288 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1289 | } | ||
1290 | impl Literal { | ||
1291 | pub fn literal_token(&self) -> Option<LiteralToken> { support::token(&self.syntax) } | ||
1292 | } | ||
1293 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1294 | pub struct MatchExpr { | ||
1295 | pub(crate) syntax: SyntaxNode, | ||
1296 | } | ||
1297 | impl AstNode for MatchExpr { | ||
1298 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_EXPR } | ||
1299 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1300 | if Self::can_cast(syntax.kind()) { | ||
1301 | Some(Self { syntax }) | ||
1302 | } else { | ||
1303 | None | ||
1304 | } | ||
1305 | } | ||
1306 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1307 | } | ||
1308 | impl ast::AttrsOwner for MatchExpr {} | ||
1309 | impl MatchExpr { | ||
1310 | pub fn match_kw(&self) -> Option<MatchKw> { support::token(&self.syntax) } | ||
1311 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1312 | pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } | ||
1313 | } | ||
1314 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1315 | pub struct MatchArmList { | ||
1316 | pub(crate) syntax: SyntaxNode, | ||
1317 | } | ||
1318 | impl AstNode for MatchArmList { | ||
1319 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM_LIST } | ||
1320 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1321 | if Self::can_cast(syntax.kind()) { | ||
1322 | Some(Self { syntax }) | ||
1323 | } else { | ||
1324 | None | ||
1325 | } | ||
1326 | } | ||
1327 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1328 | } | ||
1329 | impl ast::AttrsOwner for MatchArmList {} | ||
1330 | impl MatchArmList { | ||
1331 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
1332 | pub fn arms(&self) -> AstChildren<MatchArm> { support::children(&self.syntax) } | ||
1333 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
1334 | } | ||
1335 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1336 | pub struct MatchArm { | ||
1337 | pub(crate) syntax: SyntaxNode, | ||
1338 | } | ||
1339 | impl AstNode for MatchArm { | ||
1340 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_ARM } | ||
1341 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1342 | if Self::can_cast(syntax.kind()) { | ||
1343 | Some(Self { syntax }) | ||
1344 | } else { | ||
1345 | None | ||
1346 | } | ||
1347 | } | ||
1348 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1349 | } | ||
1350 | impl ast::AttrsOwner for MatchArm {} | ||
1351 | impl MatchArm { | ||
1352 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1353 | pub fn guard(&self) -> Option<MatchGuard> { support::child(&self.syntax) } | ||
1354 | pub fn fat_arrow(&self) -> Option<FatArrow> { support::token(&self.syntax) } | ||
1355 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1356 | } | ||
1357 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1358 | pub struct MatchGuard { | ||
1359 | pub(crate) syntax: SyntaxNode, | ||
1360 | } | ||
1361 | impl AstNode for MatchGuard { | ||
1362 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_GUARD } | ||
1363 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1364 | if Self::can_cast(syntax.kind()) { | ||
1365 | Some(Self { syntax }) | ||
1366 | } else { | ||
1367 | None | ||
1368 | } | ||
1369 | } | ||
1370 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1371 | } | ||
1372 | impl MatchGuard { | ||
1373 | pub fn if_kw(&self) -> Option<IfKw> { support::token(&self.syntax) } | ||
1374 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1375 | } | ||
1376 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1377 | pub struct RecordLit { | ||
1378 | pub(crate) syntax: SyntaxNode, | ||
1379 | } | ||
1380 | impl AstNode for RecordLit { | ||
1381 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_LIT } | ||
1382 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1383 | if Self::can_cast(syntax.kind()) { | ||
1384 | Some(Self { syntax }) | ||
1385 | } else { | ||
1386 | None | ||
1387 | } | ||
1388 | } | ||
1389 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1390 | } | ||
1391 | impl RecordLit { | ||
1392 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1393 | pub fn record_field_list(&self) -> Option<RecordFieldList> { support::child(&self.syntax) } | ||
1394 | } | ||
1395 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1396 | pub struct RecordFieldList { | ||
1397 | pub(crate) syntax: SyntaxNode, | ||
1398 | } | ||
1399 | impl AstNode for RecordFieldList { | ||
1400 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_LIST } | ||
1401 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1402 | if Self::can_cast(syntax.kind()) { | ||
1403 | Some(Self { syntax }) | ||
1404 | } else { | ||
1405 | None | ||
1406 | } | ||
1407 | } | ||
1408 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1409 | } | ||
1410 | impl RecordFieldList { | ||
1411 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
1412 | pub fn fields(&self) -> AstChildren<RecordField> { support::children(&self.syntax) } | ||
1413 | pub fn dotdot(&self) -> Option<Dotdot> { support::token(&self.syntax) } | ||
1414 | pub fn spread(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1415 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
1416 | } | ||
1417 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1418 | pub struct RecordField { | ||
1419 | pub(crate) syntax: SyntaxNode, | ||
1420 | } | ||
1421 | impl AstNode for RecordField { | ||
1422 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD } | ||
1423 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1424 | if Self::can_cast(syntax.kind()) { | ||
1425 | Some(Self { syntax }) | ||
1426 | } else { | ||
1427 | None | ||
1428 | } | ||
1429 | } | ||
1430 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1431 | } | ||
1432 | impl ast::AttrsOwner for RecordField {} | ||
1433 | impl RecordField { | ||
1434 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
1435 | pub fn colon(&self) -> Option<Colon> { support::token(&self.syntax) } | ||
1436 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1437 | } | ||
1438 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1439 | pub struct OrPat { | ||
1440 | pub(crate) syntax: SyntaxNode, | ||
1441 | } | ||
1442 | impl AstNode for OrPat { | ||
1443 | fn can_cast(kind: SyntaxKind) -> bool { kind == OR_PAT } | ||
1444 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1445 | if Self::can_cast(syntax.kind()) { | ||
1446 | Some(Self { syntax }) | ||
1447 | } else { | ||
1448 | None | ||
1449 | } | ||
1450 | } | ||
1451 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1452 | } | ||
1453 | impl OrPat { | ||
1454 | pub fn pats(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | ||
1455 | } | ||
1456 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1457 | pub struct ParenPat { | ||
1458 | pub(crate) syntax: SyntaxNode, | ||
1459 | } | ||
1460 | impl AstNode for ParenPat { | ||
1461 | fn can_cast(kind: SyntaxKind) -> bool { kind == PAREN_PAT } | ||
1462 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1463 | if Self::can_cast(syntax.kind()) { | ||
1464 | Some(Self { syntax }) | ||
1465 | } else { | ||
1466 | None | ||
1467 | } | ||
1468 | } | ||
1469 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1470 | } | ||
1471 | impl ParenPat { | ||
1472 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
1473 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1474 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
1475 | } | ||
1476 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1477 | pub struct RefPat { | ||
1478 | pub(crate) syntax: SyntaxNode, | ||
1479 | } | ||
1480 | impl AstNode for RefPat { | ||
1481 | fn can_cast(kind: SyntaxKind) -> bool { kind == REF_PAT } | ||
1482 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1483 | if Self::can_cast(syntax.kind()) { | ||
1484 | Some(Self { syntax }) | ||
1485 | } else { | ||
1486 | None | ||
1487 | } | ||
1488 | } | ||
1489 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1490 | } | ||
1491 | impl RefPat { | ||
1492 | pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } | ||
1493 | pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } | ||
1494 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1495 | } | ||
1496 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1497 | pub struct BoxPat { | ||
1498 | pub(crate) syntax: SyntaxNode, | ||
1499 | } | ||
1500 | impl AstNode for BoxPat { | ||
1501 | fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_PAT } | ||
1502 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1503 | if Self::can_cast(syntax.kind()) { | ||
1504 | Some(Self { syntax }) | ||
1505 | } else { | ||
1506 | None | ||
1507 | } | ||
1508 | } | ||
1509 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1510 | } | ||
1511 | impl BoxPat { | ||
1512 | pub fn box_kw(&self) -> Option<BoxKw> { support::token(&self.syntax) } | ||
1513 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1514 | } | ||
1515 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1516 | pub struct BindPat { | ||
1517 | pub(crate) syntax: SyntaxNode, | ||
1518 | } | ||
1519 | impl AstNode for BindPat { | ||
1520 | fn can_cast(kind: SyntaxKind) -> bool { kind == BIND_PAT } | ||
1521 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1522 | if Self::can_cast(syntax.kind()) { | ||
1523 | Some(Self { syntax }) | ||
1524 | } else { | ||
1525 | None | ||
1526 | } | ||
1527 | } | ||
1528 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1529 | } | ||
1530 | impl ast::AttrsOwner for BindPat {} | ||
1531 | impl ast::NameOwner for BindPat {} | ||
1532 | impl BindPat { | ||
1533 | pub fn ref_kw(&self) -> Option<RefKw> { support::token(&self.syntax) } | ||
1534 | pub fn mut_kw(&self) -> Option<MutKw> { support::token(&self.syntax) } | ||
1535 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1536 | } | ||
1537 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1538 | pub struct PlaceholderPat { | ||
1539 | pub(crate) syntax: SyntaxNode, | ||
1540 | } | ||
1541 | impl AstNode for PlaceholderPat { | ||
1542 | fn can_cast(kind: SyntaxKind) -> bool { kind == PLACEHOLDER_PAT } | ||
1543 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1544 | if Self::can_cast(syntax.kind()) { | ||
1545 | Some(Self { syntax }) | ||
1546 | } else { | ||
1547 | None | ||
1548 | } | ||
1549 | } | ||
1550 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1551 | } | ||
1552 | impl PlaceholderPat { | ||
1553 | pub fn underscore(&self) -> Option<Underscore> { support::token(&self.syntax) } | ||
1554 | } | ||
1555 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1556 | pub struct DotDotPat { | ||
1557 | pub(crate) syntax: SyntaxNode, | ||
1558 | } | ||
1559 | impl AstNode for DotDotPat { | ||
1560 | fn can_cast(kind: SyntaxKind) -> bool { kind == DOT_DOT_PAT } | ||
1561 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1562 | if Self::can_cast(syntax.kind()) { | ||
1563 | Some(Self { syntax }) | ||
1564 | } else { | ||
1565 | None | ||
1566 | } | ||
1567 | } | ||
1568 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1569 | } | ||
1570 | impl DotDotPat { | ||
1571 | pub fn dotdot(&self) -> Option<Dotdot> { support::token(&self.syntax) } | ||
1572 | } | ||
1573 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1574 | pub struct PathPat { | ||
1575 | pub(crate) syntax: SyntaxNode, | ||
1576 | } | ||
1577 | impl AstNode for PathPat { | ||
1578 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_PAT } | ||
1579 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1580 | if Self::can_cast(syntax.kind()) { | ||
1581 | Some(Self { syntax }) | ||
1582 | } else { | ||
1583 | None | ||
1584 | } | ||
1585 | } | ||
1586 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1587 | } | ||
1588 | impl PathPat { | ||
1589 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1590 | } | ||
1591 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1592 | pub struct SlicePat { | ||
1593 | pub(crate) syntax: SyntaxNode, | ||
1594 | } | ||
1595 | impl AstNode for SlicePat { | ||
1596 | fn can_cast(kind: SyntaxKind) -> bool { kind == SLICE_PAT } | ||
1597 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1598 | if Self::can_cast(syntax.kind()) { | ||
1599 | Some(Self { syntax }) | ||
1600 | } else { | ||
1601 | None | ||
1602 | } | ||
1603 | } | ||
1604 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1605 | } | ||
1606 | impl SlicePat { | ||
1607 | pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } | ||
1608 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | ||
1609 | pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } | ||
1610 | } | ||
1611 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1612 | pub struct RangePat { | ||
1613 | pub(crate) syntax: SyntaxNode, | ||
1614 | } | ||
1615 | impl AstNode for RangePat { | ||
1616 | fn can_cast(kind: SyntaxKind) -> bool { kind == RANGE_PAT } | ||
1617 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1618 | if Self::can_cast(syntax.kind()) { | ||
1619 | Some(Self { syntax }) | ||
1620 | } else { | ||
1621 | None | ||
1622 | } | ||
1623 | } | ||
1624 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1625 | } | ||
1626 | impl RangePat { | ||
1627 | pub fn range_separator(&self) -> Option<RangeSeparator> { support::token(&self.syntax) } | ||
1628 | } | ||
1629 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1630 | pub struct LiteralPat { | ||
1631 | pub(crate) syntax: SyntaxNode, | ||
1632 | } | ||
1633 | impl AstNode for LiteralPat { | ||
1634 | fn can_cast(kind: SyntaxKind) -> bool { kind == LITERAL_PAT } | ||
1635 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1636 | if Self::can_cast(syntax.kind()) { | ||
1637 | Some(Self { syntax }) | ||
1638 | } else { | ||
1639 | None | ||
1640 | } | ||
1641 | } | ||
1642 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1643 | } | ||
1644 | impl LiteralPat { | ||
1645 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | ||
1646 | } | ||
1647 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1648 | pub struct MacroPat { | ||
1649 | pub(crate) syntax: SyntaxNode, | ||
1650 | } | ||
1651 | impl AstNode for MacroPat { | ||
1652 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_PAT } | ||
1653 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1654 | if Self::can_cast(syntax.kind()) { | ||
1655 | Some(Self { syntax }) | ||
1656 | } else { | ||
1657 | None | ||
1658 | } | ||
1659 | } | ||
1660 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1661 | } | ||
1662 | impl MacroPat { | ||
1663 | pub fn macro_call(&self) -> Option<MacroCall> { support::child(&self.syntax) } | ||
1664 | } | ||
1665 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1666 | pub struct RecordPat { | ||
1667 | pub(crate) syntax: SyntaxNode, | ||
1668 | } | ||
1669 | impl AstNode for RecordPat { | ||
1670 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_PAT } | ||
1671 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1672 | if Self::can_cast(syntax.kind()) { | ||
1673 | Some(Self { syntax }) | ||
1674 | } else { | ||
1675 | None | ||
1676 | } | ||
1677 | } | ||
1678 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1679 | } | ||
1680 | impl RecordPat { | ||
1681 | pub fn record_field_pat_list(&self) -> Option<RecordFieldPatList> { | ||
1682 | support::child(&self.syntax) | ||
1683 | } | ||
1684 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1685 | } | ||
1686 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1687 | pub struct RecordFieldPatList { | ||
1688 | pub(crate) syntax: SyntaxNode, | ||
1689 | } | ||
1690 | impl AstNode for RecordFieldPatList { | ||
1691 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT_LIST } | ||
1692 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1693 | if Self::can_cast(syntax.kind()) { | ||
1694 | Some(Self { syntax }) | ||
1695 | } else { | ||
1696 | None | ||
1697 | } | ||
1698 | } | ||
1699 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1700 | } | ||
1701 | impl RecordFieldPatList { | ||
1702 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
1703 | pub fn pats(&self) -> AstChildren<RecordInnerPat> { support::children(&self.syntax) } | ||
1704 | pub fn record_field_pats(&self) -> AstChildren<RecordFieldPat> { | ||
1705 | support::children(&self.syntax) | ||
1706 | } | ||
1707 | pub fn bind_pats(&self) -> AstChildren<BindPat> { support::children(&self.syntax) } | ||
1708 | pub fn dotdot(&self) -> Option<Dotdot> { support::token(&self.syntax) } | ||
1709 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
1710 | } | ||
1711 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1712 | pub struct RecordFieldPat { | ||
1713 | pub(crate) syntax: SyntaxNode, | ||
1714 | } | ||
1715 | impl AstNode for RecordFieldPat { | ||
1716 | fn can_cast(kind: SyntaxKind) -> bool { kind == RECORD_FIELD_PAT } | ||
1717 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1718 | if Self::can_cast(syntax.kind()) { | ||
1719 | Some(Self { syntax }) | ||
1720 | } else { | ||
1721 | None | ||
1722 | } | ||
1723 | } | ||
1724 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1725 | } | ||
1726 | impl ast::AttrsOwner for RecordFieldPat {} | ||
1727 | impl ast::NameOwner for RecordFieldPat {} | ||
1728 | impl RecordFieldPat { | ||
1729 | pub fn colon(&self) -> Option<Colon> { support::token(&self.syntax) } | ||
1730 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
1731 | } | ||
1732 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1733 | pub struct TupleStructPat { | ||
1734 | pub(crate) syntax: SyntaxNode, | ||
1735 | } | ||
1736 | impl AstNode for TupleStructPat { | ||
1737 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_STRUCT_PAT } | ||
1738 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1739 | if Self::can_cast(syntax.kind()) { | ||
1740 | Some(Self { syntax }) | ||
1741 | } else { | ||
1742 | None | ||
1743 | } | ||
1744 | } | ||
1745 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1746 | } | ||
1747 | impl TupleStructPat { | ||
1748 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1749 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
1750 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | ||
1751 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
1752 | } | ||
1753 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1754 | pub struct TuplePat { | ||
1755 | pub(crate) syntax: SyntaxNode, | ||
1756 | } | ||
1757 | impl AstNode for TuplePat { | ||
1758 | fn can_cast(kind: SyntaxKind) -> bool { kind == TUPLE_PAT } | ||
1759 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1760 | if Self::can_cast(syntax.kind()) { | ||
1761 | Some(Self { syntax }) | ||
1762 | } else { | ||
1763 | None | ||
1764 | } | ||
1765 | } | ||
1766 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1767 | } | ||
1768 | impl TuplePat { | ||
1769 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
1770 | pub fn args(&self) -> AstChildren<Pat> { support::children(&self.syntax) } | ||
1771 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
1772 | } | ||
1773 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1774 | pub struct Visibility { | ||
1775 | pub(crate) syntax: SyntaxNode, | ||
1776 | } | ||
1777 | impl AstNode for Visibility { | ||
1778 | fn can_cast(kind: SyntaxKind) -> bool { kind == VISIBILITY } | ||
1779 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1780 | if Self::can_cast(syntax.kind()) { | ||
1781 | Some(Self { syntax }) | ||
1782 | } else { | ||
1783 | None | ||
1784 | } | ||
1785 | } | ||
1786 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1787 | } | ||
1788 | impl Visibility { | ||
1789 | pub fn pub_kw(&self) -> Option<PubKw> { support::token(&self.syntax) } | ||
1790 | pub fn super_kw(&self) -> Option<SuperKw> { support::token(&self.syntax) } | ||
1791 | pub fn self_kw(&self) -> Option<SelfKw> { support::token(&self.syntax) } | ||
1792 | pub fn crate_kw(&self) -> Option<CrateKw> { support::token(&self.syntax) } | ||
1793 | } | ||
1794 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1795 | pub struct Name { | ||
1796 | pub(crate) syntax: SyntaxNode, | ||
1797 | } | ||
1798 | impl AstNode for Name { | ||
1799 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME } | ||
1800 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1801 | if Self::can_cast(syntax.kind()) { | ||
1802 | Some(Self { syntax }) | ||
1803 | } else { | ||
1804 | None | ||
1805 | } | ||
1806 | } | ||
1807 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1808 | } | ||
1809 | impl Name { | ||
1810 | pub fn ident(&self) -> Option<Ident> { support::token(&self.syntax) } | ||
1811 | } | ||
1812 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1813 | pub struct NameRef { | ||
1814 | pub(crate) syntax: SyntaxNode, | ||
1815 | } | ||
1816 | impl AstNode for NameRef { | ||
1817 | fn can_cast(kind: SyntaxKind) -> bool { kind == NAME_REF } | ||
1818 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1819 | if Self::can_cast(syntax.kind()) { | ||
1820 | Some(Self { syntax }) | ||
1821 | } else { | ||
1822 | None | ||
1823 | } | ||
1824 | } | ||
1825 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1826 | } | ||
1827 | impl NameRef { | ||
1828 | pub fn name_ref_token(&self) -> Option<NameRefToken> { support::token(&self.syntax) } | ||
1829 | } | ||
1830 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1831 | pub struct MacroCall { | ||
1832 | pub(crate) syntax: SyntaxNode, | ||
1833 | } | ||
1834 | impl AstNode for MacroCall { | ||
1835 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_CALL } | ||
1836 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1837 | if Self::can_cast(syntax.kind()) { | ||
1838 | Some(Self { syntax }) | ||
1839 | } else { | ||
1840 | None | ||
1841 | } | ||
1842 | } | ||
1843 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1844 | } | ||
1845 | impl ast::NameOwner for MacroCall {} | ||
1846 | impl ast::AttrsOwner for MacroCall {} | ||
1847 | impl ast::DocCommentsOwner for MacroCall {} | ||
1848 | impl MacroCall { | ||
1849 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1850 | pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } | ||
1851 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | ||
1852 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
1853 | } | ||
1854 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1855 | pub struct Attr { | ||
1856 | pub(crate) syntax: SyntaxNode, | ||
1857 | } | ||
1858 | impl AstNode for Attr { | ||
1859 | fn can_cast(kind: SyntaxKind) -> bool { kind == ATTR } | ||
1860 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1861 | if Self::can_cast(syntax.kind()) { | ||
1862 | Some(Self { syntax }) | ||
1863 | } else { | ||
1864 | None | ||
1865 | } | ||
1866 | } | ||
1867 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1868 | } | ||
1869 | impl Attr { | ||
1870 | pub fn pound(&self) -> Option<Pound> { support::token(&self.syntax) } | ||
1871 | pub fn excl(&self) -> Option<Excl> { support::token(&self.syntax) } | ||
1872 | pub fn l_brack(&self) -> Option<LBrack> { support::token(&self.syntax) } | ||
1873 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
1874 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
1875 | pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) } | ||
1876 | pub fn r_brack(&self) -> Option<RBrack> { support::token(&self.syntax) } | ||
1877 | } | ||
1878 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1879 | pub struct TokenTree { | ||
1880 | pub(crate) syntax: SyntaxNode, | ||
1881 | } | ||
1882 | impl AstNode for TokenTree { | ||
1883 | fn can_cast(kind: SyntaxKind) -> bool { kind == TOKEN_TREE } | ||
1884 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1885 | if Self::can_cast(syntax.kind()) { | ||
1886 | Some(Self { syntax }) | ||
1887 | } else { | ||
1888 | None | ||
1889 | } | ||
1890 | } | ||
1891 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1892 | } | ||
1893 | impl TokenTree {} | ||
1894 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1895 | pub struct TypeParamList { | ||
1896 | pub(crate) syntax: SyntaxNode, | ||
1897 | } | ||
1898 | impl AstNode for TypeParamList { | ||
1899 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM_LIST } | ||
1900 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1901 | if Self::can_cast(syntax.kind()) { | ||
1902 | Some(Self { syntax }) | ||
1903 | } else { | ||
1904 | None | ||
1905 | } | ||
1906 | } | ||
1907 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1908 | } | ||
1909 | impl TypeParamList { | ||
1910 | pub fn l_angle(&self) -> Option<LAngle> { support::token(&self.syntax) } | ||
1911 | pub fn generic_params(&self) -> AstChildren<GenericParam> { support::children(&self.syntax) } | ||
1912 | pub fn type_params(&self) -> AstChildren<TypeParam> { support::children(&self.syntax) } | ||
1913 | pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> { support::children(&self.syntax) } | ||
1914 | pub fn const_params(&self) -> AstChildren<ConstParam> { support::children(&self.syntax) } | ||
1915 | pub fn r_angle(&self) -> Option<RAngle> { support::token(&self.syntax) } | ||
1916 | } | ||
1917 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1918 | pub struct TypeParam { | ||
1919 | pub(crate) syntax: SyntaxNode, | ||
1920 | } | ||
1921 | impl AstNode for TypeParam { | ||
1922 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_PARAM } | ||
1923 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1924 | if Self::can_cast(syntax.kind()) { | ||
1925 | Some(Self { syntax }) | ||
1926 | } else { | ||
1927 | None | ||
1928 | } | ||
1929 | } | ||
1930 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1931 | } | ||
1932 | impl ast::NameOwner for TypeParam {} | ||
1933 | impl ast::AttrsOwner for TypeParam {} | ||
1934 | impl ast::TypeBoundsOwner for TypeParam {} | ||
1935 | impl TypeParam { | ||
1936 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
1937 | pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
1938 | } | ||
1939 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1940 | pub struct ConstParam { | ||
1941 | pub(crate) syntax: SyntaxNode, | ||
1942 | } | ||
1943 | impl AstNode for ConstParam { | ||
1944 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_PARAM } | ||
1945 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1946 | if Self::can_cast(syntax.kind()) { | ||
1947 | Some(Self { syntax }) | ||
1948 | } else { | ||
1949 | None | ||
1950 | } | ||
1951 | } | ||
1952 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1953 | } | ||
1954 | impl ast::NameOwner for ConstParam {} | ||
1955 | impl ast::AttrsOwner for ConstParam {} | ||
1956 | impl ast::TypeAscriptionOwner for ConstParam {} | ||
1957 | impl ConstParam { | ||
1958 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
1959 | pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
1960 | } | ||
1961 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1962 | pub struct LifetimeParam { | ||
1963 | pub(crate) syntax: SyntaxNode, | ||
1964 | } | ||
1965 | impl AstNode for LifetimeParam { | ||
1966 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_PARAM } | ||
1967 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1968 | if Self::can_cast(syntax.kind()) { | ||
1969 | Some(Self { syntax }) | ||
1970 | } else { | ||
1971 | None | ||
1972 | } | ||
1973 | } | ||
1974 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1975 | } | ||
1976 | impl ast::AttrsOwner for LifetimeParam {} | ||
1977 | impl LifetimeParam { | ||
1978 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
1979 | } | ||
1980 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1981 | pub struct TypeBound { | ||
1982 | pub(crate) syntax: SyntaxNode, | ||
1983 | } | ||
1984 | impl AstNode for TypeBound { | ||
1985 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND } | ||
1986 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
1987 | if Self::can_cast(syntax.kind()) { | ||
1988 | Some(Self { syntax }) | ||
1989 | } else { | ||
1990 | None | ||
1991 | } | ||
1992 | } | ||
1993 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
1994 | } | ||
1995 | impl TypeBound { | ||
1996 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
1997 | pub fn const_kw(&self) -> Option<ConstKw> { support::token(&self.syntax) } | ||
1998 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
1999 | } | ||
2000 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2001 | pub struct TypeBoundList { | ||
2002 | pub(crate) syntax: SyntaxNode, | ||
2003 | } | ||
2004 | impl AstNode for TypeBoundList { | ||
2005 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_BOUND_LIST } | ||
2006 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2007 | if Self::can_cast(syntax.kind()) { | ||
2008 | Some(Self { syntax }) | ||
2009 | } else { | ||
2010 | None | ||
2011 | } | ||
2012 | } | ||
2013 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2014 | } | ||
2015 | impl TypeBoundList { | ||
2016 | pub fn bounds(&self) -> AstChildren<TypeBound> { support::children(&self.syntax) } | ||
2017 | } | ||
2018 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2019 | pub struct WherePred { | ||
2020 | pub(crate) syntax: SyntaxNode, | ||
2021 | } | ||
2022 | impl AstNode for WherePred { | ||
2023 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_PRED } | ||
2024 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2025 | if Self::can_cast(syntax.kind()) { | ||
2026 | Some(Self { syntax }) | ||
2027 | } else { | ||
2028 | None | ||
2029 | } | ||
2030 | } | ||
2031 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2032 | } | ||
2033 | impl ast::TypeBoundsOwner for WherePred {} | ||
2034 | impl WherePred { | ||
2035 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
2036 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
2037 | } | ||
2038 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2039 | pub struct WhereClause { | ||
2040 | pub(crate) syntax: SyntaxNode, | ||
2041 | } | ||
2042 | impl AstNode for WhereClause { | ||
2043 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_CLAUSE } | ||
2044 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2045 | if Self::can_cast(syntax.kind()) { | ||
2046 | Some(Self { syntax }) | ||
2047 | } else { | ||
2048 | None | ||
2049 | } | ||
2050 | } | ||
2051 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2052 | } | ||
2053 | impl WhereClause { | ||
2054 | pub fn where_kw(&self) -> Option<WhereKw> { support::token(&self.syntax) } | ||
2055 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } | ||
2056 | } | ||
2057 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2058 | pub struct Abi { | ||
2059 | pub(crate) syntax: SyntaxNode, | ||
2060 | } | ||
2061 | impl AstNode for Abi { | ||
2062 | fn can_cast(kind: SyntaxKind) -> bool { kind == ABI } | ||
2063 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2064 | if Self::can_cast(syntax.kind()) { | ||
2065 | Some(Self { syntax }) | ||
2066 | } else { | ||
2067 | None | ||
2068 | } | ||
2069 | } | ||
2070 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2071 | } | ||
2072 | impl Abi { | ||
2073 | pub fn string(&self) -> Option<String> { support::token(&self.syntax) } | ||
2074 | } | ||
2075 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2076 | pub struct ExprStmt { | ||
2077 | pub(crate) syntax: SyntaxNode, | ||
2078 | } | ||
2079 | impl AstNode for ExprStmt { | ||
2080 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXPR_STMT } | ||
2081 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2082 | if Self::can_cast(syntax.kind()) { | ||
2083 | Some(Self { syntax }) | ||
2084 | } else { | ||
2085 | None | ||
2086 | } | ||
2087 | } | ||
2088 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2089 | } | ||
2090 | impl ast::AttrsOwner for ExprStmt {} | ||
2091 | impl ExprStmt { | ||
2092 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
2093 | pub fn semi(&self) -> Option<Semi> { support::token(&self.syntax) } | ||
2094 | } | ||
2095 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2096 | pub struct LetStmt { | ||
2097 | pub(crate) syntax: SyntaxNode, | ||
2098 | } | ||
2099 | impl AstNode for LetStmt { | ||
2100 | fn can_cast(kind: SyntaxKind) -> bool { kind == LET_STMT } | ||
2101 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2102 | if Self::can_cast(syntax.kind()) { | ||
2103 | Some(Self { syntax }) | ||
2104 | } else { | ||
2105 | None | ||
2106 | } | ||
2107 | } | ||
2108 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2109 | } | ||
2110 | impl ast::AttrsOwner for LetStmt {} | ||
2111 | impl ast::TypeAscriptionOwner for LetStmt {} | ||
2112 | impl LetStmt { | ||
2113 | pub fn let_kw(&self) -> Option<LetKw> { support::token(&self.syntax) } | ||
2114 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
2115 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
2116 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
2117 | } | ||
2118 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2119 | pub struct Condition { | ||
2120 | pub(crate) syntax: SyntaxNode, | ||
2121 | } | ||
2122 | impl AstNode for Condition { | ||
2123 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONDITION } | ||
2124 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2125 | if Self::can_cast(syntax.kind()) { | ||
2126 | Some(Self { syntax }) | ||
2127 | } else { | ||
2128 | None | ||
2129 | } | ||
2130 | } | ||
2131 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2132 | } | ||
2133 | impl Condition { | ||
2134 | pub fn let_kw(&self) -> Option<LetKw> { support::token(&self.syntax) } | ||
2135 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
2136 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
2137 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
2138 | } | ||
2139 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2140 | pub struct Block { | ||
2141 | pub(crate) syntax: SyntaxNode, | ||
2142 | } | ||
2143 | impl AstNode for Block { | ||
2144 | fn can_cast(kind: SyntaxKind) -> bool { kind == BLOCK } | ||
2145 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2146 | if Self::can_cast(syntax.kind()) { | ||
2147 | Some(Self { syntax }) | ||
2148 | } else { | ||
2149 | None | ||
2150 | } | ||
2151 | } | ||
2152 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2153 | } | ||
2154 | impl ast::AttrsOwner for Block {} | ||
2155 | impl ast::ModuleItemOwner for Block {} | ||
2156 | impl Block { | ||
2157 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
2158 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | ||
2159 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
2160 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
2161 | } | ||
2162 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2163 | pub struct ParamList { | ||
2164 | pub(crate) syntax: SyntaxNode, | ||
2165 | } | ||
2166 | impl AstNode for ParamList { | ||
2167 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM_LIST } | ||
2168 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2169 | if Self::can_cast(syntax.kind()) { | ||
2170 | Some(Self { syntax }) | ||
2171 | } else { | ||
2172 | None | ||
2173 | } | ||
2174 | } | ||
2175 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2176 | } | ||
2177 | impl ParamList { | ||
2178 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
2179 | pub fn self_param(&self) -> Option<SelfParam> { support::child(&self.syntax) } | ||
2180 | pub fn params(&self) -> AstChildren<Param> { support::children(&self.syntax) } | ||
2181 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
2182 | } | ||
2183 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2184 | pub struct SelfParam { | ||
2185 | pub(crate) syntax: SyntaxNode, | ||
2186 | } | ||
2187 | impl AstNode for SelfParam { | ||
2188 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_PARAM } | ||
2189 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2190 | if Self::can_cast(syntax.kind()) { | ||
2191 | Some(Self { syntax }) | ||
2192 | } else { | ||
2193 | None | ||
2194 | } | ||
2195 | } | ||
2196 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2197 | } | ||
2198 | impl ast::TypeAscriptionOwner for SelfParam {} | ||
2199 | impl ast::AttrsOwner for SelfParam {} | ||
2200 | impl SelfParam { | ||
2201 | pub fn amp(&self) -> Option<Amp> { support::token(&self.syntax) } | ||
2202 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
2203 | pub fn self_kw(&self) -> Option<SelfKw> { support::token(&self.syntax) } | ||
2204 | } | ||
2205 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2206 | pub struct Param { | ||
2207 | pub(crate) syntax: SyntaxNode, | ||
2208 | } | ||
2209 | impl AstNode for Param { | ||
2210 | fn can_cast(kind: SyntaxKind) -> bool { kind == PARAM } | ||
2211 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2212 | if Self::can_cast(syntax.kind()) { | ||
2213 | Some(Self { syntax }) | ||
2214 | } else { | ||
2215 | None | ||
2216 | } | ||
2217 | } | ||
2218 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2219 | } | ||
2220 | impl ast::TypeAscriptionOwner for Param {} | ||
2221 | impl ast::AttrsOwner for Param {} | ||
2222 | impl Param { | ||
2223 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | ||
2224 | pub fn dotdotdot(&self) -> Option<Dotdotdot> { support::token(&self.syntax) } | ||
2225 | } | ||
2226 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2227 | pub struct UseItem { | ||
2228 | pub(crate) syntax: SyntaxNode, | ||
2229 | } | ||
2230 | impl AstNode for UseItem { | ||
2231 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_ITEM } | ||
2232 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2233 | if Self::can_cast(syntax.kind()) { | ||
2234 | Some(Self { syntax }) | ||
2235 | } else { | ||
2236 | None | ||
2237 | } | ||
2238 | } | ||
2239 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2240 | } | ||
2241 | impl ast::AttrsOwner for UseItem {} | ||
2242 | impl ast::VisibilityOwner for UseItem {} | ||
2243 | impl UseItem { | ||
2244 | pub fn use_kw(&self) -> Option<UseKw> { support::token(&self.syntax) } | ||
2245 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } | ||
2246 | } | ||
2247 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2248 | pub struct UseTree { | ||
2249 | pub(crate) syntax: SyntaxNode, | ||
2250 | } | ||
2251 | impl AstNode for UseTree { | ||
2252 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE } | ||
2253 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2254 | if Self::can_cast(syntax.kind()) { | ||
2255 | Some(Self { syntax }) | ||
2256 | } else { | ||
2257 | None | ||
2258 | } | ||
2259 | } | ||
2260 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2261 | } | ||
2262 | impl UseTree { | ||
2263 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
2264 | pub fn star(&self) -> Option<Star> { support::token(&self.syntax) } | ||
2265 | pub fn use_tree_list(&self) -> Option<UseTreeList> { support::child(&self.syntax) } | ||
2266 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | ||
2267 | } | ||
2268 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2269 | pub struct Alias { | ||
2270 | pub(crate) syntax: SyntaxNode, | ||
2271 | } | ||
2272 | impl AstNode for Alias { | ||
2273 | fn can_cast(kind: SyntaxKind) -> bool { kind == ALIAS } | ||
2274 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2275 | if Self::can_cast(syntax.kind()) { | ||
2276 | Some(Self { syntax }) | ||
2277 | } else { | ||
2278 | None | ||
2279 | } | ||
2280 | } | ||
2281 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2282 | } | ||
2283 | impl ast::NameOwner for Alias {} | ||
2284 | impl Alias { | ||
2285 | pub fn as_kw(&self) -> Option<AsKw> { support::token(&self.syntax) } | ||
2286 | } | ||
2287 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2288 | pub struct UseTreeList { | ||
2289 | pub(crate) syntax: SyntaxNode, | ||
2290 | } | ||
2291 | impl AstNode for UseTreeList { | ||
2292 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_TREE_LIST } | ||
2293 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2294 | if Self::can_cast(syntax.kind()) { | ||
2295 | Some(Self { syntax }) | ||
2296 | } else { | ||
2297 | None | ||
2298 | } | ||
2299 | } | ||
2300 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2301 | } | ||
2302 | impl UseTreeList { | ||
2303 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
2304 | pub fn use_trees(&self) -> AstChildren<UseTree> { support::children(&self.syntax) } | ||
2305 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
2306 | } | ||
2307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2308 | pub struct ExternCrateItem { | ||
2309 | pub(crate) syntax: SyntaxNode, | ||
2310 | } | ||
2311 | impl AstNode for ExternCrateItem { | ||
2312 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_CRATE_ITEM } | ||
2313 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2314 | if Self::can_cast(syntax.kind()) { | ||
2315 | Some(Self { syntax }) | ||
2316 | } else { | ||
2317 | None | ||
2318 | } | ||
2319 | } | ||
2320 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2321 | } | ||
2322 | impl ast::AttrsOwner for ExternCrateItem {} | ||
2323 | impl ast::VisibilityOwner for ExternCrateItem {} | ||
2324 | impl ExternCrateItem { | ||
2325 | pub fn extern_kw(&self) -> Option<ExternKw> { support::token(&self.syntax) } | ||
2326 | pub fn crate_kw(&self) -> Option<CrateKw> { support::token(&self.syntax) } | ||
2327 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
2328 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | ||
2329 | } | ||
2330 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2331 | pub struct ArgList { | ||
2332 | pub(crate) syntax: SyntaxNode, | ||
2333 | } | ||
2334 | impl AstNode for ArgList { | ||
2335 | fn can_cast(kind: SyntaxKind) -> bool { kind == ARG_LIST } | ||
2336 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2337 | if Self::can_cast(syntax.kind()) { | ||
2338 | Some(Self { syntax }) | ||
2339 | } else { | ||
2340 | None | ||
2341 | } | ||
2342 | } | ||
2343 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2344 | } | ||
2345 | impl ArgList { | ||
2346 | pub fn l_paren(&self) -> Option<LParen> { support::token(&self.syntax) } | ||
2347 | pub fn args(&self) -> AstChildren<Expr> { support::children(&self.syntax) } | ||
2348 | pub fn r_paren(&self) -> Option<RParen> { support::token(&self.syntax) } | ||
2349 | } | ||
2350 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2351 | pub struct Path { | ||
2352 | pub(crate) syntax: SyntaxNode, | ||
2353 | } | ||
2354 | impl AstNode for Path { | ||
2355 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH } | ||
2356 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2357 | if Self::can_cast(syntax.kind()) { | ||
2358 | Some(Self { syntax }) | ||
2359 | } else { | ||
2360 | None | ||
2361 | } | ||
2362 | } | ||
2363 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2364 | } | ||
2365 | impl Path { | ||
2366 | pub fn segment(&self) -> Option<PathSegment> { support::child(&self.syntax) } | ||
2367 | pub fn qualifier(&self) -> Option<Path> { support::child(&self.syntax) } | ||
2368 | } | ||
2369 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2370 | pub struct PathSegment { | ||
2371 | pub(crate) syntax: SyntaxNode, | ||
2372 | } | ||
2373 | impl AstNode for PathSegment { | ||
2374 | fn can_cast(kind: SyntaxKind) -> bool { kind == PATH_SEGMENT } | ||
2375 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2376 | if Self::can_cast(syntax.kind()) { | ||
2377 | Some(Self { syntax }) | ||
2378 | } else { | ||
2379 | None | ||
2380 | } | ||
2381 | } | ||
2382 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2383 | } | ||
2384 | impl PathSegment { | ||
2385 | pub fn coloncolon(&self) -> Option<Coloncolon> { support::token(&self.syntax) } | ||
2386 | pub fn l_angle(&self) -> Option<LAngle> { support::token(&self.syntax) } | ||
2387 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
2388 | pub fn type_arg_list(&self) -> Option<TypeArgList> { support::child(&self.syntax) } | ||
2389 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | ||
2390 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | ||
2391 | pub fn path_type(&self) -> Option<PathType> { support::child(&self.syntax) } | ||
2392 | pub fn r_angle(&self) -> Option<RAngle> { support::token(&self.syntax) } | ||
2393 | } | ||
2394 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2395 | pub struct TypeArgList { | ||
2396 | pub(crate) syntax: SyntaxNode, | ||
2397 | } | ||
2398 | impl AstNode for TypeArgList { | ||
2399 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG_LIST } | ||
2400 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2401 | if Self::can_cast(syntax.kind()) { | ||
2402 | Some(Self { syntax }) | ||
2403 | } else { | ||
2404 | None | ||
2405 | } | ||
2406 | } | ||
2407 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2408 | } | ||
2409 | impl TypeArgList { | ||
2410 | pub fn coloncolon(&self) -> Option<Coloncolon> { support::token(&self.syntax) } | ||
2411 | pub fn l_angle(&self) -> Option<LAngle> { support::token(&self.syntax) } | ||
2412 | pub fn generic_args(&self) -> AstChildren<GenericArg> { support::children(&self.syntax) } | ||
2413 | pub fn type_args(&self) -> AstChildren<TypeArg> { support::children(&self.syntax) } | ||
2414 | pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> { support::children(&self.syntax) } | ||
2415 | pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> { support::children(&self.syntax) } | ||
2416 | pub fn const_args(&self) -> AstChildren<ConstArg> { support::children(&self.syntax) } | ||
2417 | pub fn r_angle(&self) -> Option<RAngle> { support::token(&self.syntax) } | ||
2418 | } | ||
2419 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2420 | pub struct TypeArg { | ||
2421 | pub(crate) syntax: SyntaxNode, | ||
2422 | } | ||
2423 | impl AstNode for TypeArg { | ||
2424 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_ARG } | ||
2425 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2426 | if Self::can_cast(syntax.kind()) { | ||
2427 | Some(Self { syntax }) | ||
2428 | } else { | ||
2429 | None | ||
2430 | } | ||
2431 | } | ||
2432 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2433 | } | ||
2434 | impl TypeArg { | ||
2435 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
2436 | } | ||
2437 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2438 | pub struct AssocTypeArg { | ||
2439 | pub(crate) syntax: SyntaxNode, | ||
2440 | } | ||
2441 | impl AstNode for AssocTypeArg { | ||
2442 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASSOC_TYPE_ARG } | ||
2443 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2444 | if Self::can_cast(syntax.kind()) { | ||
2445 | Some(Self { syntax }) | ||
2446 | } else { | ||
2447 | None | ||
2448 | } | ||
2449 | } | ||
2450 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2451 | } | ||
2452 | impl ast::TypeBoundsOwner for AssocTypeArg {} | ||
2453 | impl AssocTypeArg { | ||
2454 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | ||
2455 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
2456 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | ||
2457 | } | ||
2458 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2459 | pub struct LifetimeArg { | ||
2460 | pub(crate) syntax: SyntaxNode, | ||
2461 | } | ||
2462 | impl AstNode for LifetimeArg { | ||
2463 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME_ARG } | ||
2464 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2465 | if Self::can_cast(syntax.kind()) { | ||
2466 | Some(Self { syntax }) | ||
2467 | } else { | ||
2468 | None | ||
2469 | } | ||
2470 | } | ||
2471 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2472 | } | ||
2473 | impl LifetimeArg { | ||
2474 | pub fn lifetime(&self) -> Option<Lifetime> { support::token(&self.syntax) } | ||
2475 | } | ||
2476 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2477 | pub struct ConstArg { | ||
2478 | pub(crate) syntax: SyntaxNode, | ||
2479 | } | ||
2480 | impl AstNode for ConstArg { | ||
2481 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_ARG } | ||
2482 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2483 | if Self::can_cast(syntax.kind()) { | ||
2484 | Some(Self { syntax }) | ||
2485 | } else { | ||
2486 | None | ||
2487 | } | ||
2488 | } | ||
2489 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2490 | } | ||
2491 | impl ConstArg { | ||
2492 | pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) } | ||
2493 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
2494 | pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | ||
2495 | } | ||
2496 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2497 | pub struct MacroItems { | ||
2498 | pub(crate) syntax: SyntaxNode, | ||
2499 | } | ||
2500 | impl AstNode for MacroItems { | ||
2501 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_ITEMS } | ||
2502 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2503 | if Self::can_cast(syntax.kind()) { | ||
2504 | Some(Self { syntax }) | ||
2505 | } else { | ||
2506 | None | ||
2507 | } | ||
2508 | } | ||
2509 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2510 | } | ||
2511 | impl ast::ModuleItemOwner for MacroItems {} | ||
2512 | impl ast::FnDefOwner for MacroItems {} | ||
2513 | impl MacroItems {} | ||
2514 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2515 | pub struct MacroStmts { | ||
2516 | pub(crate) syntax: SyntaxNode, | ||
2517 | } | ||
2518 | impl AstNode for MacroStmts { | ||
2519 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_STMTS } | ||
2520 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2521 | if Self::can_cast(syntax.kind()) { | ||
2522 | Some(Self { syntax }) | ||
2523 | } else { | ||
2524 | None | ||
2525 | } | ||
2526 | } | ||
2527 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2528 | } | ||
2529 | impl MacroStmts { | ||
2530 | pub fn statements(&self) -> AstChildren<Stmt> { support::children(&self.syntax) } | ||
2531 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | ||
2532 | } | ||
2533 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2534 | pub struct ExternItemList { | ||
2535 | pub(crate) syntax: SyntaxNode, | ||
2536 | } | ||
2537 | impl AstNode for ExternItemList { | ||
2538 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_ITEM_LIST } | ||
2539 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2540 | if Self::can_cast(syntax.kind()) { | ||
2541 | Some(Self { syntax }) | ||
2542 | } else { | ||
2543 | None | ||
2544 | } | ||
2545 | } | ||
2546 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2547 | } | ||
2548 | impl ast::FnDefOwner for ExternItemList {} | ||
2549 | impl ast::ModuleItemOwner for ExternItemList {} | ||
2550 | impl ExternItemList { | ||
2551 | pub fn l_curly(&self) -> Option<LCurly> { support::token(&self.syntax) } | ||
2552 | pub fn extern_items(&self) -> AstChildren<ExternItem> { support::children(&self.syntax) } | ||
2553 | pub fn r_curly(&self) -> Option<RCurly> { support::token(&self.syntax) } | ||
2554 | } | ||
2555 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2556 | pub struct ExternBlock { | ||
2557 | pub(crate) syntax: SyntaxNode, | ||
2558 | } | ||
2559 | impl AstNode for ExternBlock { | ||
2560 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_BLOCK } | ||
2561 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2562 | if Self::can_cast(syntax.kind()) { | ||
2563 | Some(Self { syntax }) | ||
2564 | } else { | ||
2565 | None | ||
2566 | } | ||
2567 | } | ||
2568 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2569 | } | ||
2570 | impl ExternBlock { | ||
2571 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | ||
2572 | pub fn extern_item_list(&self) -> Option<ExternItemList> { support::child(&self.syntax) } | ||
2573 | } | ||
2574 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2575 | pub struct MetaItem { | ||
2576 | pub(crate) syntax: SyntaxNode, | ||
2577 | } | ||
2578 | impl AstNode for MetaItem { | ||
2579 | fn can_cast(kind: SyntaxKind) -> bool { kind == META_ITEM } | ||
2580 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2581 | if Self::can_cast(syntax.kind()) { | ||
2582 | Some(Self { syntax }) | ||
2583 | } else { | ||
2584 | None | ||
2585 | } | ||
2586 | } | ||
2587 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2588 | } | ||
2589 | impl MetaItem { | ||
2590 | pub fn path(&self) -> Option<Path> { support::child(&self.syntax) } | ||
2591 | pub fn eq(&self) -> Option<Eq> { support::token(&self.syntax) } | ||
2592 | pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) } | ||
2593 | pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) } | ||
2594 | } | ||
2595 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2596 | pub struct MacroDef { | ||
2597 | pub(crate) syntax: SyntaxNode, | ||
2598 | } | ||
2599 | impl AstNode for MacroDef { | ||
2600 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_DEF } | ||
2601 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2602 | if Self::can_cast(syntax.kind()) { | ||
2603 | Some(Self { syntax }) | ||
2604 | } else { | ||
2605 | None | ||
2606 | } | ||
2607 | } | ||
2608 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
2609 | } | ||
2610 | impl MacroDef { | ||
2611 | pub fn name(&self) -> Option<Name> { support::child(&self.syntax) } | ||
2612 | pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) } | ||
2613 | } | ||
2614 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2615 | pub enum NominalDef { | ||
2616 | StructDef(StructDef), | ||
2617 | EnumDef(EnumDef), | ||
2618 | UnionDef(UnionDef), | ||
2619 | } | ||
2620 | impl From<StructDef> for NominalDef { | ||
2621 | fn from(node: StructDef) -> NominalDef { NominalDef::StructDef(node) } | ||
2622 | } | ||
2623 | impl From<EnumDef> for NominalDef { | ||
2624 | fn from(node: EnumDef) -> NominalDef { NominalDef::EnumDef(node) } | ||
2625 | } | ||
2626 | impl From<UnionDef> for NominalDef { | ||
2627 | fn from(node: UnionDef) -> NominalDef { NominalDef::UnionDef(node) } | ||
2628 | } | ||
2629 | impl AstNode for NominalDef { | ||
2630 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2631 | match kind { | ||
2632 | STRUCT_DEF | ENUM_DEF | UNION_DEF => true, | ||
2633 | _ => false, | ||
2634 | } | ||
2635 | } | ||
2636 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2637 | let res = match syntax.kind() { | ||
2638 | STRUCT_DEF => NominalDef::StructDef(StructDef { syntax }), | ||
2639 | ENUM_DEF => NominalDef::EnumDef(EnumDef { syntax }), | ||
2640 | UNION_DEF => NominalDef::UnionDef(UnionDef { syntax }), | ||
2641 | _ => return None, | ||
2642 | }; | ||
2643 | Some(res) | ||
2644 | } | ||
2645 | fn syntax(&self) -> &SyntaxNode { | ||
2646 | match self { | ||
2647 | NominalDef::StructDef(it) => &it.syntax, | ||
2648 | NominalDef::EnumDef(it) => &it.syntax, | ||
2649 | NominalDef::UnionDef(it) => &it.syntax, | ||
2650 | } | ||
2651 | } | ||
2652 | } | ||
2653 | impl ast::NameOwner for NominalDef {} | ||
2654 | impl ast::TypeParamsOwner for NominalDef {} | ||
2655 | impl ast::AttrsOwner for NominalDef {} | ||
2656 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2657 | pub enum GenericParam { | ||
2658 | LifetimeParam(LifetimeParam), | ||
2659 | TypeParam(TypeParam), | ||
2660 | ConstParam(ConstParam), | ||
2661 | } | ||
2662 | impl From<LifetimeParam> for GenericParam { | ||
2663 | fn from(node: LifetimeParam) -> GenericParam { GenericParam::LifetimeParam(node) } | ||
2664 | } | ||
2665 | impl From<TypeParam> for GenericParam { | ||
2666 | fn from(node: TypeParam) -> GenericParam { GenericParam::TypeParam(node) } | ||
2667 | } | ||
2668 | impl From<ConstParam> for GenericParam { | ||
2669 | fn from(node: ConstParam) -> GenericParam { GenericParam::ConstParam(node) } | ||
2670 | } | ||
2671 | impl AstNode for GenericParam { | ||
2672 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2673 | match kind { | ||
2674 | LIFETIME_PARAM | TYPE_PARAM | CONST_PARAM => true, | ||
2675 | _ => false, | ||
2676 | } | ||
2677 | } | ||
2678 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2679 | let res = match syntax.kind() { | ||
2680 | LIFETIME_PARAM => GenericParam::LifetimeParam(LifetimeParam { syntax }), | ||
2681 | TYPE_PARAM => GenericParam::TypeParam(TypeParam { syntax }), | ||
2682 | CONST_PARAM => GenericParam::ConstParam(ConstParam { syntax }), | ||
2683 | _ => return None, | ||
2684 | }; | ||
2685 | Some(res) | ||
2686 | } | ||
2687 | fn syntax(&self) -> &SyntaxNode { | ||
2688 | match self { | ||
2689 | GenericParam::LifetimeParam(it) => &it.syntax, | ||
2690 | GenericParam::TypeParam(it) => &it.syntax, | ||
2691 | GenericParam::ConstParam(it) => &it.syntax, | ||
2692 | } | ||
2693 | } | ||
2694 | } | ||
2695 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2696 | pub enum GenericArg { | ||
2697 | LifetimeArg(LifetimeArg), | ||
2698 | TypeArg(TypeArg), | ||
2699 | ConstArg(ConstArg), | ||
2700 | AssocTypeArg(AssocTypeArg), | ||
2701 | } | ||
2702 | impl From<LifetimeArg> for GenericArg { | ||
2703 | fn from(node: LifetimeArg) -> GenericArg { GenericArg::LifetimeArg(node) } | ||
2704 | } | ||
2705 | impl From<TypeArg> for GenericArg { | ||
2706 | fn from(node: TypeArg) -> GenericArg { GenericArg::TypeArg(node) } | ||
2707 | } | ||
2708 | impl From<ConstArg> for GenericArg { | ||
2709 | fn from(node: ConstArg) -> GenericArg { GenericArg::ConstArg(node) } | ||
2710 | } | ||
2711 | impl From<AssocTypeArg> for GenericArg { | ||
2712 | fn from(node: AssocTypeArg) -> GenericArg { GenericArg::AssocTypeArg(node) } | ||
2713 | } | ||
2714 | impl AstNode for GenericArg { | ||
2715 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2716 | match kind { | ||
2717 | LIFETIME_ARG | TYPE_ARG | CONST_ARG | ASSOC_TYPE_ARG => true, | ||
2718 | _ => false, | ||
2719 | } | ||
2720 | } | ||
2721 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2722 | let res = match syntax.kind() { | ||
2723 | LIFETIME_ARG => GenericArg::LifetimeArg(LifetimeArg { syntax }), | ||
2724 | TYPE_ARG => GenericArg::TypeArg(TypeArg { syntax }), | ||
2725 | CONST_ARG => GenericArg::ConstArg(ConstArg { syntax }), | ||
2726 | ASSOC_TYPE_ARG => GenericArg::AssocTypeArg(AssocTypeArg { syntax }), | ||
2727 | _ => return None, | ||
2728 | }; | ||
2729 | Some(res) | ||
2730 | } | ||
2731 | fn syntax(&self) -> &SyntaxNode { | ||
2732 | match self { | ||
2733 | GenericArg::LifetimeArg(it) => &it.syntax, | ||
2734 | GenericArg::TypeArg(it) => &it.syntax, | ||
2735 | GenericArg::ConstArg(it) => &it.syntax, | ||
2736 | GenericArg::AssocTypeArg(it) => &it.syntax, | ||
2737 | } | ||
2738 | } | ||
2739 | } | ||
2740 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2741 | pub enum TypeRef { | ||
2742 | ParenType(ParenType), | ||
2743 | TupleType(TupleType), | ||
2744 | NeverType(NeverType), | ||
2745 | PathType(PathType), | ||
2746 | PointerType(PointerType), | ||
2747 | ArrayType(ArrayType), | ||
2748 | SliceType(SliceType), | ||
2749 | ReferenceType(ReferenceType), | ||
2750 | PlaceholderType(PlaceholderType), | ||
2751 | FnPointerType(FnPointerType), | ||
2752 | ForType(ForType), | ||
2753 | ImplTraitType(ImplTraitType), | ||
2754 | DynTraitType(DynTraitType), | ||
2755 | } | ||
2756 | impl From<ParenType> for TypeRef { | ||
2757 | fn from(node: ParenType) -> TypeRef { TypeRef::ParenType(node) } | ||
2758 | } | ||
2759 | impl From<TupleType> for TypeRef { | ||
2760 | fn from(node: TupleType) -> TypeRef { TypeRef::TupleType(node) } | ||
2761 | } | ||
2762 | impl From<NeverType> for TypeRef { | ||
2763 | fn from(node: NeverType) -> TypeRef { TypeRef::NeverType(node) } | ||
2764 | } | ||
2765 | impl From<PathType> for TypeRef { | ||
2766 | fn from(node: PathType) -> TypeRef { TypeRef::PathType(node) } | ||
2767 | } | ||
2768 | impl From<PointerType> for TypeRef { | ||
2769 | fn from(node: PointerType) -> TypeRef { TypeRef::PointerType(node) } | ||
2770 | } | ||
2771 | impl From<ArrayType> for TypeRef { | ||
2772 | fn from(node: ArrayType) -> TypeRef { TypeRef::ArrayType(node) } | ||
2773 | } | ||
2774 | impl From<SliceType> for TypeRef { | ||
2775 | fn from(node: SliceType) -> TypeRef { TypeRef::SliceType(node) } | ||
2776 | } | ||
2777 | impl From<ReferenceType> for TypeRef { | ||
2778 | fn from(node: ReferenceType) -> TypeRef { TypeRef::ReferenceType(node) } | ||
2779 | } | ||
2780 | impl From<PlaceholderType> for TypeRef { | ||
2781 | fn from(node: PlaceholderType) -> TypeRef { TypeRef::PlaceholderType(node) } | ||
2782 | } | ||
2783 | impl From<FnPointerType> for TypeRef { | ||
2784 | fn from(node: FnPointerType) -> TypeRef { TypeRef::FnPointerType(node) } | ||
2785 | } | ||
2786 | impl From<ForType> for TypeRef { | ||
2787 | fn from(node: ForType) -> TypeRef { TypeRef::ForType(node) } | ||
2788 | } | ||
2789 | impl From<ImplTraitType> for TypeRef { | ||
2790 | fn from(node: ImplTraitType) -> TypeRef { TypeRef::ImplTraitType(node) } | ||
2791 | } | ||
2792 | impl From<DynTraitType> for TypeRef { | ||
2793 | fn from(node: DynTraitType) -> TypeRef { TypeRef::DynTraitType(node) } | ||
2794 | } | ||
2795 | impl AstNode for TypeRef { | ||
2796 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2797 | match kind { | ||
2798 | PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE | ||
2799 | | SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE | ||
2800 | | IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true, | ||
2801 | _ => false, | ||
2802 | } | ||
2803 | } | ||
2804 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2805 | let res = match syntax.kind() { | ||
2806 | PAREN_TYPE => TypeRef::ParenType(ParenType { syntax }), | ||
2807 | TUPLE_TYPE => TypeRef::TupleType(TupleType { syntax }), | ||
2808 | NEVER_TYPE => TypeRef::NeverType(NeverType { syntax }), | ||
2809 | PATH_TYPE => TypeRef::PathType(PathType { syntax }), | ||
2810 | POINTER_TYPE => TypeRef::PointerType(PointerType { syntax }), | ||
2811 | ARRAY_TYPE => TypeRef::ArrayType(ArrayType { syntax }), | ||
2812 | SLICE_TYPE => TypeRef::SliceType(SliceType { syntax }), | ||
2813 | REFERENCE_TYPE => TypeRef::ReferenceType(ReferenceType { syntax }), | ||
2814 | PLACEHOLDER_TYPE => TypeRef::PlaceholderType(PlaceholderType { syntax }), | ||
2815 | FN_POINTER_TYPE => TypeRef::FnPointerType(FnPointerType { syntax }), | ||
2816 | FOR_TYPE => TypeRef::ForType(ForType { syntax }), | ||
2817 | IMPL_TRAIT_TYPE => TypeRef::ImplTraitType(ImplTraitType { syntax }), | ||
2818 | DYN_TRAIT_TYPE => TypeRef::DynTraitType(DynTraitType { syntax }), | ||
2819 | _ => return None, | ||
2820 | }; | ||
2821 | Some(res) | ||
2822 | } | ||
2823 | fn syntax(&self) -> &SyntaxNode { | ||
2824 | match self { | ||
2825 | TypeRef::ParenType(it) => &it.syntax, | ||
2826 | TypeRef::TupleType(it) => &it.syntax, | ||
2827 | TypeRef::NeverType(it) => &it.syntax, | ||
2828 | TypeRef::PathType(it) => &it.syntax, | ||
2829 | TypeRef::PointerType(it) => &it.syntax, | ||
2830 | TypeRef::ArrayType(it) => &it.syntax, | ||
2831 | TypeRef::SliceType(it) => &it.syntax, | ||
2832 | TypeRef::ReferenceType(it) => &it.syntax, | ||
2833 | TypeRef::PlaceholderType(it) => &it.syntax, | ||
2834 | TypeRef::FnPointerType(it) => &it.syntax, | ||
2835 | TypeRef::ForType(it) => &it.syntax, | ||
2836 | TypeRef::ImplTraitType(it) => &it.syntax, | ||
2837 | TypeRef::DynTraitType(it) => &it.syntax, | ||
2838 | } | ||
2839 | } | ||
2840 | } | ||
2841 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2842 | pub enum ModuleItem { | ||
2843 | StructDef(StructDef), | ||
2844 | UnionDef(UnionDef), | ||
2845 | EnumDef(EnumDef), | ||
2846 | FnDef(FnDef), | ||
2847 | TraitDef(TraitDef), | ||
2848 | TypeAliasDef(TypeAliasDef), | ||
2849 | ImplDef(ImplDef), | ||
2850 | UseItem(UseItem), | ||
2851 | ExternCrateItem(ExternCrateItem), | ||
2852 | ConstDef(ConstDef), | ||
2853 | StaticDef(StaticDef), | ||
2854 | Module(Module), | ||
2855 | MacroCall(MacroCall), | ||
2856 | ExternBlock(ExternBlock), | ||
2857 | } | ||
2858 | impl From<StructDef> for ModuleItem { | ||
2859 | fn from(node: StructDef) -> ModuleItem { ModuleItem::StructDef(node) } | ||
2860 | } | ||
2861 | impl From<UnionDef> for ModuleItem { | ||
2862 | fn from(node: UnionDef) -> ModuleItem { ModuleItem::UnionDef(node) } | ||
2863 | } | ||
2864 | impl From<EnumDef> for ModuleItem { | ||
2865 | fn from(node: EnumDef) -> ModuleItem { ModuleItem::EnumDef(node) } | ||
2866 | } | ||
2867 | impl From<FnDef> for ModuleItem { | ||
2868 | fn from(node: FnDef) -> ModuleItem { ModuleItem::FnDef(node) } | ||
2869 | } | ||
2870 | impl From<TraitDef> for ModuleItem { | ||
2871 | fn from(node: TraitDef) -> ModuleItem { ModuleItem::TraitDef(node) } | ||
2872 | } | ||
2873 | impl From<TypeAliasDef> for ModuleItem { | ||
2874 | fn from(node: TypeAliasDef) -> ModuleItem { ModuleItem::TypeAliasDef(node) } | ||
2875 | } | ||
2876 | impl From<ImplDef> for ModuleItem { | ||
2877 | fn from(node: ImplDef) -> ModuleItem { ModuleItem::ImplDef(node) } | ||
2878 | } | ||
2879 | impl From<UseItem> for ModuleItem { | ||
2880 | fn from(node: UseItem) -> ModuleItem { ModuleItem::UseItem(node) } | ||
2881 | } | ||
2882 | impl From<ExternCrateItem> for ModuleItem { | ||
2883 | fn from(node: ExternCrateItem) -> ModuleItem { ModuleItem::ExternCrateItem(node) } | ||
2884 | } | ||
2885 | impl From<ConstDef> for ModuleItem { | ||
2886 | fn from(node: ConstDef) -> ModuleItem { ModuleItem::ConstDef(node) } | ||
2887 | } | ||
2888 | impl From<StaticDef> for ModuleItem { | ||
2889 | fn from(node: StaticDef) -> ModuleItem { ModuleItem::StaticDef(node) } | ||
2890 | } | ||
2891 | impl From<Module> for ModuleItem { | ||
2892 | fn from(node: Module) -> ModuleItem { ModuleItem::Module(node) } | ||
2893 | } | ||
2894 | impl From<MacroCall> for ModuleItem { | ||
2895 | fn from(node: MacroCall) -> ModuleItem { ModuleItem::MacroCall(node) } | ||
2896 | } | ||
2897 | impl From<ExternBlock> for ModuleItem { | ||
2898 | fn from(node: ExternBlock) -> ModuleItem { ModuleItem::ExternBlock(node) } | ||
2899 | } | ||
2900 | impl AstNode for ModuleItem { | ||
2901 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2902 | match kind { | ||
2903 | STRUCT_DEF | UNION_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_DEF | ||
2904 | | USE_ITEM | EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE | MACRO_CALL | ||
2905 | | EXTERN_BLOCK => true, | ||
2906 | _ => false, | ||
2907 | } | ||
2908 | } | ||
2909 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2910 | let res = match syntax.kind() { | ||
2911 | STRUCT_DEF => ModuleItem::StructDef(StructDef { syntax }), | ||
2912 | UNION_DEF => ModuleItem::UnionDef(UnionDef { syntax }), | ||
2913 | ENUM_DEF => ModuleItem::EnumDef(EnumDef { syntax }), | ||
2914 | FN_DEF => ModuleItem::FnDef(FnDef { syntax }), | ||
2915 | TRAIT_DEF => ModuleItem::TraitDef(TraitDef { syntax }), | ||
2916 | TYPE_ALIAS_DEF => ModuleItem::TypeAliasDef(TypeAliasDef { syntax }), | ||
2917 | IMPL_DEF => ModuleItem::ImplDef(ImplDef { syntax }), | ||
2918 | USE_ITEM => ModuleItem::UseItem(UseItem { syntax }), | ||
2919 | EXTERN_CRATE_ITEM => ModuleItem::ExternCrateItem(ExternCrateItem { syntax }), | ||
2920 | CONST_DEF => ModuleItem::ConstDef(ConstDef { syntax }), | ||
2921 | STATIC_DEF => ModuleItem::StaticDef(StaticDef { syntax }), | ||
2922 | MODULE => ModuleItem::Module(Module { syntax }), | ||
2923 | MACRO_CALL => ModuleItem::MacroCall(MacroCall { syntax }), | ||
2924 | EXTERN_BLOCK => ModuleItem::ExternBlock(ExternBlock { syntax }), | ||
2925 | _ => return None, | ||
2926 | }; | ||
2927 | Some(res) | ||
2928 | } | ||
2929 | fn syntax(&self) -> &SyntaxNode { | ||
2930 | match self { | ||
2931 | ModuleItem::StructDef(it) => &it.syntax, | ||
2932 | ModuleItem::UnionDef(it) => &it.syntax, | ||
2933 | ModuleItem::EnumDef(it) => &it.syntax, | ||
2934 | ModuleItem::FnDef(it) => &it.syntax, | ||
2935 | ModuleItem::TraitDef(it) => &it.syntax, | ||
2936 | ModuleItem::TypeAliasDef(it) => &it.syntax, | ||
2937 | ModuleItem::ImplDef(it) => &it.syntax, | ||
2938 | ModuleItem::UseItem(it) => &it.syntax, | ||
2939 | ModuleItem::ExternCrateItem(it) => &it.syntax, | ||
2940 | ModuleItem::ConstDef(it) => &it.syntax, | ||
2941 | ModuleItem::StaticDef(it) => &it.syntax, | ||
2942 | ModuleItem::Module(it) => &it.syntax, | ||
2943 | ModuleItem::MacroCall(it) => &it.syntax, | ||
2944 | ModuleItem::ExternBlock(it) => &it.syntax, | ||
2945 | } | ||
2946 | } | ||
2947 | } | ||
2948 | impl ast::NameOwner for ModuleItem {} | ||
2949 | impl ast::AttrsOwner for ModuleItem {} | ||
2950 | impl ast::VisibilityOwner for ModuleItem {} | ||
2951 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2952 | pub enum ImplItem { | ||
2953 | FnDef(FnDef), | ||
2954 | TypeAliasDef(TypeAliasDef), | ||
2955 | ConstDef(ConstDef), | ||
2956 | } | ||
2957 | impl From<FnDef> for ImplItem { | ||
2958 | fn from(node: FnDef) -> ImplItem { ImplItem::FnDef(node) } | ||
2959 | } | ||
2960 | impl From<TypeAliasDef> for ImplItem { | ||
2961 | fn from(node: TypeAliasDef) -> ImplItem { ImplItem::TypeAliasDef(node) } | ||
2962 | } | ||
2963 | impl From<ConstDef> for ImplItem { | ||
2964 | fn from(node: ConstDef) -> ImplItem { ImplItem::ConstDef(node) } | ||
2965 | } | ||
2966 | impl AstNode for ImplItem { | ||
2967 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2968 | match kind { | ||
2969 | FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true, | ||
2970 | _ => false, | ||
2971 | } | ||
2972 | } | ||
2973 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
2974 | let res = match syntax.kind() { | ||
2975 | FN_DEF => ImplItem::FnDef(FnDef { syntax }), | ||
2976 | TYPE_ALIAS_DEF => ImplItem::TypeAliasDef(TypeAliasDef { syntax }), | ||
2977 | CONST_DEF => ImplItem::ConstDef(ConstDef { syntax }), | ||
2978 | _ => return None, | ||
2979 | }; | ||
2980 | Some(res) | ||
2981 | } | ||
2982 | fn syntax(&self) -> &SyntaxNode { | ||
2983 | match self { | ||
2984 | ImplItem::FnDef(it) => &it.syntax, | ||
2985 | ImplItem::TypeAliasDef(it) => &it.syntax, | ||
2986 | ImplItem::ConstDef(it) => &it.syntax, | ||
2987 | } | ||
2988 | } | ||
2989 | } | ||
2990 | impl ast::NameOwner for ImplItem {} | ||
2991 | impl ast::AttrsOwner for ImplItem {} | ||
2992 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2993 | pub enum ExternItem { | ||
2994 | FnDef(FnDef), | ||
2995 | StaticDef(StaticDef), | ||
2996 | } | ||
2997 | impl From<FnDef> for ExternItem { | ||
2998 | fn from(node: FnDef) -> ExternItem { ExternItem::FnDef(node) } | ||
2999 | } | ||
3000 | impl From<StaticDef> for ExternItem { | ||
3001 | fn from(node: StaticDef) -> ExternItem { ExternItem::StaticDef(node) } | ||
3002 | } | ||
3003 | impl AstNode for ExternItem { | ||
3004 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3005 | match kind { | ||
3006 | FN_DEF | STATIC_DEF => true, | ||
3007 | _ => false, | ||
3008 | } | ||
3009 | } | ||
3010 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3011 | let res = match syntax.kind() { | ||
3012 | FN_DEF => ExternItem::FnDef(FnDef { syntax }), | ||
3013 | STATIC_DEF => ExternItem::StaticDef(StaticDef { syntax }), | ||
3014 | _ => return None, | ||
3015 | }; | ||
3016 | Some(res) | ||
3017 | } | ||
3018 | fn syntax(&self) -> &SyntaxNode { | ||
3019 | match self { | ||
3020 | ExternItem::FnDef(it) => &it.syntax, | ||
3021 | ExternItem::StaticDef(it) => &it.syntax, | ||
3022 | } | ||
3023 | } | ||
3024 | } | ||
3025 | impl ast::NameOwner for ExternItem {} | ||
3026 | impl ast::AttrsOwner for ExternItem {} | ||
3027 | impl ast::VisibilityOwner for ExternItem {} | ||
3028 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3029 | pub enum Expr { | ||
3030 | TupleExpr(TupleExpr), | ||
3031 | ArrayExpr(ArrayExpr), | ||
3032 | ParenExpr(ParenExpr), | ||
3033 | PathExpr(PathExpr), | ||
3034 | LambdaExpr(LambdaExpr), | ||
3035 | IfExpr(IfExpr), | ||
3036 | LoopExpr(LoopExpr), | ||
3037 | ForExpr(ForExpr), | ||
3038 | WhileExpr(WhileExpr), | ||
3039 | ContinueExpr(ContinueExpr), | ||
3040 | BreakExpr(BreakExpr), | ||
3041 | Label(Label), | ||
3042 | BlockExpr(BlockExpr), | ||
3043 | ReturnExpr(ReturnExpr), | ||
3044 | MatchExpr(MatchExpr), | ||
3045 | RecordLit(RecordLit), | ||
3046 | CallExpr(CallExpr), | ||
3047 | IndexExpr(IndexExpr), | ||
3048 | MethodCallExpr(MethodCallExpr), | ||
3049 | FieldExpr(FieldExpr), | ||
3050 | AwaitExpr(AwaitExpr), | ||
3051 | TryExpr(TryExpr), | ||
3052 | TryBlockExpr(TryBlockExpr), | ||
3053 | CastExpr(CastExpr), | ||
3054 | RefExpr(RefExpr), | ||
3055 | PrefixExpr(PrefixExpr), | ||
3056 | RangeExpr(RangeExpr), | ||
3057 | BinExpr(BinExpr), | ||
3058 | Literal(Literal), | ||
3059 | MacroCall(MacroCall), | ||
3060 | BoxExpr(BoxExpr), | ||
3061 | } | ||
3062 | impl From<TupleExpr> for Expr { | ||
3063 | fn from(node: TupleExpr) -> Expr { Expr::TupleExpr(node) } | ||
3064 | } | ||
3065 | impl From<ArrayExpr> for Expr { | ||
3066 | fn from(node: ArrayExpr) -> Expr { Expr::ArrayExpr(node) } | ||
3067 | } | ||
3068 | impl From<ParenExpr> for Expr { | ||
3069 | fn from(node: ParenExpr) -> Expr { Expr::ParenExpr(node) } | ||
3070 | } | ||
3071 | impl From<PathExpr> for Expr { | ||
3072 | fn from(node: PathExpr) -> Expr { Expr::PathExpr(node) } | ||
3073 | } | ||
3074 | impl From<LambdaExpr> for Expr { | ||
3075 | fn from(node: LambdaExpr) -> Expr { Expr::LambdaExpr(node) } | ||
3076 | } | ||
3077 | impl From<IfExpr> for Expr { | ||
3078 | fn from(node: IfExpr) -> Expr { Expr::IfExpr(node) } | ||
3079 | } | ||
3080 | impl From<LoopExpr> for Expr { | ||
3081 | fn from(node: LoopExpr) -> Expr { Expr::LoopExpr(node) } | ||
3082 | } | ||
3083 | impl From<ForExpr> for Expr { | ||
3084 | fn from(node: ForExpr) -> Expr { Expr::ForExpr(node) } | ||
3085 | } | ||
3086 | impl From<WhileExpr> for Expr { | ||
3087 | fn from(node: WhileExpr) -> Expr { Expr::WhileExpr(node) } | ||
3088 | } | ||
3089 | impl From<ContinueExpr> for Expr { | ||
3090 | fn from(node: ContinueExpr) -> Expr { Expr::ContinueExpr(node) } | ||
3091 | } | ||
3092 | impl From<BreakExpr> for Expr { | ||
3093 | fn from(node: BreakExpr) -> Expr { Expr::BreakExpr(node) } | ||
3094 | } | ||
3095 | impl From<Label> for Expr { | ||
3096 | fn from(node: Label) -> Expr { Expr::Label(node) } | ||
3097 | } | ||
3098 | impl From<BlockExpr> for Expr { | ||
3099 | fn from(node: BlockExpr) -> Expr { Expr::BlockExpr(node) } | ||
3100 | } | ||
3101 | impl From<ReturnExpr> for Expr { | ||
3102 | fn from(node: ReturnExpr) -> Expr { Expr::ReturnExpr(node) } | ||
3103 | } | ||
3104 | impl From<MatchExpr> for Expr { | ||
3105 | fn from(node: MatchExpr) -> Expr { Expr::MatchExpr(node) } | ||
3106 | } | ||
3107 | impl From<RecordLit> for Expr { | ||
3108 | fn from(node: RecordLit) -> Expr { Expr::RecordLit(node) } | ||
3109 | } | ||
3110 | impl From<CallExpr> for Expr { | ||
3111 | fn from(node: CallExpr) -> Expr { Expr::CallExpr(node) } | ||
3112 | } | ||
3113 | impl From<IndexExpr> for Expr { | ||
3114 | fn from(node: IndexExpr) -> Expr { Expr::IndexExpr(node) } | ||
3115 | } | ||
3116 | impl From<MethodCallExpr> for Expr { | ||
3117 | fn from(node: MethodCallExpr) -> Expr { Expr::MethodCallExpr(node) } | ||
3118 | } | ||
3119 | impl From<FieldExpr> for Expr { | ||
3120 | fn from(node: FieldExpr) -> Expr { Expr::FieldExpr(node) } | ||
3121 | } | ||
3122 | impl From<AwaitExpr> for Expr { | ||
3123 | fn from(node: AwaitExpr) -> Expr { Expr::AwaitExpr(node) } | ||
3124 | } | ||
3125 | impl From<TryExpr> for Expr { | ||
3126 | fn from(node: TryExpr) -> Expr { Expr::TryExpr(node) } | ||
3127 | } | ||
3128 | impl From<TryBlockExpr> for Expr { | ||
3129 | fn from(node: TryBlockExpr) -> Expr { Expr::TryBlockExpr(node) } | ||
3130 | } | ||
3131 | impl From<CastExpr> for Expr { | ||
3132 | fn from(node: CastExpr) -> Expr { Expr::CastExpr(node) } | ||
3133 | } | ||
3134 | impl From<RefExpr> for Expr { | ||
3135 | fn from(node: RefExpr) -> Expr { Expr::RefExpr(node) } | ||
3136 | } | ||
3137 | impl From<PrefixExpr> for Expr { | ||
3138 | fn from(node: PrefixExpr) -> Expr { Expr::PrefixExpr(node) } | ||
3139 | } | ||
3140 | impl From<RangeExpr> for Expr { | ||
3141 | fn from(node: RangeExpr) -> Expr { Expr::RangeExpr(node) } | ||
3142 | } | ||
3143 | impl From<BinExpr> for Expr { | ||
3144 | fn from(node: BinExpr) -> Expr { Expr::BinExpr(node) } | ||
3145 | } | ||
3146 | impl From<Literal> for Expr { | ||
3147 | fn from(node: Literal) -> Expr { Expr::Literal(node) } | ||
3148 | } | ||
3149 | impl From<MacroCall> for Expr { | ||
3150 | fn from(node: MacroCall) -> Expr { Expr::MacroCall(node) } | ||
3151 | } | ||
3152 | impl From<BoxExpr> for Expr { | ||
3153 | fn from(node: BoxExpr) -> Expr { Expr::BoxExpr(node) } | ||
3154 | } | ||
3155 | impl AstNode for Expr { | ||
3156 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3157 | match kind { | ||
3158 | TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR | ||
3159 | | LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL | ||
3160 | | BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | RECORD_LIT | CALL_EXPR | INDEX_EXPR | ||
3161 | | METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR | ||
3162 | | CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL | ||
3163 | | BOX_EXPR => true, | ||
3164 | _ => false, | ||
3165 | } | ||
3166 | } | ||
3167 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3168 | let res = match syntax.kind() { | ||
3169 | TUPLE_EXPR => Expr::TupleExpr(TupleExpr { syntax }), | ||
3170 | ARRAY_EXPR => Expr::ArrayExpr(ArrayExpr { syntax }), | ||
3171 | PAREN_EXPR => Expr::ParenExpr(ParenExpr { syntax }), | ||
3172 | PATH_EXPR => Expr::PathExpr(PathExpr { syntax }), | ||
3173 | LAMBDA_EXPR => Expr::LambdaExpr(LambdaExpr { syntax }), | ||
3174 | IF_EXPR => Expr::IfExpr(IfExpr { syntax }), | ||
3175 | LOOP_EXPR => Expr::LoopExpr(LoopExpr { syntax }), | ||
3176 | FOR_EXPR => Expr::ForExpr(ForExpr { syntax }), | ||
3177 | WHILE_EXPR => Expr::WhileExpr(WhileExpr { syntax }), | ||
3178 | CONTINUE_EXPR => Expr::ContinueExpr(ContinueExpr { syntax }), | ||
3179 | BREAK_EXPR => Expr::BreakExpr(BreakExpr { syntax }), | ||
3180 | LABEL => Expr::Label(Label { syntax }), | ||
3181 | BLOCK_EXPR => Expr::BlockExpr(BlockExpr { syntax }), | ||
3182 | RETURN_EXPR => Expr::ReturnExpr(ReturnExpr { syntax }), | ||
3183 | MATCH_EXPR => Expr::MatchExpr(MatchExpr { syntax }), | ||
3184 | RECORD_LIT => Expr::RecordLit(RecordLit { syntax }), | ||
3185 | CALL_EXPR => Expr::CallExpr(CallExpr { syntax }), | ||
3186 | INDEX_EXPR => Expr::IndexExpr(IndexExpr { syntax }), | ||
3187 | METHOD_CALL_EXPR => Expr::MethodCallExpr(MethodCallExpr { syntax }), | ||
3188 | FIELD_EXPR => Expr::FieldExpr(FieldExpr { syntax }), | ||
3189 | AWAIT_EXPR => Expr::AwaitExpr(AwaitExpr { syntax }), | ||
3190 | TRY_EXPR => Expr::TryExpr(TryExpr { syntax }), | ||
3191 | TRY_BLOCK_EXPR => Expr::TryBlockExpr(TryBlockExpr { syntax }), | ||
3192 | CAST_EXPR => Expr::CastExpr(CastExpr { syntax }), | ||
3193 | REF_EXPR => Expr::RefExpr(RefExpr { syntax }), | ||
3194 | PREFIX_EXPR => Expr::PrefixExpr(PrefixExpr { syntax }), | ||
3195 | RANGE_EXPR => Expr::RangeExpr(RangeExpr { syntax }), | ||
3196 | BIN_EXPR => Expr::BinExpr(BinExpr { syntax }), | ||
3197 | LITERAL => Expr::Literal(Literal { syntax }), | ||
3198 | MACRO_CALL => Expr::MacroCall(MacroCall { syntax }), | ||
3199 | BOX_EXPR => Expr::BoxExpr(BoxExpr { syntax }), | ||
3200 | _ => return None, | ||
3201 | }; | ||
3202 | Some(res) | ||
3203 | } | ||
3204 | fn syntax(&self) -> &SyntaxNode { | ||
3205 | match self { | ||
3206 | Expr::TupleExpr(it) => &it.syntax, | ||
3207 | Expr::ArrayExpr(it) => &it.syntax, | ||
3208 | Expr::ParenExpr(it) => &it.syntax, | ||
3209 | Expr::PathExpr(it) => &it.syntax, | ||
3210 | Expr::LambdaExpr(it) => &it.syntax, | ||
3211 | Expr::IfExpr(it) => &it.syntax, | ||
3212 | Expr::LoopExpr(it) => &it.syntax, | ||
3213 | Expr::ForExpr(it) => &it.syntax, | ||
3214 | Expr::WhileExpr(it) => &it.syntax, | ||
3215 | Expr::ContinueExpr(it) => &it.syntax, | ||
3216 | Expr::BreakExpr(it) => &it.syntax, | ||
3217 | Expr::Label(it) => &it.syntax, | ||
3218 | Expr::BlockExpr(it) => &it.syntax, | ||
3219 | Expr::ReturnExpr(it) => &it.syntax, | ||
3220 | Expr::MatchExpr(it) => &it.syntax, | ||
3221 | Expr::RecordLit(it) => &it.syntax, | ||
3222 | Expr::CallExpr(it) => &it.syntax, | ||
3223 | Expr::IndexExpr(it) => &it.syntax, | ||
3224 | Expr::MethodCallExpr(it) => &it.syntax, | ||
3225 | Expr::FieldExpr(it) => &it.syntax, | ||
3226 | Expr::AwaitExpr(it) => &it.syntax, | ||
3227 | Expr::TryExpr(it) => &it.syntax, | ||
3228 | Expr::TryBlockExpr(it) => &it.syntax, | ||
3229 | Expr::CastExpr(it) => &it.syntax, | ||
3230 | Expr::RefExpr(it) => &it.syntax, | ||
3231 | Expr::PrefixExpr(it) => &it.syntax, | ||
3232 | Expr::RangeExpr(it) => &it.syntax, | ||
3233 | Expr::BinExpr(it) => &it.syntax, | ||
3234 | Expr::Literal(it) => &it.syntax, | ||
3235 | Expr::MacroCall(it) => &it.syntax, | ||
3236 | Expr::BoxExpr(it) => &it.syntax, | ||
3237 | } | ||
3238 | } | ||
3239 | } | ||
3240 | impl ast::AttrsOwner for Expr {} | ||
3241 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3242 | pub enum Pat { | ||
3243 | OrPat(OrPat), | ||
3244 | ParenPat(ParenPat), | ||
3245 | RefPat(RefPat), | ||
3246 | BoxPat(BoxPat), | ||
3247 | BindPat(BindPat), | ||
3248 | PlaceholderPat(PlaceholderPat), | ||
3249 | DotDotPat(DotDotPat), | ||
3250 | PathPat(PathPat), | ||
3251 | RecordPat(RecordPat), | ||
3252 | TupleStructPat(TupleStructPat), | ||
3253 | TuplePat(TuplePat), | ||
3254 | SlicePat(SlicePat), | ||
3255 | RangePat(RangePat), | ||
3256 | LiteralPat(LiteralPat), | ||
3257 | MacroPat(MacroPat), | ||
3258 | } | ||
3259 | impl From<OrPat> for Pat { | ||
3260 | fn from(node: OrPat) -> Pat { Pat::OrPat(node) } | ||
3261 | } | ||
3262 | impl From<ParenPat> for Pat { | ||
3263 | fn from(node: ParenPat) -> Pat { Pat::ParenPat(node) } | ||
3264 | } | ||
3265 | impl From<RefPat> for Pat { | ||
3266 | fn from(node: RefPat) -> Pat { Pat::RefPat(node) } | ||
3267 | } | ||
3268 | impl From<BoxPat> for Pat { | ||
3269 | fn from(node: BoxPat) -> Pat { Pat::BoxPat(node) } | ||
3270 | } | ||
3271 | impl From<BindPat> for Pat { | ||
3272 | fn from(node: BindPat) -> Pat { Pat::BindPat(node) } | ||
3273 | } | ||
3274 | impl From<PlaceholderPat> for Pat { | ||
3275 | fn from(node: PlaceholderPat) -> Pat { Pat::PlaceholderPat(node) } | ||
3276 | } | ||
3277 | impl From<DotDotPat> for Pat { | ||
3278 | fn from(node: DotDotPat) -> Pat { Pat::DotDotPat(node) } | ||
3279 | } | ||
3280 | impl From<PathPat> for Pat { | ||
3281 | fn from(node: PathPat) -> Pat { Pat::PathPat(node) } | ||
3282 | } | ||
3283 | impl From<RecordPat> for Pat { | ||
3284 | fn from(node: RecordPat) -> Pat { Pat::RecordPat(node) } | ||
3285 | } | ||
3286 | impl From<TupleStructPat> for Pat { | ||
3287 | fn from(node: TupleStructPat) -> Pat { Pat::TupleStructPat(node) } | ||
3288 | } | ||
3289 | impl From<TuplePat> for Pat { | ||
3290 | fn from(node: TuplePat) -> Pat { Pat::TuplePat(node) } | ||
3291 | } | ||
3292 | impl From<SlicePat> for Pat { | ||
3293 | fn from(node: SlicePat) -> Pat { Pat::SlicePat(node) } | ||
3294 | } | ||
3295 | impl From<RangePat> for Pat { | ||
3296 | fn from(node: RangePat) -> Pat { Pat::RangePat(node) } | ||
3297 | } | ||
3298 | impl From<LiteralPat> for Pat { | ||
3299 | fn from(node: LiteralPat) -> Pat { Pat::LiteralPat(node) } | ||
3300 | } | ||
3301 | impl From<MacroPat> for Pat { | ||
3302 | fn from(node: MacroPat) -> Pat { Pat::MacroPat(node) } | ||
3303 | } | ||
3304 | impl AstNode for Pat { | ||
3305 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3306 | match kind { | ||
3307 | OR_PAT | PAREN_PAT | REF_PAT | BOX_PAT | BIND_PAT | PLACEHOLDER_PAT | DOT_DOT_PAT | ||
3308 | | PATH_PAT | RECORD_PAT | TUPLE_STRUCT_PAT | TUPLE_PAT | SLICE_PAT | RANGE_PAT | ||
3309 | | LITERAL_PAT | MACRO_PAT => true, | ||
3310 | _ => false, | ||
3311 | } | ||
3312 | } | ||
3313 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3314 | let res = match syntax.kind() { | ||
3315 | OR_PAT => Pat::OrPat(OrPat { syntax }), | ||
3316 | PAREN_PAT => Pat::ParenPat(ParenPat { syntax }), | ||
3317 | REF_PAT => Pat::RefPat(RefPat { syntax }), | ||
3318 | BOX_PAT => Pat::BoxPat(BoxPat { syntax }), | ||
3319 | BIND_PAT => Pat::BindPat(BindPat { syntax }), | ||
3320 | PLACEHOLDER_PAT => Pat::PlaceholderPat(PlaceholderPat { syntax }), | ||
3321 | DOT_DOT_PAT => Pat::DotDotPat(DotDotPat { syntax }), | ||
3322 | PATH_PAT => Pat::PathPat(PathPat { syntax }), | ||
3323 | RECORD_PAT => Pat::RecordPat(RecordPat { syntax }), | ||
3324 | TUPLE_STRUCT_PAT => Pat::TupleStructPat(TupleStructPat { syntax }), | ||
3325 | TUPLE_PAT => Pat::TuplePat(TuplePat { syntax }), | ||
3326 | SLICE_PAT => Pat::SlicePat(SlicePat { syntax }), | ||
3327 | RANGE_PAT => Pat::RangePat(RangePat { syntax }), | ||
3328 | LITERAL_PAT => Pat::LiteralPat(LiteralPat { syntax }), | ||
3329 | MACRO_PAT => Pat::MacroPat(MacroPat { syntax }), | ||
3330 | _ => return None, | ||
3331 | }; | ||
3332 | Some(res) | ||
3333 | } | ||
3334 | fn syntax(&self) -> &SyntaxNode { | ||
3335 | match self { | ||
3336 | Pat::OrPat(it) => &it.syntax, | ||
3337 | Pat::ParenPat(it) => &it.syntax, | ||
3338 | Pat::RefPat(it) => &it.syntax, | ||
3339 | Pat::BoxPat(it) => &it.syntax, | ||
3340 | Pat::BindPat(it) => &it.syntax, | ||
3341 | Pat::PlaceholderPat(it) => &it.syntax, | ||
3342 | Pat::DotDotPat(it) => &it.syntax, | ||
3343 | Pat::PathPat(it) => &it.syntax, | ||
3344 | Pat::RecordPat(it) => &it.syntax, | ||
3345 | Pat::TupleStructPat(it) => &it.syntax, | ||
3346 | Pat::TuplePat(it) => &it.syntax, | ||
3347 | Pat::SlicePat(it) => &it.syntax, | ||
3348 | Pat::RangePat(it) => &it.syntax, | ||
3349 | Pat::LiteralPat(it) => &it.syntax, | ||
3350 | Pat::MacroPat(it) => &it.syntax, | ||
3351 | } | ||
3352 | } | ||
3353 | } | ||
3354 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3355 | pub enum RecordInnerPat { | ||
3356 | RecordFieldPat(RecordFieldPat), | ||
3357 | BindPat(BindPat), | ||
3358 | } | ||
3359 | impl From<RecordFieldPat> for RecordInnerPat { | ||
3360 | fn from(node: RecordFieldPat) -> RecordInnerPat { RecordInnerPat::RecordFieldPat(node) } | ||
3361 | } | ||
3362 | impl From<BindPat> for RecordInnerPat { | ||
3363 | fn from(node: BindPat) -> RecordInnerPat { RecordInnerPat::BindPat(node) } | ||
3364 | } | ||
3365 | impl AstNode for RecordInnerPat { | ||
3366 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3367 | match kind { | ||
3368 | RECORD_FIELD_PAT | BIND_PAT => true, | ||
3369 | _ => false, | ||
3370 | } | ||
3371 | } | ||
3372 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3373 | let res = match syntax.kind() { | ||
3374 | RECORD_FIELD_PAT => RecordInnerPat::RecordFieldPat(RecordFieldPat { syntax }), | ||
3375 | BIND_PAT => RecordInnerPat::BindPat(BindPat { syntax }), | ||
3376 | _ => return None, | ||
3377 | }; | ||
3378 | Some(res) | ||
3379 | } | ||
3380 | fn syntax(&self) -> &SyntaxNode { | ||
3381 | match self { | ||
3382 | RecordInnerPat::RecordFieldPat(it) => &it.syntax, | ||
3383 | RecordInnerPat::BindPat(it) => &it.syntax, | ||
3384 | } | ||
3385 | } | ||
3386 | } | ||
3387 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3388 | pub enum AttrInput { | ||
3389 | Literal(Literal), | ||
3390 | TokenTree(TokenTree), | ||
3391 | } | ||
3392 | impl From<Literal> for AttrInput { | ||
3393 | fn from(node: Literal) -> AttrInput { AttrInput::Literal(node) } | ||
3394 | } | ||
3395 | impl From<TokenTree> for AttrInput { | ||
3396 | fn from(node: TokenTree) -> AttrInput { AttrInput::TokenTree(node) } | ||
3397 | } | ||
3398 | impl AstNode for AttrInput { | ||
3399 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3400 | match kind { | ||
3401 | LITERAL | TOKEN_TREE => true, | ||
3402 | _ => false, | ||
3403 | } | ||
3404 | } | ||
3405 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3406 | let res = match syntax.kind() { | ||
3407 | LITERAL => AttrInput::Literal(Literal { syntax }), | ||
3408 | TOKEN_TREE => AttrInput::TokenTree(TokenTree { syntax }), | ||
3409 | _ => return None, | ||
3410 | }; | ||
3411 | Some(res) | ||
3412 | } | ||
3413 | fn syntax(&self) -> &SyntaxNode { | ||
3414 | match self { | ||
3415 | AttrInput::Literal(it) => &it.syntax, | ||
3416 | AttrInput::TokenTree(it) => &it.syntax, | ||
3417 | } | ||
3418 | } | ||
3419 | } | ||
3420 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3421 | pub enum Stmt { | ||
3422 | LetStmt(LetStmt), | ||
3423 | ExprStmt(ExprStmt), | ||
3424 | } | ||
3425 | impl From<LetStmt> for Stmt { | ||
3426 | fn from(node: LetStmt) -> Stmt { Stmt::LetStmt(node) } | ||
3427 | } | ||
3428 | impl From<ExprStmt> for Stmt { | ||
3429 | fn from(node: ExprStmt) -> Stmt { Stmt::ExprStmt(node) } | ||
3430 | } | ||
3431 | impl AstNode for Stmt { | ||
3432 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3433 | match kind { | ||
3434 | LET_STMT | EXPR_STMT => true, | ||
3435 | _ => false, | ||
3436 | } | ||
3437 | } | ||
3438 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3439 | let res = match syntax.kind() { | ||
3440 | LET_STMT => Stmt::LetStmt(LetStmt { syntax }), | ||
3441 | EXPR_STMT => Stmt::ExprStmt(ExprStmt { syntax }), | ||
3442 | _ => return None, | ||
3443 | }; | ||
3444 | Some(res) | ||
3445 | } | ||
3446 | fn syntax(&self) -> &SyntaxNode { | ||
3447 | match self { | ||
3448 | Stmt::LetStmt(it) => &it.syntax, | ||
3449 | Stmt::ExprStmt(it) => &it.syntax, | ||
3450 | } | ||
3451 | } | ||
3452 | } | ||
3453 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
3454 | pub enum FieldDefList { | ||
3455 | RecordFieldDefList(RecordFieldDefList), | ||
3456 | TupleFieldDefList(TupleFieldDefList), | ||
3457 | } | ||
3458 | impl From<RecordFieldDefList> for FieldDefList { | ||
3459 | fn from(node: RecordFieldDefList) -> FieldDefList { FieldDefList::RecordFieldDefList(node) } | ||
3460 | } | ||
3461 | impl From<TupleFieldDefList> for FieldDefList { | ||
3462 | fn from(node: TupleFieldDefList) -> FieldDefList { FieldDefList::TupleFieldDefList(node) } | ||
3463 | } | ||
3464 | impl AstNode for FieldDefList { | ||
3465 | fn can_cast(kind: SyntaxKind) -> bool { | ||
3466 | match kind { | ||
3467 | RECORD_FIELD_DEF_LIST | TUPLE_FIELD_DEF_LIST => true, | ||
3468 | _ => false, | ||
3469 | } | ||
3470 | } | ||
3471 | fn cast(syntax: SyntaxNode) -> Option<Self> { | ||
3472 | let res = match syntax.kind() { | ||
3473 | RECORD_FIELD_DEF_LIST => { | ||
3474 | FieldDefList::RecordFieldDefList(RecordFieldDefList { syntax }) | ||
3475 | } | ||
3476 | TUPLE_FIELD_DEF_LIST => FieldDefList::TupleFieldDefList(TupleFieldDefList { syntax }), | ||
3477 | _ => return None, | ||
3478 | }; | ||
3479 | Some(res) | ||
3480 | } | ||
3481 | fn syntax(&self) -> &SyntaxNode { | ||
3482 | match self { | ||
3483 | FieldDefList::RecordFieldDefList(it) => &it.syntax, | ||
3484 | FieldDefList::TupleFieldDefList(it) => &it.syntax, | ||
3485 | } | ||
3486 | } | ||
3487 | } | ||
3488 | impl std::fmt::Display for NominalDef { | ||
3489 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3490 | std::fmt::Display::fmt(self.syntax(), f) | ||
3491 | } | ||
3492 | } | ||
3493 | impl std::fmt::Display for GenericParam { | ||
3494 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3495 | std::fmt::Display::fmt(self.syntax(), f) | ||
3496 | } | ||
3497 | } | ||
3498 | impl std::fmt::Display for GenericArg { | ||
3499 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3500 | std::fmt::Display::fmt(self.syntax(), f) | ||
3501 | } | ||
3502 | } | ||
3503 | impl std::fmt::Display for TypeRef { | ||
3504 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3505 | std::fmt::Display::fmt(self.syntax(), f) | ||
3506 | } | ||
3507 | } | ||
3508 | impl std::fmt::Display for ModuleItem { | ||
3509 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3510 | std::fmt::Display::fmt(self.syntax(), f) | ||
3511 | } | ||
3512 | } | ||
3513 | impl std::fmt::Display for ImplItem { | ||
3514 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3515 | std::fmt::Display::fmt(self.syntax(), f) | ||
3516 | } | ||
3517 | } | ||
3518 | impl std::fmt::Display for ExternItem { | ||
3519 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3520 | std::fmt::Display::fmt(self.syntax(), f) | ||
3521 | } | ||
3522 | } | ||
3523 | impl std::fmt::Display for Expr { | ||
3524 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3525 | std::fmt::Display::fmt(self.syntax(), f) | ||
3526 | } | ||
3527 | } | ||
3528 | impl std::fmt::Display for Pat { | ||
3529 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3530 | std::fmt::Display::fmt(self.syntax(), f) | ||
3531 | } | ||
3532 | } | ||
3533 | impl std::fmt::Display for RecordInnerPat { | ||
3534 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3535 | std::fmt::Display::fmt(self.syntax(), f) | ||
3536 | } | ||
3537 | } | ||
3538 | impl std::fmt::Display for AttrInput { | ||
3539 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3540 | std::fmt::Display::fmt(self.syntax(), f) | ||
3541 | } | ||
3542 | } | ||
3543 | impl std::fmt::Display for Stmt { | ||
3544 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3545 | std::fmt::Display::fmt(self.syntax(), f) | ||
3546 | } | ||
3547 | } | ||
3548 | impl std::fmt::Display for FieldDefList { | ||
3549 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3550 | std::fmt::Display::fmt(self.syntax(), f) | ||
3551 | } | ||
3552 | } | ||
3553 | impl std::fmt::Display for SourceFile { | ||
3554 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3555 | std::fmt::Display::fmt(self.syntax(), f) | ||
3556 | } | ||
3557 | } | ||
3558 | impl std::fmt::Display for FnDef { | ||
3559 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3560 | std::fmt::Display::fmt(self.syntax(), f) | ||
3561 | } | ||
3562 | } | ||
3563 | impl std::fmt::Display for RetType { | ||
3564 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3565 | std::fmt::Display::fmt(self.syntax(), f) | ||
3566 | } | ||
3567 | } | ||
3568 | impl std::fmt::Display for StructDef { | ||
3569 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3570 | std::fmt::Display::fmt(self.syntax(), f) | ||
3571 | } | ||
3572 | } | ||
3573 | impl std::fmt::Display for UnionDef { | ||
3574 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3575 | std::fmt::Display::fmt(self.syntax(), f) | ||
3576 | } | ||
3577 | } | ||
3578 | impl std::fmt::Display for RecordFieldDefList { | ||
3579 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3580 | std::fmt::Display::fmt(self.syntax(), f) | ||
3581 | } | ||
3582 | } | ||
3583 | impl std::fmt::Display for RecordFieldDef { | ||
3584 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3585 | std::fmt::Display::fmt(self.syntax(), f) | ||
3586 | } | ||
3587 | } | ||
3588 | impl std::fmt::Display for TupleFieldDefList { | ||
3589 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3590 | std::fmt::Display::fmt(self.syntax(), f) | ||
3591 | } | ||
3592 | } | ||
3593 | impl std::fmt::Display for TupleFieldDef { | ||
3594 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3595 | std::fmt::Display::fmt(self.syntax(), f) | ||
3596 | } | ||
3597 | } | ||
3598 | impl std::fmt::Display for EnumDef { | ||
3599 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3600 | std::fmt::Display::fmt(self.syntax(), f) | ||
3601 | } | ||
3602 | } | ||
3603 | impl std::fmt::Display for EnumVariantList { | ||
3604 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3605 | std::fmt::Display::fmt(self.syntax(), f) | ||
3606 | } | ||
3607 | } | ||
3608 | impl std::fmt::Display for EnumVariant { | ||
3609 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3610 | std::fmt::Display::fmt(self.syntax(), f) | ||
3611 | } | ||
3612 | } | ||
3613 | impl std::fmt::Display for TraitDef { | ||
3614 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3615 | std::fmt::Display::fmt(self.syntax(), f) | ||
3616 | } | ||
3617 | } | ||
3618 | impl std::fmt::Display for Module { | ||
3619 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3620 | std::fmt::Display::fmt(self.syntax(), f) | ||
3621 | } | ||
3622 | } | ||
3623 | impl std::fmt::Display for ItemList { | ||
3624 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3625 | std::fmt::Display::fmt(self.syntax(), f) | ||
3626 | } | ||
3627 | } | ||
3628 | impl std::fmt::Display for ConstDef { | ||
3629 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3630 | std::fmt::Display::fmt(self.syntax(), f) | ||
3631 | } | ||
3632 | } | ||
3633 | impl std::fmt::Display for StaticDef { | ||
3634 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3635 | std::fmt::Display::fmt(self.syntax(), f) | ||
3636 | } | ||
3637 | } | ||
3638 | impl std::fmt::Display for TypeAliasDef { | ||
3639 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3640 | std::fmt::Display::fmt(self.syntax(), f) | ||
3641 | } | ||
3642 | } | ||
3643 | impl std::fmt::Display for ImplDef { | ||
3644 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3645 | std::fmt::Display::fmt(self.syntax(), f) | ||
3646 | } | ||
3647 | } | ||
3648 | impl std::fmt::Display for ParenType { | ||
3649 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3650 | std::fmt::Display::fmt(self.syntax(), f) | ||
3651 | } | ||
3652 | } | ||
3653 | impl std::fmt::Display for TupleType { | ||
3654 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3655 | std::fmt::Display::fmt(self.syntax(), f) | ||
3656 | } | ||
3657 | } | ||
3658 | impl std::fmt::Display for NeverType { | ||
3659 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3660 | std::fmt::Display::fmt(self.syntax(), f) | ||
3661 | } | ||
3662 | } | ||
3663 | impl std::fmt::Display for PathType { | ||
3664 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3665 | std::fmt::Display::fmt(self.syntax(), f) | ||
3666 | } | ||
3667 | } | ||
3668 | impl std::fmt::Display for PointerType { | ||
3669 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3670 | std::fmt::Display::fmt(self.syntax(), f) | ||
3671 | } | ||
3672 | } | ||
3673 | impl std::fmt::Display for ArrayType { | ||
3674 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3675 | std::fmt::Display::fmt(self.syntax(), f) | ||
3676 | } | ||
3677 | } | ||
3678 | impl std::fmt::Display for SliceType { | ||
3679 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3680 | std::fmt::Display::fmt(self.syntax(), f) | ||
3681 | } | ||
3682 | } | ||
3683 | impl std::fmt::Display for ReferenceType { | ||
3684 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3685 | std::fmt::Display::fmt(self.syntax(), f) | ||
3686 | } | ||
3687 | } | ||
3688 | impl std::fmt::Display for PlaceholderType { | ||
3689 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3690 | std::fmt::Display::fmt(self.syntax(), f) | ||
3691 | } | ||
3692 | } | ||
3693 | impl std::fmt::Display for FnPointerType { | ||
3694 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3695 | std::fmt::Display::fmt(self.syntax(), f) | ||
3696 | } | ||
3697 | } | ||
3698 | impl std::fmt::Display for ForType { | ||
3699 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3700 | std::fmt::Display::fmt(self.syntax(), f) | ||
3701 | } | ||
3702 | } | ||
3703 | impl std::fmt::Display for ImplTraitType { | ||
3704 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3705 | std::fmt::Display::fmt(self.syntax(), f) | ||
3706 | } | ||
3707 | } | ||
3708 | impl std::fmt::Display for DynTraitType { | ||
3709 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3710 | std::fmt::Display::fmt(self.syntax(), f) | ||
3711 | } | ||
3712 | } | ||
3713 | impl std::fmt::Display for TupleExpr { | ||
3714 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3715 | std::fmt::Display::fmt(self.syntax(), f) | ||
3716 | } | ||
3717 | } | ||
3718 | impl std::fmt::Display for ArrayExpr { | ||
3719 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3720 | std::fmt::Display::fmt(self.syntax(), f) | ||
3721 | } | ||
3722 | } | ||
3723 | impl std::fmt::Display for ParenExpr { | ||
3724 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3725 | std::fmt::Display::fmt(self.syntax(), f) | ||
3726 | } | ||
3727 | } | ||
3728 | impl std::fmt::Display for PathExpr { | ||
3729 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3730 | std::fmt::Display::fmt(self.syntax(), f) | ||
3731 | } | ||
3732 | } | ||
3733 | impl std::fmt::Display for LambdaExpr { | ||
3734 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3735 | std::fmt::Display::fmt(self.syntax(), f) | ||
3736 | } | ||
3737 | } | ||
3738 | impl std::fmt::Display for IfExpr { | ||
3739 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3740 | std::fmt::Display::fmt(self.syntax(), f) | ||
3741 | } | ||
3742 | } | ||
3743 | impl std::fmt::Display for LoopExpr { | ||
3744 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3745 | std::fmt::Display::fmt(self.syntax(), f) | ||
3746 | } | ||
3747 | } | ||
3748 | impl std::fmt::Display for TryBlockExpr { | ||
3749 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3750 | std::fmt::Display::fmt(self.syntax(), f) | ||
3751 | } | ||
3752 | } | ||
3753 | impl std::fmt::Display for ForExpr { | ||
3754 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3755 | std::fmt::Display::fmt(self.syntax(), f) | ||
3756 | } | ||
3757 | } | ||
3758 | impl std::fmt::Display for WhileExpr { | ||
3759 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3760 | std::fmt::Display::fmt(self.syntax(), f) | ||
3761 | } | ||
3762 | } | ||
3763 | impl std::fmt::Display for ContinueExpr { | ||
3764 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3765 | std::fmt::Display::fmt(self.syntax(), f) | ||
3766 | } | ||
3767 | } | ||
3768 | impl std::fmt::Display for BreakExpr { | ||
3769 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3770 | std::fmt::Display::fmt(self.syntax(), f) | ||
3771 | } | ||
3772 | } | ||
3773 | impl std::fmt::Display for Label { | ||
3774 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3775 | std::fmt::Display::fmt(self.syntax(), f) | ||
3776 | } | ||
3777 | } | ||
3778 | impl std::fmt::Display for BlockExpr { | ||
3779 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3780 | std::fmt::Display::fmt(self.syntax(), f) | ||
3781 | } | ||
3782 | } | ||
3783 | impl std::fmt::Display for ReturnExpr { | ||
3784 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3785 | std::fmt::Display::fmt(self.syntax(), f) | ||
3786 | } | ||
3787 | } | ||
3788 | impl std::fmt::Display for CallExpr { | ||
3789 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3790 | std::fmt::Display::fmt(self.syntax(), f) | ||
3791 | } | ||
3792 | } | ||
3793 | impl std::fmt::Display for MethodCallExpr { | ||
3794 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3795 | std::fmt::Display::fmt(self.syntax(), f) | ||
3796 | } | ||
3797 | } | ||
3798 | impl std::fmt::Display for IndexExpr { | ||
3799 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3800 | std::fmt::Display::fmt(self.syntax(), f) | ||
3801 | } | ||
3802 | } | ||
3803 | impl std::fmt::Display for FieldExpr { | ||
3804 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3805 | std::fmt::Display::fmt(self.syntax(), f) | ||
3806 | } | ||
3807 | } | ||
3808 | impl std::fmt::Display for AwaitExpr { | ||
3809 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3810 | std::fmt::Display::fmt(self.syntax(), f) | ||
3811 | } | ||
3812 | } | ||
3813 | impl std::fmt::Display for TryExpr { | ||
3814 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3815 | std::fmt::Display::fmt(self.syntax(), f) | ||
3816 | } | ||
3817 | } | ||
3818 | impl std::fmt::Display for CastExpr { | ||
3819 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3820 | std::fmt::Display::fmt(self.syntax(), f) | ||
3821 | } | ||
3822 | } | ||
3823 | impl std::fmt::Display for RefExpr { | ||
3824 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3825 | std::fmt::Display::fmt(self.syntax(), f) | ||
3826 | } | ||
3827 | } | ||
3828 | impl std::fmt::Display for PrefixExpr { | ||
3829 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3830 | std::fmt::Display::fmt(self.syntax(), f) | ||
3831 | } | ||
3832 | } | ||
3833 | impl std::fmt::Display for BoxExpr { | ||
3834 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3835 | std::fmt::Display::fmt(self.syntax(), f) | ||
3836 | } | ||
3837 | } | ||
3838 | impl std::fmt::Display for RangeExpr { | ||
3839 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3840 | std::fmt::Display::fmt(self.syntax(), f) | ||
3841 | } | ||
3842 | } | ||
3843 | impl std::fmt::Display for BinExpr { | ||
3844 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3845 | std::fmt::Display::fmt(self.syntax(), f) | ||
3846 | } | ||
3847 | } | ||
3848 | impl std::fmt::Display for Literal { | ||
3849 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3850 | std::fmt::Display::fmt(self.syntax(), f) | ||
3851 | } | ||
3852 | } | ||
3853 | impl std::fmt::Display for MatchExpr { | ||
3854 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3855 | std::fmt::Display::fmt(self.syntax(), f) | ||
3856 | } | ||
3857 | } | ||
3858 | impl std::fmt::Display for MatchArmList { | ||
3859 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3860 | std::fmt::Display::fmt(self.syntax(), f) | ||
3861 | } | ||
3862 | } | ||
3863 | impl std::fmt::Display for MatchArm { | ||
3864 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3865 | std::fmt::Display::fmt(self.syntax(), f) | ||
3866 | } | ||
3867 | } | ||
3868 | impl std::fmt::Display for MatchGuard { | ||
3869 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3870 | std::fmt::Display::fmt(self.syntax(), f) | ||
3871 | } | ||
3872 | } | ||
3873 | impl std::fmt::Display for RecordLit { | ||
3874 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3875 | std::fmt::Display::fmt(self.syntax(), f) | ||
3876 | } | ||
3877 | } | ||
3878 | impl std::fmt::Display for RecordFieldList { | ||
3879 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3880 | std::fmt::Display::fmt(self.syntax(), f) | ||
3881 | } | ||
3882 | } | ||
3883 | impl std::fmt::Display for RecordField { | ||
3884 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3885 | std::fmt::Display::fmt(self.syntax(), f) | ||
3886 | } | ||
3887 | } | ||
3888 | impl std::fmt::Display for OrPat { | ||
3889 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3890 | std::fmt::Display::fmt(self.syntax(), f) | ||
3891 | } | ||
3892 | } | ||
3893 | impl std::fmt::Display for ParenPat { | ||
3894 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3895 | std::fmt::Display::fmt(self.syntax(), f) | ||
3896 | } | ||
3897 | } | ||
3898 | impl std::fmt::Display for RefPat { | ||
3899 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3900 | std::fmt::Display::fmt(self.syntax(), f) | ||
3901 | } | ||
3902 | } | ||
3903 | impl std::fmt::Display for BoxPat { | ||
3904 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3905 | std::fmt::Display::fmt(self.syntax(), f) | ||
3906 | } | ||
3907 | } | ||
3908 | impl std::fmt::Display for BindPat { | ||
3909 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3910 | std::fmt::Display::fmt(self.syntax(), f) | ||
3911 | } | ||
3912 | } | ||
3913 | impl std::fmt::Display for PlaceholderPat { | ||
3914 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3915 | std::fmt::Display::fmt(self.syntax(), f) | ||
3916 | } | ||
3917 | } | ||
3918 | impl std::fmt::Display for DotDotPat { | ||
3919 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3920 | std::fmt::Display::fmt(self.syntax(), f) | ||
3921 | } | ||
3922 | } | ||
3923 | impl std::fmt::Display for PathPat { | ||
3924 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3925 | std::fmt::Display::fmt(self.syntax(), f) | ||
3926 | } | ||
3927 | } | ||
3928 | impl std::fmt::Display for SlicePat { | ||
3929 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3930 | std::fmt::Display::fmt(self.syntax(), f) | ||
3931 | } | ||
3932 | } | ||
3933 | impl std::fmt::Display for RangePat { | ||
3934 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3935 | std::fmt::Display::fmt(self.syntax(), f) | ||
3936 | } | ||
3937 | } | ||
3938 | impl std::fmt::Display for LiteralPat { | ||
3939 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3940 | std::fmt::Display::fmt(self.syntax(), f) | ||
3941 | } | ||
3942 | } | ||
3943 | impl std::fmt::Display for MacroPat { | ||
3944 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3945 | std::fmt::Display::fmt(self.syntax(), f) | ||
3946 | } | ||
3947 | } | ||
3948 | impl std::fmt::Display for RecordPat { | ||
3949 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3950 | std::fmt::Display::fmt(self.syntax(), f) | ||
3951 | } | ||
3952 | } | ||
3953 | impl std::fmt::Display for RecordFieldPatList { | ||
3954 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3955 | std::fmt::Display::fmt(self.syntax(), f) | ||
3956 | } | ||
3957 | } | ||
3958 | impl std::fmt::Display for RecordFieldPat { | ||
3959 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3960 | std::fmt::Display::fmt(self.syntax(), f) | ||
3961 | } | ||
3962 | } | ||
3963 | impl std::fmt::Display for TupleStructPat { | ||
3964 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3965 | std::fmt::Display::fmt(self.syntax(), f) | ||
3966 | } | ||
3967 | } | ||
3968 | impl std::fmt::Display for TuplePat { | ||
3969 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3970 | std::fmt::Display::fmt(self.syntax(), f) | ||
3971 | } | ||
3972 | } | ||
3973 | impl std::fmt::Display for Visibility { | ||
3974 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3975 | std::fmt::Display::fmt(self.syntax(), f) | ||
3976 | } | ||
3977 | } | ||
3978 | impl std::fmt::Display for Name { | ||
3979 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3980 | std::fmt::Display::fmt(self.syntax(), f) | ||
3981 | } | ||
3982 | } | ||
3983 | impl std::fmt::Display for NameRef { | ||
3984 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3985 | std::fmt::Display::fmt(self.syntax(), f) | ||
3986 | } | ||
3987 | } | ||
3988 | impl std::fmt::Display for MacroCall { | ||
3989 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3990 | std::fmt::Display::fmt(self.syntax(), f) | ||
3991 | } | ||
3992 | } | ||
3993 | impl std::fmt::Display for Attr { | ||
3994 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
3995 | std::fmt::Display::fmt(self.syntax(), f) | ||
3996 | } | ||
3997 | } | ||
3998 | impl std::fmt::Display for TokenTree { | ||
3999 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4000 | std::fmt::Display::fmt(self.syntax(), f) | ||
4001 | } | ||
4002 | } | ||
4003 | impl std::fmt::Display for TypeParamList { | ||
4004 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4005 | std::fmt::Display::fmt(self.syntax(), f) | ||
4006 | } | ||
4007 | } | ||
4008 | impl std::fmt::Display for TypeParam { | ||
4009 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4010 | std::fmt::Display::fmt(self.syntax(), f) | ||
4011 | } | ||
4012 | } | ||
4013 | impl std::fmt::Display for ConstParam { | ||
4014 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4015 | std::fmt::Display::fmt(self.syntax(), f) | ||
4016 | } | ||
4017 | } | ||
4018 | impl std::fmt::Display for LifetimeParam { | ||
4019 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4020 | std::fmt::Display::fmt(self.syntax(), f) | ||
4021 | } | ||
4022 | } | ||
4023 | impl std::fmt::Display for TypeBound { | ||
4024 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4025 | std::fmt::Display::fmt(self.syntax(), f) | ||
4026 | } | ||
4027 | } | ||
4028 | impl std::fmt::Display for TypeBoundList { | ||
4029 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4030 | std::fmt::Display::fmt(self.syntax(), f) | ||
4031 | } | ||
4032 | } | ||
4033 | impl std::fmt::Display for WherePred { | ||
4034 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4035 | std::fmt::Display::fmt(self.syntax(), f) | ||
4036 | } | ||
4037 | } | ||
4038 | impl std::fmt::Display for WhereClause { | ||
4039 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4040 | std::fmt::Display::fmt(self.syntax(), f) | ||
4041 | } | ||
4042 | } | ||
4043 | impl std::fmt::Display for Abi { | ||
4044 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4045 | std::fmt::Display::fmt(self.syntax(), f) | ||
4046 | } | ||
4047 | } | ||
4048 | impl std::fmt::Display for ExprStmt { | ||
4049 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4050 | std::fmt::Display::fmt(self.syntax(), f) | ||
4051 | } | ||
4052 | } | ||
4053 | impl std::fmt::Display for LetStmt { | ||
4054 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4055 | std::fmt::Display::fmt(self.syntax(), f) | ||
4056 | } | ||
4057 | } | ||
4058 | impl std::fmt::Display for Condition { | ||
4059 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4060 | std::fmt::Display::fmt(self.syntax(), f) | ||
4061 | } | ||
4062 | } | ||
4063 | impl std::fmt::Display for Block { | ||
4064 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4065 | std::fmt::Display::fmt(self.syntax(), f) | ||
4066 | } | ||
4067 | } | ||
4068 | impl std::fmt::Display for ParamList { | ||
4069 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4070 | std::fmt::Display::fmt(self.syntax(), f) | ||
4071 | } | ||
4072 | } | ||
4073 | impl std::fmt::Display for SelfParam { | ||
4074 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4075 | std::fmt::Display::fmt(self.syntax(), f) | ||
4076 | } | ||
4077 | } | ||
4078 | impl std::fmt::Display for Param { | ||
4079 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4080 | std::fmt::Display::fmt(self.syntax(), f) | ||
4081 | } | ||
4082 | } | ||
4083 | impl std::fmt::Display for UseItem { | ||
4084 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4085 | std::fmt::Display::fmt(self.syntax(), f) | ||
4086 | } | ||
4087 | } | ||
4088 | impl std::fmt::Display for UseTree { | ||
4089 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4090 | std::fmt::Display::fmt(self.syntax(), f) | ||
4091 | } | ||
4092 | } | ||
4093 | impl std::fmt::Display for Alias { | ||
4094 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4095 | std::fmt::Display::fmt(self.syntax(), f) | ||
4096 | } | ||
4097 | } | ||
4098 | impl std::fmt::Display for UseTreeList { | ||
4099 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4100 | std::fmt::Display::fmt(self.syntax(), f) | ||
4101 | } | ||
4102 | } | ||
4103 | impl std::fmt::Display for ExternCrateItem { | ||
4104 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4105 | std::fmt::Display::fmt(self.syntax(), f) | ||
4106 | } | ||
4107 | } | ||
4108 | impl std::fmt::Display for ArgList { | ||
4109 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4110 | std::fmt::Display::fmt(self.syntax(), f) | ||
4111 | } | ||
4112 | } | ||
4113 | impl std::fmt::Display for Path { | ||
4114 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4115 | std::fmt::Display::fmt(self.syntax(), f) | ||
4116 | } | ||
4117 | } | ||
4118 | impl std::fmt::Display for PathSegment { | ||
4119 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4120 | std::fmt::Display::fmt(self.syntax(), f) | ||
4121 | } | ||
4122 | } | ||
4123 | impl std::fmt::Display for TypeArgList { | ||
4124 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4125 | std::fmt::Display::fmt(self.syntax(), f) | ||
4126 | } | ||
4127 | } | ||
4128 | impl std::fmt::Display for TypeArg { | ||
4129 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4130 | std::fmt::Display::fmt(self.syntax(), f) | ||
4131 | } | ||
4132 | } | ||
4133 | impl std::fmt::Display for AssocTypeArg { | ||
4134 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4135 | std::fmt::Display::fmt(self.syntax(), f) | ||
4136 | } | ||
4137 | } | ||
4138 | impl std::fmt::Display for LifetimeArg { | ||
4139 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4140 | std::fmt::Display::fmt(self.syntax(), f) | ||
4141 | } | ||
4142 | } | ||
4143 | impl std::fmt::Display for ConstArg { | ||
4144 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4145 | std::fmt::Display::fmt(self.syntax(), f) | ||
4146 | } | ||
4147 | } | ||
4148 | impl std::fmt::Display for MacroItems { | ||
4149 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4150 | std::fmt::Display::fmt(self.syntax(), f) | ||
4151 | } | ||
4152 | } | ||
4153 | impl std::fmt::Display for MacroStmts { | ||
4154 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4155 | std::fmt::Display::fmt(self.syntax(), f) | ||
4156 | } | ||
4157 | } | ||
4158 | impl std::fmt::Display for ExternItemList { | ||
4159 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4160 | std::fmt::Display::fmt(self.syntax(), f) | ||
4161 | } | ||
4162 | } | ||
4163 | impl std::fmt::Display for ExternBlock { | ||
4164 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4165 | std::fmt::Display::fmt(self.syntax(), f) | ||
4166 | } | ||
4167 | } | ||
4168 | impl std::fmt::Display for MetaItem { | ||
4169 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4170 | std::fmt::Display::fmt(self.syntax(), f) | ||
4171 | } | ||
4172 | } | ||
4173 | impl std::fmt::Display for MacroDef { | ||
4174 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
4175 | std::fmt::Display::fmt(self.syntax(), f) | ||
4176 | } | ||
4177 | } | ||
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs new file mode 100644 index 000000000..e64b8bce6 --- /dev/null +++ b/crates/ra_syntax/src/ast/generated/tokens.rs | |||
@@ -0,0 +1,2808 @@ | |||
1 | //! Generated file, do not edit by hand, see `xtask/src/codegen` | ||
2 | |||
3 | use crate::{ | ||
4 | ast::AstToken, | ||
5 | SyntaxKind::{self, *}, | ||
6 | SyntaxToken, | ||
7 | }; | ||
8 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
9 | pub struct Semi { | ||
10 | pub(crate) syntax: SyntaxToken, | ||
11 | } | ||
12 | impl std::fmt::Display for Semi { | ||
13 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
14 | std::fmt::Display::fmt(&self.syntax, f) | ||
15 | } | ||
16 | } | ||
17 | impl AstToken for Semi { | ||
18 | fn can_cast(kind: SyntaxKind) -> bool { kind == SEMI } | ||
19 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
20 | if Self::can_cast(syntax.kind()) { | ||
21 | Some(Self { syntax }) | ||
22 | } else { | ||
23 | None | ||
24 | } | ||
25 | } | ||
26 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
27 | } | ||
28 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
29 | pub struct Comma { | ||
30 | pub(crate) syntax: SyntaxToken, | ||
31 | } | ||
32 | impl std::fmt::Display for Comma { | ||
33 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
34 | std::fmt::Display::fmt(&self.syntax, f) | ||
35 | } | ||
36 | } | ||
37 | impl AstToken for Comma { | ||
38 | fn can_cast(kind: SyntaxKind) -> bool { kind == COMMA } | ||
39 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
40 | if Self::can_cast(syntax.kind()) { | ||
41 | Some(Self { syntax }) | ||
42 | } else { | ||
43 | None | ||
44 | } | ||
45 | } | ||
46 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
47 | } | ||
48 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
49 | pub struct LParen { | ||
50 | pub(crate) syntax: SyntaxToken, | ||
51 | } | ||
52 | impl std::fmt::Display for LParen { | ||
53 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
54 | std::fmt::Display::fmt(&self.syntax, f) | ||
55 | } | ||
56 | } | ||
57 | impl AstToken for LParen { | ||
58 | fn can_cast(kind: SyntaxKind) -> bool { kind == L_PAREN } | ||
59 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
60 | if Self::can_cast(syntax.kind()) { | ||
61 | Some(Self { syntax }) | ||
62 | } else { | ||
63 | None | ||
64 | } | ||
65 | } | ||
66 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
67 | } | ||
68 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
69 | pub struct RParen { | ||
70 | pub(crate) syntax: SyntaxToken, | ||
71 | } | ||
72 | impl std::fmt::Display for RParen { | ||
73 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
74 | std::fmt::Display::fmt(&self.syntax, f) | ||
75 | } | ||
76 | } | ||
77 | impl AstToken for RParen { | ||
78 | fn can_cast(kind: SyntaxKind) -> bool { kind == R_PAREN } | ||
79 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
80 | if Self::can_cast(syntax.kind()) { | ||
81 | Some(Self { syntax }) | ||
82 | } else { | ||
83 | None | ||
84 | } | ||
85 | } | ||
86 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
87 | } | ||
88 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
89 | pub struct LCurly { | ||
90 | pub(crate) syntax: SyntaxToken, | ||
91 | } | ||
92 | impl std::fmt::Display for LCurly { | ||
93 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
94 | std::fmt::Display::fmt(&self.syntax, f) | ||
95 | } | ||
96 | } | ||
97 | impl AstToken for LCurly { | ||
98 | fn can_cast(kind: SyntaxKind) -> bool { kind == L_CURLY } | ||
99 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
100 | if Self::can_cast(syntax.kind()) { | ||
101 | Some(Self { syntax }) | ||
102 | } else { | ||
103 | None | ||
104 | } | ||
105 | } | ||
106 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
107 | } | ||
108 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
109 | pub struct RCurly { | ||
110 | pub(crate) syntax: SyntaxToken, | ||
111 | } | ||
112 | impl std::fmt::Display for RCurly { | ||
113 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
114 | std::fmt::Display::fmt(&self.syntax, f) | ||
115 | } | ||
116 | } | ||
117 | impl AstToken for RCurly { | ||
118 | fn can_cast(kind: SyntaxKind) -> bool { kind == R_CURLY } | ||
119 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
120 | if Self::can_cast(syntax.kind()) { | ||
121 | Some(Self { syntax }) | ||
122 | } else { | ||
123 | None | ||
124 | } | ||
125 | } | ||
126 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
127 | } | ||
128 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
129 | pub struct LBrack { | ||
130 | pub(crate) syntax: SyntaxToken, | ||
131 | } | ||
132 | impl std::fmt::Display for LBrack { | ||
133 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
134 | std::fmt::Display::fmt(&self.syntax, f) | ||
135 | } | ||
136 | } | ||
137 | impl AstToken for LBrack { | ||
138 | fn can_cast(kind: SyntaxKind) -> bool { kind == L_BRACK } | ||
139 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
140 | if Self::can_cast(syntax.kind()) { | ||
141 | Some(Self { syntax }) | ||
142 | } else { | ||
143 | None | ||
144 | } | ||
145 | } | ||
146 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
147 | } | ||
148 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
149 | pub struct RBrack { | ||
150 | pub(crate) syntax: SyntaxToken, | ||
151 | } | ||
152 | impl std::fmt::Display for RBrack { | ||
153 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
154 | std::fmt::Display::fmt(&self.syntax, f) | ||
155 | } | ||
156 | } | ||
157 | impl AstToken for RBrack { | ||
158 | fn can_cast(kind: SyntaxKind) -> bool { kind == R_BRACK } | ||
159 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
160 | if Self::can_cast(syntax.kind()) { | ||
161 | Some(Self { syntax }) | ||
162 | } else { | ||
163 | None | ||
164 | } | ||
165 | } | ||
166 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
167 | } | ||
168 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
169 | pub struct LAngle { | ||
170 | pub(crate) syntax: SyntaxToken, | ||
171 | } | ||
172 | impl std::fmt::Display for LAngle { | ||
173 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
174 | std::fmt::Display::fmt(&self.syntax, f) | ||
175 | } | ||
176 | } | ||
177 | impl AstToken for LAngle { | ||
178 | fn can_cast(kind: SyntaxKind) -> bool { kind == L_ANGLE } | ||
179 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
180 | if Self::can_cast(syntax.kind()) { | ||
181 | Some(Self { syntax }) | ||
182 | } else { | ||
183 | None | ||
184 | } | ||
185 | } | ||
186 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
187 | } | ||
188 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
189 | pub struct RAngle { | ||
190 | pub(crate) syntax: SyntaxToken, | ||
191 | } | ||
192 | impl std::fmt::Display for RAngle { | ||
193 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
194 | std::fmt::Display::fmt(&self.syntax, f) | ||
195 | } | ||
196 | } | ||
197 | impl AstToken for RAngle { | ||
198 | fn can_cast(kind: SyntaxKind) -> bool { kind == R_ANGLE } | ||
199 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
200 | if Self::can_cast(syntax.kind()) { | ||
201 | Some(Self { syntax }) | ||
202 | } else { | ||
203 | None | ||
204 | } | ||
205 | } | ||
206 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
207 | } | ||
208 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
209 | pub struct At { | ||
210 | pub(crate) syntax: SyntaxToken, | ||
211 | } | ||
212 | impl std::fmt::Display for At { | ||
213 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
214 | std::fmt::Display::fmt(&self.syntax, f) | ||
215 | } | ||
216 | } | ||
217 | impl AstToken for At { | ||
218 | fn can_cast(kind: SyntaxKind) -> bool { kind == AT } | ||
219 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
220 | if Self::can_cast(syntax.kind()) { | ||
221 | Some(Self { syntax }) | ||
222 | } else { | ||
223 | None | ||
224 | } | ||
225 | } | ||
226 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
227 | } | ||
228 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
229 | pub struct Pound { | ||
230 | pub(crate) syntax: SyntaxToken, | ||
231 | } | ||
232 | impl std::fmt::Display for Pound { | ||
233 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
234 | std::fmt::Display::fmt(&self.syntax, f) | ||
235 | } | ||
236 | } | ||
237 | impl AstToken for Pound { | ||
238 | fn can_cast(kind: SyntaxKind) -> bool { kind == POUND } | ||
239 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
240 | if Self::can_cast(syntax.kind()) { | ||
241 | Some(Self { syntax }) | ||
242 | } else { | ||
243 | None | ||
244 | } | ||
245 | } | ||
246 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
247 | } | ||
248 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
249 | pub struct Tilde { | ||
250 | pub(crate) syntax: SyntaxToken, | ||
251 | } | ||
252 | impl std::fmt::Display for Tilde { | ||
253 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
254 | std::fmt::Display::fmt(&self.syntax, f) | ||
255 | } | ||
256 | } | ||
257 | impl AstToken for Tilde { | ||
258 | fn can_cast(kind: SyntaxKind) -> bool { kind == TILDE } | ||
259 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
260 | if Self::can_cast(syntax.kind()) { | ||
261 | Some(Self { syntax }) | ||
262 | } else { | ||
263 | None | ||
264 | } | ||
265 | } | ||
266 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
267 | } | ||
268 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
269 | pub struct Question { | ||
270 | pub(crate) syntax: SyntaxToken, | ||
271 | } | ||
272 | impl std::fmt::Display for Question { | ||
273 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
274 | std::fmt::Display::fmt(&self.syntax, f) | ||
275 | } | ||
276 | } | ||
277 | impl AstToken for Question { | ||
278 | fn can_cast(kind: SyntaxKind) -> bool { kind == QUESTION } | ||
279 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
280 | if Self::can_cast(syntax.kind()) { | ||
281 | Some(Self { syntax }) | ||
282 | } else { | ||
283 | None | ||
284 | } | ||
285 | } | ||
286 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
287 | } | ||
288 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
289 | pub struct Dollar { | ||
290 | pub(crate) syntax: SyntaxToken, | ||
291 | } | ||
292 | impl std::fmt::Display for Dollar { | ||
293 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
294 | std::fmt::Display::fmt(&self.syntax, f) | ||
295 | } | ||
296 | } | ||
297 | impl AstToken for Dollar { | ||
298 | fn can_cast(kind: SyntaxKind) -> bool { kind == DOLLAR } | ||
299 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
300 | if Self::can_cast(syntax.kind()) { | ||
301 | Some(Self { syntax }) | ||
302 | } else { | ||
303 | None | ||
304 | } | ||
305 | } | ||
306 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
307 | } | ||
308 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
309 | pub struct Amp { | ||
310 | pub(crate) syntax: SyntaxToken, | ||
311 | } | ||
312 | impl std::fmt::Display for Amp { | ||
313 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
314 | std::fmt::Display::fmt(&self.syntax, f) | ||
315 | } | ||
316 | } | ||
317 | impl AstToken for Amp { | ||
318 | fn can_cast(kind: SyntaxKind) -> bool { kind == AMP } | ||
319 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
320 | if Self::can_cast(syntax.kind()) { | ||
321 | Some(Self { syntax }) | ||
322 | } else { | ||
323 | None | ||
324 | } | ||
325 | } | ||
326 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
327 | } | ||
328 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
329 | pub struct Pipe { | ||
330 | pub(crate) syntax: SyntaxToken, | ||
331 | } | ||
332 | impl std::fmt::Display for Pipe { | ||
333 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
334 | std::fmt::Display::fmt(&self.syntax, f) | ||
335 | } | ||
336 | } | ||
337 | impl AstToken for Pipe { | ||
338 | fn can_cast(kind: SyntaxKind) -> bool { kind == PIPE } | ||
339 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
340 | if Self::can_cast(syntax.kind()) { | ||
341 | Some(Self { syntax }) | ||
342 | } else { | ||
343 | None | ||
344 | } | ||
345 | } | ||
346 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
347 | } | ||
348 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
349 | pub struct Plus { | ||
350 | pub(crate) syntax: SyntaxToken, | ||
351 | } | ||
352 | impl std::fmt::Display for Plus { | ||
353 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
354 | std::fmt::Display::fmt(&self.syntax, f) | ||
355 | } | ||
356 | } | ||
357 | impl AstToken for Plus { | ||
358 | fn can_cast(kind: SyntaxKind) -> bool { kind == PLUS } | ||
359 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
360 | if Self::can_cast(syntax.kind()) { | ||
361 | Some(Self { syntax }) | ||
362 | } else { | ||
363 | None | ||
364 | } | ||
365 | } | ||
366 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
367 | } | ||
368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
369 | pub struct Star { | ||
370 | pub(crate) syntax: SyntaxToken, | ||
371 | } | ||
372 | impl std::fmt::Display for Star { | ||
373 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
374 | std::fmt::Display::fmt(&self.syntax, f) | ||
375 | } | ||
376 | } | ||
377 | impl AstToken for Star { | ||
378 | fn can_cast(kind: SyntaxKind) -> bool { kind == STAR } | ||
379 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
380 | if Self::can_cast(syntax.kind()) { | ||
381 | Some(Self { syntax }) | ||
382 | } else { | ||
383 | None | ||
384 | } | ||
385 | } | ||
386 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
387 | } | ||
388 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
389 | pub struct Slash { | ||
390 | pub(crate) syntax: SyntaxToken, | ||
391 | } | ||
392 | impl std::fmt::Display for Slash { | ||
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 Slash { | ||
398 | fn can_cast(kind: SyntaxKind) -> bool { kind == SLASH } | ||
399 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
400 | if Self::can_cast(syntax.kind()) { | ||
401 | Some(Self { syntax }) | ||
402 | } else { | ||
403 | None | ||
404 | } | ||
405 | } | ||
406 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
407 | } | ||
408 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
409 | pub struct Caret { | ||
410 | pub(crate) syntax: SyntaxToken, | ||
411 | } | ||
412 | impl std::fmt::Display for Caret { | ||
413 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
414 | std::fmt::Display::fmt(&self.syntax, f) | ||
415 | } | ||
416 | } | ||
417 | impl AstToken for Caret { | ||
418 | fn can_cast(kind: SyntaxKind) -> bool { kind == CARET } | ||
419 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
420 | if Self::can_cast(syntax.kind()) { | ||
421 | Some(Self { syntax }) | ||
422 | } else { | ||
423 | None | ||
424 | } | ||
425 | } | ||
426 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
427 | } | ||
428 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
429 | pub struct Percent { | ||
430 | pub(crate) syntax: SyntaxToken, | ||
431 | } | ||
432 | impl std::fmt::Display for Percent { | ||
433 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
434 | std::fmt::Display::fmt(&self.syntax, f) | ||
435 | } | ||
436 | } | ||
437 | impl AstToken for Percent { | ||
438 | fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENT } | ||
439 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
440 | if Self::can_cast(syntax.kind()) { | ||
441 | Some(Self { syntax }) | ||
442 | } else { | ||
443 | None | ||
444 | } | ||
445 | } | ||
446 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
447 | } | ||
448 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
449 | pub struct Underscore { | ||
450 | pub(crate) syntax: SyntaxToken, | ||
451 | } | ||
452 | impl std::fmt::Display for Underscore { | ||
453 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
454 | std::fmt::Display::fmt(&self.syntax, f) | ||
455 | } | ||
456 | } | ||
457 | impl AstToken for Underscore { | ||
458 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNDERSCORE } | ||
459 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
460 | if Self::can_cast(syntax.kind()) { | ||
461 | Some(Self { syntax }) | ||
462 | } else { | ||
463 | None | ||
464 | } | ||
465 | } | ||
466 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
467 | } | ||
468 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
469 | pub struct Dot { | ||
470 | pub(crate) syntax: SyntaxToken, | ||
471 | } | ||
472 | impl std::fmt::Display for Dot { | ||
473 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
474 | std::fmt::Display::fmt(&self.syntax, f) | ||
475 | } | ||
476 | } | ||
477 | impl AstToken for Dot { | ||
478 | fn can_cast(kind: SyntaxKind) -> bool { kind == DOT } | ||
479 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
480 | if Self::can_cast(syntax.kind()) { | ||
481 | Some(Self { syntax }) | ||
482 | } else { | ||
483 | None | ||
484 | } | ||
485 | } | ||
486 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
487 | } | ||
488 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
489 | pub struct Dotdot { | ||
490 | pub(crate) syntax: SyntaxToken, | ||
491 | } | ||
492 | impl std::fmt::Display for Dotdot { | ||
493 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
494 | std::fmt::Display::fmt(&self.syntax, f) | ||
495 | } | ||
496 | } | ||
497 | impl AstToken for Dotdot { | ||
498 | fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOT } | ||
499 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
500 | if Self::can_cast(syntax.kind()) { | ||
501 | Some(Self { syntax }) | ||
502 | } else { | ||
503 | None | ||
504 | } | ||
505 | } | ||
506 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
507 | } | ||
508 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
509 | pub struct Dotdotdot { | ||
510 | pub(crate) syntax: SyntaxToken, | ||
511 | } | ||
512 | impl std::fmt::Display for Dotdotdot { | ||
513 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
514 | std::fmt::Display::fmt(&self.syntax, f) | ||
515 | } | ||
516 | } | ||
517 | impl AstToken for Dotdotdot { | ||
518 | fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTDOT } | ||
519 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
520 | if Self::can_cast(syntax.kind()) { | ||
521 | Some(Self { syntax }) | ||
522 | } else { | ||
523 | None | ||
524 | } | ||
525 | } | ||
526 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
527 | } | ||
528 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
529 | pub struct Dotdoteq { | ||
530 | pub(crate) syntax: SyntaxToken, | ||
531 | } | ||
532 | impl std::fmt::Display for Dotdoteq { | ||
533 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
534 | std::fmt::Display::fmt(&self.syntax, f) | ||
535 | } | ||
536 | } | ||
537 | impl AstToken for Dotdoteq { | ||
538 | fn can_cast(kind: SyntaxKind) -> bool { kind == DOTDOTEQ } | ||
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 { &self.syntax } | ||
547 | } | ||
548 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
549 | pub struct Colon { | ||
550 | pub(crate) syntax: SyntaxToken, | ||
551 | } | ||
552 | impl std::fmt::Display for Colon { | ||
553 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
554 | std::fmt::Display::fmt(&self.syntax, f) | ||
555 | } | ||
556 | } | ||
557 | impl AstToken for Colon { | ||
558 | fn can_cast(kind: SyntaxKind) -> bool { kind == COLON } | ||
559 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
560 | if Self::can_cast(syntax.kind()) { | ||
561 | Some(Self { syntax }) | ||
562 | } else { | ||
563 | None | ||
564 | } | ||
565 | } | ||
566 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
567 | } | ||
568 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
569 | pub struct Coloncolon { | ||
570 | pub(crate) syntax: SyntaxToken, | ||
571 | } | ||
572 | impl std::fmt::Display for Coloncolon { | ||
573 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
574 | std::fmt::Display::fmt(&self.syntax, f) | ||
575 | } | ||
576 | } | ||
577 | impl AstToken for Coloncolon { | ||
578 | fn can_cast(kind: SyntaxKind) -> bool { kind == COLONCOLON } | ||
579 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
580 | if Self::can_cast(syntax.kind()) { | ||
581 | Some(Self { syntax }) | ||
582 | } else { | ||
583 | None | ||
584 | } | ||
585 | } | ||
586 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
587 | } | ||
588 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
589 | pub struct Eq { | ||
590 | pub(crate) syntax: SyntaxToken, | ||
591 | } | ||
592 | impl std::fmt::Display for Eq { | ||
593 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
594 | std::fmt::Display::fmt(&self.syntax, f) | ||
595 | } | ||
596 | } | ||
597 | impl AstToken for Eq { | ||
598 | fn can_cast(kind: SyntaxKind) -> bool { kind == EQ } | ||
599 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
600 | if Self::can_cast(syntax.kind()) { | ||
601 | Some(Self { syntax }) | ||
602 | } else { | ||
603 | None | ||
604 | } | ||
605 | } | ||
606 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
607 | } | ||
608 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
609 | pub struct Eqeq { | ||
610 | pub(crate) syntax: SyntaxToken, | ||
611 | } | ||
612 | impl std::fmt::Display for Eqeq { | ||
613 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
614 | std::fmt::Display::fmt(&self.syntax, f) | ||
615 | } | ||
616 | } | ||
617 | impl AstToken for Eqeq { | ||
618 | fn can_cast(kind: SyntaxKind) -> bool { kind == EQEQ } | ||
619 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
620 | if Self::can_cast(syntax.kind()) { | ||
621 | Some(Self { syntax }) | ||
622 | } else { | ||
623 | None | ||
624 | } | ||
625 | } | ||
626 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
627 | } | ||
628 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
629 | pub struct FatArrow { | ||
630 | pub(crate) syntax: SyntaxToken, | ||
631 | } | ||
632 | impl std::fmt::Display for FatArrow { | ||
633 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
634 | std::fmt::Display::fmt(&self.syntax, f) | ||
635 | } | ||
636 | } | ||
637 | impl AstToken for FatArrow { | ||
638 | fn can_cast(kind: SyntaxKind) -> bool { kind == FAT_ARROW } | ||
639 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
640 | if Self::can_cast(syntax.kind()) { | ||
641 | Some(Self { syntax }) | ||
642 | } else { | ||
643 | None | ||
644 | } | ||
645 | } | ||
646 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
647 | } | ||
648 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
649 | pub struct Excl { | ||
650 | pub(crate) syntax: SyntaxToken, | ||
651 | } | ||
652 | impl std::fmt::Display for Excl { | ||
653 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
654 | std::fmt::Display::fmt(&self.syntax, f) | ||
655 | } | ||
656 | } | ||
657 | impl AstToken for Excl { | ||
658 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXCL } | ||
659 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
660 | if Self::can_cast(syntax.kind()) { | ||
661 | Some(Self { syntax }) | ||
662 | } else { | ||
663 | None | ||
664 | } | ||
665 | } | ||
666 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
667 | } | ||
668 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
669 | pub struct Neq { | ||
670 | pub(crate) syntax: SyntaxToken, | ||
671 | } | ||
672 | impl std::fmt::Display for Neq { | ||
673 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
674 | std::fmt::Display::fmt(&self.syntax, f) | ||
675 | } | ||
676 | } | ||
677 | impl AstToken for Neq { | ||
678 | fn can_cast(kind: SyntaxKind) -> bool { kind == NEQ } | ||
679 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
680 | if Self::can_cast(syntax.kind()) { | ||
681 | Some(Self { syntax }) | ||
682 | } else { | ||
683 | None | ||
684 | } | ||
685 | } | ||
686 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
687 | } | ||
688 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
689 | pub struct Minus { | ||
690 | pub(crate) syntax: SyntaxToken, | ||
691 | } | ||
692 | impl std::fmt::Display for Minus { | ||
693 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
694 | std::fmt::Display::fmt(&self.syntax, f) | ||
695 | } | ||
696 | } | ||
697 | impl AstToken for Minus { | ||
698 | fn can_cast(kind: SyntaxKind) -> bool { kind == MINUS } | ||
699 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
700 | if Self::can_cast(syntax.kind()) { | ||
701 | Some(Self { syntax }) | ||
702 | } else { | ||
703 | None | ||
704 | } | ||
705 | } | ||
706 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
707 | } | ||
708 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
709 | pub struct ThinArrow { | ||
710 | pub(crate) syntax: SyntaxToken, | ||
711 | } | ||
712 | impl std::fmt::Display for ThinArrow { | ||
713 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
714 | std::fmt::Display::fmt(&self.syntax, f) | ||
715 | } | ||
716 | } | ||
717 | impl AstToken for ThinArrow { | ||
718 | fn can_cast(kind: SyntaxKind) -> bool { kind == THIN_ARROW } | ||
719 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
720 | if Self::can_cast(syntax.kind()) { | ||
721 | Some(Self { syntax }) | ||
722 | } else { | ||
723 | None | ||
724 | } | ||
725 | } | ||
726 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
727 | } | ||
728 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
729 | pub struct Lteq { | ||
730 | pub(crate) syntax: SyntaxToken, | ||
731 | } | ||
732 | impl std::fmt::Display for Lteq { | ||
733 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
734 | std::fmt::Display::fmt(&self.syntax, f) | ||
735 | } | ||
736 | } | ||
737 | impl AstToken for Lteq { | ||
738 | fn can_cast(kind: SyntaxKind) -> bool { kind == LTEQ } | ||
739 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
740 | if Self::can_cast(syntax.kind()) { | ||
741 | Some(Self { syntax }) | ||
742 | } else { | ||
743 | None | ||
744 | } | ||
745 | } | ||
746 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
747 | } | ||
748 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
749 | pub struct Gteq { | ||
750 | pub(crate) syntax: SyntaxToken, | ||
751 | } | ||
752 | impl std::fmt::Display for Gteq { | ||
753 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
754 | std::fmt::Display::fmt(&self.syntax, f) | ||
755 | } | ||
756 | } | ||
757 | impl AstToken for Gteq { | ||
758 | fn can_cast(kind: SyntaxKind) -> bool { kind == GTEQ } | ||
759 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
760 | if Self::can_cast(syntax.kind()) { | ||
761 | Some(Self { syntax }) | ||
762 | } else { | ||
763 | None | ||
764 | } | ||
765 | } | ||
766 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
767 | } | ||
768 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
769 | pub struct Pluseq { | ||
770 | pub(crate) syntax: SyntaxToken, | ||
771 | } | ||
772 | impl std::fmt::Display for Pluseq { | ||
773 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
774 | std::fmt::Display::fmt(&self.syntax, f) | ||
775 | } | ||
776 | } | ||
777 | impl AstToken for Pluseq { | ||
778 | fn can_cast(kind: SyntaxKind) -> bool { kind == PLUSEQ } | ||
779 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
780 | if Self::can_cast(syntax.kind()) { | ||
781 | Some(Self { syntax }) | ||
782 | } else { | ||
783 | None | ||
784 | } | ||
785 | } | ||
786 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
787 | } | ||
788 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
789 | pub struct Minuseq { | ||
790 | pub(crate) syntax: SyntaxToken, | ||
791 | } | ||
792 | impl std::fmt::Display for Minuseq { | ||
793 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
794 | std::fmt::Display::fmt(&self.syntax, f) | ||
795 | } | ||
796 | } | ||
797 | impl AstToken for Minuseq { | ||
798 | fn can_cast(kind: SyntaxKind) -> bool { kind == MINUSEQ } | ||
799 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
800 | if Self::can_cast(syntax.kind()) { | ||
801 | Some(Self { syntax }) | ||
802 | } else { | ||
803 | None | ||
804 | } | ||
805 | } | ||
806 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
807 | } | ||
808 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
809 | pub struct Pipeeq { | ||
810 | pub(crate) syntax: SyntaxToken, | ||
811 | } | ||
812 | impl std::fmt::Display for Pipeeq { | ||
813 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
814 | std::fmt::Display::fmt(&self.syntax, f) | ||
815 | } | ||
816 | } | ||
817 | impl AstToken for Pipeeq { | ||
818 | fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEEQ } | ||
819 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
820 | if Self::can_cast(syntax.kind()) { | ||
821 | Some(Self { syntax }) | ||
822 | } else { | ||
823 | None | ||
824 | } | ||
825 | } | ||
826 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
827 | } | ||
828 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
829 | pub struct Ampeq { | ||
830 | pub(crate) syntax: SyntaxToken, | ||
831 | } | ||
832 | impl std::fmt::Display for Ampeq { | ||
833 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
834 | std::fmt::Display::fmt(&self.syntax, f) | ||
835 | } | ||
836 | } | ||
837 | impl AstToken for Ampeq { | ||
838 | fn can_cast(kind: SyntaxKind) -> bool { kind == AMPEQ } | ||
839 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
840 | if Self::can_cast(syntax.kind()) { | ||
841 | Some(Self { syntax }) | ||
842 | } else { | ||
843 | None | ||
844 | } | ||
845 | } | ||
846 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
847 | } | ||
848 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
849 | pub struct Careteq { | ||
850 | pub(crate) syntax: SyntaxToken, | ||
851 | } | ||
852 | impl std::fmt::Display for Careteq { | ||
853 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
854 | std::fmt::Display::fmt(&self.syntax, f) | ||
855 | } | ||
856 | } | ||
857 | impl AstToken for Careteq { | ||
858 | fn can_cast(kind: SyntaxKind) -> bool { kind == CARETEQ } | ||
859 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
860 | if Self::can_cast(syntax.kind()) { | ||
861 | Some(Self { syntax }) | ||
862 | } else { | ||
863 | None | ||
864 | } | ||
865 | } | ||
866 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
867 | } | ||
868 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
869 | pub struct Slasheq { | ||
870 | pub(crate) syntax: SyntaxToken, | ||
871 | } | ||
872 | impl std::fmt::Display for Slasheq { | ||
873 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
874 | std::fmt::Display::fmt(&self.syntax, f) | ||
875 | } | ||
876 | } | ||
877 | impl AstToken for Slasheq { | ||
878 | fn can_cast(kind: SyntaxKind) -> bool { kind == SLASHEQ } | ||
879 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
880 | if Self::can_cast(syntax.kind()) { | ||
881 | Some(Self { syntax }) | ||
882 | } else { | ||
883 | None | ||
884 | } | ||
885 | } | ||
886 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
887 | } | ||
888 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
889 | pub struct Stareq { | ||
890 | pub(crate) syntax: SyntaxToken, | ||
891 | } | ||
892 | impl std::fmt::Display for Stareq { | ||
893 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
894 | std::fmt::Display::fmt(&self.syntax, f) | ||
895 | } | ||
896 | } | ||
897 | impl AstToken for Stareq { | ||
898 | fn can_cast(kind: SyntaxKind) -> bool { kind == STAREQ } | ||
899 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
900 | if Self::can_cast(syntax.kind()) { | ||
901 | Some(Self { syntax }) | ||
902 | } else { | ||
903 | None | ||
904 | } | ||
905 | } | ||
906 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
907 | } | ||
908 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
909 | pub struct Percenteq { | ||
910 | pub(crate) syntax: SyntaxToken, | ||
911 | } | ||
912 | impl std::fmt::Display for Percenteq { | ||
913 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
914 | std::fmt::Display::fmt(&self.syntax, f) | ||
915 | } | ||
916 | } | ||
917 | impl AstToken for Percenteq { | ||
918 | fn can_cast(kind: SyntaxKind) -> bool { kind == PERCENTEQ } | ||
919 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
920 | if Self::can_cast(syntax.kind()) { | ||
921 | Some(Self { syntax }) | ||
922 | } else { | ||
923 | None | ||
924 | } | ||
925 | } | ||
926 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
927 | } | ||
928 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
929 | pub struct Ampamp { | ||
930 | pub(crate) syntax: SyntaxToken, | ||
931 | } | ||
932 | impl std::fmt::Display for Ampamp { | ||
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 Ampamp { | ||
938 | fn can_cast(kind: SyntaxKind) -> bool { kind == AMPAMP } | ||
939 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
940 | if Self::can_cast(syntax.kind()) { | ||
941 | Some(Self { syntax }) | ||
942 | } else { | ||
943 | None | ||
944 | } | ||
945 | } | ||
946 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
947 | } | ||
948 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
949 | pub struct Pipepipe { | ||
950 | pub(crate) syntax: SyntaxToken, | ||
951 | } | ||
952 | impl std::fmt::Display for Pipepipe { | ||
953 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
954 | std::fmt::Display::fmt(&self.syntax, f) | ||
955 | } | ||
956 | } | ||
957 | impl AstToken for Pipepipe { | ||
958 | fn can_cast(kind: SyntaxKind) -> bool { kind == PIPEPIPE } | ||
959 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
960 | if Self::can_cast(syntax.kind()) { | ||
961 | Some(Self { syntax }) | ||
962 | } else { | ||
963 | None | ||
964 | } | ||
965 | } | ||
966 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
967 | } | ||
968 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
969 | pub struct Shl { | ||
970 | pub(crate) syntax: SyntaxToken, | ||
971 | } | ||
972 | impl std::fmt::Display for Shl { | ||
973 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
974 | std::fmt::Display::fmt(&self.syntax, f) | ||
975 | } | ||
976 | } | ||
977 | impl AstToken for Shl { | ||
978 | fn can_cast(kind: SyntaxKind) -> bool { kind == SHL } | ||
979 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
980 | if Self::can_cast(syntax.kind()) { | ||
981 | Some(Self { syntax }) | ||
982 | } else { | ||
983 | None | ||
984 | } | ||
985 | } | ||
986 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
987 | } | ||
988 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
989 | pub struct Shr { | ||
990 | pub(crate) syntax: SyntaxToken, | ||
991 | } | ||
992 | impl std::fmt::Display for Shr { | ||
993 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
994 | std::fmt::Display::fmt(&self.syntax, f) | ||
995 | } | ||
996 | } | ||
997 | impl AstToken for Shr { | ||
998 | fn can_cast(kind: SyntaxKind) -> bool { kind == SHR } | ||
999 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1000 | if Self::can_cast(syntax.kind()) { | ||
1001 | Some(Self { syntax }) | ||
1002 | } else { | ||
1003 | None | ||
1004 | } | ||
1005 | } | ||
1006 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1007 | } | ||
1008 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1009 | pub struct Shleq { | ||
1010 | pub(crate) syntax: SyntaxToken, | ||
1011 | } | ||
1012 | impl std::fmt::Display for Shleq { | ||
1013 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1014 | std::fmt::Display::fmt(&self.syntax, f) | ||
1015 | } | ||
1016 | } | ||
1017 | impl AstToken for Shleq { | ||
1018 | fn can_cast(kind: SyntaxKind) -> bool { kind == SHLEQ } | ||
1019 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1020 | if Self::can_cast(syntax.kind()) { | ||
1021 | Some(Self { syntax }) | ||
1022 | } else { | ||
1023 | None | ||
1024 | } | ||
1025 | } | ||
1026 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1027 | } | ||
1028 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1029 | pub struct Shreq { | ||
1030 | pub(crate) syntax: SyntaxToken, | ||
1031 | } | ||
1032 | impl std::fmt::Display for Shreq { | ||
1033 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1034 | std::fmt::Display::fmt(&self.syntax, f) | ||
1035 | } | ||
1036 | } | ||
1037 | impl AstToken for Shreq { | ||
1038 | fn can_cast(kind: SyntaxKind) -> bool { kind == SHREQ } | ||
1039 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1040 | if Self::can_cast(syntax.kind()) { | ||
1041 | Some(Self { syntax }) | ||
1042 | } else { | ||
1043 | None | ||
1044 | } | ||
1045 | } | ||
1046 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1047 | } | ||
1048 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1049 | pub struct AsKw { | ||
1050 | pub(crate) syntax: SyntaxToken, | ||
1051 | } | ||
1052 | impl std::fmt::Display for AsKw { | ||
1053 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1054 | std::fmt::Display::fmt(&self.syntax, f) | ||
1055 | } | ||
1056 | } | ||
1057 | impl AstToken for AsKw { | ||
1058 | fn can_cast(kind: SyntaxKind) -> bool { kind == AS_KW } | ||
1059 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1060 | if Self::can_cast(syntax.kind()) { | ||
1061 | Some(Self { syntax }) | ||
1062 | } else { | ||
1063 | None | ||
1064 | } | ||
1065 | } | ||
1066 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1067 | } | ||
1068 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1069 | pub struct AsyncKw { | ||
1070 | pub(crate) syntax: SyntaxToken, | ||
1071 | } | ||
1072 | impl std::fmt::Display for AsyncKw { | ||
1073 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1074 | std::fmt::Display::fmt(&self.syntax, f) | ||
1075 | } | ||
1076 | } | ||
1077 | impl AstToken for AsyncKw { | ||
1078 | fn can_cast(kind: SyntaxKind) -> bool { kind == ASYNC_KW } | ||
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 { &self.syntax } | ||
1087 | } | ||
1088 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1089 | pub struct AwaitKw { | ||
1090 | pub(crate) syntax: SyntaxToken, | ||
1091 | } | ||
1092 | impl std::fmt::Display for AwaitKw { | ||
1093 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1094 | std::fmt::Display::fmt(&self.syntax, f) | ||
1095 | } | ||
1096 | } | ||
1097 | impl AstToken for AwaitKw { | ||
1098 | fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_KW } | ||
1099 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1100 | if Self::can_cast(syntax.kind()) { | ||
1101 | Some(Self { syntax }) | ||
1102 | } else { | ||
1103 | None | ||
1104 | } | ||
1105 | } | ||
1106 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1107 | } | ||
1108 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1109 | pub struct BoxKw { | ||
1110 | pub(crate) syntax: SyntaxToken, | ||
1111 | } | ||
1112 | impl std::fmt::Display for BoxKw { | ||
1113 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1114 | std::fmt::Display::fmt(&self.syntax, f) | ||
1115 | } | ||
1116 | } | ||
1117 | impl AstToken for BoxKw { | ||
1118 | fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_KW } | ||
1119 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1120 | if Self::can_cast(syntax.kind()) { | ||
1121 | Some(Self { syntax }) | ||
1122 | } else { | ||
1123 | None | ||
1124 | } | ||
1125 | } | ||
1126 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1127 | } | ||
1128 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1129 | pub struct BreakKw { | ||
1130 | pub(crate) syntax: SyntaxToken, | ||
1131 | } | ||
1132 | impl std::fmt::Display for BreakKw { | ||
1133 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1134 | std::fmt::Display::fmt(&self.syntax, f) | ||
1135 | } | ||
1136 | } | ||
1137 | impl AstToken for BreakKw { | ||
1138 | fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_KW } | ||
1139 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1140 | if Self::can_cast(syntax.kind()) { | ||
1141 | Some(Self { syntax }) | ||
1142 | } else { | ||
1143 | None | ||
1144 | } | ||
1145 | } | ||
1146 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1147 | } | ||
1148 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1149 | pub struct ConstKw { | ||
1150 | pub(crate) syntax: SyntaxToken, | ||
1151 | } | ||
1152 | impl std::fmt::Display for ConstKw { | ||
1153 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1154 | std::fmt::Display::fmt(&self.syntax, f) | ||
1155 | } | ||
1156 | } | ||
1157 | impl AstToken for ConstKw { | ||
1158 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_KW } | ||
1159 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1160 | if Self::can_cast(syntax.kind()) { | ||
1161 | Some(Self { syntax }) | ||
1162 | } else { | ||
1163 | None | ||
1164 | } | ||
1165 | } | ||
1166 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1167 | } | ||
1168 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1169 | pub struct ContinueKw { | ||
1170 | pub(crate) syntax: SyntaxToken, | ||
1171 | } | ||
1172 | impl std::fmt::Display for ContinueKw { | ||
1173 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1174 | std::fmt::Display::fmt(&self.syntax, f) | ||
1175 | } | ||
1176 | } | ||
1177 | impl AstToken for ContinueKw { | ||
1178 | fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_KW } | ||
1179 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1180 | if Self::can_cast(syntax.kind()) { | ||
1181 | Some(Self { syntax }) | ||
1182 | } else { | ||
1183 | None | ||
1184 | } | ||
1185 | } | ||
1186 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1187 | } | ||
1188 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1189 | pub struct CrateKw { | ||
1190 | pub(crate) syntax: SyntaxToken, | ||
1191 | } | ||
1192 | impl std::fmt::Display for CrateKw { | ||
1193 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1194 | std::fmt::Display::fmt(&self.syntax, f) | ||
1195 | } | ||
1196 | } | ||
1197 | impl AstToken for CrateKw { | ||
1198 | fn can_cast(kind: SyntaxKind) -> bool { kind == CRATE_KW } | ||
1199 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1200 | if Self::can_cast(syntax.kind()) { | ||
1201 | Some(Self { syntax }) | ||
1202 | } else { | ||
1203 | None | ||
1204 | } | ||
1205 | } | ||
1206 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1207 | } | ||
1208 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1209 | pub struct DynKw { | ||
1210 | pub(crate) syntax: SyntaxToken, | ||
1211 | } | ||
1212 | impl std::fmt::Display for DynKw { | ||
1213 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1214 | std::fmt::Display::fmt(&self.syntax, f) | ||
1215 | } | ||
1216 | } | ||
1217 | impl AstToken for DynKw { | ||
1218 | fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_KW } | ||
1219 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1220 | if Self::can_cast(syntax.kind()) { | ||
1221 | Some(Self { syntax }) | ||
1222 | } else { | ||
1223 | None | ||
1224 | } | ||
1225 | } | ||
1226 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1227 | } | ||
1228 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1229 | pub struct ElseKw { | ||
1230 | pub(crate) syntax: SyntaxToken, | ||
1231 | } | ||
1232 | impl std::fmt::Display for ElseKw { | ||
1233 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1234 | std::fmt::Display::fmt(&self.syntax, f) | ||
1235 | } | ||
1236 | } | ||
1237 | impl AstToken for ElseKw { | ||
1238 | fn can_cast(kind: SyntaxKind) -> bool { kind == ELSE_KW } | ||
1239 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1240 | if Self::can_cast(syntax.kind()) { | ||
1241 | Some(Self { syntax }) | ||
1242 | } else { | ||
1243 | None | ||
1244 | } | ||
1245 | } | ||
1246 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1247 | } | ||
1248 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1249 | pub struct EnumKw { | ||
1250 | pub(crate) syntax: SyntaxToken, | ||
1251 | } | ||
1252 | impl std::fmt::Display for EnumKw { | ||
1253 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1254 | std::fmt::Display::fmt(&self.syntax, f) | ||
1255 | } | ||
1256 | } | ||
1257 | impl AstToken for EnumKw { | ||
1258 | fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_KW } | ||
1259 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1260 | if Self::can_cast(syntax.kind()) { | ||
1261 | Some(Self { syntax }) | ||
1262 | } else { | ||
1263 | None | ||
1264 | } | ||
1265 | } | ||
1266 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1267 | } | ||
1268 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1269 | pub struct ExternKw { | ||
1270 | pub(crate) syntax: SyntaxToken, | ||
1271 | } | ||
1272 | impl std::fmt::Display for ExternKw { | ||
1273 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1274 | std::fmt::Display::fmt(&self.syntax, f) | ||
1275 | } | ||
1276 | } | ||
1277 | impl AstToken for ExternKw { | ||
1278 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_KW } | ||
1279 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1280 | if Self::can_cast(syntax.kind()) { | ||
1281 | Some(Self { syntax }) | ||
1282 | } else { | ||
1283 | None | ||
1284 | } | ||
1285 | } | ||
1286 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1287 | } | ||
1288 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1289 | pub struct FalseKw { | ||
1290 | pub(crate) syntax: SyntaxToken, | ||
1291 | } | ||
1292 | impl std::fmt::Display for FalseKw { | ||
1293 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1294 | std::fmt::Display::fmt(&self.syntax, f) | ||
1295 | } | ||
1296 | } | ||
1297 | impl AstToken for FalseKw { | ||
1298 | fn can_cast(kind: SyntaxKind) -> bool { kind == FALSE_KW } | ||
1299 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1300 | if Self::can_cast(syntax.kind()) { | ||
1301 | Some(Self { syntax }) | ||
1302 | } else { | ||
1303 | None | ||
1304 | } | ||
1305 | } | ||
1306 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1307 | } | ||
1308 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1309 | pub struct FnKw { | ||
1310 | pub(crate) syntax: SyntaxToken, | ||
1311 | } | ||
1312 | impl std::fmt::Display for FnKw { | ||
1313 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1314 | std::fmt::Display::fmt(&self.syntax, f) | ||
1315 | } | ||
1316 | } | ||
1317 | impl AstToken for FnKw { | ||
1318 | fn can_cast(kind: SyntaxKind) -> bool { kind == FN_KW } | ||
1319 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1320 | if Self::can_cast(syntax.kind()) { | ||
1321 | Some(Self { syntax }) | ||
1322 | } else { | ||
1323 | None | ||
1324 | } | ||
1325 | } | ||
1326 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1327 | } | ||
1328 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1329 | pub struct ForKw { | ||
1330 | pub(crate) syntax: SyntaxToken, | ||
1331 | } | ||
1332 | impl std::fmt::Display for ForKw { | ||
1333 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1334 | std::fmt::Display::fmt(&self.syntax, f) | ||
1335 | } | ||
1336 | } | ||
1337 | impl AstToken for ForKw { | ||
1338 | fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_KW } | ||
1339 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1340 | if Self::can_cast(syntax.kind()) { | ||
1341 | Some(Self { syntax }) | ||
1342 | } else { | ||
1343 | None | ||
1344 | } | ||
1345 | } | ||
1346 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1347 | } | ||
1348 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1349 | pub struct IfKw { | ||
1350 | pub(crate) syntax: SyntaxToken, | ||
1351 | } | ||
1352 | impl std::fmt::Display for IfKw { | ||
1353 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1354 | std::fmt::Display::fmt(&self.syntax, f) | ||
1355 | } | ||
1356 | } | ||
1357 | impl AstToken for IfKw { | ||
1358 | fn can_cast(kind: SyntaxKind) -> bool { kind == IF_KW } | ||
1359 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1360 | if Self::can_cast(syntax.kind()) { | ||
1361 | Some(Self { syntax }) | ||
1362 | } else { | ||
1363 | None | ||
1364 | } | ||
1365 | } | ||
1366 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1367 | } | ||
1368 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1369 | pub struct ImplKw { | ||
1370 | pub(crate) syntax: SyntaxToken, | ||
1371 | } | ||
1372 | impl std::fmt::Display for ImplKw { | ||
1373 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1374 | std::fmt::Display::fmt(&self.syntax, f) | ||
1375 | } | ||
1376 | } | ||
1377 | impl AstToken for ImplKw { | ||
1378 | fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_KW } | ||
1379 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1380 | if Self::can_cast(syntax.kind()) { | ||
1381 | Some(Self { syntax }) | ||
1382 | } else { | ||
1383 | None | ||
1384 | } | ||
1385 | } | ||
1386 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1387 | } | ||
1388 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1389 | pub struct InKw { | ||
1390 | pub(crate) syntax: SyntaxToken, | ||
1391 | } | ||
1392 | impl std::fmt::Display for InKw { | ||
1393 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1394 | std::fmt::Display::fmt(&self.syntax, f) | ||
1395 | } | ||
1396 | } | ||
1397 | impl AstToken for InKw { | ||
1398 | fn can_cast(kind: SyntaxKind) -> bool { kind == IN_KW } | ||
1399 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1400 | if Self::can_cast(syntax.kind()) { | ||
1401 | Some(Self { syntax }) | ||
1402 | } else { | ||
1403 | None | ||
1404 | } | ||
1405 | } | ||
1406 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1407 | } | ||
1408 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1409 | pub struct LetKw { | ||
1410 | pub(crate) syntax: SyntaxToken, | ||
1411 | } | ||
1412 | impl std::fmt::Display for LetKw { | ||
1413 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1414 | std::fmt::Display::fmt(&self.syntax, f) | ||
1415 | } | ||
1416 | } | ||
1417 | impl AstToken for LetKw { | ||
1418 | fn can_cast(kind: SyntaxKind) -> bool { kind == LET_KW } | ||
1419 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1420 | if Self::can_cast(syntax.kind()) { | ||
1421 | Some(Self { syntax }) | ||
1422 | } else { | ||
1423 | None | ||
1424 | } | ||
1425 | } | ||
1426 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1427 | } | ||
1428 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1429 | pub struct LoopKw { | ||
1430 | pub(crate) syntax: SyntaxToken, | ||
1431 | } | ||
1432 | impl std::fmt::Display for LoopKw { | ||
1433 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1434 | std::fmt::Display::fmt(&self.syntax, f) | ||
1435 | } | ||
1436 | } | ||
1437 | impl AstToken for LoopKw { | ||
1438 | fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_KW } | ||
1439 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1440 | if Self::can_cast(syntax.kind()) { | ||
1441 | Some(Self { syntax }) | ||
1442 | } else { | ||
1443 | None | ||
1444 | } | ||
1445 | } | ||
1446 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1447 | } | ||
1448 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1449 | pub struct MacroKw { | ||
1450 | pub(crate) syntax: SyntaxToken, | ||
1451 | } | ||
1452 | impl std::fmt::Display for MacroKw { | ||
1453 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1454 | std::fmt::Display::fmt(&self.syntax, f) | ||
1455 | } | ||
1456 | } | ||
1457 | impl AstToken for MacroKw { | ||
1458 | fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_KW } | ||
1459 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1460 | if Self::can_cast(syntax.kind()) { | ||
1461 | Some(Self { syntax }) | ||
1462 | } else { | ||
1463 | None | ||
1464 | } | ||
1465 | } | ||
1466 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1467 | } | ||
1468 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1469 | pub struct MatchKw { | ||
1470 | pub(crate) syntax: SyntaxToken, | ||
1471 | } | ||
1472 | impl std::fmt::Display for MatchKw { | ||
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 MatchKw { | ||
1478 | fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_KW } | ||
1479 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1480 | if Self::can_cast(syntax.kind()) { | ||
1481 | Some(Self { syntax }) | ||
1482 | } else { | ||
1483 | None | ||
1484 | } | ||
1485 | } | ||
1486 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1487 | } | ||
1488 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1489 | pub struct ModKw { | ||
1490 | pub(crate) syntax: SyntaxToken, | ||
1491 | } | ||
1492 | impl std::fmt::Display for ModKw { | ||
1493 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1494 | std::fmt::Display::fmt(&self.syntax, f) | ||
1495 | } | ||
1496 | } | ||
1497 | impl AstToken for ModKw { | ||
1498 | fn can_cast(kind: SyntaxKind) -> bool { kind == MOD_KW } | ||
1499 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1500 | if Self::can_cast(syntax.kind()) { | ||
1501 | Some(Self { syntax }) | ||
1502 | } else { | ||
1503 | None | ||
1504 | } | ||
1505 | } | ||
1506 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1507 | } | ||
1508 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1509 | pub struct MoveKw { | ||
1510 | pub(crate) syntax: SyntaxToken, | ||
1511 | } | ||
1512 | impl std::fmt::Display for MoveKw { | ||
1513 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1514 | std::fmt::Display::fmt(&self.syntax, f) | ||
1515 | } | ||
1516 | } | ||
1517 | impl AstToken for MoveKw { | ||
1518 | fn can_cast(kind: SyntaxKind) -> bool { kind == MOVE_KW } | ||
1519 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1520 | if Self::can_cast(syntax.kind()) { | ||
1521 | Some(Self { syntax }) | ||
1522 | } else { | ||
1523 | None | ||
1524 | } | ||
1525 | } | ||
1526 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1527 | } | ||
1528 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1529 | pub struct MutKw { | ||
1530 | pub(crate) syntax: SyntaxToken, | ||
1531 | } | ||
1532 | impl std::fmt::Display for MutKw { | ||
1533 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1534 | std::fmt::Display::fmt(&self.syntax, f) | ||
1535 | } | ||
1536 | } | ||
1537 | impl AstToken for MutKw { | ||
1538 | fn can_cast(kind: SyntaxKind) -> bool { kind == MUT_KW } | ||
1539 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1540 | if Self::can_cast(syntax.kind()) { | ||
1541 | Some(Self { syntax }) | ||
1542 | } else { | ||
1543 | None | ||
1544 | } | ||
1545 | } | ||
1546 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1547 | } | ||
1548 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1549 | pub struct PubKw { | ||
1550 | pub(crate) syntax: SyntaxToken, | ||
1551 | } | ||
1552 | impl std::fmt::Display for PubKw { | ||
1553 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1554 | std::fmt::Display::fmt(&self.syntax, f) | ||
1555 | } | ||
1556 | } | ||
1557 | impl AstToken for PubKw { | ||
1558 | fn can_cast(kind: SyntaxKind) -> bool { kind == PUB_KW } | ||
1559 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1560 | if Self::can_cast(syntax.kind()) { | ||
1561 | Some(Self { syntax }) | ||
1562 | } else { | ||
1563 | None | ||
1564 | } | ||
1565 | } | ||
1566 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1567 | } | ||
1568 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1569 | pub struct RefKw { | ||
1570 | pub(crate) syntax: SyntaxToken, | ||
1571 | } | ||
1572 | impl std::fmt::Display for RefKw { | ||
1573 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1574 | std::fmt::Display::fmt(&self.syntax, f) | ||
1575 | } | ||
1576 | } | ||
1577 | impl AstToken for RefKw { | ||
1578 | fn can_cast(kind: SyntaxKind) -> bool { kind == REF_KW } | ||
1579 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1580 | if Self::can_cast(syntax.kind()) { | ||
1581 | Some(Self { syntax }) | ||
1582 | } else { | ||
1583 | None | ||
1584 | } | ||
1585 | } | ||
1586 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1587 | } | ||
1588 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1589 | pub struct ReturnKw { | ||
1590 | pub(crate) syntax: SyntaxToken, | ||
1591 | } | ||
1592 | impl std::fmt::Display for ReturnKw { | ||
1593 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1594 | std::fmt::Display::fmt(&self.syntax, f) | ||
1595 | } | ||
1596 | } | ||
1597 | impl AstToken for ReturnKw { | ||
1598 | fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_KW } | ||
1599 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1600 | if Self::can_cast(syntax.kind()) { | ||
1601 | Some(Self { syntax }) | ||
1602 | } else { | ||
1603 | None | ||
1604 | } | ||
1605 | } | ||
1606 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1607 | } | ||
1608 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1609 | pub struct SelfKw { | ||
1610 | pub(crate) syntax: SyntaxToken, | ||
1611 | } | ||
1612 | impl std::fmt::Display for SelfKw { | ||
1613 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1614 | std::fmt::Display::fmt(&self.syntax, f) | ||
1615 | } | ||
1616 | } | ||
1617 | impl AstToken for SelfKw { | ||
1618 | fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_KW } | ||
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 { &self.syntax } | ||
1627 | } | ||
1628 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1629 | pub struct StaticKw { | ||
1630 | pub(crate) syntax: SyntaxToken, | ||
1631 | } | ||
1632 | impl std::fmt::Display for StaticKw { | ||
1633 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1634 | std::fmt::Display::fmt(&self.syntax, f) | ||
1635 | } | ||
1636 | } | ||
1637 | impl AstToken for StaticKw { | ||
1638 | fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_KW } | ||
1639 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1640 | if Self::can_cast(syntax.kind()) { | ||
1641 | Some(Self { syntax }) | ||
1642 | } else { | ||
1643 | None | ||
1644 | } | ||
1645 | } | ||
1646 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1647 | } | ||
1648 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1649 | pub struct StructKw { | ||
1650 | pub(crate) syntax: SyntaxToken, | ||
1651 | } | ||
1652 | impl std::fmt::Display for StructKw { | ||
1653 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1654 | std::fmt::Display::fmt(&self.syntax, f) | ||
1655 | } | ||
1656 | } | ||
1657 | impl AstToken for StructKw { | ||
1658 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_KW } | ||
1659 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1660 | if Self::can_cast(syntax.kind()) { | ||
1661 | Some(Self { syntax }) | ||
1662 | } else { | ||
1663 | None | ||
1664 | } | ||
1665 | } | ||
1666 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1667 | } | ||
1668 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1669 | pub struct SuperKw { | ||
1670 | pub(crate) syntax: SyntaxToken, | ||
1671 | } | ||
1672 | impl std::fmt::Display for SuperKw { | ||
1673 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1674 | std::fmt::Display::fmt(&self.syntax, f) | ||
1675 | } | ||
1676 | } | ||
1677 | impl AstToken for SuperKw { | ||
1678 | fn can_cast(kind: SyntaxKind) -> bool { kind == SUPER_KW } | ||
1679 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1680 | if Self::can_cast(syntax.kind()) { | ||
1681 | Some(Self { syntax }) | ||
1682 | } else { | ||
1683 | None | ||
1684 | } | ||
1685 | } | ||
1686 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1687 | } | ||
1688 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1689 | pub struct TraitKw { | ||
1690 | pub(crate) syntax: SyntaxToken, | ||
1691 | } | ||
1692 | impl std::fmt::Display for TraitKw { | ||
1693 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1694 | std::fmt::Display::fmt(&self.syntax, f) | ||
1695 | } | ||
1696 | } | ||
1697 | impl AstToken for TraitKw { | ||
1698 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_KW } | ||
1699 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1700 | if Self::can_cast(syntax.kind()) { | ||
1701 | Some(Self { syntax }) | ||
1702 | } else { | ||
1703 | None | ||
1704 | } | ||
1705 | } | ||
1706 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1707 | } | ||
1708 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1709 | pub struct TrueKw { | ||
1710 | pub(crate) syntax: SyntaxToken, | ||
1711 | } | ||
1712 | impl std::fmt::Display for TrueKw { | ||
1713 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1714 | std::fmt::Display::fmt(&self.syntax, f) | ||
1715 | } | ||
1716 | } | ||
1717 | impl AstToken for TrueKw { | ||
1718 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRUE_KW } | ||
1719 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1720 | if Self::can_cast(syntax.kind()) { | ||
1721 | Some(Self { syntax }) | ||
1722 | } else { | ||
1723 | None | ||
1724 | } | ||
1725 | } | ||
1726 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1727 | } | ||
1728 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1729 | pub struct TryKw { | ||
1730 | pub(crate) syntax: SyntaxToken, | ||
1731 | } | ||
1732 | impl std::fmt::Display for TryKw { | ||
1733 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1734 | std::fmt::Display::fmt(&self.syntax, f) | ||
1735 | } | ||
1736 | } | ||
1737 | impl AstToken for TryKw { | ||
1738 | fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_KW } | ||
1739 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1740 | if Self::can_cast(syntax.kind()) { | ||
1741 | Some(Self { syntax }) | ||
1742 | } else { | ||
1743 | None | ||
1744 | } | ||
1745 | } | ||
1746 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1747 | } | ||
1748 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1749 | pub struct TypeKw { | ||
1750 | pub(crate) syntax: SyntaxToken, | ||
1751 | } | ||
1752 | impl std::fmt::Display for TypeKw { | ||
1753 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1754 | std::fmt::Display::fmt(&self.syntax, f) | ||
1755 | } | ||
1756 | } | ||
1757 | impl AstToken for TypeKw { | ||
1758 | fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_KW } | ||
1759 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1760 | if Self::can_cast(syntax.kind()) { | ||
1761 | Some(Self { syntax }) | ||
1762 | } else { | ||
1763 | None | ||
1764 | } | ||
1765 | } | ||
1766 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1767 | } | ||
1768 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1769 | pub struct UnsafeKw { | ||
1770 | pub(crate) syntax: SyntaxToken, | ||
1771 | } | ||
1772 | impl std::fmt::Display for UnsafeKw { | ||
1773 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1774 | std::fmt::Display::fmt(&self.syntax, f) | ||
1775 | } | ||
1776 | } | ||
1777 | impl AstToken for UnsafeKw { | ||
1778 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNSAFE_KW } | ||
1779 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1780 | if Self::can_cast(syntax.kind()) { | ||
1781 | Some(Self { syntax }) | ||
1782 | } else { | ||
1783 | None | ||
1784 | } | ||
1785 | } | ||
1786 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1787 | } | ||
1788 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1789 | pub struct UseKw { | ||
1790 | pub(crate) syntax: SyntaxToken, | ||
1791 | } | ||
1792 | impl std::fmt::Display for UseKw { | ||
1793 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1794 | std::fmt::Display::fmt(&self.syntax, f) | ||
1795 | } | ||
1796 | } | ||
1797 | impl AstToken for UseKw { | ||
1798 | fn can_cast(kind: SyntaxKind) -> bool { kind == USE_KW } | ||
1799 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1800 | if Self::can_cast(syntax.kind()) { | ||
1801 | Some(Self { syntax }) | ||
1802 | } else { | ||
1803 | None | ||
1804 | } | ||
1805 | } | ||
1806 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1807 | } | ||
1808 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1809 | pub struct WhereKw { | ||
1810 | pub(crate) syntax: SyntaxToken, | ||
1811 | } | ||
1812 | impl std::fmt::Display for WhereKw { | ||
1813 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1814 | std::fmt::Display::fmt(&self.syntax, f) | ||
1815 | } | ||
1816 | } | ||
1817 | impl AstToken for WhereKw { | ||
1818 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_KW } | ||
1819 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1820 | if Self::can_cast(syntax.kind()) { | ||
1821 | Some(Self { syntax }) | ||
1822 | } else { | ||
1823 | None | ||
1824 | } | ||
1825 | } | ||
1826 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1827 | } | ||
1828 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1829 | pub struct WhileKw { | ||
1830 | pub(crate) syntax: SyntaxToken, | ||
1831 | } | ||
1832 | impl std::fmt::Display for WhileKw { | ||
1833 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1834 | std::fmt::Display::fmt(&self.syntax, f) | ||
1835 | } | ||
1836 | } | ||
1837 | impl AstToken for WhileKw { | ||
1838 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_KW } | ||
1839 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1840 | if Self::can_cast(syntax.kind()) { | ||
1841 | Some(Self { syntax }) | ||
1842 | } else { | ||
1843 | None | ||
1844 | } | ||
1845 | } | ||
1846 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1847 | } | ||
1848 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1849 | pub struct AutoKw { | ||
1850 | pub(crate) syntax: SyntaxToken, | ||
1851 | } | ||
1852 | impl std::fmt::Display for AutoKw { | ||
1853 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1854 | std::fmt::Display::fmt(&self.syntax, f) | ||
1855 | } | ||
1856 | } | ||
1857 | impl AstToken for AutoKw { | ||
1858 | fn can_cast(kind: SyntaxKind) -> bool { kind == AUTO_KW } | ||
1859 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1860 | if Self::can_cast(syntax.kind()) { | ||
1861 | Some(Self { syntax }) | ||
1862 | } else { | ||
1863 | None | ||
1864 | } | ||
1865 | } | ||
1866 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1867 | } | ||
1868 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1869 | pub struct DefaultKw { | ||
1870 | pub(crate) syntax: SyntaxToken, | ||
1871 | } | ||
1872 | impl std::fmt::Display for DefaultKw { | ||
1873 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1874 | std::fmt::Display::fmt(&self.syntax, f) | ||
1875 | } | ||
1876 | } | ||
1877 | impl AstToken for DefaultKw { | ||
1878 | fn can_cast(kind: SyntaxKind) -> bool { kind == DEFAULT_KW } | ||
1879 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1880 | if Self::can_cast(syntax.kind()) { | ||
1881 | Some(Self { syntax }) | ||
1882 | } else { | ||
1883 | None | ||
1884 | } | ||
1885 | } | ||
1886 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1887 | } | ||
1888 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1889 | pub struct ExistentialKw { | ||
1890 | pub(crate) syntax: SyntaxToken, | ||
1891 | } | ||
1892 | impl std::fmt::Display for ExistentialKw { | ||
1893 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1894 | std::fmt::Display::fmt(&self.syntax, f) | ||
1895 | } | ||
1896 | } | ||
1897 | impl AstToken for ExistentialKw { | ||
1898 | fn can_cast(kind: SyntaxKind) -> bool { kind == EXISTENTIAL_KW } | ||
1899 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1900 | if Self::can_cast(syntax.kind()) { | ||
1901 | Some(Self { syntax }) | ||
1902 | } else { | ||
1903 | None | ||
1904 | } | ||
1905 | } | ||
1906 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1907 | } | ||
1908 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1909 | pub struct UnionKw { | ||
1910 | pub(crate) syntax: SyntaxToken, | ||
1911 | } | ||
1912 | impl std::fmt::Display for UnionKw { | ||
1913 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1914 | std::fmt::Display::fmt(&self.syntax, f) | ||
1915 | } | ||
1916 | } | ||
1917 | impl AstToken for UnionKw { | ||
1918 | fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_KW } | ||
1919 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1920 | if Self::can_cast(syntax.kind()) { | ||
1921 | Some(Self { syntax }) | ||
1922 | } else { | ||
1923 | None | ||
1924 | } | ||
1925 | } | ||
1926 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1927 | } | ||
1928 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1929 | pub struct RawKw { | ||
1930 | pub(crate) syntax: SyntaxToken, | ||
1931 | } | ||
1932 | impl std::fmt::Display for RawKw { | ||
1933 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1934 | std::fmt::Display::fmt(&self.syntax, f) | ||
1935 | } | ||
1936 | } | ||
1937 | impl AstToken for RawKw { | ||
1938 | fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_KW } | ||
1939 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1940 | if Self::can_cast(syntax.kind()) { | ||
1941 | Some(Self { syntax }) | ||
1942 | } else { | ||
1943 | None | ||
1944 | } | ||
1945 | } | ||
1946 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1947 | } | ||
1948 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1949 | pub struct IntNumber { | ||
1950 | pub(crate) syntax: SyntaxToken, | ||
1951 | } | ||
1952 | impl std::fmt::Display for IntNumber { | ||
1953 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1954 | std::fmt::Display::fmt(&self.syntax, f) | ||
1955 | } | ||
1956 | } | ||
1957 | impl AstToken for IntNumber { | ||
1958 | fn can_cast(kind: SyntaxKind) -> bool { kind == INT_NUMBER } | ||
1959 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1960 | if Self::can_cast(syntax.kind()) { | ||
1961 | Some(Self { syntax }) | ||
1962 | } else { | ||
1963 | None | ||
1964 | } | ||
1965 | } | ||
1966 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1967 | } | ||
1968 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1969 | pub struct FloatNumber { | ||
1970 | pub(crate) syntax: SyntaxToken, | ||
1971 | } | ||
1972 | impl std::fmt::Display for FloatNumber { | ||
1973 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1974 | std::fmt::Display::fmt(&self.syntax, f) | ||
1975 | } | ||
1976 | } | ||
1977 | impl AstToken for FloatNumber { | ||
1978 | fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER } | ||
1979 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
1980 | if Self::can_cast(syntax.kind()) { | ||
1981 | Some(Self { syntax }) | ||
1982 | } else { | ||
1983 | None | ||
1984 | } | ||
1985 | } | ||
1986 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
1987 | } | ||
1988 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
1989 | pub struct Char { | ||
1990 | pub(crate) syntax: SyntaxToken, | ||
1991 | } | ||
1992 | impl std::fmt::Display for Char { | ||
1993 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
1994 | std::fmt::Display::fmt(&self.syntax, f) | ||
1995 | } | ||
1996 | } | ||
1997 | impl AstToken for Char { | ||
1998 | fn can_cast(kind: SyntaxKind) -> bool { kind == CHAR } | ||
1999 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2000 | if Self::can_cast(syntax.kind()) { | ||
2001 | Some(Self { syntax }) | ||
2002 | } else { | ||
2003 | None | ||
2004 | } | ||
2005 | } | ||
2006 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2007 | } | ||
2008 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2009 | pub struct Byte { | ||
2010 | pub(crate) syntax: SyntaxToken, | ||
2011 | } | ||
2012 | impl std::fmt::Display for Byte { | ||
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 Byte { | ||
2018 | fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE } | ||
2019 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2020 | if Self::can_cast(syntax.kind()) { | ||
2021 | Some(Self { syntax }) | ||
2022 | } else { | ||
2023 | None | ||
2024 | } | ||
2025 | } | ||
2026 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2027 | } | ||
2028 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2029 | pub struct String { | ||
2030 | pub(crate) syntax: SyntaxToken, | ||
2031 | } | ||
2032 | impl std::fmt::Display for String { | ||
2033 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2034 | std::fmt::Display::fmt(&self.syntax, f) | ||
2035 | } | ||
2036 | } | ||
2037 | impl AstToken for String { | ||
2038 | fn can_cast(kind: SyntaxKind) -> bool { kind == STRING } | ||
2039 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2040 | if Self::can_cast(syntax.kind()) { | ||
2041 | Some(Self { syntax }) | ||
2042 | } else { | ||
2043 | None | ||
2044 | } | ||
2045 | } | ||
2046 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2047 | } | ||
2048 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2049 | pub struct RawString { | ||
2050 | pub(crate) syntax: SyntaxToken, | ||
2051 | } | ||
2052 | impl std::fmt::Display for RawString { | ||
2053 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2054 | std::fmt::Display::fmt(&self.syntax, f) | ||
2055 | } | ||
2056 | } | ||
2057 | impl AstToken for RawString { | ||
2058 | fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_STRING } | ||
2059 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2060 | if Self::can_cast(syntax.kind()) { | ||
2061 | Some(Self { syntax }) | ||
2062 | } else { | ||
2063 | None | ||
2064 | } | ||
2065 | } | ||
2066 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2067 | } | ||
2068 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2069 | pub struct ByteString { | ||
2070 | pub(crate) syntax: SyntaxToken, | ||
2071 | } | ||
2072 | impl std::fmt::Display for ByteString { | ||
2073 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2074 | std::fmt::Display::fmt(&self.syntax, f) | ||
2075 | } | ||
2076 | } | ||
2077 | impl AstToken for ByteString { | ||
2078 | fn can_cast(kind: SyntaxKind) -> bool { kind == BYTE_STRING } | ||
2079 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2080 | if Self::can_cast(syntax.kind()) { | ||
2081 | Some(Self { syntax }) | ||
2082 | } else { | ||
2083 | None | ||
2084 | } | ||
2085 | } | ||
2086 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2087 | } | ||
2088 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2089 | pub struct RawByteString { | ||
2090 | pub(crate) syntax: SyntaxToken, | ||
2091 | } | ||
2092 | impl std::fmt::Display for RawByteString { | ||
2093 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2094 | std::fmt::Display::fmt(&self.syntax, f) | ||
2095 | } | ||
2096 | } | ||
2097 | impl AstToken for RawByteString { | ||
2098 | fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_BYTE_STRING } | ||
2099 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2100 | if Self::can_cast(syntax.kind()) { | ||
2101 | Some(Self { syntax }) | ||
2102 | } else { | ||
2103 | None | ||
2104 | } | ||
2105 | } | ||
2106 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2107 | } | ||
2108 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2109 | pub struct Error { | ||
2110 | pub(crate) syntax: SyntaxToken, | ||
2111 | } | ||
2112 | impl std::fmt::Display for Error { | ||
2113 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2114 | std::fmt::Display::fmt(&self.syntax, f) | ||
2115 | } | ||
2116 | } | ||
2117 | impl AstToken for Error { | ||
2118 | fn can_cast(kind: SyntaxKind) -> bool { kind == ERROR } | ||
2119 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2120 | if Self::can_cast(syntax.kind()) { | ||
2121 | Some(Self { syntax }) | ||
2122 | } else { | ||
2123 | None | ||
2124 | } | ||
2125 | } | ||
2126 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2127 | } | ||
2128 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2129 | pub struct Ident { | ||
2130 | pub(crate) syntax: SyntaxToken, | ||
2131 | } | ||
2132 | impl std::fmt::Display for Ident { | ||
2133 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2134 | std::fmt::Display::fmt(&self.syntax, f) | ||
2135 | } | ||
2136 | } | ||
2137 | impl AstToken for Ident { | ||
2138 | fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT } | ||
2139 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2140 | if Self::can_cast(syntax.kind()) { | ||
2141 | Some(Self { syntax }) | ||
2142 | } else { | ||
2143 | None | ||
2144 | } | ||
2145 | } | ||
2146 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2147 | } | ||
2148 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2149 | pub struct Whitespace { | ||
2150 | pub(crate) syntax: SyntaxToken, | ||
2151 | } | ||
2152 | impl std::fmt::Display for Whitespace { | ||
2153 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2154 | std::fmt::Display::fmt(&self.syntax, f) | ||
2155 | } | ||
2156 | } | ||
2157 | impl AstToken for Whitespace { | ||
2158 | fn can_cast(kind: SyntaxKind) -> bool { kind == WHITESPACE } | ||
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 { &self.syntax } | ||
2167 | } | ||
2168 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2169 | pub struct Lifetime { | ||
2170 | pub(crate) syntax: SyntaxToken, | ||
2171 | } | ||
2172 | impl std::fmt::Display for Lifetime { | ||
2173 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2174 | std::fmt::Display::fmt(&self.syntax, f) | ||
2175 | } | ||
2176 | } | ||
2177 | impl AstToken for Lifetime { | ||
2178 | fn can_cast(kind: SyntaxKind) -> bool { kind == LIFETIME } | ||
2179 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2180 | if Self::can_cast(syntax.kind()) { | ||
2181 | Some(Self { syntax }) | ||
2182 | } else { | ||
2183 | None | ||
2184 | } | ||
2185 | } | ||
2186 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2187 | } | ||
2188 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2189 | pub struct Comment { | ||
2190 | pub(crate) syntax: SyntaxToken, | ||
2191 | } | ||
2192 | impl std::fmt::Display for Comment { | ||
2193 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2194 | std::fmt::Display::fmt(&self.syntax, f) | ||
2195 | } | ||
2196 | } | ||
2197 | impl AstToken for Comment { | ||
2198 | fn can_cast(kind: SyntaxKind) -> bool { kind == COMMENT } | ||
2199 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2200 | if Self::can_cast(syntax.kind()) { | ||
2201 | Some(Self { syntax }) | ||
2202 | } else { | ||
2203 | None | ||
2204 | } | ||
2205 | } | ||
2206 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2207 | } | ||
2208 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2209 | pub struct Shebang { | ||
2210 | pub(crate) syntax: SyntaxToken, | ||
2211 | } | ||
2212 | impl std::fmt::Display for Shebang { | ||
2213 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2214 | std::fmt::Display::fmt(&self.syntax, f) | ||
2215 | } | ||
2216 | } | ||
2217 | impl AstToken for Shebang { | ||
2218 | fn can_cast(kind: SyntaxKind) -> bool { kind == SHEBANG } | ||
2219 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2220 | if Self::can_cast(syntax.kind()) { | ||
2221 | Some(Self { syntax }) | ||
2222 | } else { | ||
2223 | None | ||
2224 | } | ||
2225 | } | ||
2226 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2227 | } | ||
2228 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2229 | pub struct LDollar { | ||
2230 | pub(crate) syntax: SyntaxToken, | ||
2231 | } | ||
2232 | impl std::fmt::Display for LDollar { | ||
2233 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2234 | std::fmt::Display::fmt(&self.syntax, f) | ||
2235 | } | ||
2236 | } | ||
2237 | impl AstToken for LDollar { | ||
2238 | fn can_cast(kind: SyntaxKind) -> bool { kind == L_DOLLAR } | ||
2239 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2240 | if Self::can_cast(syntax.kind()) { | ||
2241 | Some(Self { syntax }) | ||
2242 | } else { | ||
2243 | None | ||
2244 | } | ||
2245 | } | ||
2246 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2247 | } | ||
2248 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2249 | pub struct RDollar { | ||
2250 | pub(crate) syntax: SyntaxToken, | ||
2251 | } | ||
2252 | impl std::fmt::Display for RDollar { | ||
2253 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2254 | std::fmt::Display::fmt(&self.syntax, f) | ||
2255 | } | ||
2256 | } | ||
2257 | impl AstToken for RDollar { | ||
2258 | fn can_cast(kind: SyntaxKind) -> bool { kind == R_DOLLAR } | ||
2259 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2260 | if Self::can_cast(syntax.kind()) { | ||
2261 | Some(Self { syntax }) | ||
2262 | } else { | ||
2263 | None | ||
2264 | } | ||
2265 | } | ||
2266 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | ||
2267 | } | ||
2268 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2269 | pub enum LeftDelimiter { | ||
2270 | LParen(LParen), | ||
2271 | LBrack(LBrack), | ||
2272 | LCurly(LCurly), | ||
2273 | } | ||
2274 | impl From<LParen> for LeftDelimiter { | ||
2275 | fn from(node: LParen) -> LeftDelimiter { LeftDelimiter::LParen(node) } | ||
2276 | } | ||
2277 | impl From<LBrack> for LeftDelimiter { | ||
2278 | fn from(node: LBrack) -> LeftDelimiter { LeftDelimiter::LBrack(node) } | ||
2279 | } | ||
2280 | impl From<LCurly> for LeftDelimiter { | ||
2281 | fn from(node: LCurly) -> LeftDelimiter { LeftDelimiter::LCurly(node) } | ||
2282 | } | ||
2283 | impl std::fmt::Display for LeftDelimiter { | ||
2284 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2285 | std::fmt::Display::fmt(self.syntax(), f) | ||
2286 | } | ||
2287 | } | ||
2288 | impl AstToken for LeftDelimiter { | ||
2289 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2290 | match kind { | ||
2291 | L_PAREN | L_BRACK | L_CURLY => true, | ||
2292 | _ => false, | ||
2293 | } | ||
2294 | } | ||
2295 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2296 | let res = match syntax.kind() { | ||
2297 | L_PAREN => LeftDelimiter::LParen(LParen { syntax }), | ||
2298 | L_BRACK => LeftDelimiter::LBrack(LBrack { syntax }), | ||
2299 | L_CURLY => LeftDelimiter::LCurly(LCurly { syntax }), | ||
2300 | _ => return None, | ||
2301 | }; | ||
2302 | Some(res) | ||
2303 | } | ||
2304 | fn syntax(&self) -> &SyntaxToken { | ||
2305 | match self { | ||
2306 | LeftDelimiter::LParen(it) => &it.syntax, | ||
2307 | LeftDelimiter::LBrack(it) => &it.syntax, | ||
2308 | LeftDelimiter::LCurly(it) => &it.syntax, | ||
2309 | } | ||
2310 | } | ||
2311 | } | ||
2312 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2313 | pub enum RightDelimiter { | ||
2314 | RParen(RParen), | ||
2315 | RBrack(RBrack), | ||
2316 | RCurly(RCurly), | ||
2317 | } | ||
2318 | impl From<RParen> for RightDelimiter { | ||
2319 | fn from(node: RParen) -> RightDelimiter { RightDelimiter::RParen(node) } | ||
2320 | } | ||
2321 | impl From<RBrack> for RightDelimiter { | ||
2322 | fn from(node: RBrack) -> RightDelimiter { RightDelimiter::RBrack(node) } | ||
2323 | } | ||
2324 | impl From<RCurly> for RightDelimiter { | ||
2325 | fn from(node: RCurly) -> RightDelimiter { RightDelimiter::RCurly(node) } | ||
2326 | } | ||
2327 | impl std::fmt::Display for RightDelimiter { | ||
2328 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2329 | std::fmt::Display::fmt(self.syntax(), f) | ||
2330 | } | ||
2331 | } | ||
2332 | impl AstToken for RightDelimiter { | ||
2333 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2334 | match kind { | ||
2335 | R_PAREN | R_BRACK | R_CURLY => true, | ||
2336 | _ => false, | ||
2337 | } | ||
2338 | } | ||
2339 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2340 | let res = match syntax.kind() { | ||
2341 | R_PAREN => RightDelimiter::RParen(RParen { syntax }), | ||
2342 | R_BRACK => RightDelimiter::RBrack(RBrack { syntax }), | ||
2343 | R_CURLY => RightDelimiter::RCurly(RCurly { syntax }), | ||
2344 | _ => return None, | ||
2345 | }; | ||
2346 | Some(res) | ||
2347 | } | ||
2348 | fn syntax(&self) -> &SyntaxToken { | ||
2349 | match self { | ||
2350 | RightDelimiter::RParen(it) => &it.syntax, | ||
2351 | RightDelimiter::RBrack(it) => &it.syntax, | ||
2352 | RightDelimiter::RCurly(it) => &it.syntax, | ||
2353 | } | ||
2354 | } | ||
2355 | } | ||
2356 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2357 | pub enum RangeSeparator { | ||
2358 | Dotdot(Dotdot), | ||
2359 | Dotdotdot(Dotdotdot), | ||
2360 | Dotdoteq(Dotdoteq), | ||
2361 | } | ||
2362 | impl From<Dotdot> for RangeSeparator { | ||
2363 | fn from(node: Dotdot) -> RangeSeparator { RangeSeparator::Dotdot(node) } | ||
2364 | } | ||
2365 | impl From<Dotdotdot> for RangeSeparator { | ||
2366 | fn from(node: Dotdotdot) -> RangeSeparator { RangeSeparator::Dotdotdot(node) } | ||
2367 | } | ||
2368 | impl From<Dotdoteq> for RangeSeparator { | ||
2369 | fn from(node: Dotdoteq) -> RangeSeparator { RangeSeparator::Dotdoteq(node) } | ||
2370 | } | ||
2371 | impl std::fmt::Display for RangeSeparator { | ||
2372 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2373 | std::fmt::Display::fmt(self.syntax(), f) | ||
2374 | } | ||
2375 | } | ||
2376 | impl AstToken for RangeSeparator { | ||
2377 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2378 | match kind { | ||
2379 | DOTDOT | DOTDOTDOT | DOTDOTEQ => true, | ||
2380 | _ => false, | ||
2381 | } | ||
2382 | } | ||
2383 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2384 | let res = match syntax.kind() { | ||
2385 | DOTDOT => RangeSeparator::Dotdot(Dotdot { syntax }), | ||
2386 | DOTDOTDOT => RangeSeparator::Dotdotdot(Dotdotdot { syntax }), | ||
2387 | DOTDOTEQ => RangeSeparator::Dotdoteq(Dotdoteq { syntax }), | ||
2388 | _ => return None, | ||
2389 | }; | ||
2390 | Some(res) | ||
2391 | } | ||
2392 | fn syntax(&self) -> &SyntaxToken { | ||
2393 | match self { | ||
2394 | RangeSeparator::Dotdot(it) => &it.syntax, | ||
2395 | RangeSeparator::Dotdotdot(it) => &it.syntax, | ||
2396 | RangeSeparator::Dotdoteq(it) => &it.syntax, | ||
2397 | } | ||
2398 | } | ||
2399 | } | ||
2400 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2401 | pub enum BinOp { | ||
2402 | Pipepipe(Pipepipe), | ||
2403 | Ampamp(Ampamp), | ||
2404 | Eqeq(Eqeq), | ||
2405 | Neq(Neq), | ||
2406 | Lteq(Lteq), | ||
2407 | Gteq(Gteq), | ||
2408 | LAngle(LAngle), | ||
2409 | RAngle(RAngle), | ||
2410 | Plus(Plus), | ||
2411 | Star(Star), | ||
2412 | Minus(Minus), | ||
2413 | Slash(Slash), | ||
2414 | Percent(Percent), | ||
2415 | Shl(Shl), | ||
2416 | Shr(Shr), | ||
2417 | Caret(Caret), | ||
2418 | Pipe(Pipe), | ||
2419 | Amp(Amp), | ||
2420 | Eq(Eq), | ||
2421 | Pluseq(Pluseq), | ||
2422 | Slasheq(Slasheq), | ||
2423 | Stareq(Stareq), | ||
2424 | Percenteq(Percenteq), | ||
2425 | Shreq(Shreq), | ||
2426 | Shleq(Shleq), | ||
2427 | Minuseq(Minuseq), | ||
2428 | Pipeeq(Pipeeq), | ||
2429 | Ampeq(Ampeq), | ||
2430 | Careteq(Careteq), | ||
2431 | } | ||
2432 | impl From<Pipepipe> for BinOp { | ||
2433 | fn from(node: Pipepipe) -> BinOp { BinOp::Pipepipe(node) } | ||
2434 | } | ||
2435 | impl From<Ampamp> for BinOp { | ||
2436 | fn from(node: Ampamp) -> BinOp { BinOp::Ampamp(node) } | ||
2437 | } | ||
2438 | impl From<Eqeq> for BinOp { | ||
2439 | fn from(node: Eqeq) -> BinOp { BinOp::Eqeq(node) } | ||
2440 | } | ||
2441 | impl From<Neq> for BinOp { | ||
2442 | fn from(node: Neq) -> BinOp { BinOp::Neq(node) } | ||
2443 | } | ||
2444 | impl From<Lteq> for BinOp { | ||
2445 | fn from(node: Lteq) -> BinOp { BinOp::Lteq(node) } | ||
2446 | } | ||
2447 | impl From<Gteq> for BinOp { | ||
2448 | fn from(node: Gteq) -> BinOp { BinOp::Gteq(node) } | ||
2449 | } | ||
2450 | impl From<LAngle> for BinOp { | ||
2451 | fn from(node: LAngle) -> BinOp { BinOp::LAngle(node) } | ||
2452 | } | ||
2453 | impl From<RAngle> for BinOp { | ||
2454 | fn from(node: RAngle) -> BinOp { BinOp::RAngle(node) } | ||
2455 | } | ||
2456 | impl From<Plus> for BinOp { | ||
2457 | fn from(node: Plus) -> BinOp { BinOp::Plus(node) } | ||
2458 | } | ||
2459 | impl From<Star> for BinOp { | ||
2460 | fn from(node: Star) -> BinOp { BinOp::Star(node) } | ||
2461 | } | ||
2462 | impl From<Minus> for BinOp { | ||
2463 | fn from(node: Minus) -> BinOp { BinOp::Minus(node) } | ||
2464 | } | ||
2465 | impl From<Slash> for BinOp { | ||
2466 | fn from(node: Slash) -> BinOp { BinOp::Slash(node) } | ||
2467 | } | ||
2468 | impl From<Percent> for BinOp { | ||
2469 | fn from(node: Percent) -> BinOp { BinOp::Percent(node) } | ||
2470 | } | ||
2471 | impl From<Shl> for BinOp { | ||
2472 | fn from(node: Shl) -> BinOp { BinOp::Shl(node) } | ||
2473 | } | ||
2474 | impl From<Shr> for BinOp { | ||
2475 | fn from(node: Shr) -> BinOp { BinOp::Shr(node) } | ||
2476 | } | ||
2477 | impl From<Caret> for BinOp { | ||
2478 | fn from(node: Caret) -> BinOp { BinOp::Caret(node) } | ||
2479 | } | ||
2480 | impl From<Pipe> for BinOp { | ||
2481 | fn from(node: Pipe) -> BinOp { BinOp::Pipe(node) } | ||
2482 | } | ||
2483 | impl From<Amp> for BinOp { | ||
2484 | fn from(node: Amp) -> BinOp { BinOp::Amp(node) } | ||
2485 | } | ||
2486 | impl From<Eq> for BinOp { | ||
2487 | fn from(node: Eq) -> BinOp { BinOp::Eq(node) } | ||
2488 | } | ||
2489 | impl From<Pluseq> for BinOp { | ||
2490 | fn from(node: Pluseq) -> BinOp { BinOp::Pluseq(node) } | ||
2491 | } | ||
2492 | impl From<Slasheq> for BinOp { | ||
2493 | fn from(node: Slasheq) -> BinOp { BinOp::Slasheq(node) } | ||
2494 | } | ||
2495 | impl From<Stareq> for BinOp { | ||
2496 | fn from(node: Stareq) -> BinOp { BinOp::Stareq(node) } | ||
2497 | } | ||
2498 | impl From<Percenteq> for BinOp { | ||
2499 | fn from(node: Percenteq) -> BinOp { BinOp::Percenteq(node) } | ||
2500 | } | ||
2501 | impl From<Shreq> for BinOp { | ||
2502 | fn from(node: Shreq) -> BinOp { BinOp::Shreq(node) } | ||
2503 | } | ||
2504 | impl From<Shleq> for BinOp { | ||
2505 | fn from(node: Shleq) -> BinOp { BinOp::Shleq(node) } | ||
2506 | } | ||
2507 | impl From<Minuseq> for BinOp { | ||
2508 | fn from(node: Minuseq) -> BinOp { BinOp::Minuseq(node) } | ||
2509 | } | ||
2510 | impl From<Pipeeq> for BinOp { | ||
2511 | fn from(node: Pipeeq) -> BinOp { BinOp::Pipeeq(node) } | ||
2512 | } | ||
2513 | impl From<Ampeq> for BinOp { | ||
2514 | fn from(node: Ampeq) -> BinOp { BinOp::Ampeq(node) } | ||
2515 | } | ||
2516 | impl From<Careteq> for BinOp { | ||
2517 | fn from(node: Careteq) -> BinOp { BinOp::Careteq(node) } | ||
2518 | } | ||
2519 | impl std::fmt::Display for BinOp { | ||
2520 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2521 | std::fmt::Display::fmt(self.syntax(), f) | ||
2522 | } | ||
2523 | } | ||
2524 | impl AstToken for BinOp { | ||
2525 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2526 | match kind { | ||
2527 | PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR | ||
2528 | | MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ | ||
2529 | | STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true, | ||
2530 | _ => false, | ||
2531 | } | ||
2532 | } | ||
2533 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2534 | let res = match syntax.kind() { | ||
2535 | PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }), | ||
2536 | AMPAMP => BinOp::Ampamp(Ampamp { syntax }), | ||
2537 | EQEQ => BinOp::Eqeq(Eqeq { syntax }), | ||
2538 | NEQ => BinOp::Neq(Neq { syntax }), | ||
2539 | LTEQ => BinOp::Lteq(Lteq { syntax }), | ||
2540 | GTEQ => BinOp::Gteq(Gteq { syntax }), | ||
2541 | L_ANGLE => BinOp::LAngle(LAngle { syntax }), | ||
2542 | R_ANGLE => BinOp::RAngle(RAngle { syntax }), | ||
2543 | PLUS => BinOp::Plus(Plus { syntax }), | ||
2544 | STAR => BinOp::Star(Star { syntax }), | ||
2545 | MINUS => BinOp::Minus(Minus { syntax }), | ||
2546 | SLASH => BinOp::Slash(Slash { syntax }), | ||
2547 | PERCENT => BinOp::Percent(Percent { syntax }), | ||
2548 | SHL => BinOp::Shl(Shl { syntax }), | ||
2549 | SHR => BinOp::Shr(Shr { syntax }), | ||
2550 | CARET => BinOp::Caret(Caret { syntax }), | ||
2551 | PIPE => BinOp::Pipe(Pipe { syntax }), | ||
2552 | AMP => BinOp::Amp(Amp { syntax }), | ||
2553 | EQ => BinOp::Eq(Eq { syntax }), | ||
2554 | PLUSEQ => BinOp::Pluseq(Pluseq { syntax }), | ||
2555 | SLASHEQ => BinOp::Slasheq(Slasheq { syntax }), | ||
2556 | STAREQ => BinOp::Stareq(Stareq { syntax }), | ||
2557 | PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }), | ||
2558 | SHREQ => BinOp::Shreq(Shreq { syntax }), | ||
2559 | SHLEQ => BinOp::Shleq(Shleq { syntax }), | ||
2560 | MINUSEQ => BinOp::Minuseq(Minuseq { syntax }), | ||
2561 | PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }), | ||
2562 | AMPEQ => BinOp::Ampeq(Ampeq { syntax }), | ||
2563 | CARETEQ => BinOp::Careteq(Careteq { syntax }), | ||
2564 | _ => return None, | ||
2565 | }; | ||
2566 | Some(res) | ||
2567 | } | ||
2568 | fn syntax(&self) -> &SyntaxToken { | ||
2569 | match self { | ||
2570 | BinOp::Pipepipe(it) => &it.syntax, | ||
2571 | BinOp::Ampamp(it) => &it.syntax, | ||
2572 | BinOp::Eqeq(it) => &it.syntax, | ||
2573 | BinOp::Neq(it) => &it.syntax, | ||
2574 | BinOp::Lteq(it) => &it.syntax, | ||
2575 | BinOp::Gteq(it) => &it.syntax, | ||
2576 | BinOp::LAngle(it) => &it.syntax, | ||
2577 | BinOp::RAngle(it) => &it.syntax, | ||
2578 | BinOp::Plus(it) => &it.syntax, | ||
2579 | BinOp::Star(it) => &it.syntax, | ||
2580 | BinOp::Minus(it) => &it.syntax, | ||
2581 | BinOp::Slash(it) => &it.syntax, | ||
2582 | BinOp::Percent(it) => &it.syntax, | ||
2583 | BinOp::Shl(it) => &it.syntax, | ||
2584 | BinOp::Shr(it) => &it.syntax, | ||
2585 | BinOp::Caret(it) => &it.syntax, | ||
2586 | BinOp::Pipe(it) => &it.syntax, | ||
2587 | BinOp::Amp(it) => &it.syntax, | ||
2588 | BinOp::Eq(it) => &it.syntax, | ||
2589 | BinOp::Pluseq(it) => &it.syntax, | ||
2590 | BinOp::Slasheq(it) => &it.syntax, | ||
2591 | BinOp::Stareq(it) => &it.syntax, | ||
2592 | BinOp::Percenteq(it) => &it.syntax, | ||
2593 | BinOp::Shreq(it) => &it.syntax, | ||
2594 | BinOp::Shleq(it) => &it.syntax, | ||
2595 | BinOp::Minuseq(it) => &it.syntax, | ||
2596 | BinOp::Pipeeq(it) => &it.syntax, | ||
2597 | BinOp::Ampeq(it) => &it.syntax, | ||
2598 | BinOp::Careteq(it) => &it.syntax, | ||
2599 | } | ||
2600 | } | ||
2601 | } | ||
2602 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2603 | pub enum PrefixOp { | ||
2604 | Minus(Minus), | ||
2605 | Excl(Excl), | ||
2606 | Star(Star), | ||
2607 | } | ||
2608 | impl From<Minus> for PrefixOp { | ||
2609 | fn from(node: Minus) -> PrefixOp { PrefixOp::Minus(node) } | ||
2610 | } | ||
2611 | impl From<Excl> for PrefixOp { | ||
2612 | fn from(node: Excl) -> PrefixOp { PrefixOp::Excl(node) } | ||
2613 | } | ||
2614 | impl From<Star> for PrefixOp { | ||
2615 | fn from(node: Star) -> PrefixOp { PrefixOp::Star(node) } | ||
2616 | } | ||
2617 | impl std::fmt::Display for PrefixOp { | ||
2618 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2619 | std::fmt::Display::fmt(self.syntax(), f) | ||
2620 | } | ||
2621 | } | ||
2622 | impl AstToken for PrefixOp { | ||
2623 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2624 | match kind { | ||
2625 | MINUS | EXCL | STAR => true, | ||
2626 | _ => false, | ||
2627 | } | ||
2628 | } | ||
2629 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2630 | let res = match syntax.kind() { | ||
2631 | MINUS => PrefixOp::Minus(Minus { syntax }), | ||
2632 | EXCL => PrefixOp::Excl(Excl { syntax }), | ||
2633 | STAR => PrefixOp::Star(Star { syntax }), | ||
2634 | _ => return None, | ||
2635 | }; | ||
2636 | Some(res) | ||
2637 | } | ||
2638 | fn syntax(&self) -> &SyntaxToken { | ||
2639 | match self { | ||
2640 | PrefixOp::Minus(it) => &it.syntax, | ||
2641 | PrefixOp::Excl(it) => &it.syntax, | ||
2642 | PrefixOp::Star(it) => &it.syntax, | ||
2643 | } | ||
2644 | } | ||
2645 | } | ||
2646 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2647 | pub enum RangeOp { | ||
2648 | Dotdot(Dotdot), | ||
2649 | Dotdoteq(Dotdoteq), | ||
2650 | } | ||
2651 | impl From<Dotdot> for RangeOp { | ||
2652 | fn from(node: Dotdot) -> RangeOp { RangeOp::Dotdot(node) } | ||
2653 | } | ||
2654 | impl From<Dotdoteq> for RangeOp { | ||
2655 | fn from(node: Dotdoteq) -> RangeOp { RangeOp::Dotdoteq(node) } | ||
2656 | } | ||
2657 | impl std::fmt::Display for RangeOp { | ||
2658 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2659 | std::fmt::Display::fmt(self.syntax(), f) | ||
2660 | } | ||
2661 | } | ||
2662 | impl AstToken for RangeOp { | ||
2663 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2664 | match kind { | ||
2665 | DOTDOT | DOTDOTEQ => true, | ||
2666 | _ => false, | ||
2667 | } | ||
2668 | } | ||
2669 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2670 | let res = match syntax.kind() { | ||
2671 | DOTDOT => RangeOp::Dotdot(Dotdot { syntax }), | ||
2672 | DOTDOTEQ => RangeOp::Dotdoteq(Dotdoteq { syntax }), | ||
2673 | _ => return None, | ||
2674 | }; | ||
2675 | Some(res) | ||
2676 | } | ||
2677 | fn syntax(&self) -> &SyntaxToken { | ||
2678 | match self { | ||
2679 | RangeOp::Dotdot(it) => &it.syntax, | ||
2680 | RangeOp::Dotdoteq(it) => &it.syntax, | ||
2681 | } | ||
2682 | } | ||
2683 | } | ||
2684 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2685 | pub enum LiteralToken { | ||
2686 | IntNumber(IntNumber), | ||
2687 | FloatNumber(FloatNumber), | ||
2688 | String(String), | ||
2689 | RawString(RawString), | ||
2690 | TrueKw(TrueKw), | ||
2691 | FalseKw(FalseKw), | ||
2692 | ByteString(ByteString), | ||
2693 | RawByteString(RawByteString), | ||
2694 | Char(Char), | ||
2695 | Byte(Byte), | ||
2696 | } | ||
2697 | impl From<IntNumber> for LiteralToken { | ||
2698 | fn from(node: IntNumber) -> LiteralToken { LiteralToken::IntNumber(node) } | ||
2699 | } | ||
2700 | impl From<FloatNumber> for LiteralToken { | ||
2701 | fn from(node: FloatNumber) -> LiteralToken { LiteralToken::FloatNumber(node) } | ||
2702 | } | ||
2703 | impl From<String> for LiteralToken { | ||
2704 | fn from(node: String) -> LiteralToken { LiteralToken::String(node) } | ||
2705 | } | ||
2706 | impl From<RawString> for LiteralToken { | ||
2707 | fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) } | ||
2708 | } | ||
2709 | impl From<TrueKw> for LiteralToken { | ||
2710 | fn from(node: TrueKw) -> LiteralToken { LiteralToken::TrueKw(node) } | ||
2711 | } | ||
2712 | impl From<FalseKw> for LiteralToken { | ||
2713 | fn from(node: FalseKw) -> LiteralToken { LiteralToken::FalseKw(node) } | ||
2714 | } | ||
2715 | impl From<ByteString> for LiteralToken { | ||
2716 | fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) } | ||
2717 | } | ||
2718 | impl From<RawByteString> for LiteralToken { | ||
2719 | fn from(node: RawByteString) -> LiteralToken { LiteralToken::RawByteString(node) } | ||
2720 | } | ||
2721 | impl From<Char> for LiteralToken { | ||
2722 | fn from(node: Char) -> LiteralToken { LiteralToken::Char(node) } | ||
2723 | } | ||
2724 | impl From<Byte> for LiteralToken { | ||
2725 | fn from(node: Byte) -> LiteralToken { LiteralToken::Byte(node) } | ||
2726 | } | ||
2727 | impl std::fmt::Display for LiteralToken { | ||
2728 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2729 | std::fmt::Display::fmt(self.syntax(), f) | ||
2730 | } | ||
2731 | } | ||
2732 | impl AstToken for LiteralToken { | ||
2733 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2734 | match kind { | ||
2735 | INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING | ||
2736 | | RAW_BYTE_STRING | CHAR | BYTE => true, | ||
2737 | _ => false, | ||
2738 | } | ||
2739 | } | ||
2740 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2741 | let res = match syntax.kind() { | ||
2742 | INT_NUMBER => LiteralToken::IntNumber(IntNumber { syntax }), | ||
2743 | FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }), | ||
2744 | STRING => LiteralToken::String(String { syntax }), | ||
2745 | RAW_STRING => LiteralToken::RawString(RawString { syntax }), | ||
2746 | TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }), | ||
2747 | FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }), | ||
2748 | BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }), | ||
2749 | RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }), | ||
2750 | CHAR => LiteralToken::Char(Char { syntax }), | ||
2751 | BYTE => LiteralToken::Byte(Byte { syntax }), | ||
2752 | _ => return None, | ||
2753 | }; | ||
2754 | Some(res) | ||
2755 | } | ||
2756 | fn syntax(&self) -> &SyntaxToken { | ||
2757 | match self { | ||
2758 | LiteralToken::IntNumber(it) => &it.syntax, | ||
2759 | LiteralToken::FloatNumber(it) => &it.syntax, | ||
2760 | LiteralToken::String(it) => &it.syntax, | ||
2761 | LiteralToken::RawString(it) => &it.syntax, | ||
2762 | LiteralToken::TrueKw(it) => &it.syntax, | ||
2763 | LiteralToken::FalseKw(it) => &it.syntax, | ||
2764 | LiteralToken::ByteString(it) => &it.syntax, | ||
2765 | LiteralToken::RawByteString(it) => &it.syntax, | ||
2766 | LiteralToken::Char(it) => &it.syntax, | ||
2767 | LiteralToken::Byte(it) => &it.syntax, | ||
2768 | } | ||
2769 | } | ||
2770 | } | ||
2771 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
2772 | pub enum NameRefToken { | ||
2773 | Ident(Ident), | ||
2774 | IntNumber(IntNumber), | ||
2775 | } | ||
2776 | impl From<Ident> for NameRefToken { | ||
2777 | fn from(node: Ident) -> NameRefToken { NameRefToken::Ident(node) } | ||
2778 | } | ||
2779 | impl From<IntNumber> for NameRefToken { | ||
2780 | fn from(node: IntNumber) -> NameRefToken { NameRefToken::IntNumber(node) } | ||
2781 | } | ||
2782 | impl std::fmt::Display for NameRefToken { | ||
2783 | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
2784 | std::fmt::Display::fmt(self.syntax(), f) | ||
2785 | } | ||
2786 | } | ||
2787 | impl AstToken for NameRefToken { | ||
2788 | fn can_cast(kind: SyntaxKind) -> bool { | ||
2789 | match kind { | ||
2790 | IDENT | INT_NUMBER => true, | ||
2791 | _ => false, | ||
2792 | } | ||
2793 | } | ||
2794 | fn cast(syntax: SyntaxToken) -> Option<Self> { | ||
2795 | let res = match syntax.kind() { | ||
2796 | IDENT => NameRefToken::Ident(Ident { syntax }), | ||
2797 | INT_NUMBER => NameRefToken::IntNumber(IntNumber { syntax }), | ||
2798 | _ => return None, | ||
2799 | }; | ||
2800 | Some(res) | ||
2801 | } | ||
2802 | fn syntax(&self) -> &SyntaxToken { | ||
2803 | match self { | ||
2804 | NameRefToken::Ident(it) => &it.syntax, | ||
2805 | NameRefToken::IntNumber(it) => &it.syntax, | ||
2806 | } | ||
2807 | } | ||
2808 | } | ||
diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index 576378306..870e83804 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs | |||
@@ -5,7 +5,7 @@ | |||
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, | 8 | ast::{self, child_opt, children, support, AstChildren, AstNode, AstToken}, |
9 | syntax_node::SyntaxElementChildren, | 9 | syntax_node::SyntaxElementChildren, |
10 | }; | 10 | }; |
11 | 11 | ||
@@ -31,6 +31,10 @@ pub trait LoopBodyOwner: AstNode { | |||
31 | fn loop_body(&self) -> Option<ast::BlockExpr> { | 31 | fn loop_body(&self) -> Option<ast::BlockExpr> { |
32 | child_opt(self) | 32 | child_opt(self) |
33 | } | 33 | } |
34 | |||
35 | fn label(&self) -> Option<ast::Label> { | ||
36 | child_opt(self) | ||
37 | } | ||
34 | } | 38 | } |
35 | 39 | ||
36 | pub trait ArgListOwner: AstNode { | 40 | pub trait ArgListOwner: AstNode { |
@@ -65,6 +69,10 @@ pub trait TypeBoundsOwner: AstNode { | |||
65 | fn type_bound_list(&self) -> Option<ast::TypeBoundList> { | 69 | fn type_bound_list(&self) -> Option<ast::TypeBoundList> { |
66 | child_opt(self) | 70 | child_opt(self) |
67 | } | 71 | } |
72 | |||
73 | fn colon(&self) -> Option<ast::Colon> { | ||
74 | support::token(self.syntax()) | ||
75 | } | ||
68 | } | 76 | } |
69 | 77 | ||
70 | pub trait AttrsOwner: AstNode { | 78 | pub trait AttrsOwner: AstNode { |