diff options
author | Kirill Bulatov <[email protected]> | 2020-12-28 12:24:13 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-12-28 13:06:10 +0000 |
commit | c4995cfbd5b265c02d3038d72b8a022cde5f7040 (patch) | |
tree | d2fdb44eedf6c5e806804a1b874643b52586bb44 /crates/ide_db/src | |
parent | 0e48cd0c3c712cea0267476de974012b2b05b508 (diff) |
Better query api and fuzzy search
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/imports_locator.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index 0de949b9a..986cb5b83 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs | |||
@@ -30,8 +30,7 @@ pub fn find_exact_imports<'a>( | |||
30 | import_map::Query::new(name_to_import) | 30 | import_map::Query::new(name_to_import) |
31 | .limit(40) | 31 | .limit(40) |
32 | .name_only() | 32 | .name_only() |
33 | .name_end() | 33 | .search_mode(import_map::SearchMode::Equals) |
34 | .strict_include() | ||
35 | .case_sensitive(), | 34 | .case_sensitive(), |
36 | ) | 35 | ) |
37 | } | 36 | } |
@@ -41,14 +40,14 @@ pub fn find_similar_imports<'a>( | |||
41 | krate: Crate, | 40 | krate: Crate, |
42 | limit: Option<usize>, | 41 | limit: Option<usize>, |
43 | name_to_import: &str, | 42 | name_to_import: &str, |
44 | // TODO kb change it to search across the whole path or not? | 43 | name_only: bool, |
45 | ignore_modules: bool, | ||
46 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 44 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
47 | let _p = profile::span("find_similar_imports"); | 45 | let _p = profile::span("find_similar_imports"); |
48 | 46 | ||
49 | let mut external_query = import_map::Query::new(name_to_import).name_only(); | 47 | let mut external_query = |
50 | if ignore_modules { | 48 | import_map::Query::new(name_to_import).search_mode(import_map::SearchMode::Fuzzy); |
51 | external_query = external_query.exclude_import_kind(import_map::ImportKind::Module); | 49 | if name_only { |
50 | external_query = external_query.name_only(); | ||
52 | } | 51 | } |
53 | 52 | ||
54 | let mut local_query = symbol_index::Query::new(name_to_import.to_string()); | 53 | let mut local_query = symbol_index::Query::new(name_to_import.to_string()); |