@@ -10,17 +10,13 @@ mod snippet;
1010#[ cfg( test) ]
1111mod tests;
1212
13- use ide_db:: text_edit:: TextEdit ;
1413use ide_db:: {
15- helpers:: mod_path_to_ast,
16- imports:: {
17- import_assets:: NameToImport ,
18- insert_use:: { self , ImportScope } ,
19- } ,
20- items_locator,
14+ imports:: insert_use:: { self , ImportScope } ,
2115 syntax_helpers:: tree_diff:: diff,
16+ text_edit:: TextEdit ,
2217 FilePosition , FxHashSet , RootDatabase ,
2318} ;
19+ use syntax:: ast:: make;
2420
2521use crate :: {
2622 completions:: Completions ,
@@ -272,7 +268,7 @@ pub fn resolve_completion_edits(
272268 db : & RootDatabase ,
273269 config : & CompletionConfig < ' _ > ,
274270 FilePosition { file_id, offset } : FilePosition ,
275- imports : impl IntoIterator < Item = ( String , String ) > ,
271+ imports : impl IntoIterator < Item = String > ,
276272) -> Option < Vec < TextEdit > > {
277273 let _p = tracing:: info_span!( "resolve_completion_edits" ) . entered ( ) ;
278274 let sema = hir:: Semantics :: new ( db) ;
@@ -289,27 +285,12 @@ pub fn resolve_completion_edits(
289285 let new_ast = scope. clone_for_update ( ) ;
290286 let mut import_insert = TextEdit :: builder ( ) ;
291287
292- let cfg = config. import_path_config ( true ) ;
293-
294- imports. into_iter ( ) . for_each ( |( full_import_path, imported_name) | {
295- let items_with_name = items_locator:: items_with_name (
296- & sema,
297- current_crate,
298- NameToImport :: exact_case_sensitive ( imported_name) ,
299- items_locator:: AssocSearchMode :: Include ,
288+ imports. into_iter ( ) . for_each ( |full_import_path| {
289+ insert_use:: insert_use (
290+ & new_ast,
291+ make:: path_from_text_with_edition ( & full_import_path, current_edition) ,
292+ & config. insert_use ,
300293 ) ;
301- let import = items_with_name
302- . filter_map ( |candidate| {
303- current_module. find_use_path ( db, candidate, config. insert_use . prefix_kind , cfg)
304- } )
305- . find ( |mod_path| mod_path. display ( db, current_edition) . to_string ( ) == full_import_path) ;
306- if let Some ( import_path) = import {
307- insert_use:: insert_use (
308- & new_ast,
309- mod_path_to_ast ( & import_path, current_edition) ,
310- & config. insert_use ,
311- ) ;
312- }
313294 } ) ;
314295
315296 diff ( scope. as_syntax_node ( ) , new_ast. as_syntax_node ( ) ) . into_text_edit ( & mut import_insert) ;
0 commit comments