diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/ast.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 6 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/extensions.rs | 18 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/nodes.rs | 140 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated/tokens.rs | 916 |
5 files changed, 87 insertions, 999 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index cb701f7f6..1ee60e74c 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs | |||
@@ -80,7 +80,7 @@ impl<N: AstNode> Iterator for AstChildren<N> { | |||
80 | } | 80 | } |
81 | 81 | ||
82 | mod support { | 82 | mod support { |
83 | use super::{AstChildren, AstNode, AstToken, SyntaxNode}; | 83 | use super::{AstChildren, AstNode, AstToken, SyntaxKind, SyntaxNode, SyntaxToken}; |
84 | 84 | ||
85 | pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> { | 85 | pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> { |
86 | parent.children().find_map(N::cast) | 86 | parent.children().find_map(N::cast) |
@@ -93,6 +93,10 @@ mod support { | |||
93 | pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> { | 93 | pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> { |
94 | parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast) | 94 | parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast) |
95 | } | 95 | } |
96 | |||
97 | pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> { | ||
98 | parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind) | ||
99 | } | ||
96 | } | 100 | } |
97 | 101 | ||
98 | #[test] | 102 | #[test] |
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 5c5f19622..93aa3d45f 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -48,12 +48,6 @@ impl ast::IfExpr { | |||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | impl ast::RefExpr { | ||
52 | pub fn raw_token(&self) -> Option<SyntaxToken> { | ||
53 | None // FIXME: implement &raw | ||
54 | } | ||
55 | } | ||
56 | |||
57 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] | 51 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] |
58 | pub enum PrefixOp { | 52 | pub enum PrefixOp { |
59 | /// The `*` operator for dereferencing | 53 | /// The `*` operator for dereferencing |
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index fc252e79c..11ec70bc0 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs | |||
@@ -279,7 +279,7 @@ pub enum SelfParamKind { | |||
279 | impl ast::SelfParam { | 279 | impl ast::SelfParam { |
280 | pub fn kind(&self) -> SelfParamKind { | 280 | pub fn kind(&self) -> SelfParamKind { |
281 | if self.amp_token().is_some() { | 281 | if self.amp_token().is_some() { |
282 | if self.amp_mut_kw_token().is_some() { | 282 | if self.amp_mut_token().is_some() { |
283 | SelfParamKind::MutRef | 283 | SelfParamKind::MutRef |
284 | } else { | 284 | } else { |
285 | SelfParamKind::Ref | 285 | SelfParamKind::Ref |
@@ -290,21 +290,21 @@ impl ast::SelfParam { | |||
290 | } | 290 | } |
291 | 291 | ||
292 | /// the "mut" in "mut self", not the one in "&mut self" | 292 | /// the "mut" in "mut self", not the one in "&mut self" |
293 | pub fn mut_kw_token(&self) -> Option<ast::MutKw> { | 293 | pub fn mut_token(&self) -> Option<SyntaxToken> { |
294 | self.syntax() | 294 | self.syntax() |
295 | .children_with_tokens() | 295 | .children_with_tokens() |
296 | .filter_map(|it| it.into_token()) | 296 | .filter_map(|it| it.into_token()) |
297 | .take_while(|it| it.kind() != T![&]) | 297 | .take_while(|it| it.kind() != T![&]) |
298 | .find_map(ast::MutKw::cast) | 298 | .find(|it| it.kind() == T![mut]) |
299 | } | 299 | } |
300 | 300 | ||
301 | /// the "mut" in "&mut self", not the one in "mut self" | 301 | /// the "mut" in "&mut self", not the one in "mut self" |
302 | pub fn amp_mut_kw_token(&self) -> Option<ast::MutKw> { | 302 | pub fn amp_mut_token(&self) -> Option<SyntaxToken> { |
303 | self.syntax() | 303 | self.syntax() |
304 | .children_with_tokens() | 304 | .children_with_tokens() |
305 | .filter_map(|it| it.into_token()) | 305 | .filter_map(|it| it.into_token()) |
306 | .skip_while(|it| it.kind() != T![&]) | 306 | .skip_while(|it| it.kind() != T![&]) |
307 | .find_map(ast::MutKw::cast) | 307 | .find(|it| it.kind() == T![mut]) |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
@@ -340,7 +340,7 @@ impl ast::TypeBound { | |||
340 | } | 340 | } |
341 | 341 | ||
342 | pub fn question_token(&self) -> Option<ast::Question> { | 342 | pub fn question_token(&self) -> Option<ast::Question> { |
343 | if self.const_kw_token().is_some() { | 343 | if self.const_token().is_some() { |
344 | self.syntax() | 344 | self.syntax() |
345 | .children_with_tokens() | 345 | .children_with_tokens() |
346 | .filter_map(|it| it.into_token()) | 346 | .filter_map(|it| it.into_token()) |
@@ -364,11 +364,11 @@ impl ast::Visibility { | |||
364 | pub fn kind(&self) -> VisibilityKind { | 364 | pub fn kind(&self) -> VisibilityKind { |
365 | if let Some(path) = support::children(self.syntax()).next() { | 365 | if let Some(path) = support::children(self.syntax()).next() { |
366 | VisibilityKind::In(path) | 366 | VisibilityKind::In(path) |
367 | } else if self.crate_kw_token().is_some() { | 367 | } else if self.crate_token().is_some() { |
368 | VisibilityKind::PubCrate | 368 | VisibilityKind::PubCrate |
369 | } else if self.super_kw_token().is_some() { | 369 | } else if self.super_token().is_some() { |
370 | VisibilityKind::PubSuper | 370 | VisibilityKind::PubSuper |
371 | } else if self.self_kw_token().is_some() { | 371 | } else if self.self_token().is_some() { |
372 | VisibilityKind::PubSuper | 372 | VisibilityKind::PubSuper |
373 | } else { | 373 | } else { |
374 | VisibilityKind::Pub | 374 | VisibilityKind::Pub |
diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 3b820507d..20f663046 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs | |||
@@ -4,7 +4,7 @@ use super::tokens::*; | |||
4 | use crate::{ | 4 | use crate::{ |
5 | ast::{self, support, AstChildren, AstNode}, | 5 | ast::{self, support, AstChildren, AstNode}, |
6 | SyntaxKind::{self, *}, | 6 | SyntaxKind::{self, *}, |
7 | SyntaxNode, | 7 | SyntaxNode, SyntaxToken, |
8 | }; | 8 | }; |
9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
10 | pub struct SourceFile { | 10 | pub struct SourceFile { |
@@ -48,11 +48,11 @@ impl ast::DocCommentsOwner for FnDef {} | |||
48 | impl ast::AttrsOwner for FnDef {} | 48 | impl ast::AttrsOwner for FnDef {} |
49 | impl FnDef { | 49 | impl FnDef { |
50 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | 50 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } |
51 | pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } | 51 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) } |
52 | pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | 52 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) } |
53 | pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) } | 53 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ASYNC_KW) } |
54 | pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | 54 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) } |
55 | pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) } | 55 | pub fn fn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FN_KW) } |
56 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 56 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
57 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 57 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
58 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 58 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
@@ -98,7 +98,7 @@ impl ast::TypeParamsOwner for StructDef {} | |||
98 | impl ast::AttrsOwner for StructDef {} | 98 | impl ast::AttrsOwner for StructDef {} |
99 | impl ast::DocCommentsOwner for StructDef {} | 99 | impl ast::DocCommentsOwner for StructDef {} |
100 | impl StructDef { | 100 | impl StructDef { |
101 | pub fn struct_kw_token(&self) -> Option<StructKw> { support::token(&self.syntax) } | 101 | pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STRUCT_KW) } |
102 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } | 102 | pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) } |
103 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } | 103 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } |
104 | } | 104 | } |
@@ -123,7 +123,7 @@ impl ast::TypeParamsOwner for UnionDef {} | |||
123 | impl ast::AttrsOwner for UnionDef {} | 123 | impl ast::AttrsOwner for UnionDef {} |
124 | impl ast::DocCommentsOwner for UnionDef {} | 124 | impl ast::DocCommentsOwner for UnionDef {} |
125 | impl UnionDef { | 125 | impl UnionDef { |
126 | pub fn union_kw_token(&self) -> Option<UnionKw> { support::token(&self.syntax) } | 126 | pub fn union_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNION_KW) } |
127 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { | 127 | pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> { |
128 | support::child(&self.syntax) | 128 | support::child(&self.syntax) |
129 | } | 129 | } |
@@ -230,7 +230,7 @@ impl ast::TypeParamsOwner for EnumDef {} | |||
230 | impl ast::AttrsOwner for EnumDef {} | 230 | impl ast::AttrsOwner for EnumDef {} |
231 | impl ast::DocCommentsOwner for EnumDef {} | 231 | impl ast::DocCommentsOwner for EnumDef {} |
232 | impl EnumDef { | 232 | impl EnumDef { |
233 | pub fn enum_kw_token(&self) -> Option<EnumKw> { support::token(&self.syntax) } | 233 | pub fn enum_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ENUM_KW) } |
234 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } | 234 | pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) } |
235 | } | 235 | } |
236 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 236 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -299,9 +299,9 @@ impl ast::DocCommentsOwner for TraitDef {} | |||
299 | impl ast::TypeParamsOwner for TraitDef {} | 299 | impl ast::TypeParamsOwner for TraitDef {} |
300 | impl ast::TypeBoundsOwner for TraitDef {} | 300 | impl ast::TypeBoundsOwner for TraitDef {} |
301 | impl TraitDef { | 301 | impl TraitDef { |
302 | pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | 302 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) } |
303 | pub fn auto_kw_token(&self) -> Option<AutoKw> { support::token(&self.syntax) } | 303 | pub fn auto_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AUTO_KW) } |
304 | pub fn trait_kw_token(&self) -> Option<TraitKw> { support::token(&self.syntax) } | 304 | pub fn trait_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRAIT_KW) } |
305 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 305 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
306 | } | 306 | } |
307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 307 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -324,7 +324,7 @@ impl ast::NameOwner for Module {} | |||
324 | impl ast::AttrsOwner for Module {} | 324 | impl ast::AttrsOwner for Module {} |
325 | impl ast::DocCommentsOwner for Module {} | 325 | impl ast::DocCommentsOwner for Module {} |
326 | impl Module { | 326 | impl Module { |
327 | pub fn mod_kw_token(&self) -> Option<ModKw> { support::token(&self.syntax) } | 327 | pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MOD_KW) } |
328 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 328 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
329 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } | 329 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } |
330 | } | 330 | } |
@@ -371,8 +371,8 @@ impl ast::AttrsOwner for ConstDef {} | |||
371 | impl ast::DocCommentsOwner for ConstDef {} | 371 | impl ast::DocCommentsOwner for ConstDef {} |
372 | impl ast::TypeAscriptionOwner for ConstDef {} | 372 | impl ast::TypeAscriptionOwner for ConstDef {} |
373 | impl ConstDef { | 373 | impl ConstDef { |
374 | pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | 374 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) } |
375 | pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } | 375 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) } |
376 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 376 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
377 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 377 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
378 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } | 378 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } |
@@ -399,8 +399,8 @@ impl ast::AttrsOwner for StaticDef {} | |||
399 | impl ast::DocCommentsOwner for StaticDef {} | 399 | impl ast::DocCommentsOwner for StaticDef {} |
400 | impl ast::TypeAscriptionOwner for StaticDef {} | 400 | impl ast::TypeAscriptionOwner for StaticDef {} |
401 | impl StaticDef { | 401 | impl StaticDef { |
402 | pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) } | 402 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STATIC_KW) } |
403 | pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } | 403 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) } |
404 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 404 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
405 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 405 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
406 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } | 406 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } |
@@ -427,8 +427,8 @@ impl ast::AttrsOwner for TypeAliasDef {} | |||
427 | impl ast::DocCommentsOwner for TypeAliasDef {} | 427 | impl ast::DocCommentsOwner for TypeAliasDef {} |
428 | impl ast::TypeBoundsOwner for TypeAliasDef {} | 428 | impl ast::TypeBoundsOwner for TypeAliasDef {} |
429 | impl TypeAliasDef { | 429 | impl TypeAliasDef { |
430 | pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | 430 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) } |
431 | pub fn type_kw_token(&self) -> Option<TypeKw> { support::token(&self.syntax) } | 431 | pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TYPE_KW) } |
432 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 432 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
433 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 433 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
434 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } | 434 | pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) } |
@@ -451,12 +451,12 @@ impl AstNode for ImplDef { | |||
451 | impl ast::TypeParamsOwner for ImplDef {} | 451 | impl ast::TypeParamsOwner for ImplDef {} |
452 | impl ast::AttrsOwner for ImplDef {} | 452 | impl ast::AttrsOwner for ImplDef {} |
453 | impl ImplDef { | 453 | impl ImplDef { |
454 | pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) } | 454 | pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) } |
455 | pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } | 455 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) } |
456 | pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | 456 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) } |
457 | pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) } | 457 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IMPL_KW) } |
458 | pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } | 458 | pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) } |
459 | pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) } | 459 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) } |
460 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } | 460 | pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) } |
461 | } | 461 | } |
462 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 462 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -552,8 +552,8 @@ impl AstNode for PointerType { | |||
552 | } | 552 | } |
553 | impl PointerType { | 553 | impl PointerType { |
554 | pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) } | 554 | pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) } |
555 | pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } | 555 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) } |
556 | pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } | 556 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) } |
557 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 557 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
558 | } | 558 | } |
559 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 559 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -616,7 +616,7 @@ impl AstNode for ReferenceType { | |||
616 | impl ReferenceType { | 616 | impl ReferenceType { |
617 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } | 617 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } |
618 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } | 618 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } |
619 | pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } | 619 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) } |
620 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 620 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
621 | } | 621 | } |
622 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 622 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -654,8 +654,8 @@ impl AstNode for FnPointerType { | |||
654 | } | 654 | } |
655 | impl FnPointerType { | 655 | impl FnPointerType { |
656 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } | 656 | pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) } |
657 | pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | 657 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) } |
658 | pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) } | 658 | pub fn fn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FN_KW) } |
659 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 659 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
660 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 660 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
661 | } | 661 | } |
@@ -675,7 +675,7 @@ impl AstNode for ForType { | |||
675 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 675 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
676 | } | 676 | } |
677 | impl ForType { | 677 | impl ForType { |
678 | pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) } | 678 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) } |
679 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } | 679 | pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) } |
680 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 680 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
681 | } | 681 | } |
@@ -696,7 +696,7 @@ impl AstNode for ImplTraitType { | |||
696 | } | 696 | } |
697 | impl ast::TypeBoundsOwner for ImplTraitType {} | 697 | impl ast::TypeBoundsOwner for ImplTraitType {} |
698 | impl ImplTraitType { | 698 | impl ImplTraitType { |
699 | pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) } | 699 | pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IMPL_KW) } |
700 | } | 700 | } |
701 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 701 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
702 | pub struct DynTraitType { | 702 | pub struct DynTraitType { |
@@ -715,7 +715,7 @@ impl AstNode for DynTraitType { | |||
715 | } | 715 | } |
716 | impl ast::TypeBoundsOwner for DynTraitType {} | 716 | impl ast::TypeBoundsOwner for DynTraitType {} |
717 | impl DynTraitType { | 717 | impl DynTraitType { |
718 | pub fn dyn_kw_token(&self) -> Option<DynKw> { support::token(&self.syntax) } | 718 | pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DYN_KW) } |
719 | } | 719 | } |
720 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 720 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
721 | pub struct TupleExpr { | 721 | pub struct TupleExpr { |
@@ -816,9 +816,9 @@ impl AstNode for LambdaExpr { | |||
816 | } | 816 | } |
817 | impl ast::AttrsOwner for LambdaExpr {} | 817 | impl ast::AttrsOwner for LambdaExpr {} |
818 | impl LambdaExpr { | 818 | impl LambdaExpr { |
819 | pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) } | 819 | pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STATIC_KW) } |
820 | pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) } | 820 | pub fn async_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ASYNC_KW) } |
821 | pub fn move_kw_token(&self) -> Option<MoveKw> { support::token(&self.syntax) } | 821 | pub fn move_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MOVE_KW) } |
822 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } | 822 | pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) } |
823 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } | 823 | pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) } |
824 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } | 824 | pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) } |
@@ -840,7 +840,7 @@ impl AstNode for IfExpr { | |||
840 | } | 840 | } |
841 | impl ast::AttrsOwner for IfExpr {} | 841 | impl ast::AttrsOwner for IfExpr {} |
842 | impl IfExpr { | 842 | impl IfExpr { |
843 | pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) } | 843 | pub fn if_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IF_KW) } |
844 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | 844 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } |
845 | } | 845 | } |
846 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 846 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -861,7 +861,7 @@ impl AstNode for LoopExpr { | |||
861 | impl ast::AttrsOwner for LoopExpr {} | 861 | impl ast::AttrsOwner for LoopExpr {} |
862 | impl ast::LoopBodyOwner for LoopExpr {} | 862 | impl ast::LoopBodyOwner for LoopExpr {} |
863 | impl LoopExpr { | 863 | impl LoopExpr { |
864 | pub fn loop_kw_token(&self) -> Option<LoopKw> { support::token(&self.syntax) } | 864 | pub fn loop_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LOOP_KW) } |
865 | } | 865 | } |
866 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 866 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
867 | pub struct TryBlockExpr { | 867 | pub struct TryBlockExpr { |
@@ -880,7 +880,7 @@ impl AstNode for TryBlockExpr { | |||
880 | } | 880 | } |
881 | impl ast::AttrsOwner for TryBlockExpr {} | 881 | impl ast::AttrsOwner for TryBlockExpr {} |
882 | impl TryBlockExpr { | 882 | impl TryBlockExpr { |
883 | pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) } | 883 | pub fn try_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRY_KW) } |
884 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } | 884 | pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) } |
885 | } | 885 | } |
886 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 886 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -901,9 +901,9 @@ impl AstNode for ForExpr { | |||
901 | impl ast::AttrsOwner for ForExpr {} | 901 | impl ast::AttrsOwner for ForExpr {} |
902 | impl ast::LoopBodyOwner for ForExpr {} | 902 | impl ast::LoopBodyOwner for ForExpr {} |
903 | impl ForExpr { | 903 | impl ForExpr { |
904 | pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) } | 904 | pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) } |
905 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 905 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
906 | pub fn in_kw_token(&self) -> Option<InKw> { support::token(&self.syntax) } | 906 | pub fn in_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IN_KW) } |
907 | pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } | 907 | pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) } |
908 | } | 908 | } |
909 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 909 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -924,7 +924,7 @@ impl AstNode for WhileExpr { | |||
924 | impl ast::AttrsOwner for WhileExpr {} | 924 | impl ast::AttrsOwner for WhileExpr {} |
925 | impl ast::LoopBodyOwner for WhileExpr {} | 925 | impl ast::LoopBodyOwner for WhileExpr {} |
926 | impl WhileExpr { | 926 | impl WhileExpr { |
927 | pub fn while_kw_token(&self) -> Option<WhileKw> { support::token(&self.syntax) } | 927 | pub fn while_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, WHILE_KW) } |
928 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } | 928 | pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) } |
929 | } | 929 | } |
930 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 930 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -944,7 +944,9 @@ impl AstNode for ContinueExpr { | |||
944 | } | 944 | } |
945 | impl ast::AttrsOwner for ContinueExpr {} | 945 | impl ast::AttrsOwner for ContinueExpr {} |
946 | impl ContinueExpr { | 946 | impl ContinueExpr { |
947 | pub fn continue_kw_token(&self) -> Option<ContinueKw> { support::token(&self.syntax) } | 947 | pub fn continue_token(&self) -> Option<SyntaxToken> { |
948 | support::token2(&self.syntax, CONTINUE_KW) | ||
949 | } | ||
948 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } | 950 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } |
949 | } | 951 | } |
950 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 952 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -964,7 +966,7 @@ impl AstNode for BreakExpr { | |||
964 | } | 966 | } |
965 | impl ast::AttrsOwner for BreakExpr {} | 967 | impl ast::AttrsOwner for BreakExpr {} |
966 | impl BreakExpr { | 968 | impl BreakExpr { |
967 | pub fn break_kw_token(&self) -> Option<BreakKw> { support::token(&self.syntax) } | 969 | pub fn break_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BREAK_KW) } |
968 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } | 970 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } |
969 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 971 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
970 | } | 972 | } |
@@ -1004,7 +1006,7 @@ impl AstNode for BlockExpr { | |||
1004 | impl ast::AttrsOwner for BlockExpr {} | 1006 | impl ast::AttrsOwner for BlockExpr {} |
1005 | impl BlockExpr { | 1007 | impl BlockExpr { |
1006 | pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } | 1008 | pub fn label(&self) -> Option<Label> { support::child(&self.syntax) } |
1007 | pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) } | 1009 | pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) } |
1008 | pub fn block(&self) -> Option<Block> { support::child(&self.syntax) } | 1010 | pub fn block(&self) -> Option<Block> { support::child(&self.syntax) } |
1009 | } | 1011 | } |
1010 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1012 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1128,7 +1130,7 @@ impl ast::AttrsOwner for AwaitExpr {} | |||
1128 | impl AwaitExpr { | 1130 | impl AwaitExpr { |
1129 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1131 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1130 | pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) } | 1132 | pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) } |
1131 | pub fn await_kw_token(&self) -> Option<AwaitKw> { support::token(&self.syntax) } | 1133 | pub fn await_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AWAIT_KW) } |
1132 | } | 1134 | } |
1133 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1135 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1134 | pub struct TryExpr { | 1136 | pub struct TryExpr { |
@@ -1147,7 +1149,7 @@ impl AstNode for TryExpr { | |||
1147 | } | 1149 | } |
1148 | impl ast::AttrsOwner for TryExpr {} | 1150 | impl ast::AttrsOwner for TryExpr {} |
1149 | impl TryExpr { | 1151 | impl TryExpr { |
1150 | pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) } | 1152 | pub fn try_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRY_KW) } |
1151 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1153 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1152 | } | 1154 | } |
1153 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1155 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1168,7 +1170,7 @@ impl AstNode for CastExpr { | |||
1168 | impl ast::AttrsOwner for CastExpr {} | 1170 | impl ast::AttrsOwner for CastExpr {} |
1169 | impl CastExpr { | 1171 | impl CastExpr { |
1170 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1172 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1171 | pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) } | 1173 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AS_KW) } |
1172 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 1174 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1173 | } | 1175 | } |
1174 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1176 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1189,8 +1191,8 @@ impl AstNode for RefExpr { | |||
1189 | impl ast::AttrsOwner for RefExpr {} | 1191 | impl ast::AttrsOwner for RefExpr {} |
1190 | impl RefExpr { | 1192 | impl RefExpr { |
1191 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } | 1193 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } |
1192 | pub fn raw_kw_token(&self) -> Option<RawKw> { support::token(&self.syntax) } | 1194 | pub fn raw_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, RAW_KW) } |
1193 | pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } | 1195 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) } |
1194 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1196 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1195 | } | 1197 | } |
1196 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1198 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1230,7 +1232,7 @@ impl AstNode for BoxExpr { | |||
1230 | } | 1232 | } |
1231 | impl ast::AttrsOwner for BoxExpr {} | 1233 | impl ast::AttrsOwner for BoxExpr {} |
1232 | impl BoxExpr { | 1234 | impl BoxExpr { |
1233 | pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) } | 1235 | pub fn box_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BOX_KW) } |
1234 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1236 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1235 | } | 1237 | } |
1236 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1238 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1306,7 +1308,7 @@ impl AstNode for MatchExpr { | |||
1306 | } | 1308 | } |
1307 | impl ast::AttrsOwner for MatchExpr {} | 1309 | impl ast::AttrsOwner for MatchExpr {} |
1308 | impl MatchExpr { | 1310 | impl MatchExpr { |
1309 | pub fn match_kw_token(&self) -> Option<MatchKw> { support::token(&self.syntax) } | 1311 | pub fn match_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MATCH_KW) } |
1310 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1312 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1311 | pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } | 1313 | pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) } |
1312 | } | 1314 | } |
@@ -1369,7 +1371,7 @@ impl AstNode for MatchGuard { | |||
1369 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1371 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1370 | } | 1372 | } |
1371 | impl MatchGuard { | 1373 | impl MatchGuard { |
1372 | pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) } | 1374 | pub fn if_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IF_KW) } |
1373 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 1375 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
1374 | } | 1376 | } |
1375 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1377 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1489,7 +1491,7 @@ impl AstNode for RefPat { | |||
1489 | } | 1491 | } |
1490 | impl RefPat { | 1492 | impl RefPat { |
1491 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } | 1493 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } |
1492 | pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } | 1494 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) } |
1493 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1495 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
1494 | } | 1496 | } |
1495 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1497 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1508,7 +1510,7 @@ impl AstNode for BoxPat { | |||
1508 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1510 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1509 | } | 1511 | } |
1510 | impl BoxPat { | 1512 | impl BoxPat { |
1511 | pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) } | 1513 | pub fn box_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BOX_KW) } |
1512 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1514 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
1513 | } | 1515 | } |
1514 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1516 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -1529,8 +1531,8 @@ impl AstNode for BindPat { | |||
1529 | impl ast::AttrsOwner for BindPat {} | 1531 | impl ast::AttrsOwner for BindPat {} |
1530 | impl ast::NameOwner for BindPat {} | 1532 | impl ast::NameOwner for BindPat {} |
1531 | impl BindPat { | 1533 | impl BindPat { |
1532 | pub fn ref_kw_token(&self) -> Option<RefKw> { support::token(&self.syntax) } | 1534 | pub fn ref_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, REF_KW) } |
1533 | pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) } | 1535 | pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) } |
1534 | pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) } | 1536 | pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) } |
1535 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 1537 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
1536 | } | 1538 | } |
@@ -1786,10 +1788,10 @@ impl AstNode for Visibility { | |||
1786 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 1788 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
1787 | } | 1789 | } |
1788 | impl Visibility { | 1790 | impl Visibility { |
1789 | pub fn pub_kw_token(&self) -> Option<PubKw> { support::token(&self.syntax) } | 1791 | pub fn pub_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, PUB_KW) } |
1790 | pub fn super_kw_token(&self) -> Option<SuperKw> { support::token(&self.syntax) } | 1792 | pub fn super_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SUPER_KW) } |
1791 | pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) } | 1793 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SELF_KW) } |
1792 | pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) } | 1794 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CRATE_KW) } |
1793 | } | 1795 | } |
1794 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 1796 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
1795 | pub struct Name { | 1797 | pub struct Name { |
@@ -1994,7 +1996,7 @@ impl AstNode for TypeBound { | |||
1994 | } | 1996 | } |
1995 | impl TypeBound { | 1997 | impl TypeBound { |
1996 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } | 1998 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } |
1997 | pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) } | 1999 | pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) } |
1998 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } | 2000 | pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) } |
1999 | } | 2001 | } |
2000 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2002 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -2051,7 +2053,7 @@ impl AstNode for WhereClause { | |||
2051 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2053 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2052 | } | 2054 | } |
2053 | impl WhereClause { | 2055 | impl WhereClause { |
2054 | pub fn where_kw_token(&self) -> Option<WhereKw> { support::token(&self.syntax) } | 2056 | pub fn where_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, WHERE_KW) } |
2055 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } | 2057 | pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) } |
2056 | } | 2058 | } |
2057 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2059 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -2110,7 +2112,7 @@ impl AstNode for LetStmt { | |||
2110 | impl ast::AttrsOwner for LetStmt {} | 2112 | impl ast::AttrsOwner for LetStmt {} |
2111 | impl ast::TypeAscriptionOwner for LetStmt {} | 2113 | impl ast::TypeAscriptionOwner for LetStmt {} |
2112 | impl LetStmt { | 2114 | impl LetStmt { |
2113 | pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) } | 2115 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LET_KW) } |
2114 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 2116 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
2115 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 2117 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
2116 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } | 2118 | pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) } |
@@ -2132,7 +2134,7 @@ impl AstNode for Condition { | |||
2132 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | 2134 | fn syntax(&self) -> &SyntaxNode { &self.syntax } |
2133 | } | 2135 | } |
2134 | impl Condition { | 2136 | impl Condition { |
2135 | pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) } | 2137 | pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LET_KW) } |
2136 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } | 2138 | pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) } |
2137 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } | 2139 | pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) } |
2138 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } | 2140 | pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) } |
@@ -2201,7 +2203,7 @@ impl ast::AttrsOwner for SelfParam {} | |||
2201 | impl SelfParam { | 2203 | impl SelfParam { |
2202 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } | 2204 | pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) } |
2203 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } | 2205 | pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) } |
2204 | pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) } | 2206 | pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SELF_KW) } |
2205 | } | 2207 | } |
2206 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2208 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2207 | pub struct Param { | 2209 | pub struct Param { |
@@ -2242,7 +2244,7 @@ impl AstNode for UseItem { | |||
2242 | impl ast::AttrsOwner for UseItem {} | 2244 | impl ast::AttrsOwner for UseItem {} |
2243 | impl ast::VisibilityOwner for UseItem {} | 2245 | impl ast::VisibilityOwner for UseItem {} |
2244 | impl UseItem { | 2246 | impl UseItem { |
2245 | pub fn use_kw_token(&self) -> Option<UseKw> { support::token(&self.syntax) } | 2247 | pub fn use_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, USE_KW) } |
2246 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } | 2248 | pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) } |
2247 | } | 2249 | } |
2248 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2250 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
@@ -2283,7 +2285,7 @@ impl AstNode for Alias { | |||
2283 | } | 2285 | } |
2284 | impl ast::NameOwner for Alias {} | 2286 | impl ast::NameOwner for Alias {} |
2285 | impl Alias { | 2287 | impl Alias { |
2286 | pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) } | 2288 | pub fn as_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AS_KW) } |
2287 | } | 2289 | } |
2288 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 2290 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
2289 | pub struct UseTreeList { | 2291 | pub struct UseTreeList { |
@@ -2323,8 +2325,8 @@ impl AstNode for ExternCrateItem { | |||
2323 | impl ast::AttrsOwner for ExternCrateItem {} | 2325 | impl ast::AttrsOwner for ExternCrateItem {} |
2324 | impl ast::VisibilityOwner for ExternCrateItem {} | 2326 | impl ast::VisibilityOwner for ExternCrateItem {} |
2325 | impl ExternCrateItem { | 2327 | impl ExternCrateItem { |
2326 | pub fn extern_kw_token(&self) -> Option<ExternKw> { support::token(&self.syntax) } | 2328 | pub fn extern_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, EXTERN_KW) } |
2327 | pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) } | 2329 | pub fn crate_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CRATE_KW) } |
2328 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } | 2330 | pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) } |
2329 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } | 2331 | pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) } |
2330 | } | 2332 | } |
diff --git a/crates/ra_syntax/src/ast/generated/tokens.rs b/crates/ra_syntax/src/ast/generated/tokens.rs index e64b8bce6..7344b0e49 100644 --- a/crates/ra_syntax/src/ast/generated/tokens.rs +++ b/crates/ra_syntax/src/ast/generated/tokens.rs | |||
@@ -1046,906 +1046,6 @@ impl AstToken for Shreq { | |||
1046 | fn syntax(&self) -> &SyntaxToken { &self.syntax } | 1046 | fn syntax(&self) -> &SyntaxToken { &self.syntax } |
1047 | } | 1047 | } |
1048 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 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 { | 1049 | pub struct IntNumber { |
1950 | pub(crate) syntax: SyntaxToken, | 1050 | pub(crate) syntax: SyntaxToken, |
1951 | } | 1051 | } |
@@ -2687,8 +1787,6 @@ pub enum LiteralToken { | |||
2687 | FloatNumber(FloatNumber), | 1787 | FloatNumber(FloatNumber), |
2688 | String(String), | 1788 | String(String), |
2689 | RawString(RawString), | 1789 | RawString(RawString), |
2690 | TrueKw(TrueKw), | ||
2691 | FalseKw(FalseKw), | ||
2692 | ByteString(ByteString), | 1790 | ByteString(ByteString), |
2693 | RawByteString(RawByteString), | 1791 | RawByteString(RawByteString), |
2694 | Char(Char), | 1792 | Char(Char), |
@@ -2706,12 +1804,6 @@ impl From<String> for LiteralToken { | |||
2706 | impl From<RawString> for LiteralToken { | 1804 | impl From<RawString> for LiteralToken { |
2707 | fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) } | 1805 | fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) } |
2708 | } | 1806 | } |
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 { | 1807 | impl From<ByteString> for LiteralToken { |
2716 | fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) } | 1808 | fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) } |
2717 | } | 1809 | } |
@@ -2732,8 +1824,8 @@ impl std::fmt::Display for LiteralToken { | |||
2732 | impl AstToken for LiteralToken { | 1824 | impl AstToken for LiteralToken { |
2733 | fn can_cast(kind: SyntaxKind) -> bool { | 1825 | fn can_cast(kind: SyntaxKind) -> bool { |
2734 | match kind { | 1826 | match kind { |
2735 | INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING | 1827 | INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING |
2736 | | RAW_BYTE_STRING | CHAR | BYTE => true, | 1828 | | CHAR | BYTE => true, |
2737 | _ => false, | 1829 | _ => false, |
2738 | } | 1830 | } |
2739 | } | 1831 | } |
@@ -2743,8 +1835,6 @@ impl AstToken for LiteralToken { | |||
2743 | FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }), | 1835 | FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }), |
2744 | STRING => LiteralToken::String(String { syntax }), | 1836 | STRING => LiteralToken::String(String { syntax }), |
2745 | RAW_STRING => LiteralToken::RawString(RawString { syntax }), | 1837 | 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 }), | 1838 | BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }), |
2749 | RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }), | 1839 | RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }), |
2750 | CHAR => LiteralToken::Char(Char { syntax }), | 1840 | CHAR => LiteralToken::Char(Char { syntax }), |
@@ -2759,8 +1849,6 @@ impl AstToken for LiteralToken { | |||
2759 | LiteralToken::FloatNumber(it) => &it.syntax, | 1849 | LiteralToken::FloatNumber(it) => &it.syntax, |
2760 | LiteralToken::String(it) => &it.syntax, | 1850 | LiteralToken::String(it) => &it.syntax, |
2761 | LiteralToken::RawString(it) => &it.syntax, | 1851 | LiteralToken::RawString(it) => &it.syntax, |
2762 | LiteralToken::TrueKw(it) => &it.syntax, | ||
2763 | LiteralToken::FalseKw(it) => &it.syntax, | ||
2764 | LiteralToken::ByteString(it) => &it.syntax, | 1852 | LiteralToken::ByteString(it) => &it.syntax, |
2765 | LiteralToken::RawByteString(it) => &it.syntax, | 1853 | LiteralToken::RawByteString(it) => &it.syntax, |
2766 | LiteralToken::Char(it) => &it.syntax, | 1854 | LiteralToken::Char(it) => &it.syntax, |