]> git.lizzy.rs Git - rust.git/blobdiff - crates/ra_assists/src/remove_dbg.rs
ra_assists: assist "providers" can produce multiple assists
[rust.git] / crates / ra_assists / src / remove_dbg.rs
index e9d0a635b3ed9563908e40494e55309745b9d47e..db260c6caf5aa646af15908f7e47ca7cb4a966cd 100644 (file)
@@ -8,7 +8,7 @@
 };
 use crate::{AssistCtx, Assist};
 
-pub(crate) fn remove_dbg(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
+pub(crate) fn remove_dbg(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
     let macro_call = ctx.node_at_offset::<ast::MacroCall>()?;
 
     if !is_valid_macrocall(macro_call, "dbg")? {
@@ -46,11 +46,13 @@ pub(crate) fn remove_dbg(ctx: AssistCtx<impl HirDatabase>) -> Option<Assist> {
         macro_args.text().slice(start..end).to_string()
     };
 
-    ctx.build("remove dbg!()", |edit| {
+    ctx.add_action("remove dbg!()", |edit| {
         edit.target(macro_call.syntax().range());
         edit.replace(macro_range, macro_content);
         edit.set_cursor(cursor_pos);
-    })
+    });
+
+    ctx.build()
 }
 
 /// Verifies that the given macro_call actually matches the given name