From 1142112c70b705f59b7d559d9d72cdc831865158 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 14:51:08 +0200 Subject: Rename FnDef -> Fn --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 12 ++++++------ .../ra_assists/src/handlers/change_return_type_to_result.rs | 2 +- crates/ra_assists/src/handlers/change_visibility.rs | 4 ++-- crates/ra_assists/src/handlers/early_return.rs | 4 ++-- crates/ra_assists/src/handlers/generate_function.rs | 2 +- crates/ra_assists/src/handlers/generate_new.rs | 2 +- crates/ra_assists/src/handlers/introduce_named_lifetime.rs | 4 ++-- crates/ra_assists/src/handlers/move_bounds.rs | 2 +- crates/ra_assists/src/utils.rs | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index a2d9006e4..4f377e37f 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -118,7 +118,7 @@ fn add_missing_impl_members_inner( let def_name = |item: &ast::AssocItem| -> Option { match item { - ast::AssocItem::FnDef(def) => def.name(), + ast::AssocItem::Fn(def) => def.name(), ast::AssocItem::TypeAliasDef(def) => def.name(), ast::AssocItem::ConstDef(def) => def.name(), ast::AssocItem::MacroCall(_) => None, @@ -129,13 +129,13 @@ fn add_missing_impl_members_inner( let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) .iter() .map(|i| match i { - hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), + hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), }) .filter(|t| def_name(&t).is_some()) .filter(|t| match t { - ast::AssocItem::FnDef(def) => match mode { + ast::AssocItem::Fn(def) => match mode { AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), }, @@ -158,7 +158,7 @@ fn add_missing_impl_members_inner( .into_iter() .map(|it| ast_transform::apply(&*ast_transform, it)) .map(|it| match it { - ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), + ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), ast::AssocItem::TypeAliasDef(def) => { ast::AssocItem::TypeAliasDef(def.remove_bounds()) } @@ -174,7 +174,7 @@ fn add_missing_impl_members_inner( Some(cap) => { let mut cursor = Cursor::Before(first_new_item.syntax()); let placeholder; - if let ast::AssocItem::FnDef(func) = &first_new_item { + if let ast::AssocItem::Fn(func) = &first_new_item { if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { if m.syntax().text() == "todo!()" { placeholder = m; @@ -192,7 +192,7 @@ fn add_missing_impl_members_inner( }) } -fn add_body(fn_def: ast::FnDef) -> ast::FnDef { +fn add_body(fn_def: ast::Fn) -> ast::Fn { if fn_def.body().is_some() { return fn_def; } diff --git a/crates/ra_assists/src/handlers/change_return_type_to_result.rs b/crates/ra_assists/src/handlers/change_return_type_to_result.rs index def00f7d8..52e24af6c 100644 --- a/crates/ra_assists/src/handlers/change_return_type_to_result.rs +++ b/crates/ra_assists/src/handlers/change_return_type_to_result.rs @@ -20,7 +20,7 @@ use test_utils::mark; pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let ret_type = ctx.find_node_at_offset::()?; // FIXME: extend to lambdas as well - let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?; + let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?; let type_ref = &ret_type.type_ref()?; let ret_type_str = type_ref.syntax().text().to_string(); diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 4343b423c..67b46376e 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs @@ -2,7 +2,7 @@ use ra_syntax::{ ast::{self, NameOwner, VisibilityOwner}, AstNode, SyntaxKind::{ - CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, + CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, }, T, }; @@ -38,7 +38,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { let (offset, target) = if let Some(keyword) = item_keyword { let parent = keyword.parent(); - let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; + let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; // Parent is not a definition, can't add visibility if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { return None; diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 330459f3c..3650289fd 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs @@ -8,7 +8,7 @@ use ra_syntax::{ make, }, AstNode, - SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, + SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, SyntaxNode, }; @@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) let early_expression: ast::Expr = match parent_container.kind() { WHILE_EXPR | LOOP_EXPR => make::expr_continue(), - FN_DEF => make::expr_return(), + FN => make::expr_return(), _ => return None, }; diff --git a/crates/ra_assists/src/handlers/generate_function.rs b/crates/ra_assists/src/handlers/generate_function.rs index b721b96bb..006d0ffb2 100644 --- a/crates/ra_assists/src/handlers/generate_function.rs +++ b/crates/ra_assists/src/handlers/generate_function.rs @@ -82,7 +82,7 @@ struct FunctionTemplate { insert_offset: TextSize, placeholder_expr: ast::MacroCall, leading_ws: String, - fn_def: ast::FnDef, + fn_def: ast::Fn, trailing_ws: String, file: FileId, } diff --git a/crates/ra_assists/src/handlers/generate_new.rs b/crates/ra_assists/src/handlers/generate_new.rs index 25bc171bf..4dff0ae4d 100644 --- a/crates/ra_assists/src/handlers/generate_new.rs +++ b/crates/ra_assists/src/handlers/generate_new.rs @@ -160,7 +160,7 @@ fn find_struct_impl(ctx: &AssistContext, strukt: &ast::StructDef) -> Option bool { if let Some(il) = imp.assoc_item_list() { for item in il.assoc_items() { - if let ast::AssocItem::FnDef(f) = item { + if let ast::AssocItem::Fn(f) = item { if let Some(name) = f.name() { if name.text().eq_ignore_ascii_case("new") { return true; diff --git a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs index 967593031..f3774fab1 100644 --- a/crates/ra_assists/src/handlers/introduce_named_lifetime.rs +++ b/crates/ra_assists/src/handlers/introduce_named_lifetime.rs @@ -38,7 +38,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - let lifetime_token = ctx .find_token_at_offset(SyntaxKind::LIFETIME) .filter(|lifetime| lifetime.text() == "'_")?; - if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) { + if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) @@ -50,7 +50,7 @@ pub(crate) fn introduce_named_lifetime(acc: &mut Assists, ctx: &AssistContext) - /// Generate the assist for the fn def case fn generate_fn_def_assist( acc: &mut Assists, - fn_def: &ast::FnDef, + fn_def: &ast::Fn, lifetime_loc: TextRange, ) -> Option<()> { let param_list: ast::ParamList = fn_def.param_list()?; diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index 6b73fff44..dae6198ed 100644 --- a/crates/ra_assists/src/handlers/move_bounds.rs +++ b/crates/ra_assists/src/handlers/move_bounds.rs @@ -37,7 +37,7 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext let anchor = match_ast! { match parent { - ast::FnDef(it) => it.body()?.syntax().clone().into(), + ast::Fn(it) => it.body()?.syntax().clone().into(), ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(), ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 27c33df23..4478ea0e2 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -66,7 +66,7 @@ pub fn get_missing_assoc_items( if let Some(item_list) = impl_def.assoc_item_list() { for item in item_list.assoc_items() { match item { - ast::AssocItem::FnDef(f) => { + ast::AssocItem::Fn(f) => { if let Some(n) = f.name() { impl_fns_consts.insert(n.syntax().to_string()); } -- cgit v1.2.3 From eb2f8063444b11257111f4f8ade990ec810e0361 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 15:25:46 +0200 Subject: Rename TypeAliasDef -> TypeAlias --- crates/ra_assists/src/handlers/add_missing_impl_members.rs | 8 +++----- crates/ra_assists/src/handlers/change_visibility.rs | 4 +--- crates/ra_assists/src/utils.rs | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 4f377e37f..1e4d4748c 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -119,7 +119,7 @@ fn add_missing_impl_members_inner( let def_name = |item: &ast::AssocItem| -> Option { match item { ast::AssocItem::Fn(def) => def.name(), - ast::AssocItem::TypeAliasDef(def) => def.name(), + ast::AssocItem::TypeAlias(def) => def.name(), ast::AssocItem::ConstDef(def) => def.name(), ast::AssocItem::MacroCall(_) => None, } @@ -130,7 +130,7 @@ fn add_missing_impl_members_inner( .iter() .map(|i| match i { hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), - hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), + hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAlias(i.source(ctx.db()).value), hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), }) .filter(|t| def_name(&t).is_some()) @@ -159,9 +159,7 @@ fn add_missing_impl_members_inner( .map(|it| ast_transform::apply(&*ast_transform, it)) .map(|it| match it { ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), - ast::AssocItem::TypeAliasDef(def) => { - ast::AssocItem::TypeAliasDef(def.remove_bounds()) - } + ast::AssocItem::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()), _ => it, }) .map(|it| edit::remove_attrs_and_docs(&it)); diff --git a/crates/ra_assists/src/handlers/change_visibility.rs b/crates/ra_assists/src/handlers/change_visibility.rs index 67b46376e..c3e1f2803 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs @@ -1,9 +1,7 @@ use ra_syntax::{ ast::{self, NameOwner, VisibilityOwner}, AstNode, - SyntaxKind::{ - CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, - }, + SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY}, T, }; use test_utils::mark; diff --git a/crates/ra_assists/src/utils.rs b/crates/ra_assists/src/utils.rs index 4478ea0e2..748be011b 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs @@ -72,7 +72,7 @@ pub fn get_missing_assoc_items( } } - ast::AssocItem::TypeAliasDef(t) => { + ast::AssocItem::TypeAlias(t) => { if let Some(n) = t.name() { impl_type.insert(n.syntax().to_string()); } -- cgit v1.2.3