aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/assists
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/assists')
-rw-r--r--crates/ra_assists/src/assists/auto_import.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_assists/src/assists/auto_import.rs b/crates/ra_assists/src/assists/auto_import.rs
index 4c3793ac7..9163cc662 100644
--- a/crates/ra_assists/src/assists/auto_import.rs
+++ b/crates/ra_assists/src/assists/auto_import.rs
@@ -1,4 +1,4 @@
1use hir::{db::HirDatabase, AsName}; 1use hir::db::HirDatabase;
2use ra_syntax::{ 2use ra_syntax::{
3 ast::{self, AstNode}, 3 ast::{self, AstNode},
4 SmolStr, SyntaxElement, 4 SmolStr, SyntaxElement,
@@ -48,7 +48,7 @@ pub(crate) fn auto_import<F: ImportsLocator>(
48 return None; 48 return None;
49 } 49 }
50 50
51 let name_to_import = &find_applicable_name_ref(ctx.covering_element())?.as_name(); 51 let name_to_import = &find_applicable_name_ref(ctx.covering_element())?.syntax().to_string();
52 let proposed_imports = imports_locator 52 let proposed_imports = imports_locator
53 .find_imports(&name_to_import.to_string()) 53 .find_imports(&name_to_import.to_string())
54 .into_iter() 54 .into_iter()
@@ -64,7 +64,7 @@ pub(crate) fn auto_import<F: ImportsLocator>(
64 ctx.add_assist_group(AssistId("auto_import"), "auto import", || { 64 ctx.add_assist_group(AssistId("auto_import"), "auto import", || {
65 proposed_imports 65 proposed_imports
66 .into_iter() 66 .into_iter()
67 .map(|import| import_to_action(import, &position, &path_to_import)) 67 .map(|import| import_to_action(import, &position, &path_to_import.syntax()))
68 .collect() 68 .collect()
69 }) 69 })
70} 70}
@@ -84,12 +84,12 @@ fn find_applicable_name_ref(element: SyntaxElement) -> Option<ast::NameRef> {
84 } 84 }
85} 85}
86 86
87fn import_to_action(import: String, position: &SyntaxNode, path: &ast::Path) -> ActionBuilder { 87fn import_to_action(import: String, position: &SyntaxNode, anchor: &SyntaxNode) -> ActionBuilder {
88 let mut action_builder = ActionBuilder::default(); 88 let mut action_builder = ActionBuilder::default();
89 action_builder.label(format!("Import `{}`", &import)); 89 action_builder.label(format!("Import `{}`", &import));
90 auto_import_text_edit( 90 auto_import_text_edit(
91 position, 91 position,
92 &path.syntax().clone(), 92 anchor,
93 &[SmolStr::new(import)], 93 &[SmolStr::new(import)],
94 action_builder.text_edit_builder(), 94 action_builder.text_edit_builder(),
95 ); 95 );