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/introduce_variable.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/ra_assists/src/assists/introduce_variable.rs') diff --git a/crates/ra_assists/src/assists/introduce_variable.rs b/crates/ra_assists/src/assists/introduce_variable.rs index 8245dc99f..0623d4475 100644 --- a/crates/ra_assists/src/assists/introduce_variable.rs +++ b/crates/ra_assists/src/assists/introduce_variable.rs @@ -28,7 +28,7 @@ use crate::{Assist, AssistCtx, AssistId}; // var_name * 4; // } // ``` -pub(crate) fn introduce_variable(mut ctx: AssistCtx) -> Option { +pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option { if ctx.frange.range.is_empty() { return None; } @@ -43,7 +43,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx) -> Option if indent.kind() != WHITESPACE { return None; } - ctx.add_action(AssistId("introduce_variable"), "introduce variable", move |edit| { + ctx.add_assist(AssistId("introduce_variable"), "introduce variable", move |edit| { let mut buf = String::new(); let cursor_offset = if wrap_in_block { @@ -88,9 +88,7 @@ pub(crate) fn introduce_variable(mut ctx: AssistCtx) -> Option } } edit.set_cursor(anchor_stmt.text_range().start() + cursor_offset); - }); - - ctx.build() + }) } /// Check whether the node is a valid expression which can be extracted to a variable. -- cgit v1.2.3