aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorgfreezy <[email protected]>2018-12-23 16:39:33 +0000
committergfreezy <[email protected]>2018-12-23 16:39:33 +0000
commit346638c8098fefd0b6fa3cf81fbdf22ebfaab9be (patch)
tree9c3065ad2d909786f802fbd1b4c2571cb2287482 /crates/ra_lsp_server/src
parent000aacafda209826b9b5aac86d175152d488f05b (diff)
add serverity to vscode diagnostics
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index 252d1ba3e..8e859e8d4 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -8,7 +8,7 @@ use languageserver_types::{
8 PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, 8 PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit,
9 WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, 9 WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents,
10}; 10};
11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; 11use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, Severity};
12use ra_syntax::{TextUnit, text_utils::intersect}; 12use ra_syntax::{TextUnit, text_utils::intersect};
13use ra_text_edit::text_utils::contains_offset_nonstrict; 13use ra_text_edit::text_utils::contains_offset_nonstrict;
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
@@ -650,7 +650,7 @@ pub fn publish_diagnostics(
650 .into_iter() 650 .into_iter()
651 .map(|d| Diagnostic { 651 .map(|d| Diagnostic {
652 range: d.range.conv_with(&line_index), 652 range: d.range.conv_with(&line_index),
653 severity: Some(DiagnosticSeverity::Error), 653 severity: d.severity.map(to_diagnostic_severity),
654 code: None, 654 code: None,
655 source: Some("rust-analyzer".to_string()), 655 source: Some("rust-analyzer".to_string()),
656 message: d.message, 656 message: d.message,
@@ -684,3 +684,14 @@ fn highlight(world: &ServerWorld, file_id: FileId) -> Result<Vec<Decoration>> {
684 .collect(); 684 .collect();
685 Ok(res) 685 Ok(res)
686} 686}
687
688fn to_diagnostic_severity(severity: Severity) -> DiagnosticSeverity {
689 use ra_analysis::Severity::*;
690
691 match severity {
692 Error => DiagnosticSeverity::Error,
693 Warning => DiagnosticSeverity::Warning,
694 Information => DiagnosticSeverity::Information,
695 Hint => DiagnosticSeverity::Hint,
696 }
697}