visitDirective method Null safety

  1. @override
StringSink visitDirective(
  1. Directive spec,
  2. [StringSink? output]
)

Implementation

@override
StringSink visitDirective(Directive spec, [StringSink? output]) {
  output ??= StringBuffer();
  switch (spec.type) {
    case DirectiveType.import:
      output.write('import ');
      break;
    case DirectiveType.export:
      output.write('export ');
      break;
    case DirectiveType.part:
      output.write('part ');
      break;
    case DirectiveType.partOf:
      output.write('part of ');
      break;
  }
  output.write("'${spec.url}'");
  if (spec.as != null) {
    if (spec.deferred) {
      output.write(' deferred ');
    }
    output.write(' as ${spec.as}');
  }
  if (spec.show.isNotEmpty) {
    output
      ..write(' show ')
      ..writeAll(spec.show, ', ');
  } else if (spec.hide.isNotEmpty) {
    output
      ..write(' hide ')
      ..writeAll(spec.hide, ', ');
  }
  output.write(';');
  return output;
}