use super::{Check, CheckContext, DiagnosticCode};
pub struct UeSpecifier;
impl Check for UeSpecifier {
const CODES: &'static [DiagnosticCode] = &[DiagnosticCode::UeSpecifier];
fn check(context: &mut CheckContext<'_>) {
let mut findings = Vec::new();
for fact in &context.summary.declarations {
let Some(reflection) = &fact.reflection() else {
continue;
};
let Some(known) = crate::project::ue::known_specifiers(&reflection.macro_name) else {
continue;
};
for specifier in &reflection.specifiers {
let name = specifier
.split_once('=')
.map(|(name, _)| name.trim())
.unwrap_or(specifier.trim());
if name.is_empty() || known.contains(&name) {
continue;
}
findings.push((
fact.range,
name.to_string(),
format!(
"`{name}` is not a `{}` specifier — the build tool ignores specifiers it does not know, so the \
declaration silently loses what this one asked for",
reflection.macro_name
),
));
}
}
for (range, name, message) in findings {
context.add_in_the_file(DiagnosticCode::UeSpecifier, range, name, message);
}
}
}