MetadataV14Expander constructor

MetadataV14Expander(
  1. List types
)

Implementation

MetadataV14Expander(List<dynamic> types) {
  final id2Portable = types
      .map((e) => (e as Map<String, dynamic>).toJson())
      .toList(growable: false);

  for (var item in id2Portable) {
    final primitive = item['type']?['def']?['Primitive'];
    if (primitive != null) {
      registeredSiType[item['id']] = primitive;
    }
  }
  for (var item in id2Portable) {
    final id = item['id'];
    final one = item['type'];
    if (item['type']?['def']?['Variant'] != null) {
      if (one['path'].length >= 2) {
        if (['Call'].contains(one['path'].last)) {
          registeredSiType[id] = 'Call';
          continue;
        }
        if ('Event' == one['path'].last) {
          registeredSiType[id] = 'Event';
          continue;
        }
        if (one['path'].last == 'Era') {
          registeredSiType[id] = 'Era';
          continue;
        }
      }
    }
  }
  for (var item in id2Portable) {
    if (item['type']['path'].length > 1 &&
        item['type']['path'][0] == 'primitive_types') {
      _fetchTypeName(item['id'], item, id2Portable);
    }
  }
  for (var item in id2Portable) {
    if (item['type']['path'].length > 1 &&
        item['type']['path'][0] == 'sp_core') {
      _fetchTypeName(item['id'], item, id2Portable);
    }
  }
  for (var item in id2Portable) {
    _fetchTypeName(item['id'], item, id2Portable);
  }
}