Get all diagnostics from matched rules. This method should be called after `collect()` to retrieve diagnostics for all rules that had diagnostic templates and matched nodes.
(&'b self, css_source: &'b str)
| 522 | /// This method should be called after `collect()` to retrieve diagnostics |
| 523 | /// for all rules that had diagnostic templates and matched nodes. |
| 524 | pub fn diagnostics<'b>(&'b self, css_source: &'b str) -> impl Iterator<Item = CollectorDiagnostic> + 'b { |
| 525 | self.collection_rules.iter().flat_map(move |rule| { |
| 526 | let Some((severity, components)) = &rule.diagnostic else { |
| 527 | return vec![in self.allocator].into_iter(); |
| 528 | }; |
| 529 | |
| 530 | let mut diagnostics = vec![in self.allocator]; |
| 531 | for match_output in rule.matches.iter() { |
| 532 | let message = self.resolve_diagnostic_message(components, match_output, css_source); |
| 533 | diagnostics.push(CollectorDiagnostic::new(*severity, match_output.span, message)); |
| 534 | } |
| 535 | diagnostics.into_iter() |
| 536 | }) |
| 537 | } |
| 538 | |
| 539 | /// Get the collected statistics. |
| 540 | /// |