diff options
author | Kirill Bulatov <[email protected]> | 2021-01-16 22:53:15 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2021-01-17 00:57:34 +0000 |
commit | 68626e4ef5acfea05812b68f41efa2bcd5bea448 (patch) | |
tree | 92ec1a8a69ce3058fd6da44f2f80f2460c9bda1d /crates/ide_db/src/imports_locator.rs | |
parent | db335a1bbf1d1bea2c761f67efb4b49831738e31 (diff) |
Draft the working completion
Diffstat (limited to 'crates/ide_db/src/imports_locator.rs')
-rw-r--r-- | crates/ide_db/src/imports_locator.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index d69e65960..502e8281a 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs | |||
@@ -15,7 +15,7 @@ use crate::{ | |||
15 | use either::Either; | 15 | use either::Either; |
16 | use rustc_hash::FxHashSet; | 16 | use rustc_hash::FxHashSet; |
17 | 17 | ||
18 | const QUERY_SEARCH_LIMIT: usize = 40; | 18 | pub(crate) const DEFAULT_QUERY_SEARCH_LIMIT: usize = 40; |
19 | 19 | ||
20 | pub fn find_exact_imports<'a>( | 20 | pub fn find_exact_imports<'a>( |
21 | sema: &Semantics<'a, RootDatabase>, | 21 | sema: &Semantics<'a, RootDatabase>, |
@@ -29,11 +29,11 @@ pub fn find_exact_imports<'a>( | |||
29 | { | 29 | { |
30 | let mut local_query = symbol_index::Query::new(name_to_import.clone()); | 30 | let mut local_query = symbol_index::Query::new(name_to_import.clone()); |
31 | local_query.exact(); | 31 | local_query.exact(); |
32 | local_query.limit(QUERY_SEARCH_LIMIT); | 32 | local_query.limit(DEFAULT_QUERY_SEARCH_LIMIT); |
33 | local_query | 33 | local_query |
34 | }, | 34 | }, |
35 | import_map::Query::new(name_to_import) | 35 | import_map::Query::new(name_to_import) |
36 | .limit(QUERY_SEARCH_LIMIT) | 36 | .limit(DEFAULT_QUERY_SEARCH_LIMIT) |
37 | .name_only() | 37 | .name_only() |
38 | .search_mode(import_map::SearchMode::Equals) | 38 | .search_mode(import_map::SearchMode::Equals) |
39 | .case_sensitive(), | 39 | .case_sensitive(), |
@@ -51,13 +51,13 @@ pub fn find_similar_imports<'a>( | |||
51 | krate: Crate, | 51 | krate: Crate, |
52 | fuzzy_search_string: String, | 52 | fuzzy_search_string: String, |
53 | assoc_item_search: AssocItemSearch, | 53 | assoc_item_search: AssocItemSearch, |
54 | limit: Option<usize>, | ||
54 | ) -> Box<dyn Iterator<Item = Either<ModuleDef, MacroDef>> + 'a> { | 55 | ) -> Box<dyn Iterator<Item = Either<ModuleDef, MacroDef>> + 'a> { |
55 | let _p = profile::span("find_similar_imports"); | 56 | let _p = profile::span("find_similar_imports"); |
56 | 57 | ||
57 | let mut external_query = import_map::Query::new(fuzzy_search_string.clone()) | 58 | let mut external_query = import_map::Query::new(fuzzy_search_string.clone()) |
58 | .search_mode(import_map::SearchMode::Fuzzy) | 59 | .search_mode(import_map::SearchMode::Fuzzy) |
59 | .name_only() | 60 | .name_only(); |
60 | .limit(QUERY_SEARCH_LIMIT); | ||
61 | 61 | ||
62 | match assoc_item_search { | 62 | match assoc_item_search { |
63 | AssocItemSearch::Include => {} | 63 | AssocItemSearch::Include => {} |
@@ -70,7 +70,11 @@ pub fn find_similar_imports<'a>( | |||
70 | } | 70 | } |
71 | 71 | ||
72 | let mut local_query = symbol_index::Query::new(fuzzy_search_string); | 72 | let mut local_query = symbol_index::Query::new(fuzzy_search_string); |
73 | local_query.limit(QUERY_SEARCH_LIMIT); | 73 | |
74 | if let Some(limit) = limit { | ||
75 | external_query = external_query.limit(limit); | ||
76 | local_query.limit(limit); | ||
77 | } | ||
74 | 78 | ||
75 | let db = sema.db; | 79 | let db = sema.db; |
76 | Box::new(find_imports(sema, krate, local_query, external_query).filter( | 80 | Box::new(find_imports(sema, krate, local_query, external_query).filter( |