visitClass method Null safety

  1. @override
StringSink visitClass(
  1. Class spec,
  2. [StringSink? output]
)

Implementation

@override
StringSink visitClass(Class spec, [StringSink? output]) {
  final out = output ??= StringBuffer();
  spec.docs.forEach(out.writeln);
  spec.annotations.forEach((a) => visitAnnotation(a, out));
  if (spec.abstract) {
    out.write('abstract ');
  }
  out.write('class ${spec.name}');
  visitTypeParameters(spec.types.map((r) => r.type), out);
  if (spec.extend != null) {
    out.write(' extends ');
    spec.extend!.type.accept(this, out);
  }
  if (spec.mixins.isNotEmpty) {
    out
      ..write(' with ')
      ..writeAll(
          spec.mixins.map<StringSink>((m) => m.type.accept(this)), ',');
  }
  if (spec.implements.isNotEmpty) {
    out
      ..write(' implements ')
      ..writeAll(
          spec.implements.map<StringSink>((m) => m.type.accept(this)), ',');
  }
  out.write(' {');
  spec.constructors.forEach((c) {
    visitConstructor(c, spec.name, out);
    out.writeln();
  });
  spec.fields.forEach((f) {
    visitField(f, out);
    out.writeln();
  });
  spec.methods.forEach((m) {
    visitMethod(m, out);
    if (_isLambdaMethod(m)) {
      out.write(';');
    }
    out.writeln();
  });
  out.writeln(' }');
  return out;
}