emit method

  1. @override
void emit(
  1. StringBuffer buffer, {
  2. required InspectionCache cache,
  3. required AppType appType,
  4. Set<String> extraKeywords = const <String>{},
  5. InstantiatedInspectEntry? parentEntry,
})
override

Emits a Dart source for this entry during interface generation.

Implementation

@override
void emit(
  StringBuffer buffer, {
  required InspectionCache cache,
  required AppType appType,
  Set<String> extraKeywords = const <String>{},
  InstantiatedInspectEntry? parentEntry,
}) {
  buffer.writeln("/// ## $name");
  emitDoc(buffer);
  emitSource(buffer);
  final (String returnType, Transform transform) =
      _getTypeStringWithTransform(
    source.signature.return_annotation,
    cache: cache,
    isReturnString: true,
    parentEntry: parentEntry,
  );
  buffer.writeln("$returnType $sanitizedName(");
  final Iterable<Transform> argumentsTransforms =
      emitArguments(buffer, cache: cache, parentEntry: parentEntry);
  buffer.writeln(") => ");
  final StringBuffer callBuffer = StringBuffer()
    ..writeln("getFunction(\"$name\").call(");
  _emitCall(callBuffer, transforms: argumentsTransforms.toList());
  callBuffer.writeln(")");
  buffer.write("${transform(callBuffer.toString())};");
}