visitField method

  1. @override
StringSink visitField(
  1. Field spec, [
  2. StringSink? output
])
inherited

Implementation

@override
StringSink visitField(Field spec, [StringSink? output]) {
  output ??= StringBuffer();
  spec.docs.forEach(output.writeln);
  for (var a in spec.annotations) {
    visitAnnotation(a, output);
  }
  if (spec.static) {
    output.write('static ');
  }
  if (spec.late && _useNullSafetySyntax) {
    output.write('late ');
  }
  if (spec.external) {
    output.write('external ');
  }
  switch (spec.modifier) {
    case FieldModifier.var$:
      if (spec.type == null) {
        output.write('var ');
      }
      break;
    case FieldModifier.final$:
      output.write('final ');
      break;
    case FieldModifier.constant:
      output.write('const ');
      break;
  }
  if (spec.type != null) {
    spec.type!.type.accept(this, output);
    output.write(' ');
  }
  output.write(spec.name);
  if (spec.assignment != null) {
    output.write(' = ');
    startConstCode(spec.modifier == FieldModifier.constant, () {
      spec.assignment!.accept(this, output);
    });
  }
  output.writeln(';');
  return output;
}