use ifc_model::Model;
use ifc_schema::Schema;
use super::budget::Budget;
use super::builtin;
use super::registry::{self, Support};
use crate::report::{Finding, Path, Report};
pub fn evaluate(model: &Model, schema: &Schema, budget: Budget, report: &mut Report) {
for entry in registry::implemented() {
if entry.applies_to(schema) {
let dispatched = builtin::run(entry, model, schema, report);
debug_assert!(dispatched, "{} has no native implementation", entry.id);
}
}
for entry in registry::unsupported() {
if report.findings().len() >= budget.max_findings {
report.mark_truncated();
return;
}
let Support::Unsupported(reason) = entry.support else {
continue;
};
if !entry.applies_to(schema) {
continue;
}
if let Some(entity) = entry.entity {
if !model_contains(model, schema, entity) {
continue;
}
}
report.push(Finding::unsupported(entry.id, Path::File, reason));
}
}
fn model_contains(model: &Model, schema: &Schema, entity: &str) -> bool {
model
.type_histogram()
.iter()
.any(|(name, _)| schema.is_a(name, entity))
}