Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
move back to just supporting empty lines to represent separation betw…
Browse files Browse the repository at this point in the history
…een comments
  • Loading branch information
devoncarew committed Nov 30, 2023
1 parent ee59ca7 commit 5f0ee18
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/src/emitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class DartEmitter extends Object

if (spec.comments.isNotEmpty) {
spec.comments
.map((line) => line == null ? '' : '// $line')
.map((line) => line.isEmpty ? '' : '// $line')
.forEach(output.writeln);
output.writeln();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/specs/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class Library
///
/// Adding a `null` String to this list will insert a blank line between
/// groups of comments.
BuiltList<String?> get comments;
BuiltList<String> get comments;

/// A list of analysis issues to ignore (`ignore_for_file: ...`).
BuiltList<String> get ignoreForFile;
Expand Down Expand Up @@ -61,7 +61,7 @@ abstract class LibraryBuilder
ListBuilder<Spec> body = ListBuilder<Spec>();
ListBuilder<Directive> directives = ListBuilder<Directive>();

ListBuilder<String?> comments = ListBuilder<String?>();
ListBuilder<String> comments = ListBuilder<String>();
ListBuilder<String> ignoreForFile = ListBuilder<String>();
String? name;
}
6 changes: 3 additions & 3 deletions lib/src/specs/library.g.dart

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

25 changes: 1 addition & 24 deletions test/specs/library_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,6 @@ void main() {
});

test('should emit a source file with multiple leading comments', () {
expect(
Library(
(b) => b
..comments.addAll([
'Generated by foo!',
null,
'Avoid editing by hand.',
])
..body.add(
Class((b) => b..name = 'Foo'),
),
),
equalsDart(r'''
// Generated by foo!
// Avoid editing by hand.
class Foo { }
''', DartEmitter(allocator: Allocator())),
);
});

test('should emit a source file with some empty leading comments', () {
expect(
Library(
(b) => b
Expand All @@ -68,7 +45,7 @@ void main() {
),
equalsDart(r'''
// Generated by foo!
//
// Avoid editing by hand.
class Foo { }
Expand Down

0 comments on commit 5f0ee18

Please sign in to comment.