Skip to content

Commit

Permalink
Merge pull request #905 from dart-lang/blank-line-after-script
Browse files Browse the repository at this point in the history
Blank line after script
  • Loading branch information
munificent authored Mar 19, 2020
2 parents 8cd12c3 + 79784cc commit 2fbd00e
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/regression/0000/0089.unit
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions test/regression/0500/0513.unit
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
library x;
<<<
#!script

library x;
>>>
#!script

library x;
<<<
#!script

library x;
48 changes: 48 additions & 0 deletions test/regression/0700/0782.unit
Original file line number Diff line number Diff line change
@@ -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.
44 changes: 43 additions & 1 deletion test/whitespace/script.unit
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
library foo;
<<<
#!script

library foo;
>>> multiple lines between script and library
#!script
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -58,4 +65,39 @@ import 'foo';
/* comment */
<<<
#!script
/* comment */

/* 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;

0 comments on commit 2fbd00e

Please sign in to comment.