diff options
Diffstat (limited to 'crates/ide/src/diagnostics.rs')
-rw-r--r-- | crates/ide/src/diagnostics.rs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index c257ea8e7..fb956d5ee 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs | |||
@@ -341,7 +341,6 @@ fn unresolved_fix(id: &'static str, label: &str, target: TextRange) -> Assist { | |||
341 | #[cfg(test)] | 341 | #[cfg(test)] |
342 | mod tests { | 342 | mod tests { |
343 | use expect_test::Expect; | 343 | use expect_test::Expect; |
344 | use hir::diagnostics::DiagnosticCode; | ||
345 | use ide_assists::AssistResolveStrategy; | 344 | use ide_assists::AssistResolveStrategy; |
346 | use stdx::trim_indent; | 345 | use stdx::trim_indent; |
347 | use test_utils::{assert_eq_text, extract_annotations}; | 346 | use test_utils::{assert_eq_text, extract_annotations}; |
@@ -442,24 +441,24 @@ mod tests { | |||
442 | 441 | ||
443 | #[track_caller] | 442 | #[track_caller] |
444 | pub(crate) fn check_diagnostics(ra_fixture: &str) { | 443 | pub(crate) fn check_diagnostics(ra_fixture: &str) { |
445 | check_diagnostics_with_inactive_code(ra_fixture, false) | 444 | let mut config = DiagnosticsConfig::default(); |
445 | config.disabled.insert("inactive-code".to_string()); | ||
446 | check_diagnostics_with_config(config, ra_fixture) | ||
446 | } | 447 | } |
447 | 448 | ||
448 | #[track_caller] | 449 | #[track_caller] |
449 | pub(crate) fn check_diagnostics_with_inactive_code(ra_fixture: &str, with_inactive_code: bool) { | 450 | pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixture: &str) { |
450 | let (analysis, file_id) = fixture::file(ra_fixture); | 451 | let (analysis, files) = fixture::files(ra_fixture); |
451 | let diagnostics = analysis | 452 | for file_id in files { |
452 | .diagnostics(&DiagnosticsConfig::default(), AssistResolveStrategy::All, file_id) | 453 | let diagnostics = |
453 | .unwrap(); | 454 | analysis.diagnostics(&config, AssistResolveStrategy::All, file_id).unwrap(); |
454 | 455 | ||
455 | let expected = extract_annotations(&*analysis.file_text(file_id).unwrap()); | 456 | let expected = extract_annotations(&*analysis.file_text(file_id).unwrap()); |
456 | let mut actual = diagnostics | 457 | let mut actual = |
457 | .into_iter() | 458 | diagnostics.into_iter().map(|d| (d.range, d.message)).collect::<Vec<_>>(); |
458 | .filter(|d| d.code != Some(DiagnosticCode("inactive-code")) || with_inactive_code) | 459 | actual.sort_by_key(|(range, _)| range.start()); |
459 | .map(|d| (d.range, d.message)) | 460 | assert_eq!(expected, actual); |
460 | .collect::<Vec<_>>(); | 461 | } |
461 | actual.sort_by_key(|(range, _)| range.start()); | ||
462 | assert_eq!(expected, actual); | ||
463 | } | 462 | } |
464 | 463 | ||
465 | #[test] | 464 | #[test] |