readProjectStyle method

AFGeneratedFile readProjectStyle(
  1. List<String> projectPath, {
  2. AFSourceTemplateInsertions? extend,
  3. Map<AFSourceTemplateInsertion, Object>? insertions,
})

Reads the specified project sytle, replacing the specified insertions.

Implementation

AFGeneratedFile readProjectStyle(
  List<String> projectPath, {
    AFSourceTemplateInsertions? extend,
    Map<AFSourceTemplateInsertion, Object>? insertions
  })  {
  var fullInsert = this.coreInsertions;
  if(insertions != null) {
    fullInsert = fullInsert.reviseAugment(insertions);
  }
  if(extend != null) {
    fullInsert = fullInsert.reviseAugment(extend.insertions);
  }

  // we need to find the template for this path.
  final templateOrig = generator.definitions.templates.findEmbeddedTemplateFile(projectPath);
  if(templateOrig == null) {
    throw AFException("No template found at ${joinAll(projectPath)}");
  }

  final generated = AFGeneratedFile.fromTemplate(
    context: this,
    projectPath: projectPath,
    template: templateOrig,
    action: AFGeneratedFileAction.skip
  );
  generated.performInsertions(this, fullInsert);
  return generated;
}