From cda6355de23825c201d02e6062cb2dd414e98bf9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 27 Oct 2019 17:35:37 +0300 Subject: simplify AssistCtx API We never actually use ability to create multiple actions out of a single context --- crates/ra_assists/src/assists/split_import.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists/src/assists/split_import.rs') diff --git a/crates/ra_assists/src/assists/split_import.rs b/crates/ra_assists/src/assists/split_import.rs index 8d8a28987..5f8d6b0be 100644 --- a/crates/ra_assists/src/assists/split_import.rs +++ b/crates/ra_assists/src/assists/split_import.rs @@ -16,7 +16,7 @@ use crate::{Assist, AssistCtx, AssistId}; // ``` // use std::{collections::HashMap}; // ``` -pub(crate) fn split_import(mut ctx: AssistCtx) -> Option { +pub(crate) fn split_import(ctx: AssistCtx) -> Option { let colon_colon = ctx.find_token_at_offset(T![::])?; let path = ast::Path::cast(colon_colon.parent())?; let top_path = successors(Some(path), |it| it.parent_path()).last()?; @@ -32,14 +32,12 @@ pub(crate) fn split_import(mut ctx: AssistCtx) -> Option top_path.syntax().text_range().end(), }; - ctx.add_action(AssistId("split_import"), "split import", |edit| { + ctx.add_assist(AssistId("split_import"), "split import", |edit| { edit.target(colon_colon.text_range()); edit.insert(l_curly, "{"); edit.insert(r_curly, "}"); edit.set_cursor(l_curly + TextUnit::of_str("{")); - }); - - ctx.build() + }) } #[cfg(test)] -- cgit v1.2.3