Skip to content

Commit

Permalink
Ensure a blank line between the directives and the declarations.
Browse files Browse the repository at this point in the history
Fix #1470.
  • Loading branch information
munificent committed May 13, 2024
1 parent bdc8a8c commit 86881b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/src/front_end/ast_node_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
sequence.visit(directive);
}

// Add a blank line between directives and declarations.
sequence.addBlank();

for (var declaration in node.declarations) {
var hasBody = declaration is ClassDeclaration ||
declaration is EnumDeclaration ||
Expand Down Expand Up @@ -312,7 +315,7 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
@override
void visitCompilationUnit(CompilationUnit node) {
throw UnsupportedError(
'CompilationUnit should be handled directly by format().');
'CompilationUnit should be handled directly by run().');
}

@override
Expand Down
2 changes: 1 addition & 1 deletion test/tall/regression/0600/0616.unit
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ main() {
Expect.equals(42, y(l[1]));
}
<<<
### TODO(1470): Should insert blank line after import.
import "package:expect/expect.dart";

int Function() x = () => 42;
int Function(int Function()) y = (int Function() x) => x();
List<int Function()> l = <int Function()>[() => 42, x];
Expand Down
1 change: 1 addition & 0 deletions test/tall/regression/0700/0782.unit
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:io';
#!/usr/bin/env dart

import 'dart:io';

// More code...
>>>
#!/usr/bin/env dart
Expand Down

0 comments on commit 86881b8

Please sign in to comment.