use crate::e2e::codegen::call_ir::{CallIr, resolve_declared_result_type};
use crate::e2e::config::{CallConfig, E2eConfig};
use crate::e2e::field_access::{FieldResolver, PhpGetterMap};
use crate::e2e::fixture::Fixture;
use std::collections::{HashMap, HashSet};
pub(super) struct CallFieldResolverInputs<'a> {
pub e2e_config: &'a E2eConfig,
pub call_config: &'a CallConfig,
pub fixture: &'a Fixture,
pub lang: &'a str,
pub type_defs: &'a [crate::core::ir::TypeDef],
pub functions: &'a [crate::core::ir::FunctionDef],
pub per_call_getter_map: &'a PhpGetterMap,
}
pub(super) fn build_call_field_resolver(inputs: CallFieldResolverInputs<'_>) -> FieldResolver {
let CallFieldResolverInputs {
e2e_config,
call_config,
fixture,
lang,
type_defs,
functions,
per_call_getter_map,
} = inputs;
let (ir_reachable_fields, ir_known_excluded_fields, ir_optional_fields) = FieldResolver::ir_field_sets(type_defs);
let call_root_type = resolve_declared_result_type(call_config, lang, CallIr { functions, type_defs });
FieldResolver::new_with_error_aliases(
e2e_config.effective_fields(call_config),
e2e_config.effective_fields_optional(call_config),
e2e_config.effective_result_fields(call_config),
e2e_config.effective_fields_array(call_config),
&HashSet::new(),
&HashMap::new(),
)
.with_php_getter_map(per_call_getter_map.clone())
.with_display_as_text_fields(e2e_config.effective_fields_display_as_text(call_config).clone())
.with_ir_collection_map(FieldResolver::ir_collection_fields(type_defs), call_root_type.clone())
.with_ir_result_fields(FieldResolver::ir_result_field_facts(type_defs, lang), call_root_type)
.with_ir_fields(ir_reachable_fields, ir_known_excluded_fields, ir_optional_fields)
.with_anchored_optional_paths(fixture.assertions.iter().filter_map(|a| a.field.as_deref()))
}
#[cfg(test)]
#[path = "call_field_resolver/tests.rs"]
mod tests;