Skip to content

Support optional new/const. #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.0.10

* Support optional `new`/`const` (#652).

# 1.0.9

* Updated tests. No user-facing changes.
Expand Down
2 changes: 1 addition & 1 deletion bin/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:dart_style/src/io.dart';
import 'package:dart_style/src/source_code.dart';

// Note: The following line of code is modified by tool/grind.dart.
const version = "1.0.9";
const version = "1.0.10";

void main(List<String> args) {
var parser = new ArgParser(allowTrailingOptions: true);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/dart_formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class DartFormatter {

// Parse it.
var parser = new Parser(stringSource, errorListener);
parser.enableAssertInitializer = true;
parser.enableOptionalNewAndConst = true;

AstNode node;
if (source.isCompilationUnit) {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/source_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1341,8 +1341,7 @@ class SourceVisitor extends ThrowingAstVisitor {

visitInstanceCreationExpression(InstanceCreationExpression node) {
builder.startSpan();
token(node.keyword);
space();
token(node.keyword, after: space);
builder.startSpan(Cost.constructorName);

// Start the expression nesting for the argument list here, in case this
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.31.1"
version: "0.31.2-alpha.0"
args:
dependency: "direct main"
description:
Expand Down Expand Up @@ -91,7 +91,7 @@ packages:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0-alpha.9"
version: "0.1.0-alpha.10"
glob:
dependency: transitive
description:
Expand Down Expand Up @@ -161,7 +161,7 @@ packages:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0-alpha.9"
version: "0.3.0-alpha.10"
logging:
dependency: transitive
description:
Expand Down
24 changes: 12 additions & 12 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: dart_style
# Note: See tool/grind.dart for how to bump the version.
version: 1.0.9+1
version: 1.0.10
author: Dart Team <misc@dartlang.org>
description: Opinionated, automatic Dart source code formatter.
homepage: https://github.com/dart-lang/dart_style
environment:
sdk: ">=1.8.0 <2.0.0"
sdk: '>=1.8.0 <2.0.0'
dependencies:
analyzer: '>=0.30.0 <0.32.0'
analyzer: ^0.31.2-alpha.0
args: '>=0.12.1 <2.0.0'
path: '>=1.0.0 <2.0.0'
source_span: '>=1.4.0 <2.0.0'
path: ^1.0.0
source_span: ^1.4.0
dev_dependencies:
async: '>=1.0.0 <=3.0.0'
browser: '>=0.10.0 <0.11.0'
grinder: '^0.8.0'
browser: ^0.10.0
grinder: ^0.8.0
js: ^0.6.0
node_preamble: ^1.0.0
pub_semver: '^1.2.3'
test: '>=0.12.0 <0.13.0'
test_descriptor: "^1.0.0"
test_process: "^1.0.0"
yaml: '^2.0.0'
pub_semver: ^1.2.3
test: ^0.12.0
test_descriptor: ^1.0.0
test_process: ^1.0.0
yaml: ^2.0.0
executables:
dartfmt: format
dartformat: format # Allow the old name for compatibility.
Expand Down
6 changes: 5 additions & 1 deletion test/whitespace/type_arguments.stmt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ new Foo<void, void Function()>();
>>> void as a generic method type argument
list.map< void,void Function()>();
<<<
list.map<void, void Function()>();
list.map<void, void Function()>();
>>> named constructor with implicit "new"
C < int ,float> .named(42);
<<<
C<int, float>.named(42);