typeDescriptorCode function
Implementation
String typeDescriptorCode(DartType type, ArtifactBuilder builder) {
String typeName = getTypeName(type);
builder.registerDef("\$AT<$typeName>");
bool isEnumType = false;
String enumTypeName = "";
if (type is InterfaceType && type.element is EnumElement) {
isEnumType = true;
enumTypeName = type.element.name ?? "";
}
String ctor = "${builder.applyDefsF("\$AT<$typeName>")}";
if (isEnumType) {
builder.registerDef(enumTypeName);
return "$ctor.e(()=>${builder.applyDefsF(enumTypeName)}.values)";
}
if (type is InterfaceType && type.typeArguments.isNotEmpty) {
List<String> typeArguments = <String>[];
for (DartType arg in type.typeArguments) {
typeArguments.add(typeDescriptorCode(arg, builder));
}
return "$ctor([${typeArguments.join(",")}])";
}
return "$ctor()";
}