diff options
-rw-r--r-- | crates/assists/src/assist_config.rs | 6 | ||||
-rw-r--r-- | crates/assists/src/handlers/merge_imports.rs | 6 | ||||
-rw-r--r-- | crates/completion/src/completions/unqualified_path.rs | 10 | ||||
-rw-r--r-- | crates/completion/src/config.rs | 6 | ||||
-rw-r--r-- | crates/completion/src/item.rs | 6 | ||||
-rw-r--r-- | crates/completion/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/helpers/insert_use.rs | 20 | ||||
-rw-r--r-- | crates/ide_db/src/helpers/insert_use/tests.rs | 16 | ||||
-rw-r--r-- | crates/rust-analyzer/src/config.rs | 14 | ||||
-rw-r--r-- | docs/dev/style.md | 1 |
10 files changed, 44 insertions, 43 deletions
diff --git a/crates/assists/src/assist_config.rs b/crates/assists/src/assist_config.rs index 786224cfa..c458d9054 100644 --- a/crates/assists/src/assist_config.rs +++ b/crates/assists/src/assist_config.rs | |||
@@ -5,7 +5,7 @@ | |||
5 | //! assists if we are allowed to. | 5 | //! assists if we are allowed to. |
6 | 6 | ||
7 | use hir::PrefixKind; | 7 | use hir::PrefixKind; |
8 | use ide_db::helpers::insert_use::MergeBehaviour; | 8 | use ide_db::helpers::insert_use::MergeBehavior; |
9 | 9 | ||
10 | use crate::AssistKind; | 10 | use crate::AssistKind; |
11 | 11 | ||
@@ -39,12 +39,12 @@ impl Default for AssistConfig { | |||
39 | 39 | ||
40 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | 40 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] |
41 | pub struct InsertUseConfig { | 41 | pub struct InsertUseConfig { |
42 | pub merge: Option<MergeBehaviour>, | 42 | pub merge: Option<MergeBehavior>, |
43 | pub prefix_kind: PrefixKind, | 43 | pub prefix_kind: PrefixKind, |
44 | } | 44 | } |
45 | 45 | ||
46 | impl Default for InsertUseConfig { | 46 | impl Default for InsertUseConfig { |
47 | fn default() -> Self { | 47 | fn default() -> Self { |
48 | InsertUseConfig { merge: Some(MergeBehaviour::Full), prefix_kind: PrefixKind::Plain } | 48 | InsertUseConfig { merge: Some(MergeBehavior::Full), prefix_kind: PrefixKind::Plain } |
49 | } | 49 | } |
50 | } | 50 | } |
diff --git a/crates/assists/src/handlers/merge_imports.rs b/crates/assists/src/handlers/merge_imports.rs index b7e853994..2f0dc7831 100644 --- a/crates/assists/src/handlers/merge_imports.rs +++ b/crates/assists/src/handlers/merge_imports.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ide_db::helpers::insert_use::{try_merge_imports, try_merge_trees, MergeBehaviour}; | 1 | use ide_db::helpers::insert_use::{try_merge_imports, try_merge_trees, MergeBehavior}; |
2 | use syntax::{ | 2 | use syntax::{ |
3 | algo::{neighbor, SyntaxRewriter}, | 3 | algo::{neighbor, SyntaxRewriter}, |
4 | ast, AstNode, | 4 | ast, AstNode, |
@@ -30,7 +30,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<() | |||
30 | if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) { | 30 | if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) { |
31 | let (merged, to_delete) = | 31 | let (merged, to_delete) = |
32 | next_prev().filter_map(|dir| neighbor(&use_item, dir)).find_map(|use_item2| { | 32 | next_prev().filter_map(|dir| neighbor(&use_item, dir)).find_map(|use_item2| { |
33 | try_merge_imports(&use_item, &use_item2, MergeBehaviour::Full).zip(Some(use_item2)) | 33 | try_merge_imports(&use_item, &use_item2, MergeBehavior::Full).zip(Some(use_item2)) |
34 | })?; | 34 | })?; |
35 | 35 | ||
36 | rewriter.replace_ast(&use_item, &merged); | 36 | rewriter.replace_ast(&use_item, &merged); |
@@ -42,7 +42,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<() | |||
42 | } else { | 42 | } else { |
43 | let (merged, to_delete) = | 43 | let (merged, to_delete) = |
44 | next_prev().filter_map(|dir| neighbor(&tree, dir)).find_map(|use_tree| { | 44 | next_prev().filter_map(|dir| neighbor(&tree, dir)).find_map(|use_tree| { |
45 | try_merge_trees(&tree, &use_tree, MergeBehaviour::Full).zip(Some(use_tree)) | 45 | try_merge_trees(&tree, &use_tree, MergeBehavior::Full).zip(Some(use_tree)) |
46 | })?; | 46 | })?; |
47 | 47 | ||
48 | rewriter.replace_ast(&tree, &merged); | 48 | rewriter.replace_ast(&tree, &merged); |
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index 4e4e2b36f..3372fb1a2 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs | |||
@@ -45,7 +45,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC | |||
45 | }); | 45 | }); |
46 | 46 | ||
47 | if ctx.config.enable_autoimport_completions && ctx.config.resolve_additional_edits_lazily() { | 47 | if ctx.config.enable_autoimport_completions && ctx.config.resolve_additional_edits_lazily() { |
48 | fuzzy_completion(acc, ctx).unwrap_or_default() | 48 | fuzzy_completion(acc, ctx); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
@@ -100,10 +100,10 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T | |||
100 | // To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only | 100 | // To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only |
101 | // (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers. | 101 | // (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers. |
102 | // | 102 | // |
103 | // .Merge Behaviour | 103 | // .Merge Behavior |
104 | // | 104 | // |
105 | // It is possible to configure how use-trees are merged with the `importMergeBehaviour` setting. | 105 | // It is possible to configure how use-trees are merged with the `importMergeBehavior` setting. |
106 | // Mimics the corresponding behaviour of the `Auto Import` feature. | 106 | // Mimics the corresponding behavior of the `Auto Import` feature. |
107 | // | 107 | // |
108 | // .LSP and performance implications | 108 | // .LSP and performance implications |
109 | // | 109 | // |
@@ -150,7 +150,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<() | |||
150 | ImportEdit { | 150 | ImportEdit { |
151 | import_path: import_path.clone(), | 151 | import_path: import_path.clone(), |
152 | import_scope: import_scope.clone(), | 152 | import_scope: import_scope.clone(), |
153 | merge_behaviour: ctx.config.merge, | 153 | merge_behavior: ctx.config.merge, |
154 | }, | 154 | }, |
155 | &definition, | 155 | &definition, |
156 | ) | 156 | ) |
diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs index 5175b9d69..30577dc11 100644 --- a/crates/completion/src/config.rs +++ b/crates/completion/src/config.rs | |||
@@ -4,7 +4,7 @@ | |||
4 | //! module, and we use to statically check that we only produce snippet | 4 | //! module, and we use to statically check that we only produce snippet |
5 | //! completions if we are allowed to. | 5 | //! completions if we are allowed to. |
6 | 6 | ||
7 | use ide_db::helpers::insert_use::MergeBehaviour; | 7 | use ide_db::helpers::insert_use::MergeBehavior; |
8 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
9 | 9 | ||
10 | #[derive(Clone, Debug, PartialEq, Eq)] | 10 | #[derive(Clone, Debug, PartialEq, Eq)] |
@@ -14,7 +14,7 @@ pub struct CompletionConfig { | |||
14 | pub add_call_parenthesis: bool, | 14 | pub add_call_parenthesis: bool, |
15 | pub add_call_argument_snippets: bool, | 15 | pub add_call_argument_snippets: bool, |
16 | pub snippet_cap: Option<SnippetCap>, | 16 | pub snippet_cap: Option<SnippetCap>, |
17 | pub merge: Option<MergeBehaviour>, | 17 | pub merge: Option<MergeBehavior>, |
18 | /// A set of capabilities, enabled on the client and supported on the server. | 18 | /// A set of capabilities, enabled on the client and supported on the server. |
19 | pub active_resolve_capabilities: FxHashSet<CompletionResolveCapability>, | 19 | pub active_resolve_capabilities: FxHashSet<CompletionResolveCapability>, |
20 | } | 20 | } |
@@ -56,7 +56,7 @@ impl Default for CompletionConfig { | |||
56 | add_call_parenthesis: true, | 56 | add_call_parenthesis: true, |
57 | add_call_argument_snippets: true, | 57 | add_call_argument_snippets: true, |
58 | snippet_cap: Some(SnippetCap { _private: () }), | 58 | snippet_cap: Some(SnippetCap { _private: () }), |
59 | merge: Some(MergeBehaviour::Full), | 59 | merge: Some(MergeBehavior::Full), |
60 | active_resolve_capabilities: FxHashSet::default(), | 60 | active_resolve_capabilities: FxHashSet::default(), |
61 | } | 61 | } |
62 | } | 62 | } |
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index bd94402d7..83166df4e 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs | |||
@@ -4,7 +4,7 @@ use std::fmt; | |||
4 | 4 | ||
5 | use hir::{Documentation, ModPath, Mutability}; | 5 | use hir::{Documentation, ModPath, Mutability}; |
6 | use ide_db::helpers::{ | 6 | use ide_db::helpers::{ |
7 | insert_use::{self, ImportScope, MergeBehaviour}, | 7 | insert_use::{self, ImportScope, MergeBehavior}, |
8 | mod_path_to_ast, | 8 | mod_path_to_ast, |
9 | }; | 9 | }; |
10 | use syntax::{algo, TextRange}; | 10 | use syntax::{algo, TextRange}; |
@@ -271,7 +271,7 @@ impl CompletionItem { | |||
271 | pub struct ImportEdit { | 271 | pub struct ImportEdit { |
272 | pub import_path: ModPath, | 272 | pub import_path: ModPath, |
273 | pub import_scope: ImportScope, | 273 | pub import_scope: ImportScope, |
274 | pub merge_behaviour: Option<MergeBehaviour>, | 274 | pub merge_behavior: Option<MergeBehavior>, |
275 | } | 275 | } |
276 | 276 | ||
277 | impl ImportEdit { | 277 | impl ImportEdit { |
@@ -283,7 +283,7 @@ impl ImportEdit { | |||
283 | let rewriter = insert_use::insert_use( | 283 | let rewriter = insert_use::insert_use( |
284 | &self.import_scope, | 284 | &self.import_scope, |
285 | mod_path_to_ast(&self.import_path), | 285 | mod_path_to_ast(&self.import_path), |
286 | self.merge_behaviour, | 286 | self.merge_behavior, |
287 | ); | 287 | ); |
288 | let old_ast = rewriter.rewrite_root()?; | 288 | let old_ast = rewriter.rewrite_root()?; |
289 | let mut import_insert = TextEdit::builder(); | 289 | let mut import_insert = TextEdit::builder(); |
diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index f60f87243..6a4b3c167 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs | |||
@@ -153,7 +153,7 @@ pub fn resolve_completion_edits( | |||
153 | }) | 153 | }) |
154 | .find(|mod_path| mod_path.to_string() == full_import_path)?; | 154 | .find(|mod_path| mod_path.to_string() == full_import_path)?; |
155 | 155 | ||
156 | ImportEdit { import_path, import_scope, merge_behaviour: config.merge } | 156 | ImportEdit { import_path, import_scope, merge_behavior: config.merge } |
157 | .to_text_edit() | 157 | .to_text_edit() |
158 | .map(|edit| vec![edit]) | 158 | .map(|edit| vec![edit]) |
159 | } | 159 | } |
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index 040843990..9be36d59b 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -93,7 +93,7 @@ fn is_inner_comment(token: SyntaxToken) -> bool { | |||
93 | pub fn insert_use<'a>( | 93 | pub fn insert_use<'a>( |
94 | scope: &ImportScope, | 94 | scope: &ImportScope, |
95 | path: ast::Path, | 95 | path: ast::Path, |
96 | merge: Option<MergeBehaviour>, | 96 | merge: Option<MergeBehavior>, |
97 | ) -> SyntaxRewriter<'a> { | 97 | ) -> SyntaxRewriter<'a> { |
98 | let _p = profile::span("insert_use"); | 98 | let _p = profile::span("insert_use"); |
99 | let mut rewriter = SyntaxRewriter::default(); | 99 | let mut rewriter = SyntaxRewriter::default(); |
@@ -183,7 +183,7 @@ fn eq_visibility(vis0: Option<ast::Visibility>, vis1: Option<ast::Visibility>) - | |||
183 | pub fn try_merge_imports( | 183 | pub fn try_merge_imports( |
184 | lhs: &ast::Use, | 184 | lhs: &ast::Use, |
185 | rhs: &ast::Use, | 185 | rhs: &ast::Use, |
186 | merge_behaviour: MergeBehaviour, | 186 | merge_behavior: MergeBehavior, |
187 | ) -> Option<ast::Use> { | 187 | ) -> Option<ast::Use> { |
188 | // don't merge imports with different visibilities | 188 | // don't merge imports with different visibilities |
189 | if !eq_visibility(lhs.visibility(), rhs.visibility()) { | 189 | if !eq_visibility(lhs.visibility(), rhs.visibility()) { |
@@ -191,14 +191,14 @@ pub fn try_merge_imports( | |||
191 | } | 191 | } |
192 | let lhs_tree = lhs.use_tree()?; | 192 | let lhs_tree = lhs.use_tree()?; |
193 | let rhs_tree = rhs.use_tree()?; | 193 | let rhs_tree = rhs.use_tree()?; |
194 | let merged = try_merge_trees(&lhs_tree, &rhs_tree, merge_behaviour)?; | 194 | let merged = try_merge_trees(&lhs_tree, &rhs_tree, merge_behavior)?; |
195 | Some(lhs.with_use_tree(merged)) | 195 | Some(lhs.with_use_tree(merged)) |
196 | } | 196 | } |
197 | 197 | ||
198 | pub fn try_merge_trees( | 198 | pub fn try_merge_trees( |
199 | lhs: &ast::UseTree, | 199 | lhs: &ast::UseTree, |
200 | rhs: &ast::UseTree, | 200 | rhs: &ast::UseTree, |
201 | merge: MergeBehaviour, | 201 | merge: MergeBehavior, |
202 | ) -> Option<ast::UseTree> { | 202 | ) -> Option<ast::UseTree> { |
203 | let lhs_path = lhs.path()?; | 203 | let lhs_path = lhs.path()?; |
204 | let rhs_path = rhs.path()?; | 204 | let rhs_path = rhs.path()?; |
@@ -220,7 +220,7 @@ pub fn try_merge_trees( | |||
220 | fn recursive_merge( | 220 | fn recursive_merge( |
221 | lhs: &ast::UseTree, | 221 | lhs: &ast::UseTree, |
222 | rhs: &ast::UseTree, | 222 | rhs: &ast::UseTree, |
223 | merge: MergeBehaviour, | 223 | merge: MergeBehavior, |
224 | ) -> Option<ast::UseTree> { | 224 | ) -> Option<ast::UseTree> { |
225 | let mut use_trees = lhs | 225 | let mut use_trees = lhs |
226 | .use_tree_list() | 226 | .use_tree_list() |
@@ -301,7 +301,7 @@ fn recursive_merge( | |||
301 | } | 301 | } |
302 | } | 302 | } |
303 | Err(_) | 303 | Err(_) |
304 | if merge == MergeBehaviour::Last | 304 | if merge == MergeBehavior::Last |
305 | && use_trees.len() > 0 | 305 | && use_trees.len() > 0 |
306 | && rhs_t.use_tree_list().is_some() => | 306 | && rhs_t.use_tree_list().is_some() => |
307 | { | 307 | { |
@@ -438,20 +438,20 @@ fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { | |||
438 | 438 | ||
439 | /// What type of merges are allowed. | 439 | /// What type of merges are allowed. |
440 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] | 440 | #[derive(Copy, Clone, Debug, PartialEq, Eq)] |
441 | pub enum MergeBehaviour { | 441 | pub enum MergeBehavior { |
442 | /// Merge everything together creating deeply nested imports. | 442 | /// Merge everything together creating deeply nested imports. |
443 | Full, | 443 | Full, |
444 | /// Only merge the last import level, doesn't allow import nesting. | 444 | /// Only merge the last import level, doesn't allow import nesting. |
445 | Last, | 445 | Last, |
446 | } | 446 | } |
447 | 447 | ||
448 | impl MergeBehaviour { | 448 | impl MergeBehavior { |
449 | #[inline] | 449 | #[inline] |
450 | fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool { | 450 | fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool { |
451 | match self { | 451 | match self { |
452 | MergeBehaviour::Full => true, | 452 | MergeBehavior::Full => true, |
453 | // only simple single segment paths are allowed | 453 | // only simple single segment paths are allowed |
454 | MergeBehaviour::Last => { | 454 | MergeBehavior::Last => { |
455 | tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) | 455 | tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1) |
456 | } | 456 | } |
457 | } | 457 | } |
diff --git a/crates/ide_db/src/helpers/insert_use/tests.rs b/crates/ide_db/src/helpers/insert_use/tests.rs index 86bfa5b41..9e194354e 100644 --- a/crates/ide_db/src/helpers/insert_use/tests.rs +++ b/crates/ide_db/src/helpers/insert_use/tests.rs | |||
@@ -533,7 +533,7 @@ fn merge_last_fail() { | |||
533 | check_merge_only_fail( | 533 | check_merge_only_fail( |
534 | r"use foo::bar::{baz::{Qux, Fez}};", | 534 | r"use foo::bar::{baz::{Qux, Fez}};", |
535 | r"use foo::bar::{baaz::{Quux, Feez}};", | 535 | r"use foo::bar::{baaz::{Quux, Feez}};", |
536 | MergeBehaviour::Last, | 536 | MergeBehavior::Last, |
537 | ); | 537 | ); |
538 | } | 538 | } |
539 | 539 | ||
@@ -542,7 +542,7 @@ fn merge_last_fail1() { | |||
542 | check_merge_only_fail( | 542 | check_merge_only_fail( |
543 | r"use foo::bar::{baz::{Qux, Fez}};", | 543 | r"use foo::bar::{baz::{Qux, Fez}};", |
544 | r"use foo::bar::baaz::{Quux, Feez};", | 544 | r"use foo::bar::baaz::{Quux, Feez};", |
545 | MergeBehaviour::Last, | 545 | MergeBehavior::Last, |
546 | ); | 546 | ); |
547 | } | 547 | } |
548 | 548 | ||
@@ -551,7 +551,7 @@ fn merge_last_fail2() { | |||
551 | check_merge_only_fail( | 551 | check_merge_only_fail( |
552 | r"use foo::bar::baz::{Qux, Fez};", | 552 | r"use foo::bar::baz::{Qux, Fez};", |
553 | r"use foo::bar::{baaz::{Quux, Feez}};", | 553 | r"use foo::bar::{baaz::{Quux, Feez}};", |
554 | MergeBehaviour::Last, | 554 | MergeBehavior::Last, |
555 | ); | 555 | ); |
556 | } | 556 | } |
557 | 557 | ||
@@ -560,7 +560,7 @@ fn merge_last_fail3() { | |||
560 | check_merge_only_fail( | 560 | check_merge_only_fail( |
561 | r"use foo::bar::baz::{Qux, Fez};", | 561 | r"use foo::bar::baz::{Qux, Fez};", |
562 | r"use foo::bar::baaz::{Quux, Feez};", | 562 | r"use foo::bar::baaz::{Quux, Feez};", |
563 | MergeBehaviour::Last, | 563 | MergeBehavior::Last, |
564 | ); | 564 | ); |
565 | } | 565 | } |
566 | 566 | ||
@@ -568,7 +568,7 @@ fn check( | |||
568 | path: &str, | 568 | path: &str, |
569 | ra_fixture_before: &str, | 569 | ra_fixture_before: &str, |
570 | ra_fixture_after: &str, | 570 | ra_fixture_after: &str, |
571 | mb: Option<MergeBehaviour>, | 571 | mb: Option<MergeBehavior>, |
572 | module: bool, | 572 | module: bool, |
573 | ) { | 573 | ) { |
574 | let mut syntax = ast::SourceFile::parse(ra_fixture_before).tree().syntax().clone(); | 574 | let mut syntax = ast::SourceFile::parse(ra_fixture_before).tree().syntax().clone(); |
@@ -589,18 +589,18 @@ fn check( | |||
589 | } | 589 | } |
590 | 590 | ||
591 | fn check_full(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | 591 | fn check_full(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { |
592 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehaviour::Full), false) | 592 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehavior::Full), false) |
593 | } | 593 | } |
594 | 594 | ||
595 | fn check_last(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | 595 | fn check_last(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { |
596 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehaviour::Last), false) | 596 | check(path, ra_fixture_before, ra_fixture_after, Some(MergeBehavior::Last), false) |
597 | } | 597 | } |
598 | 598 | ||
599 | fn check_none(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { | 599 | fn check_none(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) { |
600 | check(path, ra_fixture_before, ra_fixture_after, None, false) | 600 | check(path, ra_fixture_before, ra_fixture_after, None, false) |
601 | } | 601 | } |
602 | 602 | ||
603 | fn check_merge_only_fail(ra_fixture0: &str, ra_fixture1: &str, mb: MergeBehaviour) { | 603 | fn check_merge_only_fail(ra_fixture0: &str, ra_fixture1: &str, mb: MergeBehavior) { |
604 | let use0 = ast::SourceFile::parse(ra_fixture0) | 604 | let use0 = ast::SourceFile::parse(ra_fixture0) |
605 | .tree() | 605 | .tree() |
606 | .syntax() | 606 | .syntax() |
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 8d37638f4..1f4b5c24c 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs | |||
@@ -12,7 +12,7 @@ use std::{convert::TryFrom, ffi::OsString, path::PathBuf}; | |||
12 | use flycheck::FlycheckConfig; | 12 | use flycheck::FlycheckConfig; |
13 | use hir::PrefixKind; | 13 | use hir::PrefixKind; |
14 | use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig}; | 14 | use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig}; |
15 | use ide_db::helpers::insert_use::MergeBehaviour; | 15 | use ide_db::helpers::insert_use::MergeBehavior; |
16 | use itertools::Itertools; | 16 | use itertools::Itertools; |
17 | use lsp_types::{ClientCapabilities, MarkupKind}; | 17 | use lsp_types::{ClientCapabilities, MarkupKind}; |
18 | use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; | 18 | use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest}; |
@@ -25,7 +25,7 @@ use crate::{caps::enabled_completions_resolve_capabilities, diagnostics::Diagnos | |||
25 | config_data! { | 25 | config_data! { |
26 | struct ConfigData { | 26 | struct ConfigData { |
27 | /// The strategy to use when inserting new imports or merging imports. | 27 | /// The strategy to use when inserting new imports or merging imports. |
28 | assist_importMergeBehaviour: MergeBehaviourDef = "\"full\"", | 28 | assist_importMergeBehaviour: MergeBehaviorDef = "\"full\"", |
29 | /// The path structure for newly inserted paths to use. | 29 | /// The path structure for newly inserted paths to use. |
30 | assist_importPrefix: ImportPrefixDef = "\"plain\"", | 30 | assist_importPrefix: ImportPrefixDef = "\"plain\"", |
31 | 31 | ||
@@ -447,9 +447,9 @@ impl Config { | |||
447 | }; | 447 | }; |
448 | 448 | ||
449 | self.assist.insert_use.merge = match data.assist_importMergeBehaviour { | 449 | self.assist.insert_use.merge = match data.assist_importMergeBehaviour { |
450 | MergeBehaviourDef::None => None, | 450 | MergeBehaviorDef::None => None, |
451 | MergeBehaviourDef::Full => Some(MergeBehaviour::Full), | 451 | MergeBehaviorDef::Full => Some(MergeBehavior::Full), |
452 | MergeBehaviourDef::Last => Some(MergeBehaviour::Last), | 452 | MergeBehaviorDef::Last => Some(MergeBehavior::Last), |
453 | }; | 453 | }; |
454 | self.assist.insert_use.prefix_kind = match data.assist_importPrefix { | 454 | self.assist.insert_use.prefix_kind = match data.assist_importPrefix { |
455 | ImportPrefixDef::Plain => PrefixKind::Plain, | 455 | ImportPrefixDef::Plain => PrefixKind::Plain, |
@@ -606,7 +606,7 @@ enum ManifestOrProjectJson { | |||
606 | 606 | ||
607 | #[derive(Deserialize)] | 607 | #[derive(Deserialize)] |
608 | #[serde(rename_all = "snake_case")] | 608 | #[serde(rename_all = "snake_case")] |
609 | enum MergeBehaviourDef { | 609 | enum MergeBehaviorDef { |
610 | None, | 610 | None, |
611 | Full, | 611 | Full, |
612 | Last, | 612 | Last, |
@@ -740,7 +740,7 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json | |||
740 | "type": ["null", "array"], | 740 | "type": ["null", "array"], |
741 | "items": { "type": "string" }, | 741 | "items": { "type": "string" }, |
742 | }, | 742 | }, |
743 | "MergeBehaviourDef" => set! { | 743 | "MergeBehaviorDef" => set! { |
744 | "type": "string", | 744 | "type": "string", |
745 | "enum": ["none", "full", "last"], | 745 | "enum": ["none", "full", "last"], |
746 | "enumDescriptions": [ | 746 | "enumDescriptions": [ |
diff --git a/docs/dev/style.md b/docs/dev/style.md index 1a952197f..c8d943142 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -514,6 +514,7 @@ impl Parent { | |||
514 | Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)). | 514 | Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)). |
515 | The default name is a lowercased name of the type: `global_state: GlobalState`. | 515 | The default name is a lowercased name of the type: `global_state: GlobalState`. |
516 | Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`). | 516 | Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`). |
517 | Prefer American spelling (color, behavior). | ||
517 | 518 | ||
518 | Default names: | 519 | Default names: |
519 | 520 | ||