Skip to content

Commit 3908fad

Browse files
committed
Normalize naming of diagnostics
1 parent df00da1 commit 3908fad

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

crates/ra_ide/src/diagnostics.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
6464
.unwrap_or_else(|| RelativePath::new(""))
6565
.join(&d.candidate);
6666
let create_file = FileSystemEdit::CreateFile { source_root, path };
67-
let fix = SourceChange::file_system_edit("create module", create_file);
67+
let fix = SourceChange::file_system_edit("Create module", create_file);
6868
res.borrow_mut().push(Diagnostic {
6969
range: sema.diagnostics_range(d).range,
7070
message: d.message(),
@@ -92,7 +92,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
9292
algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder);
9393

9494
Some(SourceChange::source_file_edit_from(
95-
"fill struct fields",
95+
"Fill struct fields",
9696
file_id,
9797
builder.finish(),
9898
))
@@ -117,7 +117,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
117117
let node = d.ast(db);
118118
let replacement = format!("Ok({})", node.syntax());
119119
let edit = TextEdit::replace(node.syntax().text_range(), replacement);
120-
let fix = SourceChange::source_file_edit_from("wrap with ok", file_id, edit);
120+
let fix = SourceChange::source_file_edit_from("Wrap with ok", file_id, edit);
121121
res.borrow_mut().push(Diagnostic {
122122
range: sema.diagnostics_range(d).range,
123123
message: d.message(),
@@ -199,7 +199,7 @@ fn check_struct_shorthand_initialization(
199199
message: "Shorthand struct initialization".to_string(),
200200
severity: Severity::WeakWarning,
201201
fix: Some(SourceChange::source_file_edit(
202-
"use struct shorthand initialization",
202+
"Use struct shorthand initialization",
203203
SourceFileEdit { file_id, edit },
204204
)),
205205
});
@@ -606,7 +606,7 @@ mod tests {
606606
range: 0..8,
607607
fix: Some(
608608
SourceChange {
609-
label: "create module",
609+
label: "Create module",
610610
source_file_edits: [],
611611
file_system_edits: [
612612
CreateFile {
@@ -655,7 +655,7 @@ mod tests {
655655
range: 224..233,
656656
fix: Some(
657657
SourceChange {
658-
label: "fill struct fields",
658+
label: "Fill struct fields",
659659
source_file_edits: [
660660
SourceFileEdit {
661661
file_id: FileId(

crates/ra_ide/src/references/rename.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn rename_mod(
122122
source_file_edits.extend(ref_edits);
123123
}
124124

125-
Some(SourceChange::from_edits("rename", source_file_edits, file_system_edits))
125+
Some(SourceChange::from_edits("Rename", source_file_edits, file_system_edits))
126126
}
127127

128128
fn rename_reference(
@@ -141,7 +141,7 @@ fn rename_reference(
141141
return None;
142142
}
143143

144-
Some(RangeInfo::new(range, SourceChange::source_file_edits("rename", edit)))
144+
Some(RangeInfo::new(range, SourceChange::source_file_edits("Rename", edit)))
145145
}
146146

147147
#[cfg(test)]
@@ -530,7 +530,7 @@ mod tests {
530530
RangeInfo {
531531
range: 4..7,
532532
info: SourceChange {
533-
label: "rename",
533+
label: "Rename",
534534
source_file_edits: [
535535
SourceFileEdit {
536536
file_id: FileId(
@@ -582,7 +582,7 @@ mod tests {
582582
RangeInfo {
583583
range: 4..7,
584584
info: SourceChange {
585-
label: "rename",
585+
label: "Rename",
586586
source_file_edits: [
587587
SourceFileEdit {
588588
file_id: FileId(
@@ -665,7 +665,7 @@ mod tests {
665665
RangeInfo {
666666
range: 8..11,
667667
info: SourceChange {
668-
label: "rename",
668+
label: "Rename",
669669
source_file_edits: [
670670
SourceFileEdit {
671671
file_id: FileId(

crates/ra_ide/src/source_change.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ impl SourceChange {
3535
/// Creates a new SourceChange with the given label,
3636
/// containing only the given `SourceFileEdits`.
3737
pub(crate) fn source_file_edits<L: Into<String>>(label: L, edits: Vec<SourceFileEdit>) -> Self {
38+
let label = label.into();
39+
assert!(label.starts_with(char::is_uppercase));
3840
SourceChange {
39-
label: label.into(),
41+
label: label,
4042
source_file_edits: edits,
4143
file_system_edits: vec![],
4244
cursor_position: None,

crates/ra_ide/src/typing/on_enter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour
4444

4545
Some(
4646
SourceChange::source_file_edit(
47-
"on enter",
47+
"On enter",
4848
SourceFileEdit { edit, file_id: position.file_id },
4949
)
5050
.with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }),

crates/rust-analyzer/tests/heavy_tests/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ fn main() {}
337337
"arguments": [
338338
{
339339
"cursorPosition": null,
340-
"label": "create module",
340+
"label": "Create module",
341341
"workspaceEdit": {
342342
"documentChanges": [
343343
{
@@ -349,9 +349,9 @@ fn main() {}
349349
}
350350
],
351351
"command": "rust-analyzer.applySourceChange",
352-
"title": "create module"
352+
"title": "Create module"
353353
},
354-
"title": "create module"
354+
"title": "Create module"
355355
}
356356
]),
357357
);
@@ -420,7 +420,7 @@ fn main() {{}}
420420
"arguments": [
421421
{
422422
"cursorPosition": null,
423-
"label": "create module",
423+
"label": "Create module",
424424
"workspaceEdit": {
425425
"documentChanges": [
426426
{
@@ -432,9 +432,9 @@ fn main() {{}}
432432
}
433433
],
434434
"command": "rust-analyzer.applySourceChange",
435-
"title": "create module"
435+
"title": "Create module"
436436
},
437-
"title": "create module"
437+
"title": "Create module"
438438
}
439439
]),
440440
);
@@ -500,7 +500,7 @@ fn main() {{}}
500500
"position": { "character": 4, "line": 1 },
501501
"textDocument": { "uri": "file:///[..]src/m0.rs" }
502502
},
503-
"label": "on enter",
503+
"label": "On enter",
504504
"workspaceEdit": {
505505
"documentChanges": [
506506
{
@@ -552,7 +552,7 @@ version = \"0.0.0\"
552552
"position": { "line": 1, "character": 4 },
553553
"textDocument": { "uri": "file:///[..]src/main.rs" }
554554
},
555-
"label": "on enter",
555+
"label": "On enter",
556556
"workspaceEdit": {
557557
"documentChanges": [
558558
{

0 commit comments

Comments
 (0)