Skip to content

Commit 17f236c

Browse files
committed
Normalize spelling to American English
1 parent 1341a98 commit 17f236c

File tree

10 files changed

+44
-43
lines changed

10 files changed

+44
-43
lines changed

crates/assists/src/assist_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! assists if we are allowed to.
66
77
use hir::PrefixKind;
8-
use ide_db::helpers::insert_use::MergeBehaviour;
8+
use ide_db::helpers::insert_use::MergeBehavior;
99

1010
use crate::AssistKind;
1111

@@ -39,12 +39,12 @@ impl Default for AssistConfig {
3939

4040
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
4141
pub struct InsertUseConfig {
42-
pub merge: Option<MergeBehaviour>,
42+
pub merge: Option<MergeBehavior>,
4343
pub prefix_kind: PrefixKind,
4444
}
4545

4646
impl Default for InsertUseConfig {
4747
fn default() -> Self {
48-
InsertUseConfig { merge: Some(MergeBehaviour::Full), prefix_kind: PrefixKind::Plain }
48+
InsertUseConfig { merge: Some(MergeBehavior::Full), prefix_kind: PrefixKind::Plain }
4949
}
5050
}

crates/assists/src/handlers/merge_imports.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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};
22
use syntax::{
33
algo::{neighbor, SyntaxRewriter},
44
ast, AstNode,
@@ -30,7 +30,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()
3030
if let Some(use_item) = tree.syntax().parent().and_then(ast::Use::cast) {
3131
let (merged, to_delete) =
3232
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))
3434
})?;
3535

3636
rewriter.replace_ast(&use_item, &merged);
@@ -42,7 +42,7 @@ pub(crate) fn merge_imports(acc: &mut Assists, ctx: &AssistContext) -> Option<()
4242
} else {
4343
let (merged, to_delete) =
4444
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))
4646
})?;
4747

4848
rewriter.replace_ast(&tree, &merged);

crates/completion/src/completions/unqualified_path.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC
4545
});
4646

4747
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);
4949
}
5050
}
5151

@@ -100,10 +100,10 @@ fn complete_enum_variants(acc: &mut Completions, ctx: &CompletionContext, ty: &T
100100
// To avoid an excessive amount of the results returned, completion input is checked for inclusion in the identifiers only
101101
// (i.e. in `HashMap` in the `std::collections::HashMap` path), also not in the module indentifiers.
102102
//
103-
// .Merge Behaviour
103+
// .Merge Behavior
104104
//
105-
// It is possible to configure how use-trees are merged with the `importMergeBehaviour` setting.
106-
// Mimics the corresponding behaviour of the `Auto Import` feature.
105+
// It is possible to configure how use-trees are merged with the `importMergeBehavior` setting.
106+
// Mimics the corresponding behavior of the `Auto Import` feature.
107107
//
108108
// .LSP and performance implications
109109
//
@@ -150,7 +150,7 @@ fn fuzzy_completion(acc: &mut Completions, ctx: &CompletionContext) -> Option<()
150150
ImportEdit {
151151
import_path: import_path.clone(),
152152
import_scope: import_scope.clone(),
153-
merge_behaviour: ctx.config.merge,
153+
merge_behavior: ctx.config.merge,
154154
},
155155
&definition,
156156
)

crates/completion/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! module, and we use to statically check that we only produce snippet
55
//! completions if we are allowed to.
66
7-
use ide_db::helpers::insert_use::MergeBehaviour;
7+
use ide_db::helpers::insert_use::MergeBehavior;
88
use rustc_hash::FxHashSet;
99

1010
#[derive(Clone, Debug, PartialEq, Eq)]
@@ -14,7 +14,7 @@ pub struct CompletionConfig {
1414
pub add_call_parenthesis: bool,
1515
pub add_call_argument_snippets: bool,
1616
pub snippet_cap: Option<SnippetCap>,
17-
pub merge: Option<MergeBehaviour>,
17+
pub merge: Option<MergeBehavior>,
1818
/// A set of capabilities, enabled on the client and supported on the server.
1919
pub active_resolve_capabilities: FxHashSet<CompletionResolveCapability>,
2020
}
@@ -56,7 +56,7 @@ impl Default for CompletionConfig {
5656
add_call_parenthesis: true,
5757
add_call_argument_snippets: true,
5858
snippet_cap: Some(SnippetCap { _private: () }),
59-
merge: Some(MergeBehaviour::Full),
59+
merge: Some(MergeBehavior::Full),
6060
active_resolve_capabilities: FxHashSet::default(),
6161
}
6262
}

crates/completion/src/item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::fmt;
44

