aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-20 09:27:16 +0100
committerGitHub <[email protected]>2021-05-20 09:27:16 +0100
commit8bb37737c9e8b7a390ae29d5fb0daaeeb495d2b5 (patch)
tree0f8d45124abe86151e1954c1766534116e174209 /crates/ide_completion
parent764241e38e46316b6370977e8b51e841e93e84b9 (diff)
parent2bf720900f94e36969af44ff8ac52470faf9af4b (diff)
Merge #8873
8873: Implement import-granularity guessing r=matklad a=Veykril This renames our `MergeBehavior` to `ImportGranularity` as rustfmt has it as the purpose of them are basically the same. `ImportGranularity::Preserve` currently has no specific purpose for us as we don't have an organize imports assist yet, so it currently acts the same as `ImportGranularity::Item`. We now try to guess the import style on a per file basis and fall back to the user granularity setting if the file has no specific style yet or where it is ambiguous. This can be turned off by setting `import.enforceGranularity` to `true`. Closes https://github.com/rust-analyzer/rust-analyzer/issues/8870 Co-authored-by: Lukas Tobias Wirth <[email protected]>
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/test_utils.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/ide_completion/src/test_utils.rs b/crates/ide_completion/src/test_utils.rs
index 939fb2d47..37be575e5 100644
--- a/crates/ide_completion/src/test_utils.rs
+++ b/crates/ide_completion/src/test_utils.rs
@@ -3,7 +3,10 @@
3use hir::{PrefixKind, Semantics}; 3use hir::{PrefixKind, Semantics};
4use ide_db::{ 4use ide_db::{
5 base_db::{fixture::ChangeFixture, FileLoader, FilePosition}, 5 base_db::{fixture::ChangeFixture, FileLoader, FilePosition},
6 helpers::{insert_use::InsertUseConfig, merge_imports::MergeBehavior, SnippetCap}, 6 helpers::{
7 insert_use::{ImportGranularity, InsertUseConfig},
8 SnippetCap,
9 },
7 RootDatabase, 10 RootDatabase,
8}; 11};
9use itertools::Itertools; 12use itertools::Itertools;
@@ -20,8 +23,9 @@ pub(crate) const TEST_CONFIG: CompletionConfig = CompletionConfig {
20 add_call_argument_snippets: true, 23 add_call_argument_snippets: true,
21 snippet_cap: SnippetCap::new(true), 24 snippet_cap: SnippetCap::new(true),
22 insert_use: InsertUseConfig { 25 insert_use: InsertUseConfig {
23 merge: Some(MergeBehavior::Crate), 26 granularity: ImportGranularity::Crate,
24 prefix_kind: PrefixKind::Plain, 27 prefix_kind: PrefixKind::Plain,
28 enforce_granularity: true,
25 group: true, 29 group: true,
26 }, 30 },
27}; 31};