visitEnum method Null safety

  1. @override
StringSink visitEnum(
  1. Enum spec,
  2. [StringSink? output]
)

Implementation

@override
StringSink visitEnum(Enum spec, [StringSink? output]) {
  final out = output ??= StringBuffer();
  spec.docs.forEach(out.writeln);
  spec.annotations.forEach((a) => visitAnnotation(a, out));
  out.writeln('enum ${spec.name} {');
  spec.values.forEach((v) {
    v.docs.forEach(out.writeln);
    v.annotations.forEach((a) => visitAnnotation(a, out));
    out.write(v.name);
    if (v != spec.values.last) {
      out.writeln(',');
    }
  });
  out.writeln('}');
  return out;
}