From 3908fad1fe02efedc810d7bd8f765b1434684cef Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 5 May 2020 20:55:12 +0200 Subject: Normalize naming of diagnostics --- crates/ra_ide/src/diagnostics.rs | 12 ++++++------ crates/ra_ide/src/references/rename.rs | 10 +++++----- crates/ra_ide/src/source_change.rs | 4 +++- crates/ra_ide/src/typing/on_enter.rs | 2 +- crates/rust-analyzer/tests/heavy_tests/main.rs | 16 ++++++++-------- 5 files changed, 23 insertions(+), 21 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index a6b4c2c28..4c04cee07 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -64,7 +64,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec .unwrap_or_else(|| RelativePath::new("")) .join(&d.candidate); let create_file = FileSystemEdit::CreateFile { source_root, path }; - let fix = SourceChange::file_system_edit("create module", create_file); + let fix = SourceChange::file_system_edit("Create module", create_file); res.borrow_mut().push(Diagnostic { range: sema.diagnostics_range(d).range, message: d.message(), @@ -92,7 +92,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder); Some(SourceChange::source_file_edit_from( - "fill struct fields", + "Fill struct fields", file_id, builder.finish(), )) @@ -117,7 +117,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec let node = d.ast(db); let replacement = format!("Ok({})", node.syntax()); let edit = TextEdit::replace(node.syntax().text_range(), replacement); - let fix = SourceChange::source_file_edit_from("wrap with ok", file_id, edit); + let fix = SourceChange::source_file_edit_from("Wrap with ok", file_id, edit); res.borrow_mut().push(Diagnostic { range: sema.diagnostics_range(d).range, message: d.message(), @@ -199,7 +199,7 @@ fn check_struct_shorthand_initialization( message: "Shorthand struct initialization".to_string(), severity: Severity::WeakWarning, fix: Some(SourceChange::source_file_edit( - "use struct shorthand initialization", + "Use struct shorthand initialization", SourceFileEdit { file_id, edit }, )), }); @@ -606,7 +606,7 @@ mod tests { range: 0..8, fix: Some( SourceChange { - label: "create module", + label: "Create module", source_file_edits: [], file_system_edits: [ CreateFile { @@ -655,7 +655,7 @@ mod tests { range: 224..233, fix: Some( SourceChange { - label: "fill struct fields", + label: "Fill struct fields", source_file_edits: [ SourceFileEdit { file_id: FileId( diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 916edaef2..52e55b0a0 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs @@ -122,7 +122,7 @@ fn rename_mod( source_file_edits.extend(ref_edits); } - Some(SourceChange::from_edits("rename", source_file_edits, file_system_edits)) + Some(SourceChange::from_edits("Rename", source_file_edits, file_system_edits)) } fn rename_reference( @@ -141,7 +141,7 @@ fn rename_reference( return None; } - Some(RangeInfo::new(range, SourceChange::source_file_edits("rename", edit))) + Some(RangeInfo::new(range, SourceChange::source_file_edits("Rename", edit))) } #[cfg(test)] @@ -530,7 +530,7 @@ mod tests { RangeInfo { range: 4..7, info: SourceChange { - label: "rename", + label: "Rename", source_file_edits: [ SourceFileEdit { file_id: FileId( @@ -582,7 +582,7 @@ mod tests { RangeInfo { range: 4..7, info: SourceChange { - label: "rename", + label: "Rename", source_file_edits: [ SourceFileEdit { file_id: FileId( @@ -665,7 +665,7 @@ mod tests { RangeInfo { range: 8..11, info: SourceChange { - label: "rename", + label: "Rename", source_file_edits: [ SourceFileEdit { file_id: FileId( diff --git a/crates/ra_ide/src/source_change.rs b/crates/ra_ide/src/source_change.rs index 71b0e8f75..10afd7825 100644 --- a/crates/ra_ide/src/source_change.rs +++ b/crates/ra_ide/src/source_change.rs @@ -35,8 +35,10 @@ impl SourceChange { /// Creates a new SourceChange with the given label, /// containing only the given `SourceFileEdits`. pub(crate) fn source_file_edits>(label: L, edits: Vec) -> Self { + let label = label.into(); + assert!(label.starts_with(char::is_uppercase)); SourceChange { - label: label.into(), + label: label, source_file_edits: edits, file_system_edits: vec![], cursor_position: None, diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 30c8c5572..725237464 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs @@ -44,7 +44,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option