Additional tests in the analyzer_plugin optype_test.dart file, follow up from https://dart-review.googlesource.com/c/sdk/+/80362.
Change-Id: Icc716fd9bc56cfe79a430f60419a0ce89cf1d2ee
Reviewed-on: https://dart-review.googlesource.com/c/80420
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer_plugin/test/src/utilities/completion/optype_test.dart b/pkg/analyzer_plugin/test/src/utilities/completion/optype_test.dart
index b9c030c..f85cb6f 100644
--- a/pkg/analyzer_plugin/test/src/utilities/completion/optype_test.dart
+++ b/pkg/analyzer_plugin/test/src/utilities/completion/optype_test.dart
@@ -50,27 +50,40 @@
constructors: true,
namedArgs: true,
returnValue: true,
- typeNames: true);
+ typeNames: true,
+ functionBody: true);
}
test_ArgumentList_namedParam() async {
// SimpleIdentifier NamedExpression ArgumentList MethodInvocation
// ExpressionStatement
addTestSource('void main() {expect(foo: ^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_ArgumentList_prefixedIdentifier() async {
// SimpleIdentifier PrefixedIdentifier ArgumentList
addTestSource('void main() {expect(aa.^)}');
await assertOpType(
- constructors: true, returnValue: true, typeNames: true, prefixed: true);
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ prefixed: true,
+ functionBody: true);
}
test_ArgumentList_resolved() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addTestSource('void main() {int.parse(^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AsIdentifier() async {
@@ -79,24 +92,37 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_Assert() async {
addTestSource('main() {assert(^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AssertInitializer() async {
addTestSource('class C { C() : assert(^); }');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ constructorBody: true);
}
test_AssignmentExpression_RHS() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('class A {} main() {int a; int b = ^}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AssignmentExpression_type() async {
@@ -115,7 +141,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_AssignmentExpression_type_newline() async {
@@ -133,7 +160,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_AssignmentExpression_type_partial() async {
@@ -152,7 +180,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_AssignmentExpression_type_partial_newline() async {
@@ -170,63 +199,104 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_AwaitExpression() async {
// SimpleIdentifier AwaitExpression ExpressionStatement
addTestSource('main() async {A a; await ^}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AwaitExpression2() async {
addTestSource('main() async {A a; await c^ await}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AwaitExpression3() async {
addTestSource('main() async {A a; await ^ await foo;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AwaitExpression4() async {
addTestSource('main() async {A a; await ^ await bar();}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AwaitExpression_assignment() async {
addTestSource('main() async {A a; int x = await ^}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AwaitExpression_assignment2() async {
addTestSource('main() async {A a; int x = await ^ await foo;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_AwaitExpression_assignment3() async {
addTestSource('main() async {A a; int x = await v^ int y = await foo;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_BinaryExpression_LHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
addTestSource('main() {int a = 1, b = ^ + 2;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_BinaryExpression_RHS() async {
// SimpleIdentifier BinaryExpression VariableDeclaration
// VariableDeclarationList VariableDeclarationStatement
addTestSource('main() {int a = 1, b = 2 + ^;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_BinaryExpression_RHS2() async {
// SimpleIdentifier BinaryExpression
addTestSource('main() {if (c < ^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_Block() async {
@@ -244,7 +314,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_Block_catch_2a() async {
@@ -254,7 +325,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_2b() async {
@@ -264,7 +336,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_2c() async {
@@ -274,7 +347,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_2d() async {
@@ -284,7 +358,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_3a() async {
@@ -294,7 +369,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_3b() async {
@@ -304,7 +380,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_3c() async {
@@ -314,7 +391,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_catch_3d() async {
@@ -324,7 +402,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_empty() async {
@@ -334,7 +413,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_Block_identifier_partial() async {
@@ -343,7 +423,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_Block_keyword() async {
@@ -353,7 +434,8 @@
prefixed: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_Block_static() async {
@@ -363,6 +445,37 @@
returnValue: true,
typeNames: true,
staticMethodBody: true,
+ methodBody: true,
+ voidReturn: true);
+ }
+
+ test_Block_in_function() async {
+ addTestSource('foo() {^}');
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true,
+ voidReturn: true);
+ }
+
+ test_Block_in_method() async {
+ addTestSource('class A {foo() {^}}');
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true,
+ voidReturn: true);
+ }
+
+ test_Block_in_constructor() async {
+ addTestSource('class A {A() {^}}');
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ constructorBody: true,
voidReturn: true);
}
@@ -377,7 +490,8 @@
returnValue: true,
typeNames: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ functionBody: true);
}
test_CascadeExpression_selector2() async {
@@ -387,7 +501,8 @@
constructors: true,
returnValue: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ functionBody: true);
}
test_CascadeExpression_selector2_withTrailingReturn() async {
@@ -397,7 +512,8 @@
constructors: true,
returnValue: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ functionBody: true);
}
test_CascadeExpression_target() async {
@@ -407,7 +523,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_CatchClause_typed() async {
@@ -417,7 +534,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_CatchClause_untyped() async {
@@ -427,7 +545,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_CommentReference() async {
@@ -438,55 +557,88 @@
returnValue: true,
typeNames: true,
voidReturn: true,
+ methodBody: true,
kind: CompletionSuggestionKind.IDENTIFIER);
}
test_ConditionalExpression_elseExpression() async {
// SimpleIdentifier ConditionalExpression ReturnStatement
addTestSource('class C {foo(){var f; {var x;} return a ? T1 : T^}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_ConditionalExpression_elseExpression_empty() async {
// SimpleIdentifier ConditionalExpression ReturnStatement
addTestSource('class C {foo(){var f; {var x;} return a ? T1 : ^}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_ConditionalExpression_partial_thenExpression() async {
// SimpleIdentifier ConditionalExpression ReturnStatement
addTestSource('class C {foo(){var f; {var x;} return a ? T^}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_ConditionalExpression_partial_thenExpression_empty() async {
// SimpleIdentifier ConditionalExpression ReturnStatement
addTestSource('class C {foo(){var f; {var x;} return a ? ^}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_ConditionalExpression_thenExpression() async {
// SimpleIdentifier ConditionalExpression ReturnStatement
addTestSource('class C {foo(){var f; {var x;} return a ? T^ : c}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_DefaultFormalParameter_named_expression() async {
// DefaultFormalParameter FormalParameterList MethodDeclaration
addTestSource('class A {a(blat: ^) { }}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_DoStatement() async {
// SimpleIdentifier DoStatement Block
addTestSource('main() {do{} while(^x);}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_ExpressionFunctionBody() async {
// SimpleIdentifier ExpressionFunctionBody FunctionExpression
addTestSource('m(){[1].forEach((x)=>^x);}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_ExpressionStatement() async {
@@ -496,13 +648,18 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_ForEachStatement() async {
// SimpleIdentifier ForEachStatement Block
addTestSource('main() {for(z in ^zs) {}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_ForEachStatement_body_typed() async {
@@ -512,7 +669,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_ForEachStatement_body_untyped() async {
@@ -522,40 +680,61 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_ForEachStatement_iterable() async {
// SimpleIdentifier ForEachStatement Block
addTestSource('main(args) {for (int foo in ^) {}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_FormalParameter_partialType() async {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(b.^ f) { }}');
await assertOpType(
- constructors: true, returnValue: true, typeNames: true, prefixed: true);
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ prefixed: true,
+ methodBody: true);
}
test_FormalParameter_partialType2() async {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(b.z^ f) { }}');
await assertOpType(
- constructors: true, returnValue: true, typeNames: true, prefixed: true);
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ prefixed: true,
+ methodBody: true);
}
test_FormalParameter_partialType3() async {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(b.^) { }}');
await assertOpType(
- constructors: true, returnValue: true, typeNames: true, prefixed: true);
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ prefixed: true,
+ methodBody: true);
}
test_ForStatement_condition() async {
// SimpleIdentifier ForStatement
addTestSource('main() {for (int index = 0; i^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_ForStatement_updaters() async {
@@ -566,13 +745,18 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_ForStatement_updaters_prefix_expression() async {
// SimpleIdentifier PrefixExpression ForStatement
addTestSource('main() {for (int index = 0; index < 10; ++i^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_IfStatement() async {
@@ -582,36 +766,57 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_IfStatement_condition() async {
// SimpleIdentifier IfStatement Block BlockFunctionBody
addTestSource('main(){var a; if (^)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_IfStatement_empty() async {
// SimpleIdentifier PrefixIdentifier IfStatement
addTestSource('class A {foo() {A a; if (^) something}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_IfStatement_invocation() async {
// SimpleIdentifier PrefixIdentifier IfStatement
addTestSource('main() {var a; if (a.^) something}');
await assertOpType(
- constructors: true, returnValue: true, typeNames: true, prefixed: true);
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ prefixed: true,
+ functionBody: true);
}
test_IndexExpression() async {
addTestSource('class C {foo(){var f; {var x;} f[^]}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_IndexExpression2() async {
addTestSource('class C {foo(){var f; {var x;} f[T^]}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_InstanceCreationExpression_keyword() async {
@@ -621,7 +826,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_InstanceCreationExpression_keyword2() async {
@@ -631,50 +837,76 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_InterpolationExpression() async {
// SimpleIdentifier InterpolationExpression StringInterpolation
addTestSource('main() {String name; print("hello \$^");}');
- await assertOpType(constructors: true, returnValue: true);
+ await assertOpType(
+ constructors: true, returnValue: true, functionBody: true);
}
test_InterpolationExpression_block() async {
// SimpleIdentifier InterpolationExpression StringInterpolation
addTestSource('main() {String name; print("hello \${n^}");}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_InterpolationExpression_prefix_selector() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
addTestSource('main() {String name; print("hello \${name.^}");}');
await assertOpType(
- constructors: true, returnValue: true, typeNames: true, prefixed: true);
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ prefixed: true,
+ functionBody: true);
}
test_InterpolationExpression_prefix_target() async {
// SimpleIdentifier PrefixedIdentifier InterpolationExpression
addTestSource('main() {String name; print("hello \${nam^e.length}");}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_IsExpression_target() async {
// IfStatement Block BlockFunctionBody
addTestSource('main(){var a; if (^ is A)}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_Literal_list() async {
// ']' ListLiteral ArgumentList MethodInvocation
addTestSource('main() {var Some; print([^]);}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_Literal_list2() async {
// SimpleIdentifier ListLiteral ArgumentList MethodInvocation
addTestSource('main() {var Some; print([S^]);}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_MapLiteralEntry() async {
@@ -707,13 +939,18 @@
returnValue: true,
typeNames: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ methodBody: true);
}
test_PostfixExpression() async {
// SimpleIdentifier PostfixExpression ForStatement
addTestSource('int x = 0; main() {ax+^+;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_PrefixedIdentifier_class_const() async {
@@ -724,7 +961,8 @@
returnValue: true,
typeNames: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ functionBody: true);
}
test_PrefixedIdentifier_class_imported() async {
@@ -735,7 +973,8 @@
returnValue: true,
typeNames: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ functionBody: true);
}
test_PrefixedIdentifier_prefix() async {
@@ -745,7 +984,8 @@
constructors: true,
typeNames: true,
returnValue: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_PropertyAccess_expression() async {
@@ -756,7 +996,8 @@
returnValue: true,
typeNames: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ methodBody: true);
}
test_PropertyAccess_selector() async {
@@ -767,13 +1008,18 @@
returnValue: true,
typeNames: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ methodBody: true);
}
test_ReturnStatement() async {
// ReturnStatement Block
addTestSource('f() { var vvv = 42; return ^ }');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_SwitchCase_between() async {
@@ -783,19 +1029,28 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_SwitchCase_expression1() async {
// SimpleIdentifier SwitchCase SwitchStatement
addTestSource('''m() {switch (x) {case ^D: return;}}''');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_SwitchCase_expression2() async {
// SimpleIdentifier SwitchCase SwitchStatement
addTestSource('''m() {switch (x) {case ^}}''');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_SwitchDefault_between() async {
@@ -805,7 +1060,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_SwitchStatement_body_end() async {
@@ -815,7 +1071,8 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_SwitchStatement_body_end2() async {
@@ -824,25 +1081,39 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ functionBody: true);
}
test_SwitchStatement_expression1() async {
// SimpleIdentifier SwitchStatement Block
addTestSource('main() {switch(^k) {case 1:{}}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_SwitchStatement_expression2() async {
// SimpleIdentifier SwitchStatement Block
addTestSource('main() {switch(k^) {case 1:{}}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
+//
test_SwitchStatement_expression_empty() async {
// SimpleIdentifier SwitchStatement Block
addTestSource('main() {switch(^) {case 1:{}}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_ThisExpression_block() async {
@@ -857,7 +1128,8 @@
constructors: true,
returnValue: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ methodBody: true);
}
test_ThisExpression_constructor() async {
@@ -870,13 +1142,18 @@
constructors: true,
returnValue: true,
voidReturn: true,
- prefixed: true);
+ prefixed: true,
+ constructorBody: true);
}
test_ThrowExpression() async {
// SimpleIdentifier ThrowExpression ExpressionStatement
addTestSource('main() {throw ^;}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
test_VariableDeclarationStatement_afterSemicolon() async {
@@ -886,27 +1163,40 @@
constructors: true,
returnValue: true,
typeNames: true,
- voidReturn: true);
+ voidReturn: true,
+ methodBody: true);
}
test_VariableDeclarationStatement_RHS() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement
addTestSource('class C {bar(){var f; {var x;} var e = ^}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_VariableDeclarationStatement_RHS_missing_semicolon() async {
// VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement
addTestSource('class C {bar(){var f; {var x;} var e = ^ var g}}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ methodBody: true);
}
test_WhileStatement() async {
// SimpleIdentifier WhileStatement Block
addTestSource('mth() { while (b^) {} }}');
- await assertOpType(constructors: true, returnValue: true, typeNames: true);
+ await assertOpType(
+ constructors: true,
+ returnValue: true,
+ typeNames: true,
+ functionBody: true);
}
@failingTest
@@ -925,7 +1215,7 @@
'main() { new A.b(^); }'
'class A{ A.b({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_constructor_named_resolved_1_1() async {
@@ -934,7 +1224,7 @@
'main() { new A.b(o^); }'
'class A { A.b({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_constructor_resolved_1_0() async {
@@ -943,7 +1233,7 @@
'main() { new A(^); }'
'class A{ A({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_constructor_resolved_1_1() async {
@@ -952,7 +1242,7 @@
'main() { new A(o^); }'
'class A { A({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_factory_named_resolved_1_0() async {
@@ -961,7 +1251,7 @@
'main() { new A.b(^); }'
'class A{ factory A.b({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_factory_named_resolved_1_1() async {
@@ -970,7 +1260,7 @@
'main() { new A.b(o^); }'
'class A { factory A.b({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_factory_resolved_1_0() async {
@@ -979,7 +1269,7 @@
'main() { new A(^); }'
'class A{ factory A({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_factory_resolved_1_1() async {
@@ -988,163 +1278,163 @@
'main() { new A(o^); }'
'class A { factory A({one, two}) {} }',
);
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_method_resolved_1_0() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addTestSource('main() { foo(^);} foo({one, two}) {}');
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_method_resolved_1_1() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addTestSource('main() { foo(o^);} foo({one, two}) {}');
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_ArgumentList_resolved_2_0() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addTestSource('void main() {int.parse("16", ^)}');
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_AsExpression() async {
// SimpleIdentifier TypeName AsExpression
addTestSource('class A {var b; X _c; foo() {var a; (a as ^).foo();}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_AsIdentifier2() async {
addTestSource('class A {var asdf; foo() {A as^}');
- await assertOpType();
+ await assertOpType(methodBody: true);
}
test_AssignmentExpression_name() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('class A {} main() {int a; int ^b = 1;}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, functionBody: true);
}
test_Block_catch_1a() async {
// '}' Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} ^}');
// Only return 'on', 'catch', and 'finally' keywords
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_Block_catch_1b() async {
// [ExpressionStatement 'c'] Block BlockFunctionBody
addTestSource('main() {try {} c^}');
// Only return 'on', 'catch', and 'finally' keywords
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_Block_catch_1c() async {
// [EmptyStatement] Block BlockFunctionBody FunctionExpression
addTestSource('main() {try {} ^;}');
// Only return 'on', 'catch', and 'finally' keywords
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_Block_catch_1d() async {
// [VariableDeclarationStatement 'Foo foo'] Block BlockFunctionBody
addTestSource('main() {try {} ^ Foo foo;}');
// Only return 'on', 'catch', and 'finally' keywords
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_Block_final() async {
addTestSource('main() {final ^}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_Block_final2() async {
addTestSource('main() {final S^ v;}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_Block_final3() async {
addTestSource('main() {final ^ v;}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_Block_final_final() async {
addTestSource('main() {final ^ final S x;}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_Block_final_final2() async {
addTestSource('main() {final S^ final S x;}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_Break_after_label() async {
addTestSource('main() { foo: while (true) { break foo ^ ; } }');
- await assertOpType(/* No valid completions */);
+ await assertOpType(/* No valid completions */ functionBody: true);
}
test_Break_before_label() async {
addTestSource('main() { foo: while (true) { break ^ foo; } }');
- await assertOpType(statementLabel: true);
+ await assertOpType(statementLabel: true, functionBody: true);
}
test_Break_no_label() async {
addTestSource('main() { foo: while (true) { break ^; } }');
- await assertOpType(statementLabel: true);
+ await assertOpType(statementLabel: true, functionBody: true);
}
test_catch_4a1() async {
addTestSource('main() {try {} ^ on SomeException {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_catch_4a2() async {
addTestSource('main() {try {} c^ on SomeException {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_catch_4b1() async {
addTestSource('main() {try {} ^ catch (e) {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_catch_4b2() async {
addTestSource('main() {try {} c^ catch (e) {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_catch_4c1() async {
addTestSource('main() {try {} ^ finally {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_catch_4c2() async {
addTestSource('main() {try {} c^ finally {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_catch_5a() async {
addTestSource('main() {try {} on ^ finally {}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_catch_5b() async {
addTestSource('main() {try {} on E^ finally {}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_CatchClause_onType() async {
// TypeName CatchClause TryStatement
addTestSource('class A {a() {try{var x;} on ^ {}}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_CatchClause_onType_noBrackets() async {
// TypeName CatchClause TryStatement
addTestSource('class A {a() {try{var x;} on ^}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_ClassDeclaration_body() async {
@@ -1180,14 +1470,14 @@
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new X.^}');
- await assertOpType(constructors: true, prefixed: true);
+ await assertOpType(constructors: true, prefixed: true, functionBody: true);
}
test_ConstructorName_name_resolved() async {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new Str^ing.fromCharCodes([]);}');
- await assertOpType(constructors: true);
+ await assertOpType(constructors: true, functionBody: true);
}
test_ConstructorName_nameAndPrefix_resolved() async {
@@ -1197,65 +1487,68 @@
import 'dart:core' as core;
main() {new core.String.from^CharCodes([]);}
''');
- await assertOpType(constructors: true, prefixed: true);
+ await assertOpType(constructors: true, prefixed: true, functionBody: true);
}
test_ConstructorName_resolved() async {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new String.fr^omCharCodes([]);}');
- await assertOpType(constructors: true, prefixed: true);
+ await assertOpType(constructors: true, prefixed: true, functionBody: true);
}
test_ConstructorName_unresolved() async {
// SimpleIdentifier PrefixedIdentifier TypeName ConstructorName
// InstanceCreationExpression
addTestSource('main() {new String.fr^omCharCodes([]);}');
- await assertOpType(constructors: true, prefixed: true);
+ await assertOpType(constructors: true, prefixed: true, functionBody: true);
}
test_Continue_after_label() async {
addTestSource('main() { foo: while (true) { continue foo ^ ; } }');
- await assertOpType(/* No valid completions */);
+ await assertOpType(/* No valid completions */ functionBody: true);
}
test_Continue_before_label() async {
addTestSource('main() { foo: while (true) { continue ^ foo; } }');
- await assertOpType(statementLabel: true, caseLabel: true);
+ await assertOpType(
+ statementLabel: true, caseLabel: true, functionBody: true);
}
test_Continue_no_label() async {
addTestSource('main() { foo: while (true) { continue ^; } }');
- await assertOpType(statementLabel: true, caseLabel: true);
+ await assertOpType(
+ statementLabel: true, caseLabel: true, functionBody: true);
}
test_DoubleLiteral() async {
addTestSource('main() { print(1.2^); }');
- await assertOpType();
+ // TODO expected functionBody: true
+ await assertOpType(functionBody: false);
}
test_ExpressionStatement_name() async {
// ExpressionStatement Block BlockFunctionBody MethodDeclaration
addTestSource('class C {a() {C ^}}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, methodBody: true);
}
test_ExpressionStatement_name_semicolon() async {
// ExpressionStatement Block BlockFunctionBody MethodDeclaration
addTestSource('class C {a() {C ^;}}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, methodBody: true);
}
test_ExpressionStatement_prefixed_name() async {
// ExpressionStatement Block BlockFunctionBody MethodDeclaration
addTestSource('class C {a() {x.Y ^}}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, methodBody: true);
}
test_ExpressionStatement_prefixed_name_semicolon() async {
// ExpressionStatement Block BlockFunctionBody MethodDeclaration
addTestSource('class C {a() {x.Y ^;}}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, methodBody: true);
}
test_ExtendsClause() async {
@@ -1281,59 +1574,59 @@
test_ForEachStatement_loopVariable() async {
// SimpleIdentifier ForEachStatement Block
addTestSource('main(args) {for (^ in args) {}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_ForEachStatement_loopVariable_name() async {
// DeclaredIdentifier ForEachStatement Block
addTestSource('main(args) {for (String ^ in args) {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_ForEachStatement_loopVariable_name2() async {
// DeclaredIdentifier ForEachStatement Block
addTestSource('main(args) {for (String f^ in args) {}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_ForEachStatement_loopVariable_type() async {
// SimpleIdentifier ForEachStatement Block
addTestSource('main(args) {for (^ foo in args) {}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_ForEachStatement_loopVariable_type2() async {
// DeclaredIdentifier ForEachStatement Block
addTestSource('main(args) {for (S^ foo in args) {}}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_FormalParameterList() async {
// FormalParameterList MethodDeclaration
addTestSource('class A {a(^) { }}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_ForStatement_initializer() async {
// SimpleIdentifier ForStatement
addTestSource('main() {List a; for (^)}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_ForStatement_initializer_inKeyword() async {
addTestSource('main() { for (var v i^) }');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_ForStatement_initializer_type() async {
// SimpleIdentifier ForStatement
addTestSource('main() {List a; for (i^ v = 0;)}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_ForStatement_initializer_variableNameEmpty_afterType() async {
addTestSource('main() { for (String ^) }');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, functionBody: true);
}
test_FunctionDeclaration1() async {
@@ -1387,7 +1680,7 @@
addTestSource('''
/// some dartdoc ^
zoo(z) { } String name;''');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_FunctionDeclaration_inLineDocComment2() async {
@@ -1395,7 +1688,7 @@
addTestSource('''
/// some ^dartdoc
zoo(z) { } String name;''');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_FunctionDeclaration_inStarComment() async {
@@ -1413,13 +1706,13 @@
test_FunctionDeclaration_inStarDocComment() async {
// Comment FunctionDeclaration CompilationUnit
addTestSource('/** ^ */ zoo(z) { } String name; ');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_FunctionDeclaration_inStarDocComment2() async {
// Comment FunctionDeclaration CompilationUnit
addTestSource('/** *^/ zoo(z) { } String name;');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_FunctionDeclaration_returnType() async {
@@ -1450,7 +1743,7 @@
addTestSource('''
/// some dartdoc
^ zoo(z) { } String name;''');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_FunctionDeclaration_returnType_afterLineDocComment2() async {
@@ -1458,7 +1751,7 @@
addTestSource('''
/// some dartdoc
^ zoo(z) { } String name;''');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_FunctionDeclaration_returnType_afterStarComment() async {
@@ -1476,25 +1769,25 @@
test_FunctionDeclaration_returnType_afterStarDocComment() async {
// FunctionDeclaration CompilationUnit
addTestSource('/** */ ^ zoo(z) { } String name;');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_FunctionDeclaration_returnType_afterStarDocComment2() async {
// FunctionDeclaration CompilationUnit
addTestSource('/** */^ zoo(z) { } String name;');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_FunctionExpression() async {
// BlockFunctionBody FunctionExpression FunctionDeclaration
addTestSource('main()^ { int b = 2; b++; b. }');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_FunctionExpressionInvocation() async {
// ArgumentList FunctionExpressionInvocation ExpressionStatement
addTestSource('main() { ((x) => x + 7)^(2) }');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_FunctionTypeAlias() async {
@@ -1520,41 +1813,43 @@
test_InstanceCreationExpression() async {
// SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
addTestSource('class C {foo(){var f; {var x;} new ^}}');
- await assertOpType(constructors: true);
+ await assertOpType(constructors: true, methodBody: true);
}
test_InstanceCreationExpression_trailingStmt() async {
// SimpleIdentifier TypeName ConstructorName InstanceCreationExpression
addTestSource('class C {foo(){var f; {var x;} new ^ int x = 7;}}');
- await assertOpType(constructors: true);
+ await assertOpType(constructors: true, methodBody: true);
}
test_IntegerLiteral_inArgumentList() async {
+ // TODO expected functionBody: true
addTestSource('main() { print(1^); }');
- await assertOpType();
+ await assertOpType(functionBody: false);
}
test_IntegerLiteral_inListLiteral() async {
+ // TODO expected functionBody: true
addTestSource('main() { var items = [1^]; }');
- await assertOpType();
+ await assertOpType(functionBody: false);
}
test_IsExpression() async {
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('main() {var x; if (x is ^) { }}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_IsExpression_type_partial() async {
// SimpleIdentifier TypeName IsExpression IfStatement
addTestSource('main(){var a; if (a is Obj^)}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_Literal_string() async {
// SimpleStringLiteral ExpressionStatement Block
addTestSource('class A {a() {"hel^lo"}}');
- await assertOpType();
+ await assertOpType(methodBody: true);
}
test_MethodDeclaration1() async {
@@ -1597,23 +1892,13 @@
await assertOpType();
}
- test_MethodDeclaration_inLineComment4() async {
- // Comment ClassDeclaration CompilationUnit
- addTestSource('''
- class C2 {
- // normal comment
- // normal comment 2^
- zoo(z) { } String name; }''');
- await assertOpType();
- }
-
test_MethodDeclaration_inLineDocComment() async {
// Comment MethodDeclaration ClassDeclaration CompilationUnit
addTestSource('''
class C2 {
/// some dartdoc ^
zoo(z) { } String name; }''');
- await assertOpType();
+ await assertOpType(methodBody: true);
}
test_MethodDeclaration_inLineDocComment2() async {
@@ -1622,7 +1907,7 @@
class C2 {
/// some ^dartdoc
zoo(z) { } String name; }''');
- await assertOpType();
+ await assertOpType(methodBody: true);
}
test_MethodDeclaration_inStarComment() async {
@@ -1640,13 +1925,13 @@
test_MethodDeclaration_inStarDocComment() async {
// Comment MethodDeclaration ClassDeclaration CompilationUnit
addTestSource('class C2 {/** ^ */ zoo(z) { } String name; }');
- await assertOpType();
+ await assertOpType(methodBody: true);
}
test_MethodDeclaration_inStarDocComment2() async {
// Comment MethodDeclaration ClassDeclaration CompilationUnit
addTestSource('class C2 {/** *^/ zoo(z) { } String name; }');
- await assertOpType();
+ await assertOpType(methodBody: true);
}
test_MethodDeclaration_returnType() async {
@@ -1680,7 +1965,7 @@
class C2 {
/// some dartdoc
^ zoo(z) { } String name; }''');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_MethodDeclaration_returnType_afterLineDocComment2() async {
@@ -1689,7 +1974,7 @@
class C2 {
/// some dartdoc
^ zoo(z) { } String name; }''');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_MethodDeclaration_returnType_afterStarComment() async {
@@ -1707,13 +1992,13 @@
test_MethodDeclaration_returnType_afterStarDocComment() async {
// MethodDeclaration ClassDeclaration CompilationUnit
addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_MethodDeclaration_returnType_afterStarDocComment2() async {
// MethodDeclaration ClassDeclaration CompilationUnit
addTestSource('class C2 {/** */^ zoo(z) { } String name; }');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, methodBody: true);
}
test_NamedExpression() async {
@@ -1721,7 +2006,7 @@
main() { f(3, ^); }
void f(int a, {int b}) {}
''');
- await assertOpType(namedArgs: true);
+ await assertOpType(namedArgs: true, functionBody: true);
}
test_OnClause() async {
@@ -1733,91 +2018,92 @@
test_PropertyAccess_noTarget() async {
// SimpleIdentifier PropertyAccess ExpressionStatement
addTestSource('main() {.^}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_PropertyAccess_noTarget2() async {
// SimpleIdentifier PropertyAccess CascadeExpressions
addTestSource('main() {.^.}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_PropertyAccess_noTarget3() async {
// SimpleIdentifier PropertyAccess CascadeExpressions
addTestSource('main() {..^}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
+//
test_SimpleFormalParameter_closure() async {
// SimpleIdentifier SimpleFormalParameter FormalParameterList
addTestSource('mth() { PNGS.sort((String a, Str^) => a.compareTo(b)); }');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SimpleFormalParameter_name1() async {
// SimpleIdentifier SimpleFormalParameter FormalParameterList
addTestSource('m(String na^) {}');
- await assertOpType(typeNames: false);
+ await assertOpType(typeNames: false, functionBody: true);
}
test_SimpleFormalParameter_name2() async {
// SimpleIdentifier SimpleFormalParameter FormalParameterList
addTestSource('m(int first, String na^) {}');
- await assertOpType(typeNames: false);
+ await assertOpType(typeNames: false, functionBody: true);
}
test_SimpleFormalParameter_type_optionalNamed() async {
// SimpleIdentifier DefaultFormalParameter FormalParameterList
addTestSource('m({Str^}) {}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SimpleFormalParameter_type_optionalPositional() async {
// SimpleIdentifier DefaultFormalParameter FormalParameterList
addTestSource('m([Str^]) {}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SimpleFormalParameter_type_withName() async {
// SimpleIdentifier SimpleFormalParameter FormalParameterList
addTestSource('m(Str^ name) {}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SimpleFormalParameter_type_withoutName1() async {
// SimpleIdentifier SimpleFormalParameter FormalParameterList
addTestSource('m(Str^) {}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SimpleFormalParameter_type_withoutName2() async {
// FormalParameterList
addTestSource('m(^) {}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SimpleFormalParameter_type_withoutName3() async {
// SimpleIdentifier SimpleFormalParameter FormalParameterList
addTestSource('m(int first, Str^) {}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_SwitchCase_before() async {
// SwitchCase SwitchStatement Block
addTestSource('main() {switch(k) {^case 1:}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_SwitchDefault_before() async {
// SwitchDefault SwitchStatement Block
addTestSource('main() {switch(k) { ^ default: return;}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_SwitchStatement_body_empty() async {
// Token('}') SwitchStatement Block
addTestSource('main() {switch(k) {^}}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_ThisExpression_constructor_param() async {
@@ -1826,7 +2112,7 @@
class A implements I {
A(this.^) {}
}''');
- await assertOpType(prefixed: true);
+ await assertOpType(prefixed: true, constructorBody: true);
}
test_ThisExpression_constructor_param2() async {
@@ -1835,7 +2121,7 @@
class A implements I {
A(this.f^) {}
}''');
- await assertOpType(prefixed: true);
+ await assertOpType(prefixed: true, constructorBody: true);
}
test_ThisExpression_constructor_param3() async {
@@ -1844,7 +2130,7 @@
class A implements I {
A(this.^f) {}
}''');
- await assertOpType(prefixed: true);
+ await assertOpType(prefixed: true, constructorBody: true);
}
test_ThisExpression_constructor_param4() async {
@@ -1853,7 +2139,7 @@
class A implements I {
A(Str^ this.foo) {}
}''');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, constructorBody: true);
}
test_TopLevelVariableDeclaration_typed_name() async {
@@ -1884,13 +2170,13 @@
test_TypeArgumentList() async {
// SimpleIdentifier BinaryExpression ExpressionStatement
addTestSource('main() { C<^> c; }');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_TypeArgumentList2() async {
// TypeName TypeArgumentList TypeName
addTestSource('main() { C<C^> c; }');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
test_TypeParameter() async {
@@ -1909,27 +2195,27 @@
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('main() {var ^}');
- await assertOpType();
+ await assertOpType(functionBody: true);
}
test_VariableDeclaration_name_hasSome_parameterizedType() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('main() {List<int> m^}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, functionBody: true);
}
test_VariableDeclaration_name_hasSome_simpleType() async {
// SimpleIdentifier VariableDeclaration VariableDeclarationList
// VariableDeclarationStatement Block
addTestSource('main() {String m^}');
- await assertOpType(varNames: true);
+ await assertOpType(varNames: true, functionBody: true);
}
test_VariableDeclarationList_final() async {
// VariableDeclarationList VariableDeclarationStatement Block
addTestSource('main() {final ^}');
- await assertOpType(typeNames: true);
+ await assertOpType(typeNames: true, functionBody: true);
}
}
@@ -1957,6 +2243,9 @@
bool returnValue: false,
bool statementLabel: false,
bool staticMethodBody: false,
+ bool methodBody: false,
+ bool functionBody: false,
+ bool constructorBody: false,
bool typeNames: false,
bool varNames: false,
bool voidReturn: false,
@@ -1983,6 +2272,10 @@
reason: 'voidReturn');
expect(visitor.inStaticMethodBody, staticMethodBody,
reason: 'staticMethodBody');
+ expect(visitor.inMethodBody, methodBody, reason: 'methodBody');
+ expect(visitor.inFunctionBody, functionBody, reason: 'functionBody');
+ expect(visitor.inConstructorBody, constructorBody,
+ reason: 'constructorBody');
expect(visitor.isPrefixed, prefixed, reason: 'prefixed');
expect(visitor.suggestKind, kind, reason: 'suggestion kind');
}