Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example_usage/lib/library_source.info.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions source_gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.1.1-wip

- Keep `// GENERATED FILE` comments on the first line.

## 3.1.0

- Prepare to stop using `dart:mirrors`: deprecate `TypeChecker.fromRuntime`.
Expand Down
9 changes: 8 additions & 1 deletion source_gen/lib/src/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,14 @@ String _defaultFormatOutput(String code, Version version) =>

/// Prefixes a dart format width and formats [code].
String _defaultFormatUnit(String code, Version version) {
code = '$dartFormatWidth\n$code';
if (code.startsWith('$defaultFileHeader\n')) {
code =
'$defaultFileHeader\n'
'$dartFormatWidth\n'
'${code.substring(defaultFileHeader.length)}';
} else {
code = '$dartFormatWidth\n$code';
}
return _defaultFormatOutput(code, version);
}

Expand Down
2 changes: 1 addition & 1 deletion source_gen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: source_gen
version: 3.1.0
version: 3.1.1-wip
description: >-
Source code generation builders and utilities for the Dart build system
repository: https://github.com/dart-lang/source_gen/tree/master/source_gen
Expand Down
10 changes: 5 additions & 5 deletions source_gen/test/builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1058,8 +1058,8 @@ final int foo = 42
''';

const _testGenPartContent = '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

part of 'test_lib.dart';

Expand All @@ -1072,8 +1072,8 @@ part of 'test_lib.dart';
''';

const _testGenPartContentForLibrary = '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

part of 'test_lib.dart';

Expand All @@ -1085,8 +1085,8 @@ part of 'test_lib.dart';
''';

const _testGenStandaloneContent = '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

// **************************************************************************
// CommentGenerator
Expand All @@ -1097,8 +1097,8 @@ $dartFormatWidth
''';

const _testGenPartContentForClassesAndLibrary = '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

part of 'test_lib.dart';

Expand All @@ -1112,8 +1112,8 @@ part of 'test_lib.dart';
''';

const _testGenNoLibrary = '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

part of 'test_lib.dart';

Expand Down
6 changes: 3 additions & 3 deletions source_gen/test/generator_for_annotation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ void main() {
_inputMap,
outputs: {
'a|lib/file.g.dart': '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

// **************************************************************************
// Generator: Repeating
Expand Down Expand Up @@ -150,8 +150,8 @@ main() {}''',
},
outputs: {
'a|lib/file.g.dart': '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

// **************************************************************************
// Generator: Deprecated
Expand Down Expand Up @@ -195,8 +195,8 @@ $dartFormatWidth
},
outputs: {
'a|lib/file.g.dart': '''
$dartFormatWidth
// GENERATED CODE - DO NOT MODIFY BY HAND
$dartFormatWidth

// **************************************************************************
// Generator: Deprecated
Expand Down
Loading