getSerializedTypes method

Future<Set<Element>> getSerializedTypes(
  1. BuildStep step,
  2. IRSerializableLibrary irLib
)

Implementation

Future<Set<Element>> getSerializedTypes(BuildStep step, IRSerializableLibrary irLib) async {
  await tryInitializeBuiltInterop(step);
  var importUri = Uri.parse(irLib.import);
  var assetId = AssetId.resolve(importUri);
  var library = await step.resolver.libraryFor(assetId);
  var possibleTypes = getClassCandidates(library);
  bool fullMatch(RegExp matcher, String str) {
    return matcher
        .allMatches(str)
        .any((element) => element.start == 0 && element.end == str.length);
  }
  if (irLib.exclude != null) {
    possibleTypes = possibleTypes.where((element) => !irLib.exclude!
        .any((test) => fullMatch(test, element.queryableUri))).toSet();
  }
  if (irLib.include != null) {
    possibleTypes = possibleTypes.where((element) => irLib.include!
        .any((test) => fullMatch(test, element.queryableUri))).toSet();
  }
  return possibleTypes;
}