normalizeType method
Normalize AbstractType by replacing any (nested Type) with the instance scanned by the analyzer.
Implementation
AbstractType normalizeType(
Set<EnumType> enumTypes,
Set<CustomType> customTypes,
) {
final customTypeOrNull =
customTypes.firstBy((type) => type.className == className);
if (customTypeOrNull != null) {
return customTypeOrNull;
}
final enumTypeOrNull =
enumTypes.firstBy((type) => type.className == className);
if (enumTypeOrNull != null) {
return enumTypeOrNull;
}
if (this is ListType) {
final listType = this as ListType;
final childType = listType.child.normalizeType(enumTypes, customTypes);
return listType.nullable
? NullableListType(childType)
: ListType(childType);
}
if (this is MapType) {
final mapType = this as MapType;
final keyType = mapType.key.normalizeType(enumTypes, customTypes);
final valueType = mapType.value.normalizeType(enumTypes, customTypes);
return mapType.nullable
? NullableMapType(key: keyType, value: valueType)
: MapType(key: keyType, value: valueType);
}
return this;
}