diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-07 15:28:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-07 15:28:47 +0100 |
commit | c7e305731c922a2d32eda89ff22cb636059bc4e7 (patch) | |
tree | 4f3ab3a70fbbb901ccec3cd162da00eaa9cbad09 /crates/ra_assists/src/handlers/add_custom_impl.rs | |
parent | f4cd75ac06dff7f5a95065a6c3868669e5c2ab27 (diff) | |
parent | 4867968d22899395e6551f22641b3617e995140c (diff) |
Merge #4350
4350: Refactor assists API to be more convenient for adding new assists r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/handlers/add_custom_impl.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/add_custom_impl.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/ra_assists/src/handlers/add_custom_impl.rs b/crates/ra_assists/src/handlers/add_custom_impl.rs index 869d4dc04..795a225a4 100644 --- a/crates/ra_assists/src/handlers/add_custom_impl.rs +++ b/crates/ra_assists/src/handlers/add_custom_impl.rs | |||
@@ -6,7 +6,10 @@ use ra_syntax::{ | |||
6 | }; | 6 | }; |
7 | use stdx::SepBy; | 7 | use stdx::SepBy; |
8 | 8 | ||
9 | use crate::{Assist, AssistCtx, AssistId}; | 9 | use crate::{ |
10 | assist_context::{AssistContext, Assists}, | ||
11 | AssistId, | ||
12 | }; | ||
10 | 13 | ||
11 | // Assist: add_custom_impl | 14 | // Assist: add_custom_impl |
12 | // | 15 | // |
@@ -25,7 +28,7 @@ use crate::{Assist, AssistCtx, AssistId}; | |||
25 | // | 28 | // |
26 | // } | 29 | // } |
27 | // ``` | 30 | // ``` |
28 | pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | 31 | pub(crate) fn add_custom_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { |
29 | let input = ctx.find_node_at_offset::<ast::AttrInput>()?; | 32 | let input = ctx.find_node_at_offset::<ast::AttrInput>()?; |
30 | let attr = input.syntax().parent().and_then(ast::Attr::cast)?; | 33 | let attr = input.syntax().parent().and_then(ast::Attr::cast)?; |
31 | 34 | ||
@@ -49,7 +52,7 @@ pub(crate) fn add_custom_impl(ctx: AssistCtx) -> Option<Assist> { | |||
49 | format!("Add custom impl '{}' for '{}'", trait_token.text().as_str(), annotated_name); | 52 | format!("Add custom impl '{}' for '{}'", trait_token.text().as_str(), annotated_name); |
50 | 53 | ||
51 | let target = attr.syntax().text_range(); | 54 | let target = attr.syntax().text_range(); |
52 | ctx.add_assist(AssistId("add_custom_impl"), label, target, |edit| { | 55 | acc.add(AssistId("add_custom_impl"), label, target, |edit| { |
53 | let new_attr_input = input | 56 | let new_attr_input = input |
54 | .syntax() | 57 | .syntax() |
55 | .descendants_with_tokens() | 58 | .descendants_with_tokens() |