mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
add serverity to vscode diagnostics
This commit is contained in:
parent
000aacafda
commit
346638c809
5 changed files with 32 additions and 12 deletions
|
@ -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<Vec<Decoration>> {
|
|||
.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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue