diff options
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r-- | crates/ra_assists/src/handlers/add_missing_impl_members.rs | 6 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/add_new.rs | 16 | ||||
-rw-r--r-- | crates/ra_assists/src/handlers/move_bounds.rs | 2 |
3 files changed, 12 insertions, 12 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 4005014bd..639180d37 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs | |||
@@ -101,7 +101,7 @@ fn add_missing_impl_members_inner( | |||
101 | label: &'static str, | 101 | label: &'static str, |
102 | ) -> Option<Assist> { | 102 | ) -> Option<Assist> { |
103 | let _p = ra_prof::profile("add_missing_impl_members_inner"); | 103 | let _p = ra_prof::profile("add_missing_impl_members_inner"); |
104 | let impl_node = ctx.find_node_at_offset::<ast::ImplBlock>()?; | 104 | let impl_node = ctx.find_node_at_offset::<ast::ImplDef>()?; |
105 | let impl_item_list = impl_node.item_list()?; | 105 | let impl_item_list = impl_node.item_list()?; |
106 | 106 | ||
107 | let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; | 107 | let trait_ = resolve_target_trait(&ctx.sema, &impl_node)?; |
@@ -257,7 +257,7 @@ impl Foo for S { | |||
257 | } | 257 | } |
258 | 258 | ||
259 | #[test] | 259 | #[test] |
260 | fn test_empty_impl_block() { | 260 | fn test_empty_impl_def() { |
261 | check_assist( | 261 | check_assist( |
262 | add_missing_impl_members, | 262 | add_missing_impl_members, |
263 | " | 263 | " |
@@ -308,7 +308,7 @@ impl<U> Foo<U> for S { | |||
308 | } | 308 | } |
309 | 309 | ||
310 | #[test] | 310 | #[test] |
311 | fn test_cursor_after_empty_impl_block() { | 311 | fn test_cursor_after_empty_impl_def() { |
312 | check_assist( | 312 | check_assist( |
313 | add_missing_impl_members, | 313 | add_missing_impl_members, |
314 | " | 314 | " |
diff --git a/crates/ra_assists/src/handlers/add_new.rs b/crates/ra_assists/src/handlers/add_new.rs index 166e907fb..697e7cda6 100644 --- a/crates/ra_assists/src/handlers/add_new.rs +++ b/crates/ra_assists/src/handlers/add_new.rs | |||
@@ -41,14 +41,14 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> { | |||
41 | }; | 41 | }; |
42 | 42 | ||
43 | // Return early if we've found an existing new fn | 43 | // Return early if we've found an existing new fn |
44 | let impl_block = find_struct_impl(&ctx, &strukt)?; | 44 | let impl_def = find_struct_impl(&ctx, &strukt)?; |
45 | 45 | ||
46 | ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| { | 46 | ctx.add_assist(AssistId("add_new"), "Add default constructor", |edit| { |
47 | edit.target(strukt.syntax().text_range()); | 47 | edit.target(strukt.syntax().text_range()); |
48 | 48 | ||
49 | let mut buf = String::with_capacity(512); | 49 | let mut buf = String::with_capacity(512); |
50 | 50 | ||
51 | if impl_block.is_some() { | 51 | if impl_def.is_some() { |
52 | buf.push('\n'); | 52 | buf.push('\n'); |
53 | } | 53 | } |
54 | 54 | ||
@@ -71,10 +71,10 @@ pub(crate) fn add_new(ctx: AssistCtx) -> Option<Assist> { | |||
71 | 71 | ||
72 | buf.push_str("} }"); | 72 | buf.push_str("} }"); |
73 | 73 | ||
74 | let (start_offset, end_offset) = impl_block | 74 | let (start_offset, end_offset) = impl_def |
75 | .and_then(|impl_block| { | 75 | .and_then(|impl_def| { |
76 | buf.push('\n'); | 76 | buf.push('\n'); |
77 | let start = impl_block | 77 | let start = impl_def |
78 | .syntax() | 78 | .syntax() |
79 | .descendants_with_tokens() | 79 | .descendants_with_tokens() |
80 | .find(|t| t.kind() == T!['{'])? | 80 | .find(|t| t.kind() == T!['{'])? |
@@ -128,7 +128,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String { | |||
128 | // | 128 | // |
129 | // FIXME: change the new fn checking to a more semantic approach when that's more | 129 | // FIXME: change the new fn checking to a more semantic approach when that's more |
130 | // viable (e.g. we process proc macros, etc) | 130 | // viable (e.g. we process proc macros, etc) |
131 | fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplBlock>> { | 131 | fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<ast::ImplDef>> { |
132 | let db = ctx.db; | 132 | let db = ctx.db; |
133 | let module = strukt.syntax().ancestors().find(|node| { | 133 | let module = strukt.syntax().ancestors().find(|node| { |
134 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) | 134 | ast::Module::can_cast(node.kind()) || ast::SourceFile::can_cast(node.kind()) |
@@ -136,7 +136,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<a | |||
136 | 136 | ||
137 | let struct_def = ctx.sema.to_def(strukt)?; | 137 | let struct_def = ctx.sema.to_def(strukt)?; |
138 | 138 | ||
139 | let block = module.descendants().filter_map(ast::ImplBlock::cast).find_map(|impl_blk| { | 139 | let block = module.descendants().filter_map(ast::ImplDef::cast).find_map(|impl_blk| { |
140 | let blk = ctx.sema.to_def(&impl_blk)?; | 140 | let blk = ctx.sema.to_def(&impl_blk)?; |
141 | 141 | ||
142 | // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` | 142 | // FIXME: handle e.g. `struct S<T>; impl<U> S<U> {}` |
@@ -164,7 +164,7 @@ fn find_struct_impl(ctx: &AssistCtx, strukt: &ast::StructDef) -> Option<Option<a | |||
164 | Some(block) | 164 | Some(block) |
165 | } | 165 | } |
166 | 166 | ||
167 | fn has_new_fn(imp: &ast::ImplBlock) -> bool { | 167 | fn has_new_fn(imp: &ast::ImplDef) -> bool { |
168 | if let Some(il) = imp.item_list() { | 168 | if let Some(il) = imp.item_list() { |
169 | for item in il.impl_items() { | 169 | for item in il.impl_items() { |
170 | if let ast::ImplItem::FnDef(f) = item { | 170 | if let ast::ImplItem::FnDef(f) = item { |
diff --git a/crates/ra_assists/src/handlers/move_bounds.rs b/crates/ra_assists/src/handlers/move_bounds.rs index 86b235366..0b501f3e5 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(ctx: AssistCtx) -> Option<Assist> { | |||
37 | let anchor: SyntaxElement = match parent.kind() { | 37 | let anchor: SyntaxElement = match parent.kind() { |
38 | FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), | 38 | FN_DEF => ast::FnDef::cast(parent)?.body()?.syntax().clone().into(), |
39 | TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), | 39 | TRAIT_DEF => ast::TraitDef::cast(parent)?.item_list()?.syntax().clone().into(), |
40 | IMPL_BLOCK => ast::ImplBlock::cast(parent)?.item_list()?.syntax().clone().into(), | 40 | IMPL_DEF => ast::ImplDef::cast(parent)?.item_list()?.syntax().clone().into(), |
41 | ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), | 41 | ENUM_DEF => ast::EnumDef::cast(parent)?.variant_list()?.syntax().clone().into(), |
42 | STRUCT_DEF => parent | 42 | STRUCT_DEF => parent |
43 | .children_with_tokens() | 43 | .children_with_tokens() |