diff options
author | gfreezy <[email protected]> | 2018-12-23 16:39:33 +0000 |
---|---|---|
committer | gfreezy <[email protected]> | 2018-12-23 16:39:33 +0000 |
commit | 346638c8098fefd0b6fa3cf81fbdf22ebfaab9be (patch) | |
tree | 9c3065ad2d909786f802fbd1b4c2571cb2287482 /crates/ra_analysis | |
parent | 000aacafda209826b9b5aac86d175152d488f05b (diff) |
add serverity to vscode diagnostics
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 5 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/tests/tests.rs | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index b01382808..e054227a9 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -3,7 +3,7 @@ use std::{ | |||
3 | sync::Arc, | 3 | sync::Arc, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use ra_editor::{self, find_node_at_offset, FileSymbol, LineIndex, LocalEdit}; | 6 | use ra_editor::{self, find_node_at_offset, FileSymbol, LineIndex, LocalEdit, Severity}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | ast::{self, ArgListOwner, Expr, NameOwner}, | 8 | ast::{self, ArgListOwner, Expr, NameOwner}, |
9 | AstNode, SourceFileNode, | 9 | AstNode, SourceFileNode, |
@@ -364,6 +364,7 @@ impl AnalysisImpl { | |||
364 | .map(|d| Diagnostic { | 364 | .map(|d| Diagnostic { |
365 | range: d.range, | 365 | range: d.range, |
366 | message: d.msg, | 366 | message: d.msg, |
367 | severity: d.severity, | ||
367 | fix: None, | 368 | fix: None, |
368 | }) | 369 | }) |
369 | .collect::<Vec<_>>(); | 370 | .collect::<Vec<_>>(); |
@@ -385,6 +386,7 @@ impl AnalysisImpl { | |||
385 | Diagnostic { | 386 | Diagnostic { |
386 | range: name_node.range(), | 387 | range: name_node.range(), |
387 | message: "unresolved module".to_string(), | 388 | message: "unresolved module".to_string(), |
389 | severity: Some(Severity::Error), | ||
388 | fix: Some(fix), | 390 | fix: Some(fix), |
389 | } | 391 | } |
390 | } | 392 | } |
@@ -407,6 +409,7 @@ impl AnalysisImpl { | |||
407 | Diagnostic { | 409 | Diagnostic { |
408 | range: name_node.range(), | 410 | range: name_node.range(), |
409 | message: "can't declare module at this location".to_string(), | 411 | message: "can't declare module at this location".to_string(), |
412 | severity: Some(Severity::Error), | ||
410 | fix: Some(fix), | 413 | fix: Some(fix), |
411 | } | 414 | } |
412 | } | 415 | } |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 85df9c089..8ab6334a7 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -34,6 +34,7 @@ pub use crate::{ | |||
34 | }; | 34 | }; |
35 | pub use ra_editor::{ | 35 | pub use ra_editor::{ |
36 | FileSymbol, Fold, FoldKind, HighlightedRange, LineIndex, Runnable, RunnableKind, StructureNode, | 36 | FileSymbol, Fold, FoldKind, HighlightedRange, LineIndex, Runnable, RunnableKind, StructureNode, |
37 | Severity | ||
37 | }; | 38 | }; |
38 | pub use hir::FnSignatureInfo; | 39 | pub use hir::FnSignatureInfo; |
39 | 40 | ||
@@ -198,6 +199,7 @@ pub struct Diagnostic { | |||
198 | pub message: String, | 199 | pub message: String, |
199 | pub range: TextRange, | 200 | pub range: TextRange, |
200 | pub fix: Option<SourceChange>, | 201 | pub fix: Option<SourceChange>, |
202 | pub severity: Option<Severity>, | ||
201 | } | 203 | } |
202 | 204 | ||
203 | #[derive(Debug)] | 205 | #[derive(Debug)] |
diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs index 938ca797a..2313e35f5 100644 --- a/crates/ra_analysis/tests/tests.rs +++ b/crates/ra_analysis/tests/tests.rs | |||
@@ -82,7 +82,8 @@ fn test_unresolved_module_diagnostic() { | |||
82 | label: "create module", | 82 | label: "create module", |
83 | source_file_edits: [], | 83 | source_file_edits: [], |
84 | file_system_edits: [CreateFile { source_root: SourceRootId(0), path: "foo.rs" }], | 84 | file_system_edits: [CreateFile { source_root: SourceRootId(0), path: "foo.rs" }], |
85 | cursor_position: None }) }]"#, | 85 | cursor_position: None }), |
86 | severity: Some(Error) }]"#, | ||
86 | &diagnostics, | 87 | &diagnostics, |
87 | ); | 88 | ); |
88 | } | 89 | } |