decorate method

  1. @override
TypeInfo decorate(
  1. TypeInfo typeInfo
)
override

Implementation

@override
TypeInfo decorate(TypeInfo typeInfo) {
  final type = typeInfo.type;
  final typeName = type != null ? type.toString() : '';

  typeInfo.typeName = typeName;

  final mixinTypeNames = detectMixinTypeName(typeInfo);
  typeInfo.isWithMixin = mixinTypeNames.isNotEmpty;
  if (typeInfo.isWithMixin) {
    typeInfo.typeName = mixinTypeNames.first;
    typeInfo.mixinTypeName = mixinTypeNames.last;
  }

  typeInfo.isDynamic = typeName == 'dynamic';
  typeInfo.isList = typeName.startsWith('_GrowableList<') ||
      typeName.startsWith('List<') ||
      typeName.startsWith('JSArray<') ||
      isUnmodifiableListView(typeInfo) ||
      isCastList(typeInfo);
  typeInfo.isSet = typeName.startsWith('_Set<') ||
      typeName.startsWith('Set<') ||
      isHashSet(typeInfo);
  typeInfo.isMap = typeName == '_JsonMap' ||
      typeName.startsWith('_Map<') ||
      typeName.startsWith('Map<') ||
      typeName.startsWith('IdentityMap<') ||
      typeName.startsWith('LinkedMap<') ||
      isHashMap(typeInfo) ||
      isLinkedHashMap(typeInfo) ||
      isUnmodifiableMapView(typeInfo);
  typeInfo.isIterable = typeInfo.isList || typeInfo.isSet;

  if (_knownClasses[type] != null) {
    typeInfo.isEnum = _knownClasses[type]!.classMirror.isEnum;
  } else {
    if (_enumValues[type] != null) {
      typeInfo.isEnum = true;
    }
  }

  typeInfo.parameters =
      getTypeParams(typeInfo).map((typeName) => detectTypeByName(typeName));

  typeInfo.genericTypeName = detectGenericTypeName(typeInfo);
  typeInfo.genericType = detectGenericType(typeInfo);

  if (typeInfo.parameters.isNotEmpty) {
    typeInfo.isGeneric = true;
  }

  if (isBigInt(typeInfo)) {
    typeInfo.type = BigInt;
    typeInfo.genericType = BigInt;
  }

  if (isRegExp(typeInfo)) {
    typeInfo.type = RegExp;
    typeInfo.genericType = RegExp;
  }

  if (isUri(typeInfo)) {
    typeInfo.type = Uri;
    typeInfo.genericType = Uri;
  }

  return typeInfo;
}