Fix some of the diagnostic tests and make DiagnosticEntry generic

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-12-09 17:53:08 +01:00
parent 65711b2256
commit 91a7bbbba2
9 changed files with 189 additions and 167 deletions

View file

@ -947,7 +947,7 @@ mod tests {
editor::{Editor, EditorSettings, Input},
fs::{FakeFs, Fs as _},
language::{
tree_sitter_rust, AnchorRangeExt, Diagnostic, Language, LanguageConfig,
tree_sitter_rust, Diagnostic, DiagnosticEntry, Language, LanguageConfig,
LanguageRegistry, LanguageServerConfig, Point,
},
lsp,
@ -1704,28 +1704,27 @@ mod tests {
buffer_b.read_with(&cx_b, |buffer, _| {
assert_eq!(
buffer
.diagnostics_in_range(0..buffer.len())
.map(|entry| (entry.range.to_point(buffer), &entry.diagnostic))
.diagnostics_in_range::<_, Point>(0..buffer.len())
.collect::<Vec<_>>(),
&[
(
Point::new(0, 4)..Point::new(0, 7),
&Diagnostic {
DiagnosticEntry {
range: Point::new(0, 4)..Point::new(0, 7),
diagnostic: Diagnostic {
group_id: 0,
message: "message 1".to_string(),
severity: lsp::DiagnosticSeverity::ERROR,
is_primary: true
}
),
(
Point::new(0, 10)..Point::new(0, 13),
&Diagnostic {
},
DiagnosticEntry {
range: Point::new(0, 10)..Point::new(0, 13),
diagnostic: Diagnostic {
group_id: 1,
severity: lsp::DiagnosticSeverity::WARNING,
message: "message 2".to_string(),
is_primary: true
}
)
}
]
);
});