diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-11 17:30:53 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-11 17:30:53 +0000 |
commit | b356ab46f2b7482bf1ae0c0f6cd5a87ece8742bf (patch) | |
tree | 094055dc8b24154fb8525c5910ae6dde4b4f4fe9 /crates/ra_assists/src/remove_dbg.rs | |
parent | 77ccac74f94fbe387fc587d46f9d93f04fce3644 (diff) | |
parent | 5c9c0d3ae2735b4b32a44742bac800ca616fdde8 (diff) |
Merge #781
781: Refactor to allow for multiple assists r=matklad a=eulerdisk
This is necessary to allow assist "providers" (which currently are simple free function) to produce multiple assists. I'm not sure this is the best possible refactoring tough.
Co-authored-by: Andrea Pretto <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/remove_dbg.rs')
-rw-r--r-- | crates/ra_assists/src/remove_dbg.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/crates/ra_assists/src/remove_dbg.rs b/crates/ra_assists/src/remove_dbg.rs index e9d0a635b..db260c6ca 100644 --- a/crates/ra_assists/src/remove_dbg.rs +++ b/crates/ra_assists/src/remove_dbg.rs | |||
@@ -8,7 +8,7 @@ use ra_syntax::{ | |||
8 | }; | 8 | }; |
9 | use crate::{AssistCtx, Assist}; | 9 | use crate::{AssistCtx, Assist}; |
10 | 10 | ||
11 | pub(crate) fn remove_dbg(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | 11 | pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { |
12 | let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; | 12 | let macro_call = ctx.node_at_offset::<ast::MacroCall>()?; |
13 | 13 | ||
14 | if !is_valid_macrocall(macro_call, "dbg")? { | 14 | if !is_valid_macrocall(macro_call, "dbg")? { |
@@ -46,11 +46,13 @@ pub(crate) fn remove_dbg(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { | |||
46 | macro_args.text().slice(start..end).to_string() | 46 | macro_args.text().slice(start..end).to_string() |
47 | }; | 47 | }; |
48 | 48 | ||
49 | ctx.build("remove dbg!()", |edit| { | 49 | ctx.add_action("remove dbg!()", |edit| { |
50 | edit.target(macro_call.syntax().range()); | 50 | edit.target(macro_call.syntax().range()); |
51 | edit.replace(macro_range, macro_content); | 51 | edit.replace(macro_range, macro_content); |
52 | edit.set_cursor(cursor_pos); | 52 | edit.set_cursor(cursor_pos); |
53 | }) | 53 | }); |
54 | |||
55 | ctx.build() | ||
54 | } | 56 | } |
55 | 57 | ||
56 | /// Verifies that the given macro_call actually matches the given name | 58 | /// Verifies that the given macro_call actually matches the given name |