diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-08 13:10:28 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-08 13:10:28 +0000 |
commit | 4d4f11925f793c45560c45c088d4b3139c2c171c (patch) | |
tree | f8c5e3c14a0bb55d4b435b8389bccf305975d39a /crates/ide_db/src | |
parent | 021e97ea03cf67ad7785ab39580e04bc69506b8c (diff) | |
parent | bf24cb3e8db94a84fb4a24c407797ab6ff5ee109 (diff) |
Merge #6706
6706: Move import text edit calculation into a completion resolve request r=matklad a=SomeoneToIgnore
Part of https://github.com/rust-analyzer/rust-analyzer/issues/6612 (presumably fixing it)
Part of https://github.com/rust-analyzer/rust-analyzer/issues/6366 (does not cover all possible resolve capabilities we can do)
Closes https://github.com/rust-analyzer/rust-analyzer/issues/6594
Further improves imports on completion performance by deferring the computations for import inserts.
To use the new mode, you have to have the experimental completions enabled and use the LSP 3.16-compliant client that reports `additionalTextEdits` in its `CompletionItemCapabilityResolveSupport` field in the client capabilities.
rust-analyzer VSCode extension does this already hence picks up the changes completely.
Performance implications are descrbed in: https://github.com/rust-analyzer/rust-analyzer/issues/6633#issuecomment-737295182
Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/imports_locator.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ide_db/src/imports_locator.rs b/crates/ide_db/src/imports_locator.rs index 09046d3c3..b2980a5d6 100644 --- a/crates/ide_db/src/imports_locator.rs +++ b/crates/ide_db/src/imports_locator.rs | |||
@@ -34,27 +34,25 @@ pub fn find_exact_imports<'a>( | |||
34 | pub fn find_similar_imports<'a>( | 34 | pub fn find_similar_imports<'a>( |
35 | sema: &Semantics<'a, RootDatabase>, | 35 | sema: &Semantics<'a, RootDatabase>, |
36 | krate: Crate, | 36 | krate: Crate, |
37 | limit: Option<usize>, | ||
37 | name_to_import: &str, | 38 | name_to_import: &str, |
38 | limit: usize, | ||
39 | ignore_modules: bool, | 39 | ignore_modules: bool, |
40 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { | 40 | ) -> impl Iterator<Item = Either<ModuleDef, MacroDef>> { |
41 | let _p = profile::span("find_similar_imports"); | 41 | let _p = profile::span("find_similar_imports"); |
42 | 42 | ||
43 | let mut external_query = import_map::Query::new(name_to_import).limit(limit); | 43 | let mut external_query = import_map::Query::new(name_to_import); |
44 | if ignore_modules { | 44 | if ignore_modules { |
45 | external_query = external_query.exclude_import_kind(import_map::ImportKind::Module); | 45 | external_query = external_query.exclude_import_kind(import_map::ImportKind::Module); |
46 | } | 46 | } |
47 | 47 | ||
48 | find_imports( | 48 | let mut local_query = symbol_index::Query::new(name_to_import.to_string()); |
49 | sema, | 49 | |
50 | krate, | 50 | if let Some(limit) = limit { |
51 | { | 51 | local_query.limit(limit); |
52 | let mut local_query = symbol_index::Query::new(name_to_import.to_string()); | 52 | external_query = external_query.limit(limit); |
53 | local_query.limit(limit); | 53 | } |
54 | local_query | 54 | |
55 | }, | 55 | find_imports(sema, krate, local_query, external_query) |
56 | external_query, | ||
57 | ) | ||
58 | } | 56 | } |
59 | 57 | ||
60 | fn find_imports<'a>( | 58 | fn find_imports<'a>( |