From 346638c8098fefd0b6fa3cf81fbdf22ebfaab9be Mon Sep 17 00:00:00 2001 From: gfreezy Date: Mon, 24 Dec 2018 00:39:33 +0800 Subject: add serverity to vscode diagnostics --- crates/ra_lsp_server/src/main_loop/handlers.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server/src') 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::{ PrepareRenameResponse, RenameParams, SymbolInformation, TextDocumentIdentifier, TextEdit, WorkspaceEdit, ParameterInformation, ParameterLabel, SignatureInformation, Hover, HoverContents, }; -use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition}; +use ra_analysis::{FileId, FoldKind, Query, RunnableKind, FilePosition, Severity}; use ra_syntax::{TextUnit, text_utils::intersect}; use ra_text_edit::text_utils::contains_offset_nonstrict; use rustc_hash::FxHashMap; @@ -650,7 +650,7 @@ pub fn publish_diagnostics( .into_iter() .map(|d| Diagnostic { range: d.range.conv_with(&line_index), - severity: Some(DiagnosticSeverity::Error), + severity: d.severity.map(to_diagnostic_severity), code: None, source: Some("rust-analyzer".to_string()), message: d.message, @@ -684,3 +684,14 @@ fn highlight(world: &ServerWorld, file_id: FileId) -> Result> { .collect(); Ok(res) } + +fn to_diagnostic_severity(severity: Severity) -> DiagnosticSeverity { + use ra_analysis::Severity::*; + + match severity { + Error => DiagnosticSeverity::Error, + Warning => DiagnosticSeverity::Warning, + Information => DiagnosticSeverity::Information, + Hint => DiagnosticSeverity::Hint, + } +} -- cgit v1.2.3