Fix a couple of bugs in the analyzer forest implementation
Change-Id: Iff246ba92976bab87b643ee9e96efa8f1db0cccb
Reviewed-on: https://dart-review.googlesource.com/57715
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/fasta/ast_building_factory.dart b/pkg/analyzer/lib/src/fasta/ast_building_factory.dart
index 699f9e3..9ea0e70 100644
--- a/pkg/analyzer/lib/src/fasta/ast_building_factory.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_building_factory.dart
@@ -103,7 +103,9 @@
Statement breakStatement(
Token breakKeyword, Identifier label, Token semicolon) =>
astFactory.breakStatement(
- breakKeyword, astFactory.simpleIdentifier(label.token), semicolon);
+ breakKeyword,
+ label == null ? null : astFactory.simpleIdentifier(label.token),
+ semicolon);
@override
kernel.Arguments castArguments(Arguments arguments) {
@@ -169,7 +171,9 @@
Statement continueStatement(
Token continueKeyword, Identifier label, Token semicolon) =>
astFactory.continueStatement(
- continueKeyword, astFactory.simpleIdentifier(label.token), semicolon);
+ continueKeyword,
+ label == null ? null : astFactory.simpleIdentifier(label.token),
+ semicolon);
@override
Generator<Expression, Statement, Arguments> deferredAccessGenerator(
@@ -436,7 +440,7 @@
astFactory.mapLiteralEntry(key, colon, value);
@override
- List mapEntryList(int length) => <MapLiteralEntry>[];
+ List mapEntryList(int length) => new List<MapLiteralEntry>(length);
@override
Expression notExpression(Expression operand, Token operator) =>
diff --git a/pkg/analyzer/test/generated/parser_forest_test.dart b/pkg/analyzer/test/generated/parser_forest_test.dart
index f3cd289..08f9778 100644
--- a/pkg/analyzer/test/generated/parser_forest_test.dart
+++ b/pkg/analyzer/test/generated/parser_forest_test.dart
@@ -492,6 +492,7 @@
@failingTest
void test_assignmentExpression_indexExpression() {
super.test_assignmentExpression_indexExpression();
+ dart2Failure();
}
@failingTest
@@ -795,11 +796,6 @@
}
@failingTest
- void test_breakOutsideOfLoop_breakInDoStatement() {
- super.test_breakOutsideOfLoop_breakInDoStatement();
- }
-
- @failingTest
void test_breakOutsideOfLoop_breakInForStatement() {
super.test_breakOutsideOfLoop_breakInForStatement();
}
@@ -815,11 +811,6 @@
}
@failingTest
- void test_breakOutsideOfLoop_breakInWhileStatement() {
- super.test_breakOutsideOfLoop_breakInWhileStatement();
- }
-
- @failingTest
void test_breakOutsideOfLoop_functionExpression_inALoop() {
super.test_breakOutsideOfLoop_functionExpression_inALoop();
}
@@ -920,11 +911,6 @@
}
@failingTest
- void test_continueOutsideOfLoop_continueInDoStatement() {
- super.test_continueOutsideOfLoop_continueInDoStatement();
- }
-
- @failingTest
void test_continueOutsideOfLoop_continueInForStatement() {
super.test_continueOutsideOfLoop_continueInForStatement();
}
@@ -940,11 +926,6 @@
}
@failingTest
- void test_continueOutsideOfLoop_continueInWhileStatement() {
- super.test_continueOutsideOfLoop_continueInWhileStatement();
- }
-
- @failingTest
void test_continueOutsideOfLoop_functionExpression_inALoop() {
super.test_continueOutsideOfLoop_functionExpression_inALoop();
}
@@ -2588,6 +2569,7 @@
@failingTest
void test_parseAssignableExpression_expression_index() {
super.test_parseAssignableExpression_expression_index();
+ dart2Failure();
}
@failingTest
@@ -2596,11 +2578,6 @@
}
@failingTest
- void test_parseAssignableExpression_identifier() {
- super.test_parseAssignableExpression_identifier();
- }
-
- @failingTest
void test_parseAssignableExpression_identifier_args_dot() {
super.test_parseAssignableExpression_identifier_args_dot();
}
@@ -2623,11 +2600,6 @@
}
@failingTest
- void test_parseAssignableExpression_identifier_index() {
- super.test_parseAssignableExpression_identifier_index();
- }
-
- @failingTest
void test_parseAssignableExpression_identifier_question_dot() {
super.test_parseAssignableExpression_identifier_question_dot();
}
@@ -2653,11 +2625,6 @@
}
@failingTest
- void test_parseAssignableSelector_none() {
- super.test_parseAssignableSelector_none();
- }
-
- @failingTest
void test_parseAssignableSelector_question_dot() {
super.test_parseAssignableSelector_question_dot();
}
@@ -3060,11 +3027,6 @@
}
@failingTest
- void test_parseListOrMapLiteral_map_noType() {
- super.test_parseListOrMapLiteral_map_noType();
- }
-
- @failingTest
void test_parseListOrMapLiteral_map_type() {
super.test_parseListOrMapLiteral_map_type();
}
@@ -3087,31 +3049,11 @@
}
@failingTest
- void test_parseMapLiteral_multiple() {
- super.test_parseMapLiteral_multiple();
- }
-
- @failingTest
- void test_parseMapLiteral_single() {
- super.test_parseMapLiteral_single();
- }
-
- @failingTest
void test_parseMapLiteralEntry_complex() {
super.test_parseMapLiteralEntry_complex();
}
@failingTest
- void test_parseMapLiteralEntry_int() {
- super.test_parseMapLiteralEntry_int();
- }
-
- @failingTest
- void test_parseMapLiteralEntry_string() {
- super.test_parseMapLiteralEntry_string();
- }
-
- @failingTest
void test_parseMultiplicativeExpression_normal() {
super.test_parseMultiplicativeExpression_normal();
}
@@ -3137,11 +3079,6 @@
}
@failingTest
- void test_parsePostfixExpression_none_indexExpression() {
- super.test_parsePostfixExpression_none_indexExpression();
- }
-
- @failingTest
void test_parsePostfixExpression_none_methodInvocation() {
super.test_parsePostfixExpression_none_methodInvocation();
}
@@ -3183,11 +3120,6 @@
}
@failingTest
- void test_parsePrefixedIdentifier_noPrefix() {
- super.test_parsePrefixedIdentifier_noPrefix();
- }
-
- @failingTest
void test_parsePrefixedIdentifier_prefix() {
super.test_parsePrefixedIdentifier_prefix();
}
@@ -3214,11 +3146,6 @@
}
@failingTest
- void test_parsePrimaryExpression_identifier() {
- super.test_parsePrimaryExpression_identifier();
- }
-
- @failingTest
void test_parsePrimaryExpression_listLiteral_typed() {
super.test_parsePrimaryExpression_listLiteral_typed();
}
@@ -3324,16 +3251,6 @@
}
@failingTest
- void test_parseSimpleIdentifier_builtInIdentifier() {
- super.test_parseSimpleIdentifier_builtInIdentifier();
- }
-
- @failingTest
- void test_parseSimpleIdentifier_normalIdentifier() {
- super.test_parseSimpleIdentifier_normalIdentifier();
- }
-
- @failingTest
void test_parseStringLiteral_endsWithInterpolation() {
super.test_parseStringLiteral_endsWithInterpolation();
}
@@ -5029,16 +4946,6 @@
}
@failingTest
- void test_parseBreakStatement_noLabel() {
- super.test_parseBreakStatement_noLabel();
- }
-
- @failingTest
- void test_parseContinueStatement_noLabel() {
- super.test_parseContinueStatement_noLabel();
- }
-
- @failingTest
void test_parseForStatement_each_await() {
super.test_parseForStatement_each_await();
}
@@ -5149,11 +5056,6 @@
}
@failingTest
- void test_parseNonLabeledStatement_const_map_nonEmpty() {
- super.test_parseNonLabeledStatement_const_map_nonEmpty();
- }
-
- @failingTest
void test_parseNonLabeledStatement_const_object() {
super.test_parseNonLabeledStatement_const_object();
}
diff --git a/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart b/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart
index aaf8164..fc243e5 100644
--- a/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart
+++ b/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart
@@ -173,8 +173,16 @@
bool inAsync: false,
bool inCatchBlock: false}) {
// TODO(brianwilkerson) Check error codes.
- return _parse(source, (parser, token) => parser.parseExpression(token),
+ Object result = _parse(
+ source, (parser, token) => parser.parseExpression(token),
inAsync: inAsync, inCatchBlock: inCatchBlock);
+ if (result is Generator) {
+ result = (result as Generator).buildForEffect();
+ }
+ if (result is! Expression) {
+ throw new StateError('Expected Expression, found ${result.runtimeType}');
+ }
+ return result;
}
@override