generate method

  1. @override
void generate(
  1. StringSink sink,
  2. PigeonOptions options,
  3. Root root,
  4. FileType fileType,
)
override

Write the generated code described in root to sink using the options.

Implementation

@override
void generate(
    StringSink sink, PigeonOptions options, Root root, FileType fileType) {
  final ObjcOptions objcOptions = options.objcOptions ?? const ObjcOptions();
  final ObjcOptions objcOptionsWithHeader = objcOptions.merge(ObjcOptions(
    fileSpecificClassNameComponent: options.objcSourceOut
            ?.split('/')
            .lastOrNull
            ?.split('.')
            .firstOrNull ??
        '',
    copyrightHeader: options.copyrightHeader != null
        ? _lineReader(
            path.posix.join(options.basePath ?? '', options.copyrightHeader))
        : null,
  ));
  final OutputFileOptions<ObjcOptions> outputFileOptions =
      OutputFileOptions<ObjcOptions>(
          fileType: fileType, languageOptions: objcOptionsWithHeader);
  const ObjcGenerator generator = ObjcGenerator();
  generator.generate(
    outputFileOptions,
    root,
    sink,
    dartPackageName: options.getPackageName(),
  );
}