@@ -19,26 +19,24 @@ pub fn items_with_name<'a>(
1919 krate : Crate ,
2020 name : NameToImport ,
2121 assoc_item_search : AssocSearchMode ,
22- limit : Option < usize > ,
2322) -> impl Iterator < Item = ItemInNs > + ' a {
2423 let _p = profile:: span ( "items_with_name" ) . detail ( || {
2524 format ! (
26- "Name: {}, crate: {:?}, assoc items: {:?}, limit: {:?} " ,
25+ "Name: {}, crate: {:?}, assoc items: {:?}" ,
2726 name. text( ) ,
2827 assoc_item_search,
2928 krate. display_name( sema. db) . map( |name| name. to_string( ) ) ,
30- limit,
3129 )
3230 } ) ;
3331
3432 let prefix = matches ! ( name, NameToImport :: Prefix ( ..) ) ;
35- let ( mut local_query, mut external_query) = match name {
33+ let ( local_query, external_query) = match name {
3634 NameToImport :: Prefix ( exact_name, case_sensitive)
3735 | NameToImport :: Exact ( exact_name, case_sensitive) => {
3836 let mut local_query = symbol_index:: Query :: new ( exact_name. clone ( ) ) ;
37+ local_query. assoc_search_mode ( assoc_item_search) ;
3938 let mut external_query =
40- // import_map::Query::new(exact_name).assoc_search_mode(assoc_item_search);
41- import_map:: Query :: new ( exact_name) ;
39+ import_map:: Query :: new ( exact_name) . assoc_search_mode ( assoc_item_search) ;
4240 if prefix {
4341 local_query. prefix ( ) ;
4442 external_query = external_query. prefix ( ) ;
@@ -55,6 +53,7 @@ pub fn items_with_name<'a>(
5553 NameToImport :: Fuzzy ( fuzzy_search_string, case_sensitive) => {
5654 let mut local_query = symbol_index:: Query :: new ( fuzzy_search_string. clone ( ) ) ;
5755 local_query. fuzzy ( ) ;
56+ local_query. assoc_search_mode ( assoc_item_search) ;
5857
5958 let mut external_query = import_map:: Query :: new ( fuzzy_search_string. clone ( ) )
6059 . fuzzy ( )
@@ -69,18 +68,12 @@ pub fn items_with_name<'a>(
6968 }
7069 } ;
7170
72- if let Some ( limit) = limit {
73- external_query = external_query. limit ( limit) ;
74- local_query. limit ( limit) ;
75- }
76-
77- find_items ( sema, krate, assoc_item_search, local_query, external_query)
71+ find_items ( sema, krate, local_query, external_query)
7872}
7973
8074fn find_items < ' a > (
8175 sema : & ' a Semantics < ' _ , RootDatabase > ,
8276 krate : Crate ,
83- assoc_item_search : AssocSearchMode ,
8477 local_query : symbol_index:: Query ,
8578 external_query : import_map:: Query ,
8679) -> impl Iterator < Item = ItemInNs > + ' a {
@@ -98,18 +91,12 @@ fn find_items<'a>(
9891 } ) ;
9992
10093 // Query the local crate using the symbol index.
101- let local_results = local_query
102- . search ( & symbol_index:: crate_symbols ( db, krate) )
103- . into_iter ( )
104- . filter ( move |candidate| match assoc_item_search {
105- AssocSearchMode :: Include => true ,
106- AssocSearchMode :: Exclude => !candidate. is_assoc ,
107- AssocSearchMode :: AssocItemsOnly => candidate. is_assoc ,
108- } )
109- . map ( |local_candidate| match local_candidate. def {
94+ let mut local_results = Vec :: new ( ) ;
95+ local_query. search ( & symbol_index:: crate_symbols ( db, krate) , |local_candidate| {
96+ local_results. push ( match local_candidate. def {
11097 hir:: ModuleDef :: Macro ( macro_def) => ItemInNs :: Macros ( macro_def) ,
11198 def => ItemInNs :: from ( def) ,
112- } ) ;
113-
114- external_importables . chain ( local_results )
99+ } )
100+ } ) ;
101+ local_results . into_iter ( ) . chain ( external_importables )
115102}
0 commit comments