From 067cb928f09482c63ec2bfbdafb04fbd53b754e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Feb 2020 22:43:13 +0100 Subject: Simplify --- crates/ra_assists/src/handlers/auto_import.rs | 1 - .../src/handlers/replace_qualified_name_with_use.rs | 16 +--------------- 2 files changed, 1 insertion(+), 16 deletions(-) (limited to 'crates/ra_assists/src/handlers') diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs index 46fbdb525..c8bf181f9 100644 --- a/crates/ra_assists/src/handlers/auto_import.rs +++ b/crates/ra_assists/src/handlers/auto_import.rs @@ -52,7 +52,6 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option { group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| { edit.target(auto_import_assets.syntax_under_caret.text_range()); insert_use_statement( - &auto_import_assets.syntax_under_caret, &auto_import_assets.syntax_under_caret, &import, edit.text_edit_builder(), diff --git a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs index 44f3f5e7f..94f5d6c50 100644 --- a/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs +++ b/crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs @@ -33,26 +33,12 @@ pub(crate) fn replace_qualified_name_with_use(ctx: AssistCtx) -> Option return None; } - let module = path.syntax().ancestors().find_map(ast::Module::cast); - let position = match module.and_then(|it| it.item_list()) { - Some(item_list) => item_list.syntax().clone(), - None => { - let current_file = path.syntax().ancestors().find_map(ast::SourceFile::cast)?; - current_file.syntax().clone() - } - }; - ctx.add_assist( AssistId("replace_qualified_name_with_use"), "Replace qualified path with use", |edit| { let path_to_import = hir_path.mod_path().clone(); - insert_use_statement( - &position, - &path.syntax(), - &path_to_import, - edit.text_edit_builder(), - ); + insert_use_statement(path.syntax(), &path_to_import, edit.text_edit_builder()); if let Some(last) = path.segment() { // Here we are assuming the assist will provide a correct use statement -- cgit v1.2.3