use std::collections::{HashMap, HashSet};
use syn::Ident;
use crate::{conversion::api::Api, known_types::known_types, types::QualifiedName};
use crate::{conversion::api::ApiDetail, types::Namespace};
use super::fun::FnAnalysis;
pub(crate) fn append_ctype_information(apis: &mut Vec<Api<FnAnalysis>>) {
let ctypes: HashMap<Ident, QualifiedName> = apis
.iter()
.map(|api| api.deps.iter())
.flatten()
.filter(|ty| known_types().is_ctype(ty))
.map(|ty| (ty.get_final_ident(), ty.clone()))
.collect();
for (id, tn) in ctypes {
apis.push(Api {
name: QualifiedName::new(&Namespace::new(), id),
deps: HashSet::new(),
detail: ApiDetail::CType { typename: tn },
});
}
}