diagnostics: Use Vec<Tag> instead of Option<Vec<Tag>>

imgbot
Blaž Hrastnik 2 years ago
parent 64b0745413
commit 1df32c917c

@ -43,6 +43,6 @@ pub struct Diagnostic {
pub message: String, pub message: String,
pub severity: Option<Severity>, pub severity: Option<Severity>,
pub code: Option<NumberOrString>, pub code: Option<NumberOrString>,
pub tags: Option<Vec<DiagnosticTag>>, pub tags: Vec<DiagnosticTag>,
pub source: Option<String>, pub source: Option<String>,
} }

@ -84,19 +84,18 @@ pub mod util {
None => None, None => None,
}; };
let tags = if let Some(ref tags) = diag.tags { let new_tags: Vec<_> = diag
let new_tags = tags .tags
.iter() .iter()
.map(|tag| match tag { .map(|tag| match tag {
helix_core::diagnostic::DiagnosticTag::Unnecessary => { helix_core::diagnostic::DiagnosticTag::Unnecessary => {
lsp::DiagnosticTag::UNNECESSARY lsp::DiagnosticTag::UNNECESSARY
} }
helix_core::diagnostic::DiagnosticTag::Deprecated => { helix_core::diagnostic::DiagnosticTag::Deprecated => lsp::DiagnosticTag::DEPRECATED,
lsp::DiagnosticTag::DEPRECATED })
} .collect();
})
.collect();
let tags = if !new_tags.is_empty() {
Some(new_tags) Some(new_tags)
} else { } else {
None None

@ -614,9 +614,9 @@ impl Application {
} }
}).collect(); }).collect();
Some(new_tags) new_tags
} else { } else {
None Vec::new()
}; };
Some(Diagnostic { Some(Diagnostic {

Loading…
Cancel
Save