collectMapper method

_InitFileContributions collectMapper(
  1. Map<String, dynamic> mapperData
)

Implementation

_InitFileContributions collectMapper(Map<String, dynamic> mapperData) {
  final className = extractNullableCodeProperty(mapperData, 'className');
  final mapperClassName =
      extractNullableCodeProperty(mapperData, 'mapperClassName');

  if (className == null || mapperClassName == null) {
    return noInitFileContributions;
  }

  // Extract all required custom mappers for this mapper, excluding those that are already providers
  final requiredMapperParameters =
      _extractRequiredMapperParameters(mapperData);
  final parametersByName =
      _indexInitFunctionParameters(requiredMapperParameters);

  // Check if this mapper should be registered globally
  final registerGlobally = mapperData['registerGlobally'] as bool? ?? true;
  final code = _buildCodeInstantiateMapperFromRequired(
      mapperClassName, requiredMapperParameters);

  if (registerGlobally) {
    return (
      [
        _Mapper(
          code: code,
          type: className,
        )
      ],
      parametersByName,
      const <String, String>{}, // No broader imports at mapper level
    );
  }
  return noInitFileContributions;
}