@@ -76,19 +76,21 @@ class DartEmitter extends Object
76
76
/// May specify an [Allocator] to use for references and imports,
77
77
/// otherwise uses [Allocator.none] which never prefixes references and will
78
78
/// 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;
84
84
85
85
/// 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
+ );
92
94
93
95
static bool _isLambdaBody (Code ? code) =>
94
96
code is ToCodeExpression && ! code.isStatement;
@@ -145,13 +147,17 @@ class DartEmitter extends Object
145
147
out
146
148
..write (' with ' )
147
149
..writeAll (
148
- spec.mixins.map <StringSink >((m) => m.type.accept (this )), ',' );
150
+ spec.mixins.map <StringSink >((m) => m.type.accept (this )),
151
+ ',' ,
152
+ );
149
153
}
150
154
if (spec.implements .isNotEmpty) {
151
155
out
152
156
..write (' implements ' )
153
157
..writeAll (
154
- spec.implements .map <StringSink >((m) => m.type.accept (this )), ',' );
158
+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
159
+ ',' ,
160
+ );
155
161
}
156
162
out.write (' {' );
157
163
for (var c in spec.constructors) {
@@ -188,7 +194,9 @@ class DartEmitter extends Object
188
194
out
189
195
..write (' implements ' )
190
196
..writeAll (
191
- spec.implements .map <StringSink >((m) => m.type.accept (this )), ',' );
197
+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
198
+ ',' ,
199
+ );
192
200
}
193
201
out.write (' {' );
194
202
for (var f in spec.fields) {
@@ -201,8 +209,11 @@ class DartEmitter extends Object
201
209
}
202
210
203
211
@override
204
- StringSink visitConstructor (Constructor spec, String clazz,
205
- [StringSink ? output]) {
212
+ StringSink visitConstructor (
213
+ Constructor spec,
214
+ String clazz, [
215
+ StringSink ? output,
216
+ ]) {
206
217
output ?? = StringBuffer ();
207
218
spec.docs.forEach (output.writeln);
208
219
for (var a in spec.annotations) {
@@ -342,7 +353,9 @@ class DartEmitter extends Object
342
353
out
343
354
..write (' implements ' )
344
355
..writeAll (
345
- spec.implements .map <StringSink >((m) => m.type.accept (this )), ',' );
356
+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
357
+ ',' ,
358
+ );
346
359
}
347
360
348
361
out.writeln (' {' );
@@ -360,7 +373,9 @@ class DartEmitter extends Object
360
373
}
361
374
362
375
void _visitRepresentationDeclaration (
363
- RepresentationDeclaration spec, StringSink out) {
376
+ RepresentationDeclaration spec,
377
+ StringSink out,
378
+ ) {
364
379
spec.docs.forEach (out.writeln);
365
380
for (var a in spec.annotations) {
366
381
visitAnnotation (a, out);
@@ -509,7 +524,8 @@ class DartEmitter extends Object
509
524
Directive ? previous;
510
525
if (directives.any ((d) => d.as ? .startsWith ('_' ) ?? false )) {
511
526
output.writeln (
512
- '// ignore_for_file: no_leading_underscores_for_library_prefixes' );
527
+ '// ignore_for_file: no_leading_underscores_for_library_prefixes' ,
528
+ );
513
529
}
514
530
for (final directive in directives) {
515
531
if (_newLineBetween (orderDirectives, previous, directive)) {
@@ -543,15 +559,17 @@ class DartEmitter extends Object
543
559
out.write ('>' );
544
560
}
545
561
out.write ('(' );
546
- final needsTrailingComma = spec.requiredParameters.length +
562
+ final needsTrailingComma =
563
+ spec.requiredParameters.length +
547
564
spec.optionalParameters.length +
548
565
spec.namedRequiredParameters.length +
549
566
spec.namedParameters.length >
550
567
1 ;
551
568
visitAll <Reference >(spec.requiredParameters, out, (spec) {
552
569
spec.accept (this , out);
553
570
});
554
- final hasNamedParameters = spec.namedRequiredParameters.isNotEmpty ||
571
+ final hasNamedParameters =
572
+ spec.namedRequiredParameters.isNotEmpty ||
555
573
spec.namedParameters.isNotEmpty;
556
574
if (spec.requiredParameters.isNotEmpty &&
557
575
(needsTrailingComma ||
@@ -610,8 +628,9 @@ class DartEmitter extends Object
610
628
out.write (', ' );
611
629
}
612
630
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
+ ) {
615
634
entry.value.accept (this , out);
616
635
out.write (' ${entry .key }' );
617
636
});
@@ -811,8 +830,10 @@ class DartEmitter extends Object
811
830
}
812
831
813
832
@override
814
- StringSink visitTypeParameters (Iterable <Reference > specs,
815
- [StringSink ? output]) {
833
+ StringSink visitTypeParameters (
834
+ Iterable <Reference > specs, [
835
+ StringSink ? output,
836
+ ]) {
816
837
output ?? = StringBuffer ();
817
838
if (specs.isNotEmpty) {
818
839
output
@@ -836,13 +857,17 @@ class DartEmitter extends Object
836
857
out
837
858
..write (' with ' )
838
859
..writeAll (
839
- spec.mixins.map <StringSink >((m) => m.type.accept (this )), ', ' );
860
+ spec.mixins.map <StringSink >((m) => m.type.accept (this )),
861
+ ', ' ,
862
+ );
840
863
}
841
864
if (spec.implements .isNotEmpty) {
842
865
out
843
866
..write (' implements ' )
844
867
..writeAll (
845
- spec.implements .map <StringSink >((m) => m.type.accept (this )), ', ' );
868
+ spec.implements .map <StringSink >((m) => m.type.accept (this )),
869
+ ', ' ,
870
+ );
846
871
}
847
872
out.write (' { ' );
848
873
for (var v in spec.values) {
@@ -855,15 +880,18 @@ class DartEmitter extends Object
855
880
out.write ('.${v .constructorName }' );
856
881
}
857
882
visitTypeParameters (v.types.map ((r) => r.type), out);
858
- final takesArguments = v.constructorName != null ||
883
+ final takesArguments =
884
+ v.constructorName != null ||
859
885
v.arguments.isNotEmpty ||
860
886
v.namedArguments.isNotEmpty;
861
887
if (takesArguments) {
862
888
out.write ('(' );
863
889
}
864
890
if (v.arguments.isNotEmpty) {
865
891
out.writeAll (
866
- v.arguments.map <StringSink >((arg) => arg.accept (this )), ', ' );
892
+ v.arguments.map <StringSink >((arg) => arg.accept (this )),
893
+ ', ' ,
894
+ );
867
895
}
868
896
if (v.arguments.isNotEmpty && v.namedArguments.isNotEmpty) {
869
897
out.write (', ' );
0 commit comments