aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/handlers')
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs1
-rw-r--r--crates/ra_assists/src/handlers/replace_qualified_name_with_use.rs16
2 files changed, 1 insertions, 16 deletions
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
@@ -53,7 +53,6 @@ pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
53 edit.target(auto_import_assets.syntax_under_caret.text_range()); 53 edit.target(auto_import_assets.syntax_under_caret.text_range());
54 insert_use_statement( 54 insert_use_statement(
55 &auto_import_assets.syntax_under_caret, 55 &auto_import_assets.syntax_under_caret,
56 &auto_import_assets.syntax_under_caret,
57 &import, 56 &import,
58 edit.text_edit_builder(), 57 edit.text_edit_builder(),
59 ); 58 );
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<Assist>
33 return None; 33 return None;
34 } 34 }
35 35
36 let module = path.syntax().ancestors().find_map(ast::Module::cast);
37 let position = match module.and_then(|it| it.item_list()) {
38 Some(item_list) => item_list.syntax().clone(),
39 None => {
40 let current_file = path.syntax().ancestors().find_map(ast::SourceFile::cast)?;
41 current_file.syntax().clone()
42 }
43 };
44
45 ctx.add_assist( 36 ctx.add_assist(
46 AssistId("replace_qualified_name_with_use"), 37 AssistId("replace_qualified_name_with_use"),
47 "Replace qualified path with use", 38 "Replace qualified path with use",
48 |edit| { 39 |edit| {
49 let path_to_import = hir_path.mod_path().clone(); 40 let path_to_import = hir_path.mod_path().clone();
50 insert_use_statement( 41 insert_use_statement(path.syntax(), &path_to_import, edit.text_edit_builder());
51 &position,
52 &path.syntax(),
53 &path_to_import,
54 edit.text_edit_builder(),
55 );
56 42
57 if let Some(last) = path.segment() { 43 if let Some(last) = path.segment() {
58 // Here we are assuming the assist will provide a correct use statement 44 // Here we are assuming the assist will provide a correct use statement