From b83c7eedccea4c9cb35b1d1cc58231f07a5e3ba2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Mar 2021 17:31:19 +0300 Subject: Tweak assits API to fit mutable syntax trees changelog: skip --- crates/ide_assists/src/handlers/move_bounds.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ide_assists/src/handlers/move_bounds.rs') diff --git a/crates/ide_assists/src/handlers/move_bounds.rs b/crates/ide_assists/src/handlers/move_bounds.rs index b5dec8014..011a28d44 100644 --- a/crates/ide_assists/src/handlers/move_bounds.rs +++ b/crates/ide_assists/src/handlers/move_bounds.rs @@ -21,7 +21,7 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // } // ``` pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { - let type_param_list = ctx.find_node_at_offset::()?.clone_for_update(); + let type_param_list = ctx.find_node_at_offset::()?; let mut type_params = type_param_list.type_params(); if type_params.all(|p| p.type_bound_list().is_none()) { @@ -29,7 +29,6 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext } let parent = type_param_list.syntax().parent()?; - let original_parent_range = parent.text_range(); let target = type_param_list.syntax().text_range(); acc.add( @@ -37,6 +36,9 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext "Move to where clause", target, |edit| { + let type_param_list = edit.make_ast_mut(type_param_list); + let parent = edit.make_mut(parent); + let where_clause: ast::WhereClause = match_ast! { match parent { ast::Fn(it) => it.get_or_create_where_clause(), @@ -56,8 +58,6 @@ pub(crate) fn move_bounds_to_where_clause(acc: &mut Assists, ctx: &AssistContext tbl.remove() } } - - edit.replace(original_parent_range, parent.to_string()) }, ) } -- cgit v1.2.3