@@ -76,19 +76,21 @@ class DartEmitter extends Object
7676 /// May specify an [Allocator] to use for references and imports,
7777 /// otherwise uses [Allocator.none] which never prefixes references and will
7878 /// not automatically emit import directives.
79- DartEmitter (
80- { this .allocator = Allocator .none,
81- this .orderDirectives = false ,
82- bool useNullSafetySyntax = false })
83- : _useNullSafetySyntax = useNullSafetySyntax;
79+ DartEmitter ({
80+ this .allocator = Allocator .none,
81+ this .orderDirectives = false ,
82+ bool useNullSafetySyntax = false ,
83+ }) : _useNullSafetySyntax = useNullSafetySyntax;
8484
8585 /// Creates a new instance of [DartEmitter] with simple automatic imports.
86- factory DartEmitter .scoped (
87- {bool orderDirectives = false , bool useNullSafetySyntax = false }) =>
88- DartEmitter (
89- allocator: Allocator .simplePrefixing (),
90- orderDirectives: orderDirectives,
91- useNullSafetySyntax: useNullSafetySyntax);
86+ factory DartEmitter .scoped ({
87+ bool orderDirectives = false ,
88+ bool useNullSafetySyntax = false ,
89+ }) => DartEmitter (
90+ allocator: Allocator .simplePrefixing (),
91+ orderDirectives: orderDirectives,
92+ useNullSafetySyntax: useNullSafetySyntax,
93+ );
9294
9395 static bool _isLambdaBody (Code ? code) =>
9496 code is ToCodeExpression && ! code.isStatement;
@@ -145,13 +147,17 @@ class DartEmitter extends Object
145147 out
146148 ..write (' with ' )
147149 ..writeAll (
148- spec.mixins.map <StringSink >((m) => m.type.accept (this )), ',' );
150+ spec.mixins.map <StringSink >((m) => m.type.accept (this )),
151+ ',' ,
152+ );
149153 }
150154 if (spec.implements .isNotEmpty) {
151155 out
152156 ..write (' implements ' )
153157 ..writeAll (
154- spec.implements .map <StringSink >((m) => m.type.accept (this )), ',' );
158+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
159+ ',' ,
160+ );
155161 }
156162 out.write (' {' );
157163 for (var c in spec.constructors) {
@@ -188,7 +194,9 @@ class DartEmitter extends Object
188194 out
189195 ..write (' implements ' )
190196 ..writeAll (
191- spec.implements .map <StringSink >((m) => m.type.accept (this )), ',' );
197+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
198+ ',' ,
199+ );
192200 }
193201 out.write (' {' );
194202 for (var f in spec.fields) {
@@ -201,8 +209,11 @@ class DartEmitter extends Object
201209 }
202210
203211 @override
204- StringSink visitConstructor (Constructor spec, String clazz,
205- [StringSink ? output]) {
212+ StringSink visitConstructor (
213+ Constructor spec,
214+ String clazz, [
215+ StringSink ? output,
216+ ]) {
206217 output ?? = StringBuffer ();
207218 spec.docs.forEach (output.writeln);
208219 for (var a in spec.annotations) {
@@ -342,7 +353,9 @@ class DartEmitter extends Object
342353 out
343354 ..write (' implements ' )
344355 ..writeAll (
345- spec.implements .map <StringSink >((m) => m.type.accept (this )), ',' );
356+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
357+ ',' ,
358+ );
346359 }
347360
348361 out.writeln (' {' );
@@ -360,7 +373,9 @@ class DartEmitter extends Object
360373 }
361374
362375 void _visitRepresentationDeclaration (
363- RepresentationDeclaration spec, StringSink out) {
376+ RepresentationDeclaration spec,
377+ StringSink out,
378+ ) {
364379 spec.docs.forEach (out.writeln);
365380 for (var a in spec.annotations) {
366381 visitAnnotation (a, out);
@@ -509,7 +524,8 @@ class DartEmitter extends Object
509524 Directive ? previous;
510525 if (directives.any ((d) => d.as ? .startsWith ('_' ) ?? false )) {
511526 output.writeln (
512- '// ignore_for_file: no_leading_underscores_for_library_prefixes' );
527+ '// ignore_for_file: no_leading_underscores_for_library_prefixes' ,
528+ );
513529 }
514530 for (final directive in directives) {
515531 if (_newLineBetween (orderDirectives, previous, directive)) {
@@ -543,15 +559,17 @@ class DartEmitter extends Object
543559 out.write ('>' );
544560 }
545561 out.write ('(' );
546- final needsTrailingComma = spec.requiredParameters.length +
562+ final needsTrailingComma =
563+ spec.requiredParameters.length +
547564 spec.optionalParameters.length +
548565 spec.namedRequiredParameters.length +
549566 spec.namedParameters.length >
550567 1 ;
551568 visitAll <Reference >(spec.requiredParameters, out, (spec) {
552569 spec.accept (this , out);
553570 });
554- final hasNamedParameters = spec.namedRequiredParameters.isNotEmpty ||
571+ final hasNamedParameters =
572+ spec.namedRequiredParameters.isNotEmpty ||
555573 spec.namedParameters.isNotEmpty;
556574 if (spec.requiredParameters.isNotEmpty &&
557575 (needsTrailingComma ||
@@ -610,8 +628,9 @@ class DartEmitter extends Object
610628 out.write (', ' );
611629 }
612630 out.write ('{' );
613- visitAll <MapEntry <String , Reference >>(spec.namedFieldTypes.entries, out,
614- (entry) {
631+ visitAll <MapEntry <String , Reference >>(spec.namedFieldTypes.entries, out, (
632+ entry,
633+ ) {
615634 entry.value.accept (this , out);
616635 out.write (' ${entry .key }' );
617636 });
@@ -811,8 +830,10 @@ class DartEmitter extends Object
811830 }
812831
813832 @override
814- StringSink visitTypeParameters (Iterable <Reference > specs,
815- [StringSink ? output]) {
833+ StringSink visitTypeParameters (
834+ Iterable <Reference > specs, [
835+ StringSink ? output,
836+ ]) {
816837 output ?? = StringBuffer ();
817838 if (specs.isNotEmpty) {
818839 output
@@ -836,13 +857,17 @@ class DartEmitter extends Object
836857 out
837858 ..write (' with ' )
838859 ..writeAll (
839- spec.mixins.map <StringSink >((m) => m.type.accept (this )), ', ' );
860+ spec.mixins.map <StringSink >((m) => m.type.accept (this )),
861+ ', ' ,
862+ );
840863 }
841864 if (spec.implements .isNotEmpty) {
842865 out
843866 ..write (' implements ' )
844867 ..writeAll (
845- spec.implements .map <StringSink >((m) => m.type.accept (this )), ', ' );
868+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
869+ ', ' ,
870+ );
846871 }
847872 out.write (' { ' );
848873 for (var v in spec.values) {
@@ -855,15 +880,18 @@ class DartEmitter extends Object
855880 out.write ('.${v .constructorName }' );
856881 }
857882 visitTypeParameters (v.types.map ((r) => r.type), out);
858- final takesArguments = v.constructorName != null ||
883+ final takesArguments =
884+ v.constructorName != null ||
859885 v.arguments.isNotEmpty ||
860886 v.namedArguments.isNotEmpty;
861887 if (takesArguments) {
862888 out.write ('(' );
863889 }
864890 if (v.arguments.isNotEmpty) {
865891 out.writeAll (
866- v.arguments.map <StringSink >((arg) => arg.accept (this )), ', ' );
892+ v.arguments.map <StringSink >((arg) => arg.accept (this )),
893+ ', ' ,
894+ );
867895 }
868896 if (v.arguments.isNotEmpty && v.namedArguments.isNotEmpty) {
869897 out.write (', ' );
0 commit comments