diff --git a/CHANGELOG.md b/CHANGELOG.md index 9265c5e8..e6daef97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,10 @@ * Add `--fix-single-cascade-statements`. * Correctly handle `var` in `--fix-function-typedefs` (#826). * Preserve leading indentation in fixed doc comments (#821). +* Add `--verbose` to hide advanced options in `--help` output * Add `--verbose` to hide advanced options in `--help` output. * Split outer nested control flow elements (#869). +* Always place a blank line after script tags (#782). # 1.3.3 diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart index caeffe94..0214e98c 100644 --- a/lib/src/source_visitor.dart +++ b/lib/src/source_visitor.dart @@ -2433,7 +2433,7 @@ class SourceVisitor extends ThrowingAstVisitor { // come at the top of the file, we don't have to worry about preceding // comments or whitespace. _writeText(node.scriptTag.lexeme.trim(), node.offset); - newline(); + twoNewlines(); } @override diff --git a/test/regression/0000/0089.unit b/test/regression/0000/0089.unit index 512d57e6..ac8f80f5 100644 --- a/test/regression/0000/0089.unit +++ b/test/regression/0000/0089.unit @@ -5,6 +5,7 @@ // BSD-style license that can be found in the LICENSE file. <<< #!/usr/bin/env dart + // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. \ No newline at end of file diff --git a/test/regression/0500/0513.unit b/test/regression/0500/0513.unit index 2aaa4a9d..4f5874fc 100644 --- a/test/regression/0500/0513.unit +++ b/test/regression/0500/0513.unit @@ -5,6 +5,7 @@ library x; <<< #!script + library x; >>> #!script @@ -12,4 +13,5 @@ library x; library x; <<< #!script + library x; \ No newline at end of file diff --git a/test/regression/0700/0782.unit b/test/regression/0700/0782.unit new file mode 100644 index 00000000..b4f2262b --- /dev/null +++ b/test/regression/0700/0782.unit @@ -0,0 +1,48 @@ +>>> +#!/usr/bin/env dart + +import 'dart:io'; +// More code... +<<< +#!/usr/bin/env dart + +import 'dart:io'; +// More code... +>>> +#!/usr/bin/env dart + +void main() {} +<<< +#!/usr/bin/env dart + +void main() {} +>>> +#!/usr/bin/env dart + +/// dartdoc comment. +<<< +#!/usr/bin/env dart + +/// dartdoc comment. +>>> +#!/usr/bin/env dart + +var someGlobal = 0; +<<< +#!/usr/bin/env dart + +var someGlobal = 0; +>>> +#!/usr/bin/env dart +import 'dart:io'; +<<< +#!/usr/bin/env dart + +import 'dart:io'; +>>> +#!/usr/bin/env dart +// Normal comment. +<<< +#!/usr/bin/env dart + +// Normal comment. \ No newline at end of file diff --git a/test/whitespace/script.unit b/test/whitespace/script.unit index cd84ba1c..cf0f9c6a 100644 --- a/test/whitespace/script.unit +++ b/test/whitespace/script.unit @@ -4,6 +4,7 @@ library foo; <<< #!script + library foo; >>> multiple lines between script and library #!script @@ -13,12 +14,14 @@ library foo; library foo; <<< #!script + library foo; >>> one line between script and import #!script import 'foo'; <<< #!script + import 'foo'; >>> multiple lines between script and import #!script @@ -28,12 +31,14 @@ import 'foo'; import 'foo'; <<< #!script + import 'foo'; >>> one line between script and line comment #!script // comment <<< #!script + // comment >>> multiple lines between script and line comment #!script @@ -43,12 +48,14 @@ import 'foo'; // comment <<< #!script + // comment >>> one line between script and block comment #!script /* comment */ <<< #!script + /* comment */ >>> multiple lines between script and block comment #!script @@ -58,4 +65,39 @@ import 'foo'; /* comment */ <<< #!script -/* comment */ \ No newline at end of file + +/* comment */ +>>> one line between script and class +#!script +class C {} +<<< +#!script + +class C {} +>>> multiple lines between script and class +#!script + + + +class C {} +<<< +#!script + +class C {} +>>> one line between script and variable +#!script +var x; +<<< +#!script + +var x; +>>> multiple lines between script and variable +#!script + + + +var x; +<<< +#!script + +var x; \ No newline at end of file