diff options
author | Aleksey Kladov <[email protected]> | 2020-07-30 13:51:08 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-30 14:16:05 +0100 |
commit | 1142112c70b705f59b7d559d9d72cdc831865158 (patch) | |
tree | 1ca467302b268c800da8b26482e90effcea08229 /crates/ra_assists/src | |
parent | 3e1e6227ca525f8631e0bff2215fa3de1b4f4cc1 (diff) |
Rename FnDef -> Fn
Diffstat (limited to 'crates/ra_assists/src')
9 files changed, 17 insertions, 17 deletions
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( | |||
118 | 118 | ||
119 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { | 119 | let def_name = |item: &ast::AssocItem| -> Option<SmolStr> { |
120 | match item { | 120 | match item { |
121 | ast::AssocItem::FnDef(def) => def.name(), | 121 | ast::AssocItem::Fn(def) => def.name(), |
122 | ast::AssocItem::TypeAliasDef(def) => def.name(), | 122 | ast::AssocItem::TypeAliasDef(def) => def.name(), |
123 | ast::AssocItem::ConstDef(def) => def.name(), | 123 | ast::AssocItem::ConstDef(def) => def.name(), |
124 | ast::AssocItem::MacroCall(_) => None, | 124 | ast::AssocItem::MacroCall(_) => None, |
@@ -129,13 +129,13 @@ fn add_missing_impl_members_inner( | |||
129 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) | 129 | let missing_items = get_missing_assoc_items(&ctx.sema, &impl_def) |
130 | .iter() | 130 | .iter() |
131 | .map(|i| match i { | 131 | .map(|i| match i { |
132 | hir::AssocItem::Function(i) => ast::AssocItem::FnDef(i.source(ctx.db()).value), | 132 | hir::AssocItem::Function(i) => ast::AssocItem::Fn(i.source(ctx.db()).value), |
133 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), | 133 | hir::AssocItem::TypeAlias(i) => ast::AssocItem::TypeAliasDef(i.source(ctx.db()).value), |
134 | hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), | 134 | hir::AssocItem::Const(i) => ast::AssocItem::ConstDef(i.source(ctx.db()).value), |
135 | }) | 135 | }) |
136 | .filter(|t| def_name(&t).is_some()) | 136 | .filter(|t| def_name(&t).is_some()) |
137 | .filter(|t| match t { | 137 | .filter(|t| match t { |
138 | ast::AssocItem::FnDef(def) => match mode { | 138 | ast::AssocItem::Fn(def) => match mode { |
139 | AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), | 139 | AddMissingImplMembersMode::DefaultMethodsOnly => def.body().is_some(), |
140 | AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), | 140 | AddMissingImplMembersMode::NoDefaultMethods => def.body().is_none(), |
141 | }, | 141 | }, |
@@ -158,7 +158,7 @@ fn add_missing_impl_members_inner( | |||
158 | .into_iter() | 158 | .into_iter() |
159 | .map(|it| ast_transform::apply(&*ast_transform, it)) | 159 | .map(|it| ast_transform::apply(&*ast_transform, it)) |
160 | .map(|it| match it { | 160 | .map(|it| match it { |
161 | ast::AssocItem::FnDef(def) => ast::AssocItem::FnDef(add_body(def)), | 161 | ast::AssocItem::Fn(def) => ast::AssocItem::Fn(add_body(def)), |
162 | ast::AssocItem::TypeAliasDef(def) => { | 162 | ast::AssocItem::TypeAliasDef(def) => { |
163 | ast::AssocItem::TypeAliasDef(def.remove_bounds()) | 163 | ast::AssocItem::TypeAliasDef(def.remove_bounds()) |
164 | } | 164 | } |
@@ -174,7 +174,7 @@ fn add_missing_impl_members_inner( | |||
174 | Some(cap) => { | 174 | Some(cap) => { |
175 | let mut cursor = Cursor::Before(first_new_item.syntax()); | 175 | let mut cursor = Cursor::Before(first_new_item.syntax()); |
176 | let placeholder; | 176 | let placeholder; |
177 | if let ast::AssocItem::FnDef(func) = &first_new_item { | 177 | if let ast::AssocItem::Fn(func) = &first_new_item { |
178 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { | 178 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { |
179 | if m.syntax().text() == "todo!()" { | 179 | if m.syntax().text() == "todo!()" { |
180 | placeholder = m; | 180 | placeholder = m; |
@@ -192,7 +192,7 @@ fn add_missing_impl_members_inner( | |||
192 | }) | 192 | }) |
193 | } | 193 | } |
194 | 194 | ||
195 | fn add_body(fn_def: ast::FnDef) -> ast::FnDef { | 195 | fn add_body(fn_def: ast::Fn) -> ast::Fn { |
196 | if fn_def.body().is_some() { | 196 | if fn_def.body().is_some() { |
197 | return fn_def; | 197 | return fn_def; |
198 | } | 198 | } |
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; | |||
20 | pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | 20 | pub(crate) fn change_return_type_to_result(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
21 | let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; | 21 | let ret_type = ctx.find_node_at_offset::<ast::RetType>()?; |
22 | // FIXME: extend to lambdas as well | 22 | // FIXME: extend to lambdas as well |
23 | let fn_def = ret_type.syntax().parent().and_then(ast::FnDef::cast)?; | 23 | let fn_def = ret_type.syntax().parent().and_then(ast::Fn::cast)?; |
24 | 24 | ||
25 | let type_ref = &ret_type.type_ref()?; | 25 | let type_ref = &ret_type.type_ref()?; |
26 | let ret_type_str = type_ref.syntax().text().to_string(); | 26 | 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::{ | |||
2 | ast::{self, NameOwner, VisibilityOwner}, | 2 | ast::{self, NameOwner, VisibilityOwner}, |
3 | AstNode, | 3 | AstNode, |
4 | SyntaxKind::{ | 4 | SyntaxKind::{ |
5 | CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, | 5 | CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, |
6 | }, | 6 | }, |
7 | T, | 7 | T, |
8 | }; | 8 | }; |
@@ -38,7 +38,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
38 | 38 | ||
39 | let (offset, target) = if let Some(keyword) = item_keyword { | 39 | let (offset, target) = if let Some(keyword) = item_keyword { |
40 | let parent = keyword.parent(); | 40 | let parent = keyword.parent(); |
41 | let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; | 41 | let def_kws = vec![CONST_DEF, STATIC_DEF, FN, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; |
42 | // Parent is not a definition, can't add visibility | 42 | // Parent is not a definition, can't add visibility |
43 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { | 43 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { |
44 | return None; | 44 | 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::{ | |||
8 | make, | 8 | make, |
9 | }, | 9 | }, |
10 | AstNode, | 10 | AstNode, |
11 | SyntaxKind::{FN_DEF, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, | 11 | SyntaxKind::{FN, LOOP_EXPR, L_CURLY, R_CURLY, WHILE_EXPR, WHITESPACE}, |
12 | SyntaxNode, | 12 | SyntaxNode, |
13 | }; | 13 | }; |
14 | 14 | ||
@@ -88,7 +88,7 @@ pub(crate) fn convert_to_guarded_return(acc: &mut Assists, ctx: &AssistContext) | |||
88 | 88 | ||
89 | let early_expression: ast::Expr = match parent_container.kind() { | 89 | let early_expression: ast::Expr = match parent_container.kind() { |
90 | WHILE_EXPR | LOOP_EXPR => make::expr_continue(), | 90 | WHILE_EXPR | LOOP_EXPR => make::expr_continue(), |
91 | FN_DEF => make::expr_return(), | 91 | FN => make::expr_return(), |
92 | _ => return None, | 92 | _ => return None, |
93 | }; | 93 | }; |
94 | 94 | ||
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 { | |||
82 | insert_offset: TextSize, | 82 | insert_offset: TextSize, |
83 | placeholder_expr: ast::MacroCall, | 83 | placeholder_expr: ast::MacroCall, |
84 | leading_ws: String, | 84 | leading_ws: String, |
85 | fn_def: ast::FnDef, | 85 | fn_def: ast::Fn, |
86 | trailing_ws: String, | 86 | trailing_ws: String, |
87 | file: FileId, | 87 | file: FileId, |
88 | } | 88 | } |
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<Opti | |||
160 | fn has_new_fn(imp: &ast::ImplDef) -> bool { | 160 | fn has_new_fn(imp: &ast::ImplDef) -> bool { |
161 | if let Some(il) = imp.assoc_item_list() { | 161 | if let Some(il) = imp.assoc_item_list() { |
162 | for item in il.assoc_items() { | 162 | for item in il.assoc_items() { |
163 | if let ast::AssocItem::FnDef(f) = item { | 163 | if let ast::AssocItem::Fn(f) = item { |
164 | if let Some(name) = f.name() { | 164 | if let Some(name) = f.name() { |
165 | if name.text().eq_ignore_ascii_case("new") { | 165 | if name.text().eq_ignore_ascii_case("new") { |
166 | return true; | 166 | 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) - | |||
38 | let lifetime_token = ctx | 38 | let lifetime_token = ctx |
39 | .find_token_at_offset(SyntaxKind::LIFETIME) | 39 | .find_token_at_offset(SyntaxKind::LIFETIME) |
40 | .filter(|lifetime| lifetime.text() == "'_")?; | 40 | .filter(|lifetime| lifetime.text() == "'_")?; |
41 | if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::FnDef::cast) { | 41 | if let Some(fn_def) = lifetime_token.ancestors().find_map(ast::Fn::cast) { |
42 | generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) | 42 | generate_fn_def_assist(acc, &fn_def, lifetime_token.text_range()) |
43 | } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { | 43 | } else if let Some(impl_def) = lifetime_token.ancestors().find_map(ast::ImplDef::cast) { |
44 | generate_impl_def_assist(acc, &impl_def, lifetime_token.text_range()) | 44 | 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) - | |||
50 | /// Generate the assist for the fn def case | 50 | /// Generate the assist for the fn def case |
51 | fn generate_fn_def_assist( | 51 | fn generate_fn_def_assist( |
52 | acc: &mut Assists, | 52 | acc: &mut Assists, |
53 | fn_def: &ast::FnDef, | 53 | fn_def: &ast::Fn, |
54 | lifetime_loc: TextRange, | 54 | lifetime_loc: TextRange, |
55 | ) -> Option<()> { | 55 | ) -> Option<()> { |
56 | let param_list: ast::ParamList = fn_def.param_list()?; | 56 | 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 | |||
37 | 37 | ||
38 | let anchor = match_ast! { | 38 | let anchor = match_ast! { |
39 | match parent { | 39 | match parent { |
40 | ast::FnDef(it) => it.body()?.syntax().clone().into(), | 40 | ast::Fn(it) => it.body()?.syntax().clone().into(), |
41 | ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(), | 41 | ast::TraitDef(it) => it.assoc_item_list()?.syntax().clone().into(), |
42 | ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), | 42 | ast::ImplDef(it) => it.assoc_item_list()?.syntax().clone().into(), |
43 | ast::EnumDef(it) => it.variant_list()?.syntax().clone().into(), | 43 | 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( | |||
66 | if let Some(item_list) = impl_def.assoc_item_list() { | 66 | if let Some(item_list) = impl_def.assoc_item_list() { |
67 | for item in item_list.assoc_items() { | 67 | for item in item_list.assoc_items() { |
68 | match item { | 68 | match item { |
69 | ast::AssocItem::FnDef(f) => { | 69 | ast::AssocItem::Fn(f) => { |
70 | if let Some(n) = f.name() { | 70 | if let Some(n) = f.name() { |
71 | impl_fns_consts.insert(n.syntax().to_string()); | 71 | impl_fns_consts.insert(n.syntax().to_string()); |
72 | } | 72 | } |