Skip to content

Commit a581aa6

Browse files
authored
Small fix to newlines when formatting is disabled, prepare for release (dart-lang/source_gen#332)
1 parent 49b49ac commit a581aa6

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

source_gen/source_gen/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.8.1+2
2+
3+
* Eliminate redundant new lines in the core builder. These were almost removed
4+
by running the default formatter. Now the unformatted code more closely
5+
matches the default output.
6+
17
## 0.8.1+1
28

39
* Support `package:analyzer` `0.32.0`.

source_gen/source_gen/lib/src/builder.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,19 @@ class _Builder extends Builder {
105105
// TODO: Upgrade to error in a future breaking change?
106106
log.warning('Missing "part \'$part\';".');
107107
}
108+
contentBuffer.writeln();
108109
contentBuffer.writeln('part of $name;');
109110
contentBuffer.writeln();
110111
}
111112

112113
for (var output in generatedOutputs) {
113114
contentBuffer
114-
..writeln('')
115+
..writeln()
115116
..writeln(_headerLine)
116117
..writeln('// Generator: ${output.generator}')
117118
..writeln(_headerLine)
118-
..writeln('')
119-
..writeln(output.output);
119+
..writeln()
120+
..write(output.output);
120121
}
121122

122123
var genPartContent = contentBuffer.toString();
@@ -226,7 +227,6 @@ Stream<GeneratedOutput> _generate(LibraryElement library,
226227
final _formatter = new DartFormatter();
227228

228229
const defaultFileHeader = '''// GENERATED CODE - DO NOT MODIFY BY HAND
229-
230230
''';
231231

232232
final _headerLine = '// '.padRight(77, '*');

source_gen/source_gen/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: source_gen
2-
version: 0.8.1+1
2+
version: 0.8.1+2
33
author: Dart Team <misc@dartlang.org>
44
description: Automated source code generation for Dart.
55
homepage: https://github.com/dart-lang/source_gen

source_gen/source_gen/test/builder_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void main() {
152152
generateFor: new Set.from(['$_pkgName|lib/a.dart']),
153153
outputs: {
154154
'$_pkgName|lib/a.g.dart':
155-
decodedMatches(startsWith('$_customHeader\npart of')),
155+
decodedMatches(startsWith('$_customHeader\n\npart of')),
156156
});
157157
});
158158

0 commit comments

Comments
 (0)