aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r--crates/ra_editor/src/lib.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index 48676f2e8..399bb8fe8 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -34,14 +34,16 @@ pub struct HighlightedRange {
34#[derive(Debug, Copy, Clone)] 34#[derive(Debug, Copy, Clone)]
35pub enum Severity { 35pub enum Severity {
36 Error, 36 Error,
37 Warning 37 Warning,
38 Information,
39 Hint,
38} 40}
39 41
40#[derive(Debug)] 42#[derive(Debug)]
41pub struct Diagnostic { 43pub struct Diagnostic {
42 pub range: TextRange, 44 pub range: TextRange,
43 pub msg: String, 45 pub msg: String,
44 pub severity: Severity, 46 pub severity: Option<Severity>,
45} 47}
46 48
47#[derive(Debug)] 49#[derive(Debug)]
@@ -104,12 +106,13 @@ pub fn diagnostics(file: &SourceFileNode) -> Vec<Diagnostic> {
104 } 106 }
105 } 107 }
106 108
107 let mut errors: Vec<Diagnostic> = file.errors() 109 let mut errors: Vec<Diagnostic> = file
110 .errors()
108 .into_iter() 111 .into_iter()
109 .map(|err| Diagnostic { 112 .map(|err| Diagnostic {
110 range: location_to_range(err.location()), 113 range: location_to_range(err.location()),
111 msg: format!("Syntax Error: {}", err), 114 msg: format!("Syntax Error: {}", err),
112 severity: Severity::Error, 115 severity: Some(Severity::Error),
113 }) 116 })
114 .collect(); 117 .collect();
115 118
@@ -127,7 +130,7 @@ fn check_unnecessary_braces_in_use_statement(file: &SourceFileNode) -> Vec<Diagn
127 diagnostics.push(Diagnostic { 130 diagnostics.push(Diagnostic {
128 range: use_tree_list.syntax().range(), 131 range: use_tree_list.syntax().range(),
129 msg: format!("Unnecessary braces in use statement"), 132 msg: format!("Unnecessary braces in use statement"),
130 severity: Severity::Warning, 133 severity: Some(Severity::Warning),
131 }) 134 })
132 } 135 }
133 } 136 }
@@ -249,9 +252,9 @@ fn main() {}
249 ); 252 );
250 let diagnostics = check_unnecessary_braces_in_use_statement(&file); 253 let diagnostics = check_unnecessary_braces_in_use_statement(&file);
251 assert_eq_dbg( 254 assert_eq_dbg(
252 r#"[Diagnostic { range: [12; 15), msg: "Unnecessary braces in use statement", severity: Warning }, 255 r#"[Diagnostic { range: [12; 15), msg: "Unnecessary braces in use statement", severity: Some(Warning) },
253 Diagnostic { range: [24; 27), msg: "Unnecessary braces in use statement", severity: Warning }, 256 Diagnostic { range: [24; 27), msg: "Unnecessary braces in use statement", severity: Some(Warning) },
254 Diagnostic { range: [61; 64), msg: "Unnecessary braces in use statement", severity: Warning }]"#, 257 Diagnostic { range: [61; 64), msg: "Unnecessary braces in use statement", severity: Some(Warning) }]"#,
255 &diagnostics, 258 &diagnostics,
256 ) 259 )
257 } 260 }