@@ -10,17 +10,13 @@ mod snippet;
10
10
#[ cfg( test) ]
11
11
mod tests;
12
12
13
- use ide_db:: text_edit:: TextEdit ;
14
13
use 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 } ,
21
15
syntax_helpers:: tree_diff:: diff,
16
+ text_edit:: TextEdit ,
22
17
FilePosition , FxHashSet , RootDatabase ,
23
18
} ;
19
+ use syntax:: ast:: make;
24
20
25
21
use crate :: {
26
22
completions:: Completions ,
@@ -272,7 +268,7 @@ pub fn resolve_completion_edits(
272
268
db : & RootDatabase ,
273
269
config : & CompletionConfig < ' _ > ,
274
270
FilePosition { file_id, offset } : FilePosition ,
275
- imports : impl IntoIterator < Item = ( String , String ) > ,
271
+ imports : impl IntoIterator < Item = String > ,
276
272
) -> Option < Vec < TextEdit > > {
277
273
let _p = tracing:: info_span!( "resolve_completion_edits" ) . entered ( ) ;
278
274
let sema = hir:: Semantics :: new ( db) ;
@@ -289,27 +285,12 @@ pub fn resolve_completion_edits(
289
285
let new_ast = scope. clone_for_update ( ) ;
290
286
let mut import_insert = TextEdit :: builder ( ) ;
291
287
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 ,
300
293
) ;
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
- }
313
294
} ) ;
314
295
315
296
diff ( scope. as_syntax_node ( ) , new_ast. as_syntax_node ( ) ) . into_text_edit ( & mut import_insert) ;
0 commit comments