saveForExtension method

Future<void> saveForExtension({
  1. required ExtensionElement extElement,
  2. required ElementAnnotation annotation,
  3. required CompilationUnit compilationUnit,
  4. required ExtensionDeclaration extAstNode,
  5. required PubspecData pubspecData,
  6. required File extFile,
  7. required TestRunInfo testRunInfo,
})

Implementation

Future<void> saveForExtension(
    {required ExtensionElement extElement,
    required ElementAnnotation annotation,
    required CompilationUnit compilationUnit,
    required ExtensionDeclaration extAstNode,
    required PubspecData pubspecData,
    required File extFile,
    required TestRunInfo testRunInfo}) async {
  final List<String> excludedMethods = annotation.excludeMethods;
  final fileImport =
      'package:${pubspecData.packageName}/${PathUtils.relatetiveLibFilePath(extFile.path)}';

  final methodAstNodes = await extElement.getMethodDeclarations;

  List<Future> saveFutures = [];
  for (int i = 0; i < methodAstNodes.entries.length; i++) {
    final method = methodAstNodes.entries.elementAt(i);
    saveFutures.add(_saveTestsForMethod(
        method: method,
        compilationUnit: compilationUnit,
        extAstNode: extAstNode,
        fileImport: fileImport,
        excludedMethods: excludedMethods,
        subjectFile: extFile,
        testRunInfo: testRunInfo,
        className: extElement.displayName,
        methodAstNodes: methodAstNodes));
  }
  await Future.wait(saveFutures);
}