Skip to content

Commit cc5eff5

Browse files
committed
misc(Generator): simplify how the source generator is printed in source
If `toString` on a generator ends in `Generator` output this: // ********************************************************************* // CommentGenerator // ********************************************************************* Instead of this: // ********************************************************************* // Generator: CommentGenerator // *********************************************************************
1 parent 2565372 commit cc5eff5

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

source_gen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.8.2
2+
3+
* Simplification to the output of generator names in header sections.
4+
15
## 0.8.1+3
26

37
* More redundant new lines elimination.

source_gen/lib/src/generated_output.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ class GeneratedOutput {
2323
: this.output = _outputFromError(error);
2424

2525
@override
26-
String toString() => 'Generator: $generator';
26+
String toString() {
27+
var output = generator.toString();
28+
if (output.endsWith('Generator')) {
29+
return output;
30+
}
31+
return 'Generator: $output';
32+
}
2733
}
2834

2935
String _outputFromError(Object error) {

source_gen/test/builder_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ const _testGenPartContent = r'''// GENERATED CODE - DO NOT MODIFY BY HAND
273273
part of test_lib;
274274
275275
// **************************************************************************
276-
// Generator: CommentGenerator
276+
// CommentGenerator
277277
// **************************************************************************
278278
279279
// Code for "class Person"
@@ -286,7 +286,7 @@ const _testGenPartContentForLibrary =
286286
part of test_lib;
287287
288288
// **************************************************************************
289-
// Generator: CommentGenerator
289+
// CommentGenerator
290290
// **************************************************************************
291291
292292
// Code for "test_lib"
@@ -295,7 +295,7 @@ part of test_lib;
295295
const _testGenStandaloneContent = r'''// GENERATED CODE - DO NOT MODIFY BY HAND
296296
297297
// **************************************************************************
298-
// Generator: CommentGenerator
298+
// CommentGenerator
299299
// **************************************************************************
300300
301301
// Code for "class Person"
@@ -308,7 +308,7 @@ const _testGenPartContentForClassesAndLibrary =
308308
part of test_lib;
309309
310310
// **************************************************************************
311-
// Generator: CommentGenerator
311+
// CommentGenerator
312312
// **************************************************************************
313313
314314
// Code for "test_lib"
@@ -321,7 +321,7 @@ const _testGenPartContentError = r'''// GENERATED CODE - DO NOT MODIFY BY HAND
321321
part of test_lib;
322322
323323
// **************************************************************************
324-
// Generator: CommentGenerator
324+
// CommentGenerator
325325
// **************************************************************************
326326
327327
// Error: Don't use classes with the word 'Error' in the name
@@ -336,7 +336,7 @@ const _testGenNoLibrary = r'''// GENERATED CODE - DO NOT MODIFY BY HAND
336336
part of 'test_lib.dart';
337337
338338
// **************************************************************************
339-
// Generator: CommentGenerator
339+
// CommentGenerator
340340
// **************************************************************************
341341
342342
// Code for "class A"

0 commit comments

Comments
 (0)