Skip to content

Commit 1618f54

Browse files
authored
Ensure a blank line between the directives and the declarations. (#1480)
Fix #1470.
1 parent bdc8a8c commit 1618f54

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

lib/src/front_end/ast_node_visitor.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
9595
sequence.visit(directive);
9696
}
9797

98+
// Add a blank line between directives and declarations.
99+
sequence.addBlank();
100+
98101
for (var declaration in node.declarations) {
99102
var hasBody = declaration is ClassDeclaration ||
100103
declaration is EnumDeclaration ||
@@ -312,7 +315,7 @@ class AstNodeVisitor extends ThrowingAstVisitor<void> with PieceFactory {
312315
@override
313316
void visitCompilationUnit(CompilationUnit node) {
314317
throw UnsupportedError(
315-
'CompilationUnit should be handled directly by format().');
318+
'CompilationUnit should be handled directly by run().');
316319
}
317320

318321
@override

test/tall/regression/0600/0616.unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ main() {
77
Expect.equals(42, y(l[1]));
88
}
99
<<<
10-
### TODO(1470): Should insert blank line after import.
1110
import "package:expect/expect.dart";
11+
1212
int Function() x = () => 42;
1313
int Function(int Function()) y = (int Function() x) => x();
1414
List<int Function()> l = <int Function()>[() => 42, x];

test/tall/regression/0700/0782.unit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:io';
77
#!/usr/bin/env dart
88

99
import 'dart:io';
10+
1011
// More code...
1112
>>>
1213
#!/usr/bin/env dart

0 commit comments

Comments
 (0)