Extract collection rule data from rule block declarations.
( &mut self, declarations: &'a [css_parse::Declaration<'a, RuleDeclarationValue<'a>, ()>], )
| 145 | impl<'a> Collector<'a> { |
| 146 | /// Extract collection rule data from rule block declarations. |
| 147 | fn extract_rule_data( |
| 148 | &mut self, |
| 149 | declarations: &'a [css_parse::Declaration<'a, RuleDeclarationValue<'a>, ()>], |
| 150 | ) -> ExtractedRuleData<'a> { |
| 151 | let mut collectors = SmallVec::new(); |
| 152 | let mut diagnostic_level = ResolvedDiagnosticLevel::Advice; |
| 153 | let mut diagnostic_components = None; |
| 154 | |
| 155 | for decl in declarations { |
| 156 | match &decl.value { |
| 157 | RuleDeclarationValue::Collect(dashed_ident) => { |
| 158 | let name = CsskitAtomSet::get_dyn_set().atom_from_bits(Cursor::from(*dashed_ident).atom_bits()); |
| 159 | collectors.push(name); |
| 160 | self.stats.entry(name).or_insert((StatType::Counter, 0)); |
| 161 | } |
| 162 | RuleDeclarationValue::Diagnostic(components) => diagnostic_components = Some(components.as_slice()), |
| 163 | RuleDeclarationValue::Level(level) => { |
| 164 | diagnostic_level = match level { |
| 165 | RuleDiagnosticLevel::Warning(_) => ResolvedDiagnosticLevel::Warning, |
| 166 | RuleDiagnosticLevel::Advice(_) => ResolvedDiagnosticLevel::Advice, |
| 167 | RuleDiagnosticLevel::Error(_) => ResolvedDiagnosticLevel::Error, |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | let diagnostic = diagnostic_components.map(|c| (diagnostic_level, c)); |
| 174 | let mut diagnostic_stats = HashSet::new(); |
| 175 | if let Some((_, components)) = &diagnostic { |
| 176 | for component in *components { |
| 177 | if let DiagnosticComponent::DashedIdent(dashed_ident) = component { |
| 178 | diagnostic_stats.insert(Cursor::from(*dashed_ident).atom_bits()); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | ExtractedRuleData { collectors, diagnostic, diagnostic_stats } |
| 184 | } |
| 185 | |
| 186 | /// Process nested rules and add them to collection rules. |
| 187 | /// The `conditions` parameter contains all conditions that must be true for nested rules to execute. |
no test coverage detected