diff options
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/helpers/insert_use.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index 4852121a1..1fdd110cc 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -18,6 +18,8 @@ pub use hir::PrefixKind; | |||
18 | /// How imports should be grouped into use statements. | 18 | /// How imports should be grouped into use statements. |
19 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | 19 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
20 | pub enum ImportGranularity { | 20 | pub enum ImportGranularity { |
21 | /// Try to guess the granularity of imports on a per module basis by observing the existing imports. | ||
22 | Guess, | ||
21 | /// Do not change the granularity of any imports and preserve the original structure written by the developer. | 23 | /// Do not change the granularity of any imports and preserve the original structure written by the developer. |
22 | Preserve, | 24 | Preserve, |
23 | /// Merge imports from the same crate into a single use statement. | 25 | /// Merge imports from the same crate into a single use statement. |
@@ -28,16 +30,6 @@ pub enum ImportGranularity { | |||
28 | Item, | 30 | Item, |
29 | } | 31 | } |
30 | 32 | ||
31 | impl ImportGranularity { | ||
32 | pub fn merge_behavior(self) -> Option<MergeBehavior> { | ||
33 | match self { | ||
34 | ImportGranularity::Crate => Some(MergeBehavior::Crate), | ||
35 | ImportGranularity::Module => Some(MergeBehavior::Module), | ||
36 | ImportGranularity::Preserve | ImportGranularity::Item => None, | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 | |||
41 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | 33 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
42 | pub struct InsertUseConfig { | 34 | pub struct InsertUseConfig { |
43 | pub granularity: ImportGranularity, | 35 | pub granularity: ImportGranularity, |
@@ -118,10 +110,10 @@ impl ImportScope { | |||
118 | pub fn insert_use<'a>(scope: &ImportScope, path: ast::Path, cfg: InsertUseConfig) { | 110 | pub fn insert_use<'a>(scope: &ImportScope, path: ast::Path, cfg: InsertUseConfig) { |
119 | let _p = profile::span("insert_use"); | 111 | let _p = profile::span("insert_use"); |
120 | let mb = match cfg.granularity { | 112 | let mb = match cfg.granularity { |
121 | ImportGranularity::Preserve => scope.guess_merge_behavior_from_scope(), | 113 | ImportGranularity::Guess => scope.guess_merge_behavior_from_scope(), |
122 | ImportGranularity::Crate => Some(MergeBehavior::Crate), | 114 | ImportGranularity::Crate => Some(MergeBehavior::Crate), |
123 | ImportGranularity::Module => Some(MergeBehavior::Module), | 115 | ImportGranularity::Module => Some(MergeBehavior::Module), |
124 | ImportGranularity::Item => None, | 116 | ImportGranularity::Item | ImportGranularity::Preserve => None, |
125 | }; | 117 | }; |
126 | 118 | ||
127 | let use_item = | 119 | let use_item = |