aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists/remove_dbg.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-27 14:38:28 +0000
committerGitHub <[email protected]>2019-10-27 14:38:28 +0000
commitcf309b6a5f2d51e9509568ab82446cc3eae29f94 (patch)
tree54c4a26d7a6688a89515cdc97ec02c1a9f9103bf /crates/ra_assists/src/assists/remove_dbg.rs
parentad950830d0902aaacfb5a76355a203626eb93b5f (diff)
parentcda6355de23825c201d02e6062cb2dd414e98bf9 (diff)
Merge #2094
2094: simplify AssistCtx API r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_assists/src/assists/remove_dbg.rs')
-rw-r--r--crates/ra_assists/src/assists/remove_dbg.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/remove_dbg.rs b/crates/ra_assists/src/assists/remove_dbg.rs
index 44b8de814..aedf8747f 100644
--- a/crates/ra_assists/src/assists/remove_dbg.rs
+++ b/crates/ra_assists/src/assists/remove_dbg.rs
@@ -21,7 +21,7 @@ use crate::{Assist, AssistCtx, AssistId};
21// 92; 21// 92;
22// } 22// }
23// ``` 23// ```
24pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> { 24pub(crate) fn remove_dbg(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
25 let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?; 25 let macro_call = ctx.find_node_at_offset::<ast::MacroCall>()?;
26 26
27 if !is_valid_macrocall(&macro_call, "dbg")? { 27 if !is_valid_macrocall(&macro_call, "dbg")? {
@@ -58,13 +58,11 @@ pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist>
58 text.slice(without_parens).to_string() 58 text.slice(without_parens).to_string()
59 }; 59 };
60 60
61 ctx.add_action(AssistId("remove_dbg"), "remove dbg!()", |edit| { 61 ctx.add_assist(AssistId("remove_dbg"), "remove dbg!()", |edit| {
62 edit.target(macro_call.syntax().text_range()); 62 edit.target(macro_call.syntax().text_range());
63 edit.replace(macro_range, macro_content); 63 edit.replace(macro_range, macro_content);
64 edit.set_cursor(cursor_pos); 64 edit.set_cursor(cursor_pos);
65 }); 65 })
66
67 ctx.build()
68} 66}
69 67
70/// Verifies that the given macro_call actually matches the given name 68/// Verifies that the given macro_call actually matches the given name