diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-30 14:26:15 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-30 14:26:15 +0100 |
commit | ee00679331b87dacc5fe608f153be160c1cb144c (patch) | |
tree | f80ef7823490a6904b3f7bf57a4609ca4c4743dc /crates/ra_assists | |
parent | 96c3ff1c573f97e5089fc0ba01ede6fe43693668 (diff) | |
parent | eb2f8063444b11257111f4f8ade990ec810e0361 (diff) |
Merge #5591
5591: Rename TypeAliasDef -> TypeAlias r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists')
9 files changed, 21 insertions, 25 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..1e4d4748c 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -118,8 +118,8 @@ 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::TypeAlias(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, |
125 | } | 125 | } |
@@ -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::TypeAlias(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,10 +158,8 @@ 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::TypeAlias(def) => ast::AssocItem::TypeAlias(def.remove_bounds()), |
163 | ast::AssocItem::TypeAliasDef(def.remove_bounds()) | ||
164 | } | ||
165 | _ => it, | 163 | _ => it, |
166 | }) | 164 | }) |
167 | .map(|it| edit::remove_attrs_and_docs(&it)); | 165 | .map(|it| edit::remove_attrs_and_docs(&it)); |
@@ -174,7 +172,7 @@ fn add_missing_impl_members_inner( | |||
174 | Some(cap) => { | 172 | Some(cap) => { |
175 | let mut cursor = Cursor::Before(first_new_item.syntax()); | 173 | let mut cursor = Cursor::Before(first_new_item.syntax()); |
176 | let placeholder; | 174 | let placeholder; |
177 | if let ast::AssocItem::FnDef(func) = &first_new_item { | 175 | if let ast::AssocItem::Fn(func) = &first_new_item { |
178 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { | 176 | if let Some(m) = func.syntax().descendants().find_map(ast::MacroCall::cast) { |
179 | if m.syntax().text() == "todo!()" { | 177 | if m.syntax().text() == "todo!()" { |
180 | placeholder = m; | 178 | placeholder = m; |
@@ -192,7 +190,7 @@ fn add_missing_impl_members_inner( | |||
192 | }) | 190 | }) |
193 | } | 191 | } |
194 | 192 | ||
195 | fn add_body(fn_def: ast::FnDef) -> ast::FnDef { | 193 | fn add_body(fn_def: ast::Fn) -> ast::Fn { |
196 | if fn_def.body().is_some() { | 194 | if fn_def.body().is_some() { |
197 | return fn_def; | 195 | return fn_def; |
198 | } | 196 | } |
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..c3e1f2803 100644 --- a/crates/ra_assists/src/handlers/change_visibility.rs +++ b/crates/ra_assists/src/handlers/change_visibility.rs | |||
@@ -1,9 +1,7 @@ | |||
1 | use ra_syntax::{ | 1 | use ra_syntax::{ |
2 | ast::{self, NameOwner, VisibilityOwner}, | 2 | ast::{self, NameOwner, VisibilityOwner}, |
3 | AstNode, | 3 | AstNode, |
4 | SyntaxKind::{ | 4 | SyntaxKind::{CONST_DEF, ENUM_DEF, FN, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY}, |
5 | CONST_DEF, ENUM_DEF, FN_DEF, MODULE, STATIC_DEF, STRUCT_DEF, TRAIT_DEF, VISIBILITY, | ||
6 | }, | ||
7 | T, | 5 | T, |
8 | }; | 6 | }; |
9 | use test_utils::mark; | 7 | use test_utils::mark; |
@@ -38,7 +36,7 @@ fn add_vis(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { | |||
38 | 36 | ||
39 | let (offset, target) = if let Some(keyword) = item_keyword { | 37 | let (offset, target) = if let Some(keyword) = item_keyword { |
40 | let parent = keyword.parent(); | 38 | let parent = keyword.parent(); |
41 | let def_kws = vec![CONST_DEF, STATIC_DEF, FN_DEF, MODULE, STRUCT_DEF, ENUM_DEF, TRAIT_DEF]; | 39 | 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 | 40 | // Parent is not a definition, can't add visibility |
43 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { | 41 | if !def_kws.iter().any(|&def_kw| def_kw == parent.kind()) { |
44 | return None; | 42 | 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..748be011b 100644 --- a/crates/ra_assists/src/utils.rs +++ b/crates/ra_assists/src/utils.rs | |||
@@ -66,13 +66,13 @@ 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 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | ast::AssocItem::TypeAliasDef(t) => { | 75 | ast::AssocItem::TypeAlias(t) => { |
76 | if let Some(n) = t.name() { | 76 | if let Some(n) = t.name() { |
77 | impl_type.insert(n.syntax().to_string()); | 77 | impl_type.insert(n.syntax().to_string()); |
78 | } | 78 | } |