55
use hir::{Documentation, ModPath, Mutability};
66
use ide_db::helpers::{
7-
insert_use::{self, ImportScope, MergeBehaviour},
7+
insert_use::{self, ImportScope, MergeBehavior},
88
mod_path_to_ast,
99
};
1010
use syntax::{algo, TextRange};
@@ -271,7 +271,7 @@ impl CompletionItem {
271271
pub struct ImportEdit {
272272
pub import_path: ModPath,
273273
pub import_scope: ImportScope,
274-
pub merge_behaviour: Option<MergeBehaviour>,
274+
pub merge_behavior: Option<MergeBehavior>,
275275
}
276276

277277
impl ImportEdit {
@@ -283,7 +283,7 @@ impl ImportEdit {
283283
let rewriter = insert_use::insert_use(
284284
&self.import_scope,
285285
mod_path_to_ast(&self.import_path),
286-
self.merge_behaviour,
286+
self.merge_behavior,
287287
);
288288
let old_ast = rewriter.rewrite_root()?;
289289
let mut import_insert = TextEdit::builder();

crates/completion/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ pub fn resolve_completion_edits(
153153
})
154154
.find(|mod_path| mod_path.to_string() == full_import_path)?;
155155

156-
ImportEdit { import_path, import_scope, merge_behaviour: config.merge }
156+
ImportEdit { import_path, import_scope, merge_behavior: config.merge }
157157
.to_text_edit()
158158
.map(|edit| vec![edit])
159159
}

crates/ide_db/src/helpers/insert_use.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn is_inner_comment(token: SyntaxToken) -> bool {
9393
pub fn insert_use<'a>(
9494
scope: &ImportScope,
9595
path: ast::Path,
96-
merge: Option<MergeBehaviour>,
96+
merge: Option<MergeBehavior>,
9797
) -> SyntaxRewriter<'a> {
9898
let _p = profile::span("insert_use");
9999
let mut rewriter = SyntaxRewriter::default();
@@ -183,22 +183,22 @@ fn eq_visibility(vis0: Option<ast::Visibility>, vis1: Option<ast::Visibility>) -
183183
pub fn try_merge_imports(
184184
lhs: &ast::Use,
185185
rhs: &ast::Use,
186-
merge_behaviour: MergeBehaviour,
186+
merge_behavior: MergeBehavior,
187187
) -> Option<ast::Use> {
188188
// don't merge imports with different visibilities
189189
if !eq_visibility(lhs.visibility(), rhs.visibility()) {
190190
return None;
191191
}
192192
let lhs_tree = lhs.use_tree()?;
193193
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)?;
195195
Some(lhs.with_use_tree(merged))
196196
}
197197

198198
pub fn try_merge_trees(
199199
lhs: &ast::UseTree,
200200
rhs: &ast::UseTree,
201-
merge: MergeBehaviour,
201+
merge: MergeBehavior,
202202
) -> Option<ast::UseTree> {
203203
let lhs_path = lhs.path()?;
204204
let rhs_path = rhs.path()?;
@@ -220,7 +220,7 @@ pub fn try_merge_trees(
220220
fn recursive_merge(
221221
lhs: &ast::UseTree,
222222
rhs: &ast::UseTree,
223-
merge: MergeBehaviour,
223+
merge: MergeBehavior,
224224
) -> Option<ast::UseTree> {
225225
let mut use_trees = lhs
226226
.use_tree_list()
@@ -301,7 +301,7 @@ fn recursive_merge(
301301
}
302302
}
303303
Err(_)
304-
if merge == MergeBehaviour::Last
304+
if merge == MergeBehavior::Last
305305
&& use_trees.len() > 0
306306
&& rhs_t.use_tree_list().is_some() =>
307307
{
@@ -438,20 +438,20 @@ fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering {
438438

439439
/// What type of merges are allowed.
440440
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
441-
pub enum MergeBehaviour {
441+
pub enum MergeBehavior {
442442
/// Merge everything together creating deeply nested imports.
443443
Full,
444444
/// Only merge the last import level, doesn't allow import nesting.
445445
Last,
446446
}
447447

448-
impl MergeBehaviour {
448+
impl MergeBehavior {
449449
#[inline]
450450
fn is_tree_allowed(&self, tree: &ast::UseTree) -> bool {
451451
match self {
452-
MergeBehaviour::Full => true,
452+
MergeBehavior::Full => true,
453453
// only simple single segment paths are allowed
454-
MergeBehaviour::Last => {
454+
MergeBehavior::Last => {
455455
tree.use_tree_list().is_none() && tree.path().map(path_len) <= Some(1)
456456
}
457457
}

crates/ide_db/src/helpers/insert_use/tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ fn merge_last_fail() {
533533
check_merge_only_fail(
534534
r"use foo::bar::{baz::{Qux, Fez}};",
535535
r"use foo::bar::{baaz::{Quux, Feez}};",
536-
MergeBehaviour::Last,
536+
MergeBehavior::Last,
537537
);
538538
}
539539

@@ -542,7 +542,7 @@ fn merge_last_fail1() {
542542
check_merge_only_fail(
543543
r"use foo::bar::{baz::{Qux, Fez}};",
544544
r"use foo::bar::baaz::{Quux, Feez};",
545-
MergeBehaviour::Last,
545+
MergeBehavior::Last,
546546
);
547547
}
548548

@@ -551,7 +551,7 @@ fn merge_last_fail2() {
551551
check_merge_only_fail(
552552
r"use foo::bar::baz::{Qux, Fez};",
553553
r"use foo::bar::{baaz::{Quux, Feez}};",
554-
MergeBehaviour::Last,
554+
MergeBehavior::Last,
555555
);
556556
}
557557

@@ -560,15 +560,15 @@ fn merge_last_fail3() {
560560
check_merge_only_fail(
561561
r"use foo::bar::baz::{Qux, Fez};",
562562
r"use foo::bar::baaz::{Quux, Feez};",
563-
MergeBehaviour::Last,
563+
MergeBehavior::Last,
564564
);
565565
}
566566

567567
fn check(
568568
path: &str,
569569
ra_fixture_before: &str,
570570
ra_fixture_after: &str,
571-
mb: Option<MergeBehaviour>,
571+
mb: Option<MergeBehavior>,
572572
module: bool,
573573
) {
574574
let mut syntax = ast::SourceFile::parse(ra_fixture_before).tree().syntax().clone();
@@ -589,18 +589,18 @@ fn check(
589589
}
590590

591591
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)
593593
}
594594

595595
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)
597597
}
598598

599599
fn check_none(path: &str, ra_fixture_before: &str, ra_fixture_after: &str) {
600600
check(path, ra_fixture_before, ra_fixture_after, None, false)
601601
}
602602

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) {
604604
let use0 = ast::SourceFile::parse(ra_fixture0)
605605
.tree()
606606
.syntax()

crates/rust-analyzer/src/config.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::{convert::TryFrom, ffi::OsString, path::PathBuf};
1212
use flycheck::FlycheckConfig;
1313
use hir::PrefixKind;
1414
use ide::{AssistConfig, CompletionConfig, DiagnosticsConfig, HoverConfig, InlayHintsConfig};
15-
use ide_db::helpers::insert_use::MergeBehaviour;
15+
use ide_db::helpers::insert_use::MergeBehavior;
1616
use itertools::Itertools;
1717
use lsp_types::{ClientCapabilities, MarkupKind};
1818
use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
@@ -25,7 +25,7 @@ use crate::{caps::enabled_completions_resolve_capabilities, diagnostics::Diagnos
2525
config_data! {
2626
struct ConfigData {
2727
/// The strategy to use when inserting new imports or merging imports.
28-
assist_importMergeBehaviour: MergeBehaviourDef = "\"full\"",
28+
assist_importMergeBehaviour: MergeBehaviorDef = "\"full\"",
2929
/// The path structure for newly inserted paths to use.
3030
assist_importPrefix: ImportPrefixDef = "\"plain\"",
3131

@@ -447,9 +447,9 @@ impl Config {
447447
};
448448

449449
self.assist.insert_use.merge = match data.assist_importMergeBehaviour {
450-
MergeBehaviourDef::None => None,
451-
MergeBehaviourDef::Full => Some(MergeBehaviour::Full),
452-
MergeBehaviourDef::Last => Some(MergeBehaviour::Last),
450+
MergeBehaviorDef::None => None,
451+
MergeBehaviorDef::Full => Some(MergeBehavior::Full),
452+
MergeBehaviorDef::Last => Some(MergeBehavior::Last),
453453
};
454454
self.assist.insert_use.prefix_kind = match data.assist_importPrefix {
455455
ImportPrefixDef::Plain => PrefixKind::Plain,
@@ -606,7 +606,7 @@ enum ManifestOrProjectJson {
606606

607607
#[derive(Deserialize)]
608608
#[serde(rename_all = "snake_case")]
609-
enum MergeBehaviourDef {
609+
enum MergeBehaviorDef {
610610
None,
611611
Full,
612612
Last,
@@ -740,7 +740,7 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
740740
"type": ["null", "array"],
741741
"items": { "type": "string" },
742742
},
743-
"MergeBehaviourDef" => set! {
743+
"MergeBehaviorDef" => set! {
744744
"type": "string",
745745
"enum": ["none", "full", "last"],
746746
"enumDescriptions": [

docs/dev/style.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ impl Parent {
514514
Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
515515
The default name is a lowercased name of the type: `global_state: GlobalState`.
516516
Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
517+
Prefer American spelling (color, behavior).
517518

518519
Default names:
519520

0 commit comments

Comments
 (0)