From a95116fbfa11cad4e03b8b31f8d4498f3ddd5d9e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 18:20:06 +0200 Subject: Simplify --- crates/ra_syntax/src/ast/extensions.rs | 39 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 33fe60762..c7df15662 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -2,16 +2,14 @@ //! Extensions for various expressions live in a sibling `expr_extensions` module. use itertools::Itertools; +use ra_parser::SyntaxKind; use crate::{ ast::{ self, child_opt, children, support, AstNode, AstToken, AttrInput, NameOwner, SyntaxNode, }, - SmolStr, SyntaxElement, - SyntaxKind::*, - SyntaxToken, T, + SmolStr, SyntaxElement, SyntaxToken, T, }; -use ra_parser::SyntaxKind; impl ast::Name { pub fn text(&self) -> &SmolStr { @@ -25,13 +23,11 @@ impl ast::NameRef { } pub fn as_tuple_field(&self) -> Option { - self.syntax().children_with_tokens().find_map(|c| { - if c.kind() == SyntaxKind::INT_NUMBER { - c.as_token().and_then(|tok| tok.text().as_str().parse().ok()) - } else { - None - } - }) + if let Some(ast::NameRefToken::IntNumber(token)) = self.name_ref_token() { + token.text().as_str().parse().ok() + } else { + None + } } } @@ -142,10 +138,7 @@ impl ast::Path { impl ast::Module { pub fn has_semi(&self) -> bool { - match self.syntax().last_child_or_token() { - None => false, - Some(node) => node.kind() == T![;], - } + self.semi().is_some() } } @@ -181,7 +174,7 @@ impl ast::ImplDef { } pub fn is_negative(&self) -> bool { - self.syntax().children_with_tokens().any(|t| t.kind() == T![!]) + self.excl().is_some() } } @@ -225,14 +218,11 @@ impl ast::EnumVariant { impl ast::FnDef { pub fn semicolon_token(&self) -> Option { - self.syntax() - .last_child_or_token() - .and_then(|it| it.into_token()) - .filter(|it| it.kind() == T![;]) + Some(self.semi()?.syntax().clone()) } pub fn is_async(&self) -> bool { - self.syntax().children_with_tokens().any(|it| it.kind() == T![async]) + self.async_kw().is_some() } } @@ -245,16 +235,13 @@ impl ast::LetStmt { } pub fn eq_token(&self) -> Option { - self.syntax().children_with_tokens().find(|t| t.kind() == EQ).and_then(|it| it.into_token()) + Some(self.eq()?.syntax().clone()) } } impl ast::ExprStmt { pub fn has_semi(&self) -> bool { - match self.syntax().last_child_or_token() { - None => false, - Some(node) => node.kind() == T![;], - } + self.semi().is_some() } } -- cgit v1.2.3 From e6d22187a67e762bb950de244a6ca15f3a0b0731 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 18:25:36 +0200 Subject: Add _token suffix to token accessors I think this makes is more clear which things are : AstNode and which are : AstToken --- crates/ra_syntax/src/ast.rs | 2 +- crates/ra_syntax/src/ast/edit.rs | 6 +- crates/ra_syntax/src/ast/extensions.rs | 22 +- crates/ra_syntax/src/ast/generated/nodes.rs | 376 ++++++++++++++-------------- 4 files changed, 201 insertions(+), 205 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index a42eec91a..15a8279f3 100644 --- a/crates/ra_syntax/src/ast.rs +++ b/crates/ra_syntax/src/ast.rs @@ -287,7 +287,7 @@ where let pred = predicates.next().unwrap(); let mut bounds = pred.type_bound_list().unwrap().bounds(); - assert_eq!("'a", pred.lifetime().unwrap().text()); + assert_eq!("'a", pred.lifetime_token().unwrap().text()); assert_bound("'b", bounds.next()); assert_bound("'c", bounds.next()); diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index d79310995..62153f199 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -96,7 +96,7 @@ impl ast::ItemList { leading_indent(it.syntax()).unwrap_or_default().to_string(), InsertPosition::After(it.syntax().clone().into()), ), - None => match self.l_curly() { + None => match self.l_curly_token() { Some(it) => ( " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), InsertPosition::After(it.syntax().clone().into()), @@ -142,7 +142,7 @@ impl ast::RecordFieldList { macro_rules! after_l_curly { () => {{ - let anchor = match self.l_curly() { + let anchor = match self.l_curly_token() { Some(it) => it.syntax().clone().into(), None => return self.clone(), }; @@ -301,7 +301,7 @@ impl ast::UseTree { suffix.clone(), self.use_tree_list(), self.alias(), - self.star().is_some(), + self.star_token().is_some(), ); let nested = make::use_tree_list(iter::once(use_tree)); return make::use_tree(prefix.clone(), Some(nested), None, false); diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index c7df15662..ff3525c84 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -23,7 +23,7 @@ impl ast::NameRef { } pub fn as_tuple_field(&self) -> Option { - if let Some(ast::NameRefToken::IntNumber(token)) = self.name_ref_token() { + if let Some(ast::NameRefToken::IntNumber(token)) = self.name_ref_token_token() { token.text().as_str().parse().ok() } else { None @@ -138,7 +138,7 @@ impl ast::Path { impl ast::Module { pub fn has_semi(&self) -> bool { - self.semi().is_some() + self.semi_token().is_some() } } @@ -174,7 +174,7 @@ impl ast::ImplDef { } pub fn is_negative(&self) -> bool { - self.excl().is_some() + self.excl_token().is_some() } } @@ -218,11 +218,11 @@ impl ast::EnumVariant { impl ast::FnDef { pub fn semicolon_token(&self) -> Option { - Some(self.semi()?.syntax().clone()) + Some(self.semi_token()?.syntax().clone()) } pub fn is_async(&self) -> bool { - self.async_kw().is_some() + self.async_kw_token().is_some() } } @@ -233,15 +233,11 @@ impl ast::LetStmt { Some(node) => node.kind() == T![;], } } - - pub fn eq_token(&self) -> Option { - Some(self.eq()?.syntax().clone()) - } } impl ast::ExprStmt { pub fn has_semi(&self) -> bool { - self.semi().is_some() + self.semi_token().is_some() } } @@ -350,7 +346,7 @@ pub enum SelfParamKind { impl ast::SelfParam { pub fn kind(&self) -> SelfParamKind { - if self.amp().is_some() { + if self.amp_token().is_some() { if self.amp_mut_kw().is_some() { SelfParamKind::MutRef } else { @@ -396,7 +392,7 @@ impl ast::TypeBound { TypeBoundKind::PathType(path_type) } else if let Some(for_type) = children(self).next() { TypeBoundKind::ForType(for_type) - } else if let Some(lifetime) = self.lifetime() { + } else if let Some(lifetime) = self.lifetime_token() { TypeBoundKind::Lifetime(lifetime) } else { unreachable!() @@ -416,7 +412,7 @@ impl ast::TypeBound { } pub fn question(&self) -> Option { - if self.const_kw().is_some() { + if self.const_kw_token().is_some() { self.syntax() .children_with_tokens() .filter_map(|it| it.into_token()) diff --git a/crates/ra_syntax/src/ast/generated/nodes.rs b/crates/ra_syntax/src/ast/generated/nodes.rs index 8b348ad6e..0bcb7fe61 100644 --- a/crates/ra_syntax/src/ast/generated/nodes.rs +++ b/crates/ra_syntax/src/ast/generated/nodes.rs @@ -49,15 +49,15 @@ impl ast::DocCommentsOwner for FnDef {} impl ast::AttrsOwner for FnDef {} impl FnDef { pub fn abi(&self) -> Option { support::child(&self.syntax) } - pub fn const_kw(&self) -> Option { support::token(&self.syntax) } - pub fn default_kw(&self) -> Option { support::token(&self.syntax) } - pub fn async_kw(&self) -> Option { support::token(&self.syntax) } - pub fn unsafe_kw(&self) -> Option { support::token(&self.syntax) } - pub fn fn_kw(&self) -> Option { support::token(&self.syntax) } + pub fn const_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn default_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn async_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn unsafe_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn fn_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn param_list(&self) -> Option { support::child(&self.syntax) } pub fn ret_type(&self) -> Option { support::child(&self.syntax) } pub fn body(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RetType { @@ -75,7 +75,7 @@ impl AstNode for RetType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl RetType { - pub fn thin_arrow(&self) -> Option { support::token(&self.syntax) } + pub fn thin_arrow_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -99,9 +99,9 @@ impl ast::TypeParamsOwner for StructDef {} impl ast::AttrsOwner for StructDef {} impl ast::DocCommentsOwner for StructDef {} impl StructDef { - pub fn struct_kw(&self) -> Option { support::token(&self.syntax) } + pub fn struct_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn field_def_list(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct UnionDef { @@ -124,7 +124,7 @@ impl ast::TypeParamsOwner for UnionDef {} impl ast::AttrsOwner for UnionDef {} impl ast::DocCommentsOwner for UnionDef {} impl UnionDef { - pub fn union_kw(&self) -> Option { support::token(&self.syntax) } + pub fn union_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn record_field_def_list(&self) -> Option { support::child(&self.syntax) } @@ -145,9 +145,9 @@ impl AstNode for RecordFieldDefList { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl RecordFieldDefList { - pub fn l_curly(&self) -> Option { support::token(&self.syntax) } + pub fn l_curly_token(&self) -> Option { support::token(&self.syntax) } pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_curly(&self) -> Option { support::token(&self.syntax) } + pub fn r_curly_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct RecordFieldDef { @@ -186,9 +186,9 @@ impl AstNode for TupleFieldDefList { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl TupleFieldDefList { - pub fn l_paren(&self) -> Option { support::token(&self.syntax) } + pub fn l_paren_token(&self) -> Option { support::token(&self.syntax) } pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_paren(&self) -> Option { support::token(&self.syntax) } + pub fn r_paren_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TupleFieldDef { @@ -231,7 +231,7 @@ impl ast::TypeParamsOwner for EnumDef {} impl ast::AttrsOwner for EnumDef {} impl ast::DocCommentsOwner for EnumDef {} impl EnumDef { - pub fn enum_kw(&self) -> Option { support::token(&self.syntax) } + pub fn enum_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn variant_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -250,9 +250,9 @@ impl AstNode for EnumVariantList { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl EnumVariantList { - pub fn l_curly(&self) -> Option { support::token(&self.syntax) } + pub fn l_curly_token(&self) -> Option { support::token(&self.syntax) } pub fn variants(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_curly(&self) -> Option { support::token(&self.syntax) } + pub fn r_curly_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct EnumVariant { @@ -275,7 +275,7 @@ impl ast::DocCommentsOwner for EnumVariant {} impl ast::AttrsOwner for EnumVariant {} impl EnumVariant { pub fn field_def_list(&self) -> Option { support::child(&self.syntax) } - pub fn eq(&self) -> Option { support::token(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax) } pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -300,9 +300,9 @@ impl ast::DocCommentsOwner for TraitDef {} impl ast::TypeParamsOwner for TraitDef {} impl ast::TypeBoundsOwner for TraitDef {} impl TraitDef { - pub fn unsafe_kw(&self) -> Option { support::token(&self.syntax) } - pub fn auto_kw(&self) -> Option { support::token(&self.syntax) } - pub fn trait_kw(&self) -> Option { support::token(&self.syntax) } + pub fn unsafe_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn auto_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn trait_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn item_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -325,9 +325,9 @@ impl ast::NameOwner for Module {} impl ast::AttrsOwner for Module {} impl ast::DocCommentsOwner for Module {} impl Module { - pub fn mod_kw(&self) -> Option { support::token(&self.syntax) } + pub fn mod_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn item_list(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ItemList { @@ -347,9 +347,9 @@ impl AstNode for ItemList { impl ast::FnDefOwner for ItemList {} impl ast::ModuleItemOwner for ItemList {} impl ItemList { - pub fn l_curly(&self) -> Option { support::token(&self.syntax) } + pub fn l_curly_token(&self) -> Option { support::token(&self.syntax) } pub fn impl_items(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_curly(&self) -> Option { support::token(&self.syntax) } + pub fn r_curly_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ConstDef { @@ -373,11 +373,11 @@ impl ast::AttrsOwner for ConstDef {} impl ast::DocCommentsOwner for ConstDef {} impl ast::TypeAscriptionOwner for ConstDef {} impl ConstDef { - pub fn default_kw(&self) -> Option { support::token(&self.syntax) } - pub fn const_kw(&self) -> Option { support::token(&self.syntax) } - pub fn eq(&self) -> Option { support::token(&self.syntax) } + pub fn default_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn const_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax) } pub fn body(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StaticDef { @@ -401,11 +401,11 @@ impl ast::AttrsOwner for StaticDef {} impl ast::DocCommentsOwner for StaticDef {} impl ast::TypeAscriptionOwner for StaticDef {} impl StaticDef { - pub fn static_kw(&self) -> Option { support::token(&self.syntax) } - pub fn mut_kw(&self) -> Option { support::token(&self.syntax) } - pub fn eq(&self) -> Option { support::token(&self.syntax) } + pub fn static_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn mut_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax) } pub fn body(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TypeAliasDef { @@ -429,11 +429,11 @@ impl ast::AttrsOwner for TypeAliasDef {} impl ast::DocCommentsOwner for TypeAliasDef {} impl ast::TypeBoundsOwner for TypeAliasDef {} impl TypeAliasDef { - pub fn default_kw(&self) -> Option { support::token(&self.syntax) } - pub fn type_kw(&self) -> Option { support::token(&self.syntax) } - pub fn eq(&self) -> Option { support::token(&self.syntax) } + pub fn default_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn type_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn eq_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ImplDef { @@ -453,12 +453,12 @@ impl AstNode for ImplDef { impl ast::TypeParamsOwner for ImplDef {} impl ast::AttrsOwner for ImplDef {} impl ImplDef { - pub fn default_kw(&self) -> Option { support::token(&self.syntax) } - pub fn const_kw(&self) -> Option { support::token(&self.syntax) } - pub fn unsafe_kw(&self) -> Option { support::token(&self.syntax) } - pub fn impl_kw(&self) -> Option { support::token(&self.syntax) } - pub fn excl(&self) -> Option { support::token(&self.syntax) } - pub fn for_kw(&self) -> Option { support::token(&self.syntax) } + pub fn default_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn const_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn unsafe_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn impl_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn excl_token(&self) -> Option { support::token(&self.syntax) } + pub fn for_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn item_list(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -477,9 +477,9 @@ impl AstNode for ParenType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ParenType { - pub fn l_paren(&self) -> Option { support::token(&self.syntax) } + pub fn l_paren_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } - pub fn r_paren(&self) -> Option { support::token(&self.syntax) } + pub fn r_paren_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TupleType { @@ -497,9 +497,9 @@ impl AstNode for TupleType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl TupleType { - pub fn l_paren(&self) -> Option { support::token(&self.syntax) } + pub fn l_paren_token(&self) -> Option { support::token(&self.syntax) } pub fn fields(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_paren(&self) -> Option { support::token(&self.syntax) } + pub fn r_paren_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct NeverType { @@ -517,7 +517,7 @@ impl AstNode for NeverType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl NeverType { - pub fn excl(&self) -> Option { support::token(&self.syntax) } + pub fn excl_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PathType { @@ -553,8 +553,8 @@ impl AstNode for PointerType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl PointerType { - pub fn star(&self) -> Option { support::token(&self.syntax) } - pub fn const_kw(&self) -> Option { support::token(&self.syntax) } + pub fn star_token(&self) -> Option { support::token(&self.syntax) } + pub fn const_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -573,11 +573,11 @@ impl AstNode for ArrayType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ArrayType { - pub fn l_brack(&self) -> Option { support::token(&self.syntax) } + pub fn l_brack_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } pub fn expr(&self) -> Option { support::child(&self.syntax) } - pub fn r_brack(&self) -> Option { support::token(&self.syntax) } + pub fn r_brack_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SliceType { @@ -595,9 +595,9 @@ impl AstNode for SliceType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl SliceType { - pub fn l_brack(&self) -> Option { support::token(&self.syntax) } + pub fn l_brack_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } - pub fn r_brack(&self) -> Option { support::token(&self.syntax) } + pub fn r_brack_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ReferenceType { @@ -615,9 +615,9 @@ impl AstNode for ReferenceType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ReferenceType { - pub fn amp(&self) -> Option { support::token(&self.syntax) } - pub fn lifetime(&self) -> Option { support::token(&self.syntax) } - pub fn mut_kw(&self) -> Option { support::token(&self.syntax) } + pub fn amp_token(&self) -> Option { support::token(&self.syntax) } + pub fn lifetime_token(&self) -> Option { support::token(&self.syntax) } + pub fn mut_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -636,7 +636,7 @@ impl AstNode for PlaceholderType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl PlaceholderType { - pub fn underscore(&self) -> Option { support::token(&self.syntax) } + pub fn underscore_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct FnPointerType { @@ -655,8 +655,8 @@ impl AstNode for FnPointerType { } impl FnPointerType { pub fn abi(&self) -> Option { support::child(&self.syntax) } - pub fn unsafe_kw(&self) -> Option { support::token(&self.syntax) } - pub fn fn_kw(&self) -> Option { support::token(&self.syntax) } + pub fn unsafe_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn fn_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn param_list(&self) -> Option { support::child(&self.syntax) } pub fn ret_type(&self) -> Option { support::child(&self.syntax) } } @@ -676,7 +676,7 @@ impl AstNode for ForType { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl ForType { - pub fn for_kw(&self) -> Option { support::token(&self.syntax) } + pub fn for_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn type_param_list(&self) -> Option { support::child(&self.syntax) } pub fn type_ref(&self) -> Option { support::child(&self.syntax) } } @@ -697,7 +697,7 @@ impl AstNode for ImplTraitType { } impl ast::TypeBoundsOwner for ImplTraitType {} impl ImplTraitType { - pub fn impl_kw(&self) -> Option { support::token(&self.syntax) } + pub fn impl_kw_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct DynTraitType { @@ -716,7 +716,7 @@ impl AstNode for DynTraitType { } impl ast::TypeBoundsOwner for DynTraitType {} impl DynTraitType { - pub fn dyn_kw(&self) -> Option { support::token(&self.syntax) } + pub fn dyn_kw_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TupleExpr { @@ -735,9 +735,9 @@ impl AstNode for TupleExpr { } impl ast::AttrsOwner for TupleExpr {} impl TupleExpr { - pub fn l_paren(&self) -> Option { support::token(&self.syntax) } + pub fn l_paren_token(&self) -> Option { support::token(&self.syntax) } pub fn exprs(&self) -> AstChildren { support::children(&self.syntax) } - pub fn r_paren(&self) -> Option { support::token(&self.syntax) } + pub fn r_paren_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ArrayExpr { @@ -756,10 +756,10 @@ impl AstNode for ArrayExpr { } impl ast::AttrsOwner for ArrayExpr {} impl ArrayExpr { - pub fn l_brack(&self) -> Option { support::token(&self.syntax) } + pub fn l_brack_token(&self) -> Option { support::token(&self.syntax) } pub fn exprs(&self) -> AstChildren { support::children(&self.syntax) } - pub fn semi(&self) -> Option { support::token(&self.syntax) } - pub fn r_brack(&self) -> Option { support::token(&self.syntax) } + pub fn semi_token(&self) -> Option { support::token(&self.syntax) } + pub fn r_brack_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ParenExpr { @@ -778,9 +778,9 @@ impl AstNode for ParenExpr { } impl ast::AttrsOwner for ParenExpr {} impl ParenExpr { - pub fn l_paren(&self) -> Option { support::token(&self.syntax) } + pub fn l_paren_token(&self) -> Option { support::token(&self.syntax) } pub fn expr(&self) -> Option { support::child(&self.syntax) } - pub fn r_paren(&self) -> Option { support::token(&self.syntax) } + pub fn r_paren_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct PathExpr { @@ -817,9 +817,9 @@ impl AstNode for LambdaExpr { } impl ast::AttrsOwner for LambdaExpr {} impl LambdaExpr { - pub fn static_kw(&self) -> Option { support::token(&self.syntax) } - pub fn async_kw(&self) -> Option { support::token(&self.syntax) } - pub fn move_kw(&self) -> Option { support::token(&self.syntax) } + pub fn static_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn async_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn move_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn param_list(&self) -> Option { support::child(&self.syntax) } pub fn ret_type(&self) -> Option { support::child(&self.syntax) } pub fn body(&self) -> Option { support::child(&self.syntax) } @@ -841,7 +841,7 @@ impl AstNode for IfExpr { } impl ast::AttrsOwner for IfExpr {} impl IfExpr { - pub fn if_kw(&self) -> Option { support::token(&self.syntax) } + pub fn if_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn condition(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -862,7 +862,7 @@ impl AstNode for LoopExpr { impl ast::AttrsOwner for LoopExpr {} impl ast::LoopBodyOwner for LoopExpr {} impl LoopExpr { - pub fn loop_kw(&self) -> Option { support::token(&self.syntax) } + pub fn loop_kw_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct TryBlockExpr { @@ -881,7 +881,7 @@ impl AstNode for TryBlockExpr { } impl ast::AttrsOwner for TryBlockExpr {} impl TryBlockExpr { - pub fn try_kw(&self) -> Option { support::token(&self.syntax) } + pub fn try_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn body(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -902,9 +902,9 @@ impl AstNode for ForExpr { impl ast::AttrsOwner for ForExpr {} impl ast::LoopBodyOwner for ForExpr {} impl ForExpr { - pub fn for_kw(&self) -> Option { support::token(&self.syntax) } + pub fn for_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn pat(&self) -> Option { support::child(&self.syntax) } - pub fn in_kw(&self) -> Option { support::token(&self.syntax) } + pub fn in_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn iterable(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -925,7 +925,7 @@ impl AstNode for WhileExpr { impl ast::AttrsOwner for WhileExpr {} impl ast::LoopBodyOwner for WhileExpr {} impl WhileExpr { - pub fn while_kw(&self) -> Option { support::token(&self.syntax) } + pub fn while_kw_token(&self) -> Option { support::token(&self.syntax) } pub fn condition(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -945,8 +945,8 @@ impl AstNode for ContinueExpr { } impl ast::AttrsOwner for ContinueExpr {} impl ContinueExpr { - pub fn continue_kw(&self) -> Option { support::token(&self.syntax) } - pub fn lifetime(&self) -> Option { support::token(&self.syntax) } + pub fn continue_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn lifetime_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BreakExpr { @@ -965,8 +965,8 @@ impl AstNode for BreakExpr { } impl ast::AttrsOwner for BreakExpr {} impl BreakExpr { - pub fn break_kw(&self) -> Option { support::token(&self.syntax) } - pub fn lifetime(&self) -> Option { support::token(&self.syntax) } + pub fn break_kw_token(&self) -> Option { support::token(&self.syntax) } + pub fn lifetime_token(&self) -> Option { support::token(&self.syntax) } pub fn expr(&self) -> Option { support::child(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -985,7 +985,7 @@ impl AstNode for Label { fn syntax(&self) -> &SyntaxNode { &self.syntax } } impl Label { - pub fn lifetime(&self) -> Option { support::token(&self.syntax) } + pub fn lifetime_token(&self) -> Option { support::token(&self.syntax) } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct BlockExpr { @@ -1005,7 +1005,7 @@ impl AstNode for BlockExpr { impl ast::AttrsOwner for BlockExpr {} impl BlockExpr { pub fn label(&self) -> Option