getGenerateContent method

String getGenerateContent(
  1. ConstantReader annotation
)

Implementation

String getGenerateContent(ConstantReader annotation) {
  String target = annotation.peek('target')?.stringValue ?? '';
  if (target.isNotEmpty) {
    /// 指定了生成目标类名,单独生成对应文件
    Template tpl = Template(ApiUtilTpl.tpl);
    String content = tpl.renderString({
      'imports': imports,
      'className': target,
      'targetClassName': 'ApiUtils',
      'functions': functions,
    });
    imports.clear();
    functions.clear();
    importMap.clear();
    return content;
  }
  /// 仅搜集注解信息,在extension注解中生成文件
  return '';
}