typeRefOf function

CobaltTypeRef typeRefOf(
  1. DartType type
)

Implementation

CobaltTypeRef typeRefOf(DartType type) {
  final element = type.element;
  return CobaltTypeRef(
    name: element?.displayName ?? type.getDisplayString(),
    import: element?.library?.uri.toString(),
    typeArguments: [
      if (type is InterfaceType)
        for (final argument in type.typeArguments) typeRefOf(argument),
    ],
    isNullable: type.nullabilitySuffix == NullabilitySuffix.question,
  );
}