diff options
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/imports_locator.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index b2980a5d6..0f4c2ca47 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs | |||
@@ -15,19 +15,23 @@ use rustc_hash::FxHashSet; | |||
15 | pub fn find_exact_imports<'a>( | 15 | pub fn find_exact_imports<'a>( |
16 | sema: &Semantics<'a, RootDatabase>, | 16 | sema: &Semantics<'a, RootDatabase>, |
17 | krate: Crate, | 17 | krate: Crate, |
18 | name_to_import: &str, | 18 | name_to_import: String, |
19 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 19 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
20 | let _p = profile::span("find_exact_imports"); | 20 | let _p = profile::span("find_exact_imports"); |
21 | find_imports( | 21 | find_imports( |
22 | sema, | 22 | sema, |
23 | krate, | 23 | krate, |
24 | { | 24 | { |
25 | let mut local_query = symbol_index::Query::new(name_to_import.to_string()); | 25 | let mut local_query = symbol_index::Query::new(name_to_import.clone()); |
26 | local_query.exact(); | 26 | local_query.exact(); |
27 | local_query.limit(40); | 27 | local_query.limit(40); |
28 | local_query | 28 | local_query |
29 | }, | 29 | }, |
30 | import_map::Query::new(name_to_import).anchor_end().case_sensitive().limit(40), | 30 | import_map::Query::new(name_to_import) |
31 | .limit(40) | ||
32 | .name_only() | ||
33 | .search_mode(import_map::SearchMode::Equals) | ||
34 | .case_sensitive(), | ||
31 | ) | 35 | ) |
32 | } | 36 | } |
33 | 37 | ||
@@ -35,17 +39,18 @@ pub fn find_similar_imports<'a>( | |||
35 | sema: &Semantics<'a, RootDatabase>, | 39 | sema: &Semantics<'a, RootDatabase>, |
36 | krate: Crate, | 40 | krate: Crate, |
37 | limit: Option<usize>, | 41 | limit: Option<usize>, |
38 | name_to_import: &str, | 42 | fuzzy_search_string: String, |
39 | ignore_modules: bool, | 43 | name_only: bool, |
40 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 44 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
41 | let _p = profile::span("find_similar_imports"); | 45 | let _p = profile::span("find_similar_imports"); |
42 | 46 | ||
43 | let mut external_query = import_map::Query::new(name_to_import); | 47 | let mut external_query = import_map::Query::new(fuzzy_search_string.clone()) |
44 | if ignore_modules { | 48 | .search_mode(import_map::SearchMode::Fuzzy); |
45 | external_query = external_query.exclude_import_kind(import_map::ImportKind::Module); | 49 | if name_only { |
50 | external_query = external_query.name_only(); | ||
46 | } | 51 | } |
47 | 52 | ||
48 | let mut local_query = symbol_index::Query::new(name_to_import.to_string()); | 53 | let mut local_query = symbol_index::Query::new(fuzzy_search_string); |
49 | 54 | ||
50 | if let Some(limit) = limit { | 55 | if let Some(limit) = limit { |
51 | local_query.limit(limit); | 56 | local_query.limit(limit); |