@@ -19,26 +19,24 @@ pub fn items_with_name<'a>(
19
19
krate : Crate ,
20
20
name : NameToImport ,
21
21
assoc_item_search : AssocSearchMode ,
22
- limit : Option < usize > ,
23
22
) -> impl Iterator < Item = ItemInNs > + ' a {
24
23
let _p = profile:: span ( "items_with_name" ) . detail ( || {
25
24
format ! (
26
- "Name: {}, crate: {:?}, assoc items: {:?}, limit: {:?} " ,
25
+ "Name: {}, crate: {:?}, assoc items: {:?}" ,
27
26
name. text( ) ,
28
27
assoc_item_search,
29
28
krate. display_name( sema. db) . map( |name| name. to_string( ) ) ,
30
- limit,
31
29
)
32
30
} ) ;
33
31
34
32
let prefix = matches ! ( name, NameToImport :: Prefix ( ..) ) ;
35
- let ( mut local_query, mut external_query) = match name {
33
+ let ( local_query, external_query) = match name {
36
34
NameToImport :: Prefix ( exact_name, case_sensitive)
37
35
| NameToImport :: Exact ( exact_name, case_sensitive) => {
38
36
let mut local_query = symbol_index:: Query :: new ( exact_name. clone ( ) ) ;
37
+ local_query. assoc_search_mode ( assoc_item_search) ;
39
38
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) ;
42
40
if prefix {
43
41
local_query. prefix ( ) ;
44
42
external_query = external_query. prefix ( ) ;
@@ -55,6 +53,7 @@ pub fn items_with_name<'a>(
55
53
NameToImport :: Fuzzy ( fuzzy_search_string, case_sensitive) => {
56
54
let mut local_query = symbol_index:: Query :: new ( fuzzy_search_string. clone ( ) ) ;
57
55
local_query. fuzzy ( ) ;
56
+ local_query. assoc_search_mode ( assoc_item_search) ;
58
57
59
58
let mut external_query = import_map:: Query :: new ( fuzzy_search_string. clone ( ) )
60
59
. fuzzy ( )
@@ -69,18 +68,12 @@ pub fn items_with_name<'a>(
69
68
}
70
69
} ;
71
70
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)
78
72
}
79
73
80
74
fn find_items < ' a > (
81
75
sema : & ' a Semantics < ' _ , RootDatabase > ,
82
76
krate : Crate ,
83
- assoc_item_search : AssocSearchMode ,
84
77
local_query : symbol_index:: Query ,
85
78
external_query : import_map:: Query ,
86
79
) -> impl Iterator < Item = ItemInNs > + ' a {
@@ -98,18 +91,12 @@ fn find_items<'a>(
98
91
} ) ;
99
92
100
93
// 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 {
110
97
hir:: ModuleDef :: Macro ( macro_def) => ItemInNs :: Macros ( macro_def) ,
111
98
def => ItemInNs :: from ( def) ,
112
- } ) ;
113
-
114
- external_importables . chain ( local_results )
99
+ } )
100
+ } ) ;
101
+ local_results . into_iter ( ) . chain ( external_importables )
115
102
}
0 commit comments