From 2a582b78a5f9c1fa908fe5f4c9ff4ab2966adb2e Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 8 Apr 2020 17:48:16 -0400 Subject: [PATCH 01/67] Add more heuristics for hiding obvious param hints This will now hide "value", "pat", "rhs" and "other" These words were selected from the std because they are used in common functions with only a single param and are obvious by their use. I think it would be good to also hide "bytes" if the type is `[u8; n]` but I'm not sure how to get the param type signature It will also hide the hint if the passed param starts or end with the param_name --- crates/ra_ide/src/inlay_hints.rs | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 4b133b19baf9..6a4fe15fd758 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -1,4 +1,4 @@ -//! FIXME: write short doc here +//! This module defines multiple types of inlay hints and their visibility use hir::{Adt, HirDisplay, Semantics, Type}; use ra_ide_db::RootDatabase; @@ -236,7 +236,10 @@ fn should_show_param_hint( argument: &ast::Expr, ) -> bool { let argument_string = argument.syntax().to_string(); - if param_name.is_empty() || argument_string.ends_with(param_name) { + if param_name.is_empty() + || argument_string.ends_with(¶m_name) + || argument_string.starts_with(¶m_name) + { return false; } @@ -245,8 +248,15 @@ fn should_show_param_hint( } else { fn_signature.parameters.len() }; + // avoid displaying hints for common functions like map, filter, etc. - if parameters_len == 1 && (param_name.len() == 1 || param_name == "predicate") { + // or other obvious words used in std + // TODO ignore "bytes" if the type is [u8; n] + let is_obvious_param_name = match param_name { + "predicate" | "value" | "pat" | "rhs" | "other" => true, + _ => false, + }; + if parameters_len == 1 && (param_name.len() == 1 || is_obvious_param_name) { return false; } @@ -1059,9 +1069,17 @@ impl Test { self } + fn field(self, value: i32) -> Self { + self + } + fn no_hints_expected(&self, _: i32, test_var: i32) {} } +struct Param {} + +fn different_order(param: Param) {} + fn main() { let container: TestVarContainer = TestVarContainer { test_var: 42 }; let test: Test = Test {}; @@ -1069,11 +1087,19 @@ fn main() { map(22); filter(33); - let test_processed: Test = test.map(1).filter(2); + let test_processed: Test = test.map(1).filter(2).field(3); let test_var: i32 = 55; test_processed.no_hints_expected(22, test_var); test_processed.no_hints_expected(33, container.test_var); + + let param_begin: Param = Param {}; + different_order(param_begin); + + let a: f64 = 7.0; + let b: f64 = 4.0; + let _: f64 = a.div_euclid(b); + let _: f64 = a.abs_sub(b); }"#, ); From a2dc18f71acf83dd2946622603d3da00b456d42a Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 8 Apr 2020 18:11:24 -0400 Subject: [PATCH 02/67] remove TODO --- crates/ra_ide/src/inlay_hints.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 6a4fe15fd758..a86e18fbbc25 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -251,7 +251,6 @@ fn should_show_param_hint( // avoid displaying hints for common functions like map, filter, etc. // or other obvious words used in std - // TODO ignore "bytes" if the type is [u8; n] let is_obvious_param_name = match param_name { "predicate" | "value" | "pat" | "rhs" | "other" => true, _ => false, From de6db0632228ae61f7ec1f87eaf520ccd4e46925 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 8 Apr 2020 19:07:21 -0400 Subject: [PATCH 03/67] ignore `&mut ` and `&` when checking params --- crates/ra_ide/src/inlay_hints.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index a86e18fbbc25..6b8b5813d42c 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -235,7 +235,15 @@ fn should_show_param_hint( param_name: &str, argument: &ast::Expr, ) -> bool { - let argument_string = argument.syntax().to_string(); + let argument_string = { + let arg_string = argument.syntax().to_string(); + let arg_split: Vec = arg_string.chars().collect(); + match arg_split.as_slice() { + ['&', 'm', 'u', 't', ' ', arg_name @ ..] => arg_name.into_iter().collect::(), + ['&', arg_name @ ..] => arg_name.into_iter().collect::(), + _ => arg_string, + } + }; if param_name.is_empty() || argument_string.ends_with(¶m_name) || argument_string.starts_with(¶m_name) @@ -1077,7 +1085,8 @@ impl Test { struct Param {} -fn different_order(param: Param) {} +fn different_order(param: &Param) {} +fn different_order_mut(param: &mut Param) {} fn main() { let container: TestVarContainer = TestVarContainer { test_var: 42 }; @@ -1093,7 +1102,8 @@ fn main() { test_processed.no_hints_expected(33, container.test_var); let param_begin: Param = Param {}; - different_order(param_begin); + different_order(¶m_begin); + different_order(&mut param_begin); let a: f64 = 7.0; let b: f64 = 4.0; From cba694c60276f7543ee9ed1dddf3fe93209f527f Mon Sep 17 00:00:00 2001 From: IceSentry Date: Wed, 8 Apr 2020 19:26:47 -0400 Subject: [PATCH 04/67] better `&mut ` and `&` matching --- crates/ra_ide/src/inlay_hints.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 6b8b5813d42c..1da61e4c4831 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -236,13 +236,13 @@ fn should_show_param_hint( argument: &ast::Expr, ) -> bool { let argument_string = { - let arg_string = argument.syntax().to_string(); - let arg_split: Vec = arg_string.chars().collect(); - match arg_split.as_slice() { - ['&', 'm', 'u', 't', ' ', arg_name @ ..] => arg_name.into_iter().collect::(), - ['&', arg_name @ ..] => arg_name.into_iter().collect::(), - _ => arg_string, + let mut arg_string = argument.syntax().to_string(); + if arg_string.get(0..5) == Some("&mut ") { + arg_string = arg_string[5..].to_string(); + } else if arg_string.get(0..1) == Some("&") { + arg_string = arg_string[1..].to_string(); } + arg_string }; if param_name.is_empty() || argument_string.ends_with(¶m_name) From ae416f3c6e90a8d2b2f9d1713d2db4ddce12df65 Mon Sep 17 00:00:00 2001 From: IceSentry Date: Thu, 9 Apr 2020 10:35:07 -0400 Subject: [PATCH 05/67] clean up param hint checking --- crates/ra_ide/src/inlay_hints.rs | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 1da61e4c4831..b1661d2383f3 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -235,19 +235,7 @@ fn should_show_param_hint( param_name: &str, argument: &ast::Expr, ) -> bool { - let argument_string = { - let mut arg_string = argument.syntax().to_string(); - if arg_string.get(0..5) == Some("&mut ") { - arg_string = arg_string[5..].to_string(); - } else if arg_string.get(0..1) == Some("&") { - arg_string = arg_string[1..].to_string(); - } - arg_string - }; - if param_name.is_empty() - || argument_string.ends_with(¶m_name) - || argument_string.starts_with(¶m_name) - { + if param_name.is_empty() || is_argument_similar_to_param(argument, param_name) { return false; } @@ -259,15 +247,27 @@ fn should_show_param_hint( // avoid displaying hints for common functions like map, filter, etc. // or other obvious words used in std + if parameters_len == 1 && is_obvious_param(param_name) { + return false; + } + true +} + +fn is_argument_similar_to_param(argument: &ast::Expr, param_name: &str) -> bool { + let argument_string = if let ast::Expr::RefExpr(ref_expr) = argument { + ref_expr.syntax().last_token().expect("RefExpr should have a last_token").to_string() + } else { + argument.syntax().to_string() + }; + argument_string.starts_with(¶m_name) || argument_string.ends_with(¶m_name) +} + +fn is_obvious_param(param_name: &str) -> bool { let is_obvious_param_name = match param_name { "predicate" | "value" | "pat" | "rhs" | "other" => true, _ => false, }; - if parameters_len == 1 && (param_name.len() == 1 || is_obvious_param_name) { - return false; - } - - true + param_name.len() == 1 || is_obvious_param_name } fn get_fn_signature(sema: &Semantics, expr: &ast::Expr) -> Option { From 19d952c603344d853567aeac42dcfa6fe40ba04b Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 9 Apr 2020 23:48:08 +0800 Subject: [PATCH 06/67] Improve tt::Subtree debug print --- crates/ra_hir_expand/src/quote.rs | 2 +- crates/ra_mbe/src/tests.rs | 79 +++++++++++++++++++++++++++++++ crates/ra_tt/src/lib.rs | 57 +++++++++++++++++++++- 3 files changed, 136 insertions(+), 2 deletions(-) diff --git a/crates/ra_hir_expand/src/quote.rs b/crates/ra_hir_expand/src/quote.rs index 3fd4233da8b6..219bc20978e5 100644 --- a/crates/ra_hir_expand/src/quote.rs +++ b/crates/ra_hir_expand/src/quote.rs @@ -232,7 +232,7 @@ mod tests { let quoted = quote!(#a); assert_eq!(quoted.to_string(), "hello"); let t = format!("{:?}", quoted); - assert_eq!(t, "Subtree { delimiter: None, token_trees: [Leaf(Ident(Ident { text: \"hello\", id: TokenId(4294967295) }))] }"); + assert_eq!(t, "SUBTREE $\n IDENT hello 4294967295"); } #[test] diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs index 254318e239d2..1ef6f6eedd3c 100644 --- a/crates/ra_mbe/src/tests.rs +++ b/crates/ra_mbe/src/tests.rs @@ -141,6 +141,79 @@ macro_rules! impl_froms { ); } +#[test] +fn test_convert_tt2() { + parse_macro( + r#" +macro_rules! impl_froms { + ($e:ident: $($v:ident),*) => { + $( + impl From<$v> for $e { + fn from(it: $v) -> $e { + $e::$v(it) + } + } + )* + } +} +"#, + ) + .assert_expand( + "impl_froms!(TokenTree: Leaf, Subtree);", + r#" +SUBTREE $ + IDENT impl 20 + IDENT From 21 + PUNCH < [joint] 22 + IDENT Leaf 53 + PUNCH > [alone] 25 + IDENT for 26 + IDENT TokenTree 51 + SUBTREE {} 29 + IDENT fn 30 + IDENT from 31 + SUBTREE () 32 + IDENT it 33 + PUNCH : [alone] 34 + IDENT Leaf 53 + PUNCH - [joint] 37 + PUNCH > [alone] 38 + IDENT TokenTree 51 + SUBTREE {} 41 + IDENT TokenTree 51 + PUNCH : [joint] 44 + PUNCH : [joint] 45 + IDENT Leaf 53 + SUBTREE () 48 + IDENT it 49 + IDENT impl 20 + IDENT From 21 + PUNCH < [joint] 22 + IDENT Subtree 55 + PUNCH > [alone] 25 + IDENT for 26 + IDENT TokenTree 51 + SUBTREE {} 29 + IDENT fn 30 + IDENT from 31 + SUBTREE () 32 + IDENT it 33 + PUNCH : [alone] 34 + IDENT Subtree 55 + PUNCH - [joint] 37 + PUNCH > [alone] 38 + IDENT TokenTree 51 + SUBTREE {} 41 + IDENT TokenTree 51 + PUNCH : [joint] 44 + PUNCH : [joint] 45 + IDENT Subtree 55 + SUBTREE () 48 + IDENT it 49 +"#, + ); +} + #[test] fn test_expr_order() { let expanded = parse_macro( @@ -1479,6 +1552,12 @@ impl MacroFixture { assert_eq!(expansion.to_string(), expected); } + fn assert_expand(&self, invocation: &str, expected: &str) { + let expansion = self.expand_tt(invocation); + let actual = format!("{:?}", expansion); + test_utils::assert_eq_text!(&actual.trim(), &expected.trim()); + } + fn assert_expand_items(&self, invocation: &str, expected: &str) -> &MacroFixture { self.assert_expansion(FragmentKind::Items, invocation, expected); self diff --git a/crates/ra_tt/src/lib.rs b/crates/ra_tt/src/lib.rs index bd484aa30a04..5248e026c520 100644 --- a/crates/ra_tt/src/lib.rs +++ b/crates/ra_tt/src/lib.rs @@ -57,7 +57,7 @@ pub enum Leaf { } impl_froms!(Leaf: Literal, Punct, Ident); -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] +#[derive(Clone, PartialEq, Eq, Hash, Default)] pub struct Subtree { pub delimiter: Option, pub token_trees: Vec, @@ -101,6 +101,61 @@ pub struct Ident { pub id: TokenId, } +fn print_debug_subtree(f: &mut fmt::Formatter<'_>, subtree: &Subtree, level: usize) -> fmt::Result { + let align = std::iter::repeat(" ").take(level).collect::(); + + let aux = match subtree.delimiter.map(|it| (it.kind, it.id.0)) { + None => "$".to_string(), + Some((DelimiterKind::Parenthesis, id)) => format!("() {}", id), + Some((DelimiterKind::Brace, id)) => format!("{{}} {}", id), + Some((DelimiterKind::Bracket, id)) => format!("[] {}", id), + }; + + if subtree.token_trees.is_empty() { + write!(f, "{}SUBTREE {}", align, aux)?; + } else { + writeln!(f, "{}SUBTREE {}", align, aux)?; + for (idx, child) in subtree.token_trees.iter().enumerate() { + print_debug_token(f, child, level + 1)?; + if idx != subtree.token_trees.len() - 1 { + writeln!(f, "")?; + } + } + } + + Ok(()) +} + +fn print_debug_token(f: &mut fmt::Formatter<'_>, tkn: &TokenTree, level: usize) -> fmt::Result { + let align = std::iter::repeat(" ").take(level).collect::(); + + match tkn { + TokenTree::Leaf(leaf) => match leaf { + Leaf::Literal(lit) => write!(f, "{}LITERAL {} {}", align, lit.text, lit.id.0)?, + Leaf::Punct(punct) => write!( + f, + "{}PUNCH {} [{}] {}", + align, + punct.char, + if punct.spacing == Spacing::Alone { "alone" } else { "joint" }, + punct.id.0 + )?, + Leaf::Ident(ident) => write!(f, "{}IDENT {} {}", align, ident.text, ident.id.0)?, + }, + TokenTree::Subtree(subtree) => { + print_debug_subtree(f, subtree, level)?; + } + } + + Ok(()) +} + +impl Debug for Subtree { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + print_debug_subtree(f, self, 0) + } +} + impl fmt::Display for TokenTree { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { From a95116fbfa11cad4e03b8b31f8d4498f3ddd5d9e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 18:20:06 +0200 Subject: [PATCH 07/67] Simplify --- crates/ra_syntax/src/ast/extensions.rs | 39 +++++++++----------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 33fe60762a34..c7df15662e58 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() } } From e6d22187a67e762bb950de244a6ca15f3a0b0731 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Apr 2020 18:25:36 +0200 Subject: [PATCH 08/67] Add _token suffix to token accessors I think this makes is more clear which things are : AstNode and which are : AstToken --- .../src/handlers/add_explicit_type.rs | 4 +- crates/ra_assists/src/handlers/add_impl.rs | 2 +- crates/ra_assists/src/handlers/add_new.rs | 2 +- .../ra_assists/src/handlers/merge_imports.rs | 2 +- crates/ra_hir_def/src/path/lower.rs | 2 +- crates/ra_hir_def/src/path/lower/lower_use.rs | 2 +- crates/ra_hir_ty/src/tests.rs | 2 +- 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 +++++++++--------- xtask/src/codegen/gen_syntax.rs | 1 + 12 files changed, 210 insertions(+), 213 deletions(-) diff --git a/crates/ra_assists/src/handlers/add_explicit_type.rs b/crates/ra_assists/src/handlers/add_explicit_type.rs index d86d804b2ee5..e7dcfb44e273 100644 --- a/crates/ra_assists/src/handlers/add_explicit_type.rs +++ b/crates/ra_assists/src/handlers/add_explicit_type.rs @@ -1,6 +1,6 @@ use hir::HirDisplay; use ra_syntax::{ - ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner}, + ast::{self, AstNode, AstToken, LetStmt, NameOwner, TypeAscriptionOwner}, TextRange, }; @@ -35,7 +35,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option { let name = pat.name()?; let name_range = name.syntax().text_range(); let stmt_range = stmt.syntax().text_range(); - let eq_range = stmt.eq_token()?.text_range(); + let eq_range = stmt.eq_token()?.syntax().text_range(); // Assist should only be applicable if cursor is between 'let' and '=' let let_range = TextRange::from_to(stmt_range.start(), eq_range.start()); let cursor_in_range = ctx.frange.range.is_subrange(&let_range); diff --git a/crates/ra_assists/src/handlers/add_impl.rs b/crates/ra_assists/src/handlers/add_impl.rs index 72a201b6d2e6..26dfed237679 100644 --- a/crates/ra_assists/src/handlers/add_impl.rs +++ b/crates/ra_assists/src/handlers/add_impl.rs @@ -42,7 +42,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option { if let Some(type_params) = type_params { let lifetime_params = type_params .lifetime_params() - .filter_map(|it| it.lifetime()) + .filter_map(|it| it.lifetime_token()) .map(|it| it.text().clone()); let type_params = type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index c10397249fd1..30360af9421d 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs @@ -106,7 +106,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { if let Some(type_params) = type_params { let lifetime_params = type_params .lifetime_params() - .filter_map(|it| it.lifetime()) + .filter_map(|it| it.lifetime_token()) .map(|it| it.text().clone()); let type_params = type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone()); diff --git a/crates/ra_assists/src/handlers/merge_imports.rs b/crates/ra_assists/src/handlers/merge_imports.rs index f8b3ddb4e18f..936d50ab49c2 100644 --- a/crates/ra_assists/src/handlers/merge_imports.rs +++ b/crates/ra_assists/src/handlers/merge_imports.rs @@ -82,7 +82,7 @@ fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option Option loop { let segment = path.segment()?; - if segment.coloncolon().is_some() { + if segment.coloncolon_token().is_some() { kind = PathKind::Abs; } diff --git a/crates/ra_hir_def/src/path/lower/lower_use.rs b/crates/ra_hir_def/src/path/lower/lower_use.rs index 6ec944228cf6..5b6854b0f003 100644 --- a/crates/ra_hir_def/src/path/lower/lower_use.rs +++ b/crates/ra_hir_def/src/path/lower/lower_use.rs @@ -34,7 +34,7 @@ pub(crate) fn lower_use_tree( let alias = tree.alias().map(|a| { a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias) }); - let is_glob = tree.star().is_some(); + let is_glob = tree.star_token().is_some(); if let Some(ast_path) = tree.path() { // Handle self in a path. // E.g. `use something::{self, <...>}` diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs index ac096623682f..f97e0bfebc87 100644 --- a/crates/ra_hir_ty/src/tests.rs +++ b/crates/ra_hir_ty/src/tests.rs @@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String { let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db)); let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) { - (self_param.self_kw().unwrap().syntax().text_range(), "self".to_string()) + (self_param.self_kw_token().unwrap().syntax().text_range(), "self".to_string()) } else { (src_ptr.value.range(), node.text().to_string().replace("\n", " ")) }; diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs index a42eec91a9c2..15a8279f3dc3 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 d7931099535b..62153f199b36 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 c7df15662e58..ff3525c8447b 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 8b348ad6e136..0bcb7fe61cde 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