]> git.lizzy.rs Git - rust.git/commitdiff
Normalize naming of diagnostics
authorAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 5 May 2020 18:55:12 +0000 (20:55 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Tue, 5 May 2020 19:35:30 +0000 (21:35 +0200)
crates/ra_ide/src/diagnostics.rs
crates/ra_ide/src/references/rename.rs
crates/ra_ide/src/source_change.rs
crates/ra_ide/src/typing/on_enter.rs
crates/rust-analyzer/tests/heavy_tests/main.rs

index a6b4c2c284701c4d8410cfd13673fa0943b7e1d4..4c04cee078d48a47b94581428fa5a09548209628 100644 (file)
@@ -64,7 +64,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
             .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<Diagnostic>
             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<Diagnostic>
         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 @@ fn test_unresolved_module_diagnostic() {
                 range: 0..8,
                 fix: Some(
                     SourceChange {
-                        label: "create module",
+                        label: "Create module",
                         source_file_edits: [],
                         file_system_edits: [
                             CreateFile {
@@ -655,7 +655,7 @@ pub struct Foo {
                 range: 224..233,
                 fix: Some(
                     SourceChange {
-                        label: "fill struct fields",
+                        label: "Fill struct fields",
                         source_file_edits: [
                             SourceFileEdit {
                                 file_id: FileId(
index 916edaef27e1d0fdbfd01a5955ee77f5f9c4559a..52e55b0a08ee7769c387f2a34e2d52a81479f988 100644 (file)
@@ -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 @@ fn test_rename_mod() {
             RangeInfo {
                 range: 4..7,
                 info: SourceChange {
-                    label: "rename",
+                    label: "Rename",
                     source_file_edits: [
                         SourceFileEdit {
                             file_id: FileId(
@@ -582,7 +582,7 @@ fn test_rename_mod_in_dir() {
             RangeInfo {
                 range: 4..7,
                 info: SourceChange {
-                    label: "rename",
+                    label: "Rename",
                     source_file_edits: [
                         SourceFileEdit {
                             file_id: FileId(
@@ -665,7 +665,7 @@ fn f() {
             RangeInfo {
                 range: 8..11,
                 info: SourceChange {
-                    label: "rename",
+                    label: "Rename",
                     source_file_edits: [
                         SourceFileEdit {
                             file_id: FileId(
index 71b0e8f757eda73f41c5bc92efcf599f6c8bbef0..10afd78256ea8679b26b0f9c1a377e6f92052648 100644 (file)
@@ -35,8 +35,10 @@ pub(crate) fn from_edits<L: Into<String>>(
     /// Creates a new SourceChange with the given label,
     /// containing only the given `SourceFileEdits`.
     pub(crate) fn source_file_edits<L: Into<String>>(label: L, edits: Vec<SourceFileEdit>) -> 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,
index 30c8c557201ea6c0a353bc6ea10d118d8cde59f0..72523746413a968f7b827cdb74dc184dbb7a3e3b 100644 (file)
@@ -44,7 +44,7 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour
 
     Some(
         SourceChange::source_file_edit(
-            "on enter",
+            "On enter",
             SourceFileEdit { edit, file_id: position.file_id },
         )
         .with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }),
index a218da76d6c579eed35503dd29a138d51ce83cc5..1efa5dd632d3805b0f1331c35b3036d14d5056dc 100644 (file)
@@ -337,7 +337,7 @@ fn main() {}
               "arguments": [
                 {
                   "cursorPosition": null,
-                  "label": "create module",
+                  "label": "Create module",
                   "workspaceEdit": {
                     "documentChanges": [
                       {
@@ -349,9 +349,9 @@ fn main() {}
                 }
               ],
               "command": "rust-analyzer.applySourceChange",
-              "title": "create module"
+              "title": "Create module"
             },
-            "title": "create module"
+            "title": "Create module"
           }
         ]),
     );
@@ -420,7 +420,7 @@ fn main() {{}}
               "arguments": [
                 {
                   "cursorPosition": null,
-                  "label": "create module",
+                  "label": "Create module",
                   "workspaceEdit": {
                     "documentChanges": [
                       {
@@ -432,9 +432,9 @@ fn main() {{}}
                 }
               ],
               "command": "rust-analyzer.applySourceChange",
-              "title": "create module"
+              "title": "Create module"
             },
-            "title": "create module"
+            "title": "Create module"
           }
         ]),
     );
@@ -500,7 +500,7 @@ fn main() {{}}
             "position": { "character": 4, "line": 1 },
             "textDocument": { "uri": "file:///[..]src/m0.rs" }
           },
-          "label": "on enter",
+          "label": "On enter",
           "workspaceEdit": {
             "documentChanges": [
               {
@@ -552,7 +552,7 @@ fn preserves_dos_line_endings() {
             "position": { "line": 1, "character": 4 },
             "textDocument": { "uri": "file:///[..]src/main.rs" }
           },
-          "label": "on enter",
+          "label": "On enter",
           "workspaceEdit": {
             "documentChanges": [
               {