Support assert in initializer list experiment. (#639)
Fix #522.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a2b581..78e0483 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
# 1.0.7-dev
-* Fix call to analyzer API
+* Fix call to analyzer API.
+* Support assert in initializer list experimental syntax (#522).
# 1.0.6
diff --git a/lib/src/dart_formatter.dart b/lib/src/dart_formatter.dart
index 2e75e62..22d0a6a 100644
--- a/lib/src/dart_formatter.dart
+++ b/lib/src/dart_formatter.dart
@@ -103,7 +103,7 @@
// Parse it.
var parser = new Parser(stringSource, errorListener);
- parser.parseGenericMethods = true;
+ parser.enableAssertInitializer = true;
AstNode node;
if (source.isCompilationUnit) {
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index bd4da53..8f2ecb3 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -171,22 +171,17 @@
builder.endSpan();
}
- // TODO(rnystrom): Type annotate once analyzer publishes a version with the
- // new AST type.
- // TODO(rnystrom): Test.
- visitAssertInitializer(node) {
- _simpleStatement(node, () {
- token(node.assertKeyword);
+ visitAssertInitializer(AssertInitializer node) {
+ token(node.assertKeyword);
- var arguments = <Expression>[node.condition];
- if (node.message != null) arguments.add(node.message);
+ var arguments = <Expression>[node.condition];
+ if (node.message != null) arguments.add(node.message);
- builder.nestExpression();
- var visitor = new ArgumentListVisitor.forArguments(
- this, node.leftParenthesis, node.rightParenthesis, arguments);
- visitor.visit();
- builder.unnest();
- });
+ builder.nestExpression();
+ var visitor = new ArgumentListVisitor.forArguments(
+ this, node.leftParenthesis, node.rightParenthesis, arguments);
+ visitor.visit();
+ builder.unnest();
}
visitAssertStatement(AssertStatement node) {
diff --git a/pubspec.lock b/pubspec.lock
index e42179e..be4d455 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -6,7 +6,7 @@
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
- version: "0.30.0"
+ version: "0.30.0+2"
ansicolor:
description:
name: ansicolor
@@ -24,7 +24,7 @@
name: async
url: "https://pub.dartlang.org"
source: hosted
- version: "1.13.2"
+ version: "1.13.3"
barback:
description:
name: barback
@@ -54,13 +54,13 @@
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
- version: "0.0.1+2"
+ version: "0.1.1"
collection:
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
- version: "1.14.0"
+ version: "1.14.1"
convert:
description:
name: convert
@@ -78,7 +78,7 @@
name: csslib
url: "https://pub.dartlang.org"
source: hosted
- version: "0.13.5"
+ version: "0.14.0"
front_end:
description:
name: front_end
@@ -102,7 +102,7 @@
name: html
url: "https://pub.dartlang.org"
source: hosted
- version: "0.13.1"
+ version: "0.13.2"
http:
description:
name: http
@@ -150,7 +150,7 @@
name: matcher
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.0+2"
+ version: "0.12.1+1"
meta:
description:
name: meta
@@ -180,7 +180,7 @@
name: package_config
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.0"
+ version: "1.0.1"
package_resolver:
description:
name: package_resolver
@@ -192,7 +192,7 @@
name: path
url: "https://pub.dartlang.org"
source: hosted
- version: "1.4.1"
+ version: "1.4.2"
plugin:
description:
name: plugin
@@ -204,7 +204,7 @@
name: pool
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.0"
+ version: "1.3.1"
pub_semver:
description:
name: pub_semver
@@ -216,7 +216,7 @@
name: scheduled_test
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.11"
+ version: "0.12.11+1"
shelf:
description:
name: shelf
@@ -258,7 +258,7 @@
name: source_span
url: "https://pub.dartlang.org"
source: hosted
- version: "1.3.1"
+ version: "1.4.0"
stack_trace:
description:
name: stack_trace
@@ -276,7 +276,7 @@
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
- version: "1.0.1"
+ version: "1.0.2"
supports_color:
description:
name: supports_color
@@ -294,7 +294,7 @@
name: test
url: "https://pub.dartlang.org"
source: hosted
- version: "0.12.20+12"
+ version: "0.12.20+13"
typed_data:
description:
name: typed_data
@@ -325,18 +325,6 @@
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
- when:
- description:
- name: when
- url: "https://pub.dartlang.org"
- source: hosted
- version: "0.2.0"
- which:
- description:
- name: which
- url: "https://pub.dartlang.org"
- source: hosted
- version: "0.1.3"
yaml:
description:
name: yaml
diff --git a/test/splitting/constructors.unit b/test/splitting/constructors.unit
index 4758102..e013b01 100644
--- a/test/splitting/constructors.unit
+++ b/test/splitting/constructors.unit
@@ -81,4 +81,29 @@
Foo()
: initializer =
function(argument, arg);
+}
+>>> assert in initializer list, short
+class Foo {
+ Foo() : assert(1), assert(2);
+}
+<<<
+class Foo {
+ Foo()
+ : assert(1),
+ assert(2);
+}
+>>> assert in initializer list, long
+class Foo {
+ Foo() : assert(function(argument, argument, argument)), assert(function(argument, function(argument, argument, argument), argument));
+}
+<<<
+class Foo {
+ Foo()
+ : assert(function(argument,
+ argument, argument)),
+ assert(function(
+ argument,
+ function(argument, argument,
+ argument),
+ argument));
}
\ No newline at end of file