mod capture;
mod raw;
use crate::hir::HirModule;
use crate::parser::RawChunk;
use super::NamingError;
use super::common::NamingEvidence;
use capture::build_capture_evidence;
use raw::{build_function_evidence, collect_raw_functions};
pub fn collect_naming_evidence(
raw: &RawChunk,
hir: &HirModule,
) -> Result<NamingEvidence, NamingError> {
let mut raw_functions = Vec::new();
collect_raw_functions(&raw.main, &mut raw_functions);
if raw_functions.len() != hir.protos.len() {
return Err(NamingError::EvidenceProtoCountMismatch {
raw_count: raw_functions.len(),
hir_count: hir.protos.len(),
});
}
let capture_evidence = build_capture_evidence(hir)?;
let functions = raw_functions
.into_iter()
.zip(hir.protos.iter())
.enumerate()
.map(|(index, (raw_proto, hir_proto))| {
build_function_evidence(raw_proto, hir_proto, capture_evidence[index].as_ref())
})
.collect();
Ok(NamingEvidence { functions })
}