aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-05-05 19:55:12 +0100
committerAleksey Kladov <[email protected]>2020-05-05 20:35:30 +0100
commit3908fad1fe02efedc810d7bd8f765b1434684cef (patch)
treebbb53074847af07a64eafb0cbea088f49a88f7ae /crates/ra_ide
parentdf00da15c435f3105007146cbbfc9afc34ad311c (diff)
Normalize naming of diagnostics
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/diagnostics.rs12
-rw-r--r--crates/ra_ide/src/references/rename.rs10
-rw-r--r--crates/ra_ide/src/source_change.rs4
-rw-r--r--crates/ra_ide/src/typing/on_enter.rs2
4 files changed, 15 insertions, 13 deletions
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<Diagnostic>
64 .unwrap_or_else(|| RelativePath::new("")) 64 .unwrap_or_else(|| RelativePath::new(""))
65 .join(&d.candidate); 65 .join(&d.candidate);
66 let create_file = FileSystemEdit::CreateFile { source_root, path }; 66 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);
68 res.borrow_mut().push(Diagnostic { 68 res.borrow_mut().push(Diagnostic {
69 range: sema.diagnostics_range(d).range, 69 range: sema.diagnostics_range(d).range,
70 message: d.message(), 70 message: d.message(),
@@ -92,7 +92,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
92 algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder); 92 algo::diff(&d.ast(db).syntax(), &field_list.syntax()).into_text_edit(&mut builder);
93 93
94 Some(SourceChange::source_file_edit_from( 94 Some(SourceChange::source_file_edit_from(
95 "fill struct fields", 95 "Fill struct fields",
96 file_id, 96 file_id,
97 builder.finish(), 97 builder.finish(),
98 )) 98 ))
@@ -117,7 +117,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
117 let node = d.ast(db); 117 let node = d.ast(db);
118 let replacement = format!("Ok({})", node.syntax()); 118 let replacement = format!("Ok({})", node.syntax());
119 let edit = TextEdit::replace(node.syntax().text_range(), replacement); 119 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);
121 res.borrow_mut().push(Diagnostic { 121 res.borrow_mut().push(Diagnostic {
122 range: sema.diagnostics_range(d).range, 122 range: sema.diagnostics_range(d).range,
123 message: d.message(), 123 message: d.message(),
@@ -199,7 +199,7 @@ fn check_struct_shorthand_initialization(
199 message: "Shorthand struct initialization".to_string(), 199 message: "Shorthand struct initialization".to_string(),
200 severity: Severity::WeakWarning, 200 severity: Severity::WeakWarning,
201 fix: Some(SourceChange::source_file_edit( 201 fix: Some(SourceChange::source_file_edit(
202 "use struct shorthand initialization", 202 "Use struct shorthand initialization",
203 SourceFileEdit { file_id, edit }, 203 SourceFileEdit { file_id, edit },
204 )), 204 )),
205 }); 205 });
@@ -606,7 +606,7 @@ mod tests {
606 range: 0..8, 606 range: 0..8,
607 fix: Some( 607 fix: Some(
608 SourceChange { 608 SourceChange {
609 label: "create module", 609 label: "Create module",
610 source_file_edits: [], 610 source_file_edits: [],
611 file_system_edits: [ 611 file_system_edits: [
612 CreateFile { 612 CreateFile {
@@ -655,7 +655,7 @@ mod tests {
655 range: 224..233, 655 range: 224..233,
656 fix: Some( 656 fix: Some(
657 SourceChange { 657 SourceChange {
658 label: "fill struct fields", 658 label: "Fill struct fields",
659 source_file_edits: [ 659 source_file_edits: [
660 SourceFileEdit { 660 SourceFileEdit {
661 file_id: FileId( 661 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(
122 source_file_edits.extend(ref_edits); 122 source_file_edits.extend(ref_edits);
123 } 123 }
124 124
125 Some(SourceChange::from_edits("rename", source_file_edits, file_system_edits)) 125 Some(SourceChange::from_edits("Rename", source_file_edits, file_system_edits))
126} 126}
127 127
128fn rename_reference( 128fn rename_reference(
@@ -141,7 +141,7 @@ fn rename_reference(
141 return None; 141 return None;
142 } 142 }
143 143
144 Some(RangeInfo::new(range, SourceChange::source_file_edits("rename", edit))) 144 Some(RangeInfo::new(range, SourceChange::source_file_edits("Rename", edit)))
145} 145}
146 146
147#[cfg(test)] 147#[cfg(test)]
@@ -530,7 +530,7 @@ mod tests {
530 RangeInfo { 530 RangeInfo {
531 range: 4..7, 531 range: 4..7,
532 info: SourceChange { 532 info: SourceChange {
533 label: "rename", 533 label: "Rename",
534 source_file_edits: [ 534 source_file_edits: [
535 SourceFileEdit { 535 SourceFileEdit {
536 file_id: FileId( 536 file_id: FileId(
@@ -582,7 +582,7 @@ mod tests {
582 RangeInfo { 582 RangeInfo {
583 range: 4..7, 583 range: 4..7,
584 info: SourceChange { 584 info: SourceChange {
585 label: "rename", 585 label: "Rename",
586 source_file_edits: [ 586 source_file_edits: [
587 SourceFileEdit { 587 SourceFileEdit {
588 file_id: FileId( 588 file_id: FileId(
@@ -665,7 +665,7 @@ mod tests {
665 RangeInfo { 665 RangeInfo {
666 range: 8..11, 666 range: 8..11,
667 info: SourceChange { 667 info: SourceChange {
668 label: "rename", 668 label: "Rename",
669 source_file_edits: [ 669 source_file_edits: [
670 SourceFileEdit { 670 SourceFileEdit {
671 file_id: FileId( 671 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 {
35 /// Creates a new SourceChange with the given label, 35 /// Creates a new SourceChange with the given label,
36 /// containing only the given `SourceFileEdits`. 36 /// containing only the given `SourceFileEdits`.
37 pub(crate) fn source_file_edits<L: Into<String>>(label: L, edits: Vec<SourceFileEdit>) -> Self { 37 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));
38 SourceChange { 40 SourceChange {
39 label: label.into(), 41 label: label,
40 source_file_edits: edits, 42 source_file_edits: edits,
41 file_system_edits: vec![], 43 file_system_edits: vec![],
42 cursor_position: None, 44 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<Sour
44 44
45 Some( 45 Some(
46 SourceChange::source_file_edit( 46 SourceChange::source_file_edit(
47 "on enter", 47 "On enter",
48 SourceFileEdit { edit, file_id: position.file_id }, 48 SourceFileEdit { edit, file_id: position.file_id },
49 ) 49 )
50 .with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }), 50 .with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }),