| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'dart:async'; | |
| 6 | |
| 7 import 'package:analysis_server/src/protocol_server.dart'; | |
| 8 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | |
| 9 import 'package:analysis_server/src/services/completion/dart/optype.dart'; | |
| 10 import 'package:analyzer/src/dart/analysis/driver.dart'; | |
| 11 import 'package:test/test.dart'; | |
| 12 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 13 | |
| 14 import '../../../abstract_context.dart'; | |
| 15 | |
| 16 main() { | |
| 17 defineReflectiveSuite(() { | |
| 18 defineReflectiveTests(OpTypeTest); | |
| 19 }); | |
| 20 } | |
| 21 | |
| 22 @reflectiveTest | |
| 23 class OpTypeTest extends AbstractContextTest { | |
| 24 static const testpath = '/completionTest.dart'; | |
| 25 int completionOffset; | |
| 26 OpType visitor; | |
| 27 | |
| 28 void addTestSource(String content) { | |
| 29 completionOffset = content.indexOf('^'); | |
| 30 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); | |
| 31 int nextOffset = content.indexOf('^', completionOffset + 1); | |
| 32 expect(nextOffset, equals(-1), reason: 'too many ^'); | |
| 33 content = content.substring(0, completionOffset) + | |
| 34 content.substring(completionOffset + 1); | |
| 35 super.addSource(testpath, content); | |
| 36 } | |
| 37 | |
| 38 Future<Null> assertOpType( | |
| 39 {bool caseLabel: false, | |
| 40 bool constructors: false, | |
| 41 bool namedArgs: false, | |
| 42 bool prefixed: false, | |
| 43 bool returnValue: false, | |
| 44 bool statementLabel: false, | |
| 45 bool staticMethodBody: false, | |
| 46 bool typeNames: false, | |
| 47 bool varNames: false, | |
| 48 bool voidReturn: false, | |
| 49 CompletionSuggestionKind kind: | |
| 50 CompletionSuggestionKind.INVOCATION}) async { | |
| 51 AnalysisResult analysisResult = await driver.getResult(testpath); | |
| 52 | |
| 53 CompletionTarget completionTarget = | |
| 54 new CompletionTarget.forOffset(analysisResult.unit, completionOffset); | |
| 55 visitor = new OpType.forCompletion(completionTarget, completionOffset); | |
| 56 | |
| 57 expect(visitor.includeCaseLabelSuggestions, caseLabel, reason: 'caseLabel'); | |
| 58 expect(visitor.includeConstructorSuggestions, constructors, | |
| 59 reason: 'constructors'); | |
| 60 expect(visitor.includeNamedArgumentSuggestions, namedArgs, | |
| 61 reason: 'namedArgs'); | |
| 62 expect(visitor.includeReturnValueSuggestions, returnValue, | |
| 63 reason: 'returnValue'); | |
| 64 expect(visitor.includeStatementLabelSuggestions, statementLabel, | |
| 65 reason: 'statementLabel'); | |
| 66 expect(visitor.includeTypeNameSuggestions, typeNames, reason: 'typeNames'); | |
| 67 expect(visitor.includeVarNameSuggestions, varNames, reason: 'varNames'); | |
| 68 expect(visitor.includeVoidReturnSuggestions, voidReturn, | |
| 69 reason: 'voidReturn'); | |
| 70 expect(visitor.inStaticMethodBody, staticMethodBody, | |
| 71 reason: 'staticMethodBody'); | |
| 72 expect(visitor.isPrefixed, prefixed, reason: 'prefixed'); | |
| 73 expect(visitor.suggestKind, kind, reason: 'suggestion kind'); | |
| 74 } | |
| 75 | |
| 76 test_Annotation() async { | |
| 77 // SimpleIdentifier Annotation MethodDeclaration ClassDeclaration | |
| 78 addTestSource('class C { @A^ }'); | |
| 79 await assertOpType(returnValue: true, typeNames: true); | |
| 80 } | |
| 81 | |
| 82 test_ArgumentList() async { | |
| 83 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 84 addTestSource('void main() {expect(^)}'); | |
| 85 // If "expect()" were resolved, then either namedArgs would be true | |
| 86 // or returnValue and typeNames would be true. | |
| 87 await assertOpType(namedArgs: true, returnValue: true, typeNames: true); | |
| 88 } | |
| 89 | |
| 90 test_ArgumentList_constructor_named_resolved_1_0() async { | |
| 91 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 92 addTestSource( | |
| 93 'main() { new A.b(^); }' | |
| 94 'class A{ A.b({one, two}) {} }', | |
| 95 ); | |
| 96 await assertOpType(namedArgs: true); | |
| 97 } | |
| 98 | |
| 99 test_ArgumentList_constructor_named_resolved_1_1() async { | |
| 100 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 101 addTestSource( | |
| 102 'main() { new A.b(o^); }' | |
| 103 'class A { A.b({one, two}) {} }', | |
| 104 ); | |
| 105 await assertOpType(namedArgs: true); | |
| 106 } | |
| 107 | |
| 108 test_ArgumentList_constructor_resolved_1_0() async { | |
| 109 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 110 addTestSource( | |
| 111 'main() { new A(^); }' | |
| 112 'class A{ A({one, two}) {} }', | |
| 113 ); | |
| 114 await assertOpType(namedArgs: true); | |
| 115 } | |
| 116 | |
| 117 test_ArgumentList_constructor_resolved_1_1() async { | |
| 118 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 119 addTestSource( | |
| 120 'main() { new A(o^); }' | |
| 121 'class A { A({one, two}) {} }', | |
| 122 ); | |
| 123 await assertOpType(namedArgs: true); | |
| 124 } | |
| 125 | |
| 126 test_ArgumentList_factory_named_resolved_1_0() async { | |
| 127 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 128 addTestSource( | |
| 129 'main() { new A.b(^); }' | |
| 130 'class A{ factory A.b({one, two}) {} }', | |
| 131 ); | |
| 132 await assertOpType(namedArgs: true); | |
| 133 } | |
| 134 | |
| 135 test_ArgumentList_factory_named_resolved_1_1() async { | |
| 136 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 137 addTestSource( | |
| 138 'main() { new A.b(o^); }' | |
| 139 'class A { factory A.b({one, two}) {} }', | |
| 140 ); | |
| 141 await assertOpType(namedArgs: true); | |
| 142 } | |
| 143 | |
| 144 test_ArgumentList_factory_resolved_1_0() async { | |
| 145 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 146 addTestSource( | |
| 147 'main() { new A(^); }' | |
| 148 'class A{ factory A({one, two}) {} }', | |
| 149 ); | |
| 150 await assertOpType(namedArgs: true); | |
| 151 } | |
| 152 | |
| 153 test_ArgumentList_factory_resolved_1_1() async { | |
| 154 // ArgumentList InstanceCreationExpression ExpressionStatement Block | |
| 155 addTestSource( | |
| 156 'main() { new A(o^); }' | |
| 157 'class A { factory A({one, two}) {} }', | |
| 158 ); | |
| 159 await assertOpType(namedArgs: true); | |
| 160 } | |
| 161 | |
| 162 test_ArgumentList_method_resolved_1_0() async { | |
| 163 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 164 addTestSource('main() { foo(^);} foo({one, two}) {}'); | |
| 165 await assertOpType(namedArgs: true); | |
| 166 } | |
| 167 | |
| 168 test_ArgumentList_method_resolved_1_1() async { | |
| 169 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 170 addTestSource('main() { foo(o^);} foo({one, two}) {}'); | |
| 171 await assertOpType(namedArgs: true); | |
| 172 } | |
| 173 | |
| 174 test_ArgumentList_namedParam() async { | |
| 175 // SimpleIdentifier NamedExpression ArgumentList MethodInvocation | |
| 176 // ExpressionStatement | |
| 177 addTestSource('void main() {expect(foo: ^)}'); | |
| 178 await assertOpType(returnValue: true, typeNames: true); | |
| 179 } | |
| 180 | |
| 181 test_ArgumentList_prefixedIdentifier() async { | |
| 182 // SimpleIdentifier PrefixedIdentifier ArgumentList | |
| 183 addTestSource('void main() {expect(aa.^)}'); | |
| 184 await assertOpType(returnValue: true, typeNames: true, prefixed: true); | |
| 185 } | |
| 186 | |
| 187 test_ArgumentList_resolved() async { | |
| 188 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 189 addTestSource('void main() {int.parse(^)}'); | |
| 190 await assertOpType(returnValue: true, typeNames: true); | |
| 191 } | |
| 192 | |
| 193 test_ArgumentList_resolved_2_0() async { | |
| 194 // ArgumentList MethodInvocation ExpressionStatement Block | |
| 195 addTestSource('void main() {int.parse("16", ^)}'); | |
| 196 await assertOpType(namedArgs: true); | |
| 197 } | |
| 198 | |
| 199 test_AsExpression() async { | |
| 200 // SimpleIdentifier TypeName AsExpression | |
| 201 addTestSource('class A {var b; X _c; foo() {var a; (a as ^).foo();}'); | |
| 202 await assertOpType(typeNames: true); | |
| 203 } | |
| 204 | |
| 205 test_AsIdentifier() async { | |
| 206 addTestSource('class A {var asdf; foo() {as^}'); | |
| 207 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 208 } | |
| 209 | |
| 210 test_AsIdentifier2() async { | |
| 211 addTestSource('class A {var asdf; foo() {A as^}'); | |
| 212 await assertOpType(); | |
| 213 } | |
| 214 | |
| 215 test_Assert() async { | |
| 216 addTestSource('main() {assert(^)}'); | |
| 217 await assertOpType(returnValue: true, typeNames: true); | |
| 218 } | |
| 219 | |
| 220 test_AssignmentExpression_name() async { | |
| 221 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 222 // VariableDeclarationStatement Block | |
| 223 addTestSource('class A {} main() {int a; int ^b = 1;}'); | |
| 224 await assertOpType(varNames: true); | |
| 225 } | |
| 226 | |
| 227 test_AssignmentExpression_RHS() async { | |
| 228 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 229 // VariableDeclarationStatement Block | |
| 230 addTestSource('class A {} main() {int a; int b = ^}'); | |
| 231 await assertOpType(returnValue: true, typeNames: true); | |
| 232 } | |
| 233 | |
| 234 test_AssignmentExpression_type() async { | |
| 235 // SimpleIdentifier TypeName VariableDeclarationList | |
| 236 // VariableDeclarationStatement Block | |
| 237 addTestSource(''' | |
| 238 main() { | |
| 239 int a; | |
| 240 ^ b = 1;}'''); | |
| 241 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | |
| 242 // the user may be either (1) entering a type for the assignment | |
| 243 // or (2) starting a new statement. | |
| 244 // Consider suggesting only types | |
| 245 // if only spaces separates the 1st and 2nd identifiers. | |
| 246 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 247 } | |
| 248 | |
| 249 test_AssignmentExpression_type_newline() async { | |
| 250 // SimpleIdentifier TypeName VariableDeclarationList | |
| 251 // VariableDeclarationStatement Block | |
| 252 addTestSource(''' | |
| 253 main() { | |
| 254 int a; | |
| 255 ^ | |
| 256 b = 1;}'''); | |
| 257 // Allow non-types preceding an identifier on LHS of assignment | |
| 258 // if newline follows first identifier | |
| 259 // because user is probably starting a new statement | |
| 260 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 261 } | |
| 262 | |
| 263 test_AssignmentExpression_type_partial() async { | |
| 264 // SimpleIdentifier TypeName VariableDeclarationList | |
| 265 // VariableDeclarationStatement Block | |
| 266 addTestSource(''' | |
| 267 main() { | |
| 268 int a; | |
| 269 int^ b = 1;}'''); | |
| 270 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | |
| 271 // the user may be either (1) entering a type for the assignment | |
| 272 // or (2) starting a new statement. | |
| 273 // Consider suggesting only types | |
| 274 // if only spaces separates the 1st and 2nd identifiers. | |
| 275 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 276 } | |
| 277 | |
| 278 test_AssignmentExpression_type_partial_newline() async { | |
| 279 // SimpleIdentifier TypeName VariableDeclarationList | |
| 280 // VariableDeclarationStatement Block | |
| 281 addTestSource(''' | |
| 282 main() { | |
| 283 int a; | |
| 284 i^ | |
| 285 b = 1;}'''); | |
| 286 // Allow non-types preceding an identifier on LHS of assignment | |
| 287 // if newline follows first identifier | |
| 288 // because user is probably starting a new statement | |
| 289 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 290 } | |
| 291 | |
| 292 test_AwaitExpression() async { | |
| 293 // SimpleIdentifier AwaitExpression ExpressionStatement | |
| 294 addTestSource('main() async {A a; await ^}'); | |
| 295 await assertOpType(returnValue: true, typeNames: true); | |
| 296 } | |
| 297 | |
| 298 test_AwaitExpression2() async { | |
| 299 addTestSource('main() async {A a; await c^ await}'); | |
| 300 await assertOpType(returnValue: true, typeNames: true); | |
| 301 } | |
| 302 | |
| 303 test_AwaitExpression3() async { | |
| 304 addTestSource('main() async {A a; await ^ await foo;}'); | |
| 305 await assertOpType(returnValue: true, typeNames: true); | |
| 306 } | |
| 307 | |
| 308 test_AwaitExpression4() async { | |
| 309 addTestSource('main() async {A a; await ^ await bar();}'); | |
| 310 await assertOpType(returnValue: true, typeNames: true); | |
| 311 } | |
| 312 | |
| 313 test_AwaitExpression_assignment() async { | |
| 314 addTestSource('main() async {A a; int x = await ^}'); | |
| 315 await assertOpType(returnValue: true, typeNames: true); | |
| 316 } | |
| 317 | |
| 318 test_AwaitExpression_assignment2() async { | |
| 319 addTestSource('main() async {A a; int x = await ^ await foo;}'); | |
| 320 await assertOpType(returnValue: true, typeNames: true); | |
| 321 } | |
| 322 | |
| 323 test_AwaitExpression_assignment3() async { | |
| 324 addTestSource('main() async {A a; int x = await v^ int y = await foo;}'); | |
| 325 await assertOpType(returnValue: true, typeNames: true); | |
| 326 } | |
| 327 | |
| 328 test_BinaryExpression_LHS() async { | |
| 329 // SimpleIdentifier BinaryExpression VariableDeclaration | |
| 330 // VariableDeclarationList VariableDeclarationStatement | |
| 331 addTestSource('main() {int a = 1, b = ^ + 2;}'); | |
| 332 await assertOpType(returnValue: true, typeNames: true); | |
| 333 } | |
| 334 | |
| 335 test_BinaryExpression_RHS() async { | |
| 336 // SimpleIdentifier BinaryExpression VariableDeclaration | |
| 337 // VariableDeclarationList VariableDeclarationStatement | |
| 338 addTestSource('main() {int a = 1, b = 2 + ^;}'); | |
| 339 await assertOpType(returnValue: true, typeNames: true); | |
| 340 } | |
| 341 | |
| 342 test_BinaryExpression_RHS2() async { | |
| 343 // SimpleIdentifier BinaryExpression | |
| 344 addTestSource('main() {if (c < ^)}'); | |
| 345 await assertOpType(returnValue: true, typeNames: true); | |
| 346 } | |
| 347 | |
| 348 test_Block() async { | |
| 349 // Block BlockFunctionBody MethodDeclaration | |
| 350 addTestSource(''' | |
| 351 class X { | |
| 352 a() { | |
| 353 var f; | |
| 354 localF(int arg1) { } | |
| 355 {var x;} | |
| 356 ^ var r; | |
| 357 } | |
| 358 }'''); | |
| 359 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 360 } | |
| 361 | |
| 362 test_Block_catch_1a() async { | |
| 363 // '}' Block BlockFunctionBody FunctionExpression | |
| 364 addTestSource('main() {try {} ^}'); | |
| 365 // Only return 'on', 'catch', and 'finally' keywords | |
| 366 await assertOpType(); | |
| 367 } | |
| 368 | |
| 369 test_Block_catch_1b() async { | |
| 370 // [ExpressionStatement 'c'] Block BlockFunctionBody | |
| 371 addTestSource('main() {try {} c^}'); | |
| 372 // Only return 'on', 'catch', and 'finally' keywords | |
| 373 await assertOpType(); | |
| 374 } | |
| 375 | |
| 376 test_Block_catch_1c() async { | |
| 377 // [EmptyStatement] Block BlockFunctionBody FunctionExpression | |
| 378 addTestSource('main() {try {} ^;}'); | |
| 379 // Only return 'on', 'catch', and 'finally' keywords | |
| 380 await assertOpType(); | |
| 381 } | |
| 382 | |
| 383 test_Block_catch_1d() async { | |
| 384 // [VariableDeclarationStatement 'Foo foo'] Block BlockFunctionBody | |
| 385 addTestSource('main() {try {} ^ Foo foo;}'); | |
| 386 // Only return 'on', 'catch', and 'finally' keywords | |
| 387 await assertOpType(); | |
| 388 } | |
| 389 | |
| 390 test_Block_catch_2a() async { | |
| 391 // '}' Block BlockFunctionBody FunctionExpression | |
| 392 addTestSource('main() {try {} catch () {} ^}'); | |
| 393 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 394 } | |
| 395 | |
| 396 test_Block_catch_2b() async { | |
| 397 // [ExpressionStatement 'c'] Block BlockFunctionBody | |
| 398 addTestSource('main() {try {} catch () {} c^}'); | |
| 399 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 400 } | |
| 401 | |
| 402 test_Block_catch_2c() async { | |
| 403 // [EmptyStatement] Block BlockFunctionBody FunctionExpression | |
| 404 addTestSource('main() {try {} catch () {} ^;}'); | |
| 405 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 406 } | |
| 407 | |
| 408 test_Block_catch_2d() async { | |
| 409 // [VariableDeclarationStatement 'Foo foo'] Block BlockFunctionBody | |
| 410 addTestSource('main() {try {} catch () {} ^ Foo foo;}'); | |
| 411 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 412 } | |
| 413 | |
| 414 test_Block_catch_3a() async { | |
| 415 // '}' Block BlockFunctionBody FunctionExpression | |
| 416 addTestSource('main() {try {} finally {} ^}'); | |
| 417 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 418 } | |
| 419 | |
| 420 test_Block_catch_3b() async { | |
| 421 // [ExpressionStatement 'c'] Block BlockFunctionBody | |
| 422 addTestSource('main() {try {} finally {} c^}'); | |
| 423 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 424 } | |
| 425 | |
| 426 test_Block_catch_3c() async { | |
| 427 // [EmptyStatement] Block BlockFunctionBody FunctionExpression | |
| 428 addTestSource('main() {try {} finally {} ^;}'); | |
| 429 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 430 } | |
| 431 | |
| 432 test_Block_catch_3d() async { | |
| 433 // [VariableDeclarationStatement 'Foo foo'] Block BlockFunctionBody | |
| 434 addTestSource('main() {try {} finally {} ^ Foo foo;}'); | |
| 435 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 436 } | |
| 437 | |
| 438 test_Block_empty() async { | |
| 439 // Block BlockFunctionBody MethodDeclaration ClassDeclaration | |
| 440 addTestSource('class A extends E implements I with M {a() {^}}'); | |
| 441 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 442 } | |
| 443 | |
| 444 test_Block_final() async { | |
| 445 addTestSource('main() {final ^}'); | |
| 446 await assertOpType(typeNames: true); | |
| 447 } | |
| 448 | |
| 449 test_Block_final2() async { | |
| 450 addTestSource('main() {final S^ v;}'); | |
| 451 await assertOpType(typeNames: true); | |
| 452 } | |
| 453 | |
| 454 test_Block_final3() async { | |
| 455 addTestSource('main() {final ^ v;}'); | |
| 456 await assertOpType(typeNames: true); | |
| 457 } | |
| 458 | |
| 459 test_Block_final_final() async { | |
| 460 addTestSource('main() {final ^ final S x;}'); | |
| 461 await assertOpType(typeNames: true); | |
| 462 } | |
| 463 | |
| 464 test_Block_final_final2() async { | |
| 465 addTestSource('main() {final S^ final S x;}'); | |
| 466 await assertOpType(typeNames: true); | |
| 467 } | |
| 468 | |
| 469 test_Block_identifier_partial() async { | |
| 470 addTestSource('class X {a() {var f; {var x;} D^ var r;} void b() { }}'); | |
| 471 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 472 } | |
| 473 | |
| 474 test_Block_keyword() async { | |
| 475 addTestSource('class C { static C get instance => null; } main() {C.in^}'); | |
| 476 await assertOpType( | |
| 477 prefixed: true, returnValue: true, typeNames: true, voidReturn: true); | |
| 478 } | |
| 479 | |
| 480 test_Block_static() async { | |
| 481 addTestSource('class A {static foo() {^}}'); | |
| 482 await assertOpType( | |
| 483 returnValue: true, | |
| 484 typeNames: true, | |
| 485 staticMethodBody: true, | |
| 486 voidReturn: true); | |
| 487 } | |
| 488 | |
| 489 test_Break_after_label() async { | |
| 490 addTestSource('main() { foo: while (true) { break foo ^ ; } }'); | |
| 491 await assertOpType(/* No valid completions */); | |
| 492 } | |
| 493 | |
| 494 test_Break_before_label() async { | |
| 495 addTestSource('main() { foo: while (true) { break ^ foo; } }'); | |
| 496 await assertOpType(statementLabel: true); | |
| 497 } | |
| 498 | |
| 499 test_Break_no_label() async { | |
| 500 addTestSource('main() { foo: while (true) { break ^; } }'); | |
| 501 await assertOpType(statementLabel: true); | |
| 502 } | |
| 503 | |
| 504 test_CascadeExpression_selector1() async { | |
| 505 // PropertyAccess CascadeExpression ExpressionStatement Block | |
| 506 addTestSource(''' | |
| 507 // looks like a cascade to the parser | |
| 508 // but the user is trying to get completions for a non-cascade | |
| 509 main() {A a; a.^.z}'''); | |
| 510 await assertOpType( | |
| 511 returnValue: true, typeNames: true, voidReturn: true, prefixed: true); | |
| 512 } | |
| 513 | |
| 514 test_CascadeExpression_selector2() async { | |
| 515 // SimpleIdentifier PropertyAccess CascadeExpression ExpressionStatement | |
| 516 addTestSource('main() {A a; a..^z}'); | |
| 517 await assertOpType(returnValue: true, voidReturn: true, prefixed: true); | |
| 518 } | |
| 519 | |
| 520 test_CascadeExpression_selector2_withTrailingReturn() async { | |
| 521 // PropertyAccess CascadeExpression ExpressionStatement Block | |
| 522 addTestSource('main() {A a; a..^ return}'); | |
| 523 await assertOpType(returnValue: true, voidReturn: true, prefixed: true); | |
| 524 } | |
| 525 | |
| 526 test_CascadeExpression_target() async { | |
| 527 // SimpleIdentifier CascadeExpression ExpressionStatement | |
| 528 addTestSource('main() {A a; a^..b}'); | |
| 529 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 530 } | |
| 531 | |
| 532 test_catch_4a1() async { | |
| 533 addTestSource('main() {try {} ^ on SomeException {}}'); | |
| 534 await assertOpType(); | |
| 535 } | |
| 536 | |
| 537 test_catch_4a2() async { | |
| 538 addTestSource('main() {try {} c^ on SomeException {}}'); | |
| 539 await assertOpType(); | |
| 540 } | |
| 541 | |
| 542 test_catch_4b1() async { | |
| 543 addTestSource('main() {try {} ^ catch (e) {}}'); | |
| 544 await assertOpType(); | |
| 545 } | |
| 546 | |
| 547 test_catch_4b2() async { | |
| 548 addTestSource('main() {try {} c^ catch (e) {}}'); | |
| 549 await assertOpType(); | |
| 550 } | |
| 551 | |
| 552 test_catch_4c1() async { | |
| 553 addTestSource('main() {try {} ^ finally {}}'); | |
| 554 await assertOpType(); | |
| 555 } | |
| 556 | |
| 557 test_catch_4c2() async { | |
| 558 addTestSource('main() {try {} c^ finally {}}'); | |
| 559 await assertOpType(); | |
| 560 } | |
| 561 | |
| 562 test_catch_5a() async { | |
| 563 addTestSource('main() {try {} on ^ finally {}}'); | |
| 564 await assertOpType(typeNames: true); | |
| 565 } | |
| 566 | |
| 567 test_catch_5b() async { | |
| 568 addTestSource('main() {try {} on E^ finally {}}'); | |
| 569 await assertOpType(typeNames: true); | |
| 570 } | |
| 571 | |
| 572 test_CatchClause_onType() async { | |
| 573 // TypeName CatchClause TryStatement | |
| 574 addTestSource('class A {a() {try{var x;} on ^ {}}}'); | |
| 575 await assertOpType(typeNames: true); | |
| 576 } | |
| 577 | |
| 578 test_CatchClause_onType_noBrackets() async { | |
| 579 // TypeName CatchClause TryStatement | |
| 580 addTestSource('class A {a() {try{var x;} on ^}}'); | |
| 581 await assertOpType(typeNames: true); | |
| 582 } | |
| 583 | |
| 584 test_CatchClause_typed() async { | |
| 585 // Block CatchClause TryStatement | |
| 586 addTestSource('class A {a() {try{var x;} on E catch (e) {^}}}'); | |
| 587 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 588 } | |
| 589 | |
| 590 test_CatchClause_untyped() async { | |
| 591 // Block CatchClause TryStatement | |
| 592 addTestSource('class A {a() {try{var x;} catch (e, s) {^}}}'); | |
| 593 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 594 } | |
| 595 | |
| 596 test_ClassDeclaration_body() async { | |
| 597 // ClassDeclaration CompilationUnit | |
| 598 addTestSource('@deprecated class A {^}'); | |
| 599 await assertOpType(typeNames: true); | |
| 600 } | |
| 601 | |
| 602 test_ClassDeclaration_body2() async { | |
| 603 // SimpleIdentifier MethodDeclaration ClassDeclaration | |
| 604 addTestSource('@deprecated class A {^mth() {}}'); | |
| 605 await assertOpType(typeNames: true); | |
| 606 } | |
| 607 | |
| 608 test_Combinator_hide() async { | |
| 609 // SimpleIdentifier HideCombinator ImportDirective | |
| 610 addTestSource(''' | |
| 611 import "/testAB.dart" hide ^; | |
| 612 class X {}'''); | |
| 613 await assertOpType(); | |
| 614 } | |
| 615 | |
| 616 test_Combinator_show() async { | |
| 617 // SimpleIdentifier HideCombinator ImportDirective | |
| 618 addTestSource(''' | |
| 619 import "/testAB.dart" show ^; | |
| 620 import "/testCD.dart"; | |
| 621 class X {}'''); | |
| 622 await assertOpType(); | |
| 623 } | |
| 624 | |
| 625 test_CommentReference() async { | |
| 626 // SimpleIdentifier CommentReference Comment MethodDeclaration | |
| 627 addTestSource('class A {/** [^] */ mth() {}'); | |
| 628 await assertOpType( | |
| 629 returnValue: true, | |
| 630 typeNames: true, | |
| 631 voidReturn: true, | |
| 632 kind: CompletionSuggestionKind.IDENTIFIER); | |
| 633 } | |
| 634 | |
| 635 test_ConditionalExpression_elseExpression() async { | |
| 636 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 637 addTestSource('class C {foo(){var f; {var x;} return a ? T1 : T^}}'); | |
| 638 await assertOpType(returnValue: true, typeNames: true); | |
| 639 } | |
| 640 | |
| 641 test_ConditionalExpression_elseExpression_empty() async { | |
| 642 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 643 addTestSource('class C {foo(){var f; {var x;} return a ? T1 : ^}}'); | |
| 644 await assertOpType(returnValue: true, typeNames: true); | |
| 645 } | |
| 646 | |
| 647 test_ConditionalExpression_partial_thenExpression() async { | |
| 648 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 649 addTestSource('class C {foo(){var f; {var x;} return a ? T^}}'); | |
| 650 await assertOpType(returnValue: true, typeNames: true); | |
| 651 } | |
| 652 | |
| 653 test_ConditionalExpression_partial_thenExpression_empty() async { | |
| 654 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 655 addTestSource('class C {foo(){var f; {var x;} return a ? ^}}'); | |
| 656 await assertOpType(returnValue: true, typeNames: true); | |
| 657 } | |
| 658 | |
| 659 test_ConditionalExpression_thenExpression() async { | |
| 660 // SimpleIdentifier ConditionalExpression ReturnStatement | |
| 661 addTestSource('class C {foo(){var f; {var x;} return a ? T^ : c}}'); | |
| 662 await assertOpType(returnValue: true, typeNames: true); | |
| 663 } | |
| 664 | |
| 665 test_ConstructorName() async { | |
| 666 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 667 // InstanceCreationExpression | |
| 668 addTestSource('main() {new X.^}'); | |
| 669 await assertOpType(constructors: true, prefixed: true); | |
| 670 } | |
| 671 | |
| 672 test_ConstructorName_name_resolved() async { | |
| 673 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 674 // InstanceCreationExpression | |
| 675 addTestSource('main() {new Str^ing.fromCharCodes([]);}'); | |
| 676 await assertOpType(constructors: true); | |
| 677 } | |
| 678 | |
| 679 test_ConstructorName_resolved() async { | |
| 680 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 681 // InstanceCreationExpression | |
| 682 addTestSource('main() {new String.fr^omCharCodes([]);}'); | |
| 683 await assertOpType(constructors: true, prefixed: true); | |
| 684 } | |
| 685 | |
| 686 test_ConstructorName_unresolved() async { | |
| 687 // SimpleIdentifier PrefixedIdentifier TypeName ConstructorName | |
| 688 // InstanceCreationExpression | |
| 689 addTestSource('main() {new String.fr^omCharCodes([]);}'); | |
| 690 await assertOpType(constructors: true, prefixed: true); | |
| 691 } | |
| 692 | |
| 693 test_Continue_after_label() async { | |
| 694 addTestSource('main() { foo: while (true) { continue foo ^ ; } }'); | |
| 695 await assertOpType(/* No valid completions */); | |
| 696 } | |
| 697 | |
| 698 test_Continue_before_label() async { | |
| 699 addTestSource('main() { foo: while (true) { continue ^ foo; } }'); | |
| 700 await assertOpType(statementLabel: true, caseLabel: true); | |
| 701 } | |
| 702 | |
| 703 test_Continue_no_label() async { | |
| 704 addTestSource('main() { foo: while (true) { continue ^; } }'); | |
| 705 await assertOpType(statementLabel: true, caseLabel: true); | |
| 706 } | |
| 707 | |
| 708 test_DefaultFormalParameter_named_expression() async { | |
| 709 // DefaultFormalParameter FormalParameterList MethodDeclaration | |
| 710 addTestSource('class A {a(blat: ^) { }}'); | |
| 711 await assertOpType(returnValue: true, typeNames: true); | |
| 712 } | |
| 713 | |
| 714 test_DoStatement() async { | |
| 715 // SimpleIdentifier DoStatement Block | |
| 716 addTestSource('main() {do{} while(^x);}'); | |
| 717 await assertOpType(returnValue: true, typeNames: true); | |
| 718 } | |
| 719 | |
| 720 test_ExpressionFunctionBody() async { | |
| 721 // SimpleIdentifier ExpressionFunctionBody FunctionExpression | |
| 722 addTestSource('m(){[1].forEach((x)=>^x);}'); | |
| 723 await assertOpType(returnValue: true, typeNames: true); | |
| 724 } | |
| 725 | |
| 726 test_ExpressionStatement() async { | |
| 727 // ExpressionStatement Block BlockFunctionBody | |
| 728 addTestSource('n(){f(3);^}'); | |
| 729 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 730 } | |
| 731 | |
| 732 test_ExpressionStatement_name() async { | |
| 733 // ExpressionStatement Block BlockFunctionBody MethodDeclaration | |
| 734 addTestSource('class C {a() {C ^}}'); | |
| 735 await assertOpType(varNames: true); | |
| 736 } | |
| 737 | |
| 738 test_ExpressionStatement_name_semicolon() async { | |
| 739 // ExpressionStatement Block BlockFunctionBody MethodDeclaration | |
| 740 addTestSource('class C {a() {C ^;}}'); | |
| 741 await assertOpType(varNames: true); | |
| 742 } | |
| 743 | |
| 744 test_ExpressionStatement_prefixed_name() async { | |
| 745 // ExpressionStatement Block BlockFunctionBody MethodDeclaration | |
| 746 addTestSource('class C {a() {x.Y ^}}'); | |
| 747 await assertOpType(varNames: true); | |
| 748 } | |
| 749 | |
| 750 test_ExpressionStatement_prefixed_name_semicolon() async { | |
| 751 // ExpressionStatement Block BlockFunctionBody MethodDeclaration | |
| 752 addTestSource('class C {a() {x.Y ^;}}'); | |
| 753 await assertOpType(varNames: true); | |
| 754 } | |
| 755 | |
| 756 test_ExtendsClause() async { | |
| 757 // ExtendsClause ClassDeclaration | |
| 758 addTestSource('class x extends ^\n{}'); | |
| 759 await assertOpType(typeNames: true); | |
| 760 } | |
| 761 | |
| 762 test_FieldDeclaration_name_typed() async { | |
| 763 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 764 // FieldDeclaration | |
| 765 addTestSource('class C {A ^}'); | |
| 766 await assertOpType(varNames: true); | |
| 767 } | |
| 768 | |
| 769 test_FieldDeclaration_name_var() async { | |
| 770 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 771 // FieldDeclaration | |
| 772 addTestSource('class C {var ^}'); | |
| 773 await assertOpType(); | |
| 774 } | |
| 775 | |
| 776 test_ForEachStatement() async { | |
| 777 // SimpleIdentifier ForEachStatement Block | |
| 778 addTestSource('main() {for(z in ^zs) {}}'); | |
| 779 await assertOpType(returnValue: true, typeNames: true); | |
| 780 } | |
| 781 | |
| 782 test_ForEachStatement_body_typed() async { | |
| 783 // Block ForEachStatement | |
| 784 addTestSource('main(args) {for (int foo in bar) {^}}'); | |
| 785 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 786 } | |
| 787 | |
| 788 test_ForEachStatement_body_untyped() async { | |
| 789 // Block ForEachStatement | |
| 790 addTestSource('main(args) {for (foo in bar) {^}}'); | |
| 791 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 792 } | |
| 793 | |
| 794 test_ForEachStatement_iterable() async { | |
| 795 // SimpleIdentifier ForEachStatement Block | |
| 796 addTestSource('main(args) {for (int foo in ^) {}}'); | |
| 797 await assertOpType(returnValue: true, typeNames: true); | |
| 798 } | |
| 799 | |
| 800 test_ForEachStatement_loopVariable() async { | |
| 801 // SimpleIdentifier ForEachStatement Block | |
| 802 addTestSource('main(args) {for (^ in args) {}}'); | |
| 803 await assertOpType(typeNames: true); | |
| 804 } | |
| 805 | |
| 806 test_ForEachStatement_loopVariable_name() async { | |
| 807 // DeclaredIdentifier ForEachStatement Block | |
| 808 addTestSource('main(args) {for (String ^ in args) {}}'); | |
| 809 await assertOpType(); | |
| 810 } | |
| 811 | |
| 812 test_ForEachStatement_loopVariable_name2() async { | |
| 813 // DeclaredIdentifier ForEachStatement Block | |
| 814 addTestSource('main(args) {for (String f^ in args) {}}'); | |
| 815 await assertOpType(); | |
| 816 } | |
| 817 | |
| 818 test_ForEachStatement_loopVariable_type() async { | |
| 819 // SimpleIdentifier ForEachStatement Block | |
| 820 addTestSource('main(args) {for (^ foo in args) {}}'); | |
| 821 await assertOpType(typeNames: true); | |
| 822 } | |
| 823 | |
| 824 test_ForEachStatement_loopVariable_type2() async { | |
| 825 // DeclaredIdentifier ForEachStatement Block | |
| 826 addTestSource('main(args) {for (S^ foo in args) {}}'); | |
| 827 await assertOpType(typeNames: true); | |
| 828 } | |
| 829 | |
| 830 test_FormalParameter_partialType() async { | |
| 831 // FormalParameterList MethodDeclaration | |
| 832 addTestSource('class A {a(b.^ f) { }}'); | |
| 833 await assertOpType(returnValue: true, typeNames: true, prefixed: true); | |
| 834 } | |
| 835 | |
| 836 test_FormalParameter_partialType2() async { | |
| 837 // FormalParameterList MethodDeclaration | |
| 838 addTestSource('class A {a(b.z^ f) { }}'); | |
| 839 await assertOpType(returnValue: true, typeNames: true, prefixed: true); | |
| 840 } | |
| 841 | |
| 842 test_FormalParameter_partialType3() async { | |
| 843 // FormalParameterList MethodDeclaration | |
| 844 addTestSource('class A {a(b.^) { }}'); | |
| 845 await assertOpType(returnValue: true, typeNames: true, prefixed: true); | |
| 846 } | |
| 847 | |
| 848 test_FormalParameterList() async { | |
| 849 // FormalParameterList MethodDeclaration | |
| 850 addTestSource('class A {a(^) { }}'); | |
| 851 await assertOpType(typeNames: true); | |
| 852 } | |
| 853 | |
| 854 test_ForStatement_condition() async { | |
| 855 // SimpleIdentifier ForStatement | |
| 856 addTestSource('main() {for (int index = 0; i^)}'); | |
| 857 await assertOpType(returnValue: true, typeNames: true); | |
| 858 } | |
| 859 | |
| 860 test_ForStatement_initializer() async { | |
| 861 // SimpleIdentifier ForStatement | |
| 862 addTestSource('main() {List a; for (^)}'); | |
| 863 await assertOpType(typeNames: true); | |
| 864 } | |
| 865 | |
| 866 test_ForStatement_initializer_inKeyword() async { | |
| 867 addTestSource('main() { for (var v i^) }'); | |
| 868 await assertOpType(); | |
| 869 } | |
| 870 | |
| 871 test_ForStatement_initializer_type() async { | |
| 872 // SimpleIdentifier ForStatement | |
| 873 addTestSource('main() {List a; for (i^ v = 0;)}'); | |
| 874 await assertOpType(typeNames: true); | |
| 875 } | |
| 876 | |
| 877 test_ForStatement_initializer_variableNameEmpty_afterType() async { | |
| 878 addTestSource('main() { for (String ^) }'); | |
| 879 await assertOpType(varNames: true); | |
| 880 } | |
| 881 | |
| 882 test_ForStatement_updaters() async { | |
| 883 // SimpleIdentifier ForStatement | |
| 884 addTestSource('main() {for (int index = 0; index < 10; i^)}'); | |
| 885 // TODO (danrubel) may want to exclude methods/functions with void return | |
| 886 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 887 } | |
| 888 | |
| 889 test_ForStatement_updaters_prefix_expression() async { | |
| 890 // SimpleIdentifier PrefixExpression ForStatement | |
| 891 addTestSource('main() {for (int index = 0; index < 10; ++i^)}'); | |
| 892 await assertOpType(returnValue: true, typeNames: true); | |
| 893 } | |
| 894 | |
| 895 test_FunctionDeclaration1() async { | |
| 896 // SimpleIdentifier FunctionDeclaration CompilationUnit | |
| 897 addTestSource('const ^Fara();'); | |
| 898 await assertOpType(typeNames: true); | |
| 899 } | |
| 900 | |
| 901 test_FunctionDeclaration2() async { | |
| 902 // SimpleIdentifier FunctionDeclaration CompilationUnit | |
| 903 addTestSource('const F^ara();'); | |
| 904 await assertOpType(typeNames: true); | |
| 905 } | |
| 906 | |
| 907 test_FunctionDeclaration_inLineComment() async { | |
| 908 // Comment CompilationUnit | |
| 909 addTestSource(''' | |
| 910 // normal comment ^ | |
| 911 zoo(z) { } String name;'''); | |
| 912 await assertOpType(); | |
| 913 } | |
| 914 | |
| 915 test_FunctionDeclaration_inLineComment2() async { | |
| 916 // Comment CompilationUnit | |
| 917 addTestSource(''' | |
| 918 // normal ^comment | |
| 919 zoo(z) { } String name;'''); | |
| 920 await assertOpType(); | |
| 921 } | |
| 922 | |
| 923 test_FunctionDeclaration_inLineComment3() async { | |
| 924 // Comment CompilationUnit | |
| 925 addTestSource(''' | |
| 926 // normal comment ^ | |
| 927 // normal comment 2 | |
| 928 zoo(z) { } String name;'''); | |
| 929 await assertOpType(); | |
| 930 } | |
| 931 | |
| 932 test_FunctionDeclaration_inLineComment4() async { | |
| 933 // Comment CompilationUnit | |
| 934 addTestSource(''' | |
| 935 // normal comment | |
| 936 // normal comment 2^ | |
| 937 zoo(z) { } String name;'''); | |
| 938 await assertOpType(); | |
| 939 } | |
| 940 | |
| 941 test_FunctionDeclaration_inLineDocComment() async { | |
| 942 // Comment FunctionDeclaration CompilationUnit | |
| 943 addTestSource(''' | |
| 944 /// some dartdoc ^ | |
| 945 zoo(z) { } String name;'''); | |
| 946 await assertOpType(); | |
| 947 } | |
| 948 | |
| 949 test_FunctionDeclaration_inLineDocComment2() async { | |
| 950 // Comment FunctionDeclaration CompilationUnit | |
| 951 addTestSource(''' | |
| 952 /// some ^dartdoc | |
| 953 zoo(z) { } String name;'''); | |
| 954 await assertOpType(); | |
| 955 } | |
| 956 | |
| 957 test_FunctionDeclaration_inStarComment() async { | |
| 958 // Comment CompilationUnit | |
| 959 addTestSource('/* ^ */ zoo(z) {} String name;'); | |
| 960 await assertOpType(); | |
| 961 } | |
| 962 | |
| 963 test_FunctionDeclaration_inStarComment2() async { | |
| 964 // Comment CompilationUnit | |
| 965 addTestSource('/* *^/ zoo(z) {} String name;'); | |
| 966 await assertOpType(); | |
| 967 } | |
| 968 | |
| 969 test_FunctionDeclaration_inStarDocComment() async { | |
| 970 // Comment FunctionDeclaration CompilationUnit | |
| 971 addTestSource('/** ^ */ zoo(z) { } String name; '); | |
| 972 await assertOpType(); | |
| 973 } | |
| 974 | |
| 975 test_FunctionDeclaration_inStarDocComment2() async { | |
| 976 // Comment FunctionDeclaration CompilationUnit | |
| 977 addTestSource('/** *^/ zoo(z) { } String name;'); | |
| 978 await assertOpType(); | |
| 979 } | |
| 980 | |
| 981 test_FunctionDeclaration_returnType() async { | |
| 982 // CompilationUnit | |
| 983 addTestSource('^ zoo(z) { } String name;'); | |
| 984 await assertOpType(typeNames: true); | |
| 985 } | |
| 986 | |
| 987 test_FunctionDeclaration_returnType_afterLineComment() async { | |
| 988 // FunctionDeclaration CompilationUnit | |
| 989 addTestSource(''' | |
| 990 // normal comment | |
| 991 ^ zoo(z) {} String name;'''); | |
| 992 await assertOpType(typeNames: true); | |
| 993 } | |
| 994 | |
| 995 test_FunctionDeclaration_returnType_afterLineComment2() async { | |
| 996 // FunctionDeclaration CompilationUnit | |
| 997 // TOD(danrubel) left align all test source | |
| 998 addTestSource(''' | |
| 999 // normal comment | |
| 1000 ^ zoo(z) {} String name;'''); | |
| 1001 await assertOpType(typeNames: true); | |
| 1002 } | |
| 1003 | |
| 1004 test_FunctionDeclaration_returnType_afterLineDocComment() async { | |
| 1005 // SimpleIdentifier FunctionDeclaration CompilationUnit | |
| 1006 addTestSource(''' | |
| 1007 /// some dartdoc | |
| 1008 ^ zoo(z) { } String name;'''); | |
| 1009 await assertOpType(typeNames: true); | |
| 1010 } | |
| 1011 | |
| 1012 test_FunctionDeclaration_returnType_afterLineDocComment2() async { | |
| 1013 // SimpleIdentifier FunctionDeclaration CompilationUnit | |
| 1014 addTestSource(''' | |
| 1015 /// some dartdoc | |
| 1016 ^ zoo(z) { } String name;'''); | |
| 1017 await assertOpType(typeNames: true); | |
| 1018 } | |
| 1019 | |
| 1020 test_FunctionDeclaration_returnType_afterStarComment() async { | |
| 1021 // CompilationUnit | |
| 1022 addTestSource('/* */ ^ zoo(z) { } String name;'); | |
| 1023 await assertOpType(typeNames: true); | |
| 1024 } | |
| 1025 | |
| 1026 test_FunctionDeclaration_returnType_afterStarComment2() async { | |
| 1027 // CompilationUnit | |
| 1028 addTestSource('/* */^ zoo(z) { } String name;'); | |
| 1029 await assertOpType(typeNames: true); | |
| 1030 } | |
| 1031 | |
| 1032 test_FunctionDeclaration_returnType_afterStarDocComment() async { | |
| 1033 // FunctionDeclaration CompilationUnit | |
| 1034 addTestSource('/** */ ^ zoo(z) { } String name;'); | |
| 1035 await assertOpType(typeNames: true); | |
| 1036 } | |
| 1037 | |
| 1038 test_FunctionDeclaration_returnType_afterStarDocComment2() async { | |
| 1039 // FunctionDeclaration CompilationUnit | |
| 1040 addTestSource('/** */^ zoo(z) { } String name;'); | |
| 1041 await assertOpType(typeNames: true); | |
| 1042 } | |
| 1043 | |
| 1044 test_FunctionExpression() async { | |
| 1045 // BlockFunctionBody FunctionExpression FunctionDeclaration | |
| 1046 addTestSource('main()^ { int b = 2; b++; b. }'); | |
| 1047 await assertOpType(); | |
| 1048 } | |
| 1049 | |
| 1050 test_FunctionExpressionInvocation() async { | |
| 1051 // ArgumentList FunctionExpressionInvocation ExpressionStatement | |
| 1052 addTestSource('main() { ((x) => x + 7)^(2) }'); | |
| 1053 await assertOpType(); | |
| 1054 } | |
| 1055 | |
| 1056 test_FunctionTypeAlias() async { | |
| 1057 // SimpleIdentifier FunctionTypeAlias CompilationUnit | |
| 1058 addTestSource('typedef n^ ;'); | |
| 1059 await assertOpType(typeNames: true); | |
| 1060 } | |
| 1061 | |
| 1062 test_IfStatement() async { | |
| 1063 // EmptyStatement IfStatement Block BlockFunctionBody | |
| 1064 addTestSource('main(){var a; if (true) ^}'); | |
| 1065 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1066 } | |
| 1067 | |
| 1068 test_IfStatement_condition() async { | |
| 1069 // SimpleIdentifier IfStatement Block BlockFunctionBody | |
| 1070 addTestSource('main(){var a; if (^)}'); | |
| 1071 await assertOpType(returnValue: true, typeNames: true); | |
| 1072 } | |
| 1073 | |
| 1074 test_IfStatement_empty() async { | |
| 1075 // SimpleIdentifier PrefixIdentifier IfStatement | |
| 1076 addTestSource('class A {foo() {A a; if (^) something}}'); | |
| 1077 await assertOpType(returnValue: true, typeNames: true); | |
| 1078 } | |
| 1079 | |
| 1080 test_IfStatement_invocation() async { | |
| 1081 // SimpleIdentifier PrefixIdentifier IfStatement | |
| 1082 addTestSource('main() {var a; if (a.^) something}'); | |
| 1083 await assertOpType(returnValue: true, typeNames: true, prefixed: true); | |
| 1084 } | |
| 1085 | |
| 1086 test_ImplementsClause() async { | |
| 1087 // ImplementsClause ClassDeclaration | |
| 1088 addTestSource('class x implements ^\n{}'); | |
| 1089 await assertOpType(typeNames: true); | |
| 1090 } | |
| 1091 | |
| 1092 test_ImportDirective_dart() async { | |
| 1093 // SimpleStringLiteral ImportDirective | |
| 1094 addTestSource(''' | |
| 1095 import "dart^"; | |
| 1096 main() {}'''); | |
| 1097 await assertOpType(); | |
| 1098 } | |
| 1099 | |
| 1100 test_IndexExpression() async { | |
| 1101 addTestSource('class C {foo(){var f; {var x;} f[^]}}'); | |
| 1102 await assertOpType(returnValue: true, typeNames: true); | |
| 1103 } | |
| 1104 | |
| 1105 test_IndexExpression2() async { | |
| 1106 addTestSource('class C {foo(){var f; {var x;} f[T^]}}'); | |
| 1107 await assertOpType(returnValue: true, typeNames: true); | |
| 1108 } | |
| 1109 | |
| 1110 test_InstanceCreationExpression() async { | |
| 1111 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | |
| 1112 addTestSource('class C {foo(){var f; {var x;} new ^}}'); | |
| 1113 await assertOpType(constructors: true); | |
| 1114 } | |
| 1115 | |
| 1116 test_InstanceCreationExpression_keyword() async { | |
| 1117 // InstanceCreationExpression ExpressionStatement Block | |
| 1118 addTestSource('class C {foo(){var f; {var x;} new^ }}'); | |
| 1119 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1120 } | |
| 1121 | |
| 1122 test_InstanceCreationExpression_keyword2() async { | |
| 1123 // InstanceCreationExpression ExpressionStatement Block | |
| 1124 addTestSource('class C {foo(){var f; {var x;} new^ C();}}'); | |
| 1125 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1126 } | |
| 1127 | |
| 1128 test_InstanceCreationExpression_trailingStmt() async { | |
| 1129 // SimpleIdentifier TypeName ConstructorName InstanceCreationExpression | |
| 1130 addTestSource('class C {foo(){var f; {var x;} new ^ int x = 7;}}'); | |
| 1131 await assertOpType(constructors: true); | |
| 1132 } | |
| 1133 | |
| 1134 test_InterpolationExpression() async { | |
| 1135 // SimpleIdentifier InterpolationExpression StringInterpolation | |
| 1136 addTestSource('main() {String name; print("hello \$^");}'); | |
| 1137 await assertOpType(returnValue: true); | |
| 1138 } | |
| 1139 | |
| 1140 test_InterpolationExpression_block() async { | |
| 1141 // SimpleIdentifier InterpolationExpression StringInterpolation | |
| 1142 addTestSource('main() {String name; print("hello \${n^}");}'); | |
| 1143 await assertOpType(returnValue: true, typeNames: true); | |
| 1144 } | |
| 1145 | |
| 1146 test_InterpolationExpression_prefix_selector() async { | |
| 1147 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | |
| 1148 addTestSource('main() {String name; print("hello \${name.^}");}'); | |
| 1149 await assertOpType(returnValue: true, typeNames: true, prefixed: true); | |
| 1150 } | |
| 1151 | |
| 1152 test_InterpolationExpression_prefix_target() async { | |
| 1153 // SimpleIdentifier PrefixedIdentifier InterpolationExpression | |
| 1154 addTestSource('main() {String name; print("hello \${nam^e.length}");}'); | |
| 1155 await assertOpType(returnValue: true, typeNames: true); | |
| 1156 } | |
| 1157 | |
| 1158 test_IsExpression() async { | |
| 1159 // SimpleIdentifier TypeName IsExpression IfStatement | |
| 1160 addTestSource('main() {var x; if (x is ^) { }}'); | |
| 1161 await assertOpType(typeNames: true); | |
| 1162 } | |
| 1163 | |
| 1164 test_IsExpression_target() async { | |
| 1165 // IfStatement Block BlockFunctionBody | |
| 1166 addTestSource('main(){var a; if (^ is A)}'); | |
| 1167 await assertOpType(returnValue: true, typeNames: true); | |
| 1168 } | |
| 1169 | |
| 1170 test_IsExpression_type_partial() async { | |
| 1171 // SimpleIdentifier TypeName IsExpression IfStatement | |
| 1172 addTestSource('main(){var a; if (a is Obj^)}'); | |
| 1173 await assertOpType(typeNames: true); | |
| 1174 } | |
| 1175 | |
| 1176 test_Literal_list() async { | |
| 1177 // ']' ListLiteral ArgumentList MethodInvocation | |
| 1178 addTestSource('main() {var Some; print([^]);}'); | |
| 1179 await assertOpType(returnValue: true, typeNames: true); | |
| 1180 } | |
| 1181 | |
| 1182 test_Literal_list2() async { | |
| 1183 // SimpleIdentifier ListLiteral ArgumentList MethodInvocation | |
| 1184 addTestSource('main() {var Some; print([S^]);}'); | |
| 1185 await assertOpType(returnValue: true, typeNames: true); | |
| 1186 } | |
| 1187 | |
| 1188 test_Literal_string() async { | |
| 1189 // SimpleStringLiteral ExpressionStatement Block | |
| 1190 addTestSource('class A {a() {"hel^lo"}}'); | |
| 1191 await assertOpType(); | |
| 1192 } | |
| 1193 | |
| 1194 test_MapLiteralEntry() async { | |
| 1195 // MapLiteralEntry MapLiteral VariableDeclaration | |
| 1196 addTestSource('foo = {^'); | |
| 1197 await assertOpType(returnValue: true, typeNames: true); | |
| 1198 } | |
| 1199 | |
| 1200 test_MapLiteralEntry1() async { | |
| 1201 // MapLiteralEntry MapLiteral VariableDeclaration | |
| 1202 addTestSource('foo = {T^'); | |
| 1203 await assertOpType(returnValue: true, typeNames: true); | |
| 1204 } | |
| 1205 | |
| 1206 test_MapLiteralEntry2() async { | |
| 1207 // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration | |
| 1208 addTestSource('foo = {7:T^};'); | |
| 1209 await assertOpType(returnValue: true, typeNames: true); | |
| 1210 } | |
| 1211 | |
| 1212 test_MethodDeclaration1() async { | |
| 1213 // SimpleIdentifier MethodDeclaration ClassDeclaration | |
| 1214 addTestSource('class Bar {const ^Fara();}'); | |
| 1215 await assertOpType(typeNames: true); | |
| 1216 } | |
| 1217 | |
| 1218 test_MethodDeclaration2() async { | |
| 1219 // SimpleIdentifier MethodDeclaration ClassDeclaration | |
| 1220 addTestSource('class Bar {const F^ara();}'); | |
| 1221 await assertOpType(typeNames: true); | |
| 1222 } | |
| 1223 | |
| 1224 test_MethodDeclaration_inLineComment() async { | |
| 1225 // Comment ClassDeclaration CompilationUnit | |
| 1226 addTestSource(''' | |
| 1227 class C2 { | |
| 1228 // normal comment ^ | |
| 1229 zoo(z) { } String name; }'''); | |
| 1230 await assertOpType(); | |
| 1231 } | |
| 1232 | |
| 1233 test_MethodDeclaration_inLineComment2() async { | |
| 1234 // Comment ClassDeclaration CompilationUnit | |
| 1235 addTestSource(''' | |
| 1236 class C2 { | |
| 1237 // normal ^comment | |
| 1238 zoo(z) { } String name; }'''); | |
| 1239 await assertOpType(); | |
| 1240 } | |
| 1241 | |
| 1242 test_MethodDeclaration_inLineComment3() async { | |
| 1243 // Comment ClassDeclaration CompilationUnit | |
| 1244 addTestSource(''' | |
| 1245 class C2 { | |
| 1246 // normal comment ^ | |
| 1247 // normal comment 2 | |
| 1248 zoo(z) { } String name; }'''); | |
| 1249 await assertOpType(); | |
| 1250 } | |
| 1251 | |
| 1252 test_MethodDeclaration_inLineComment4() async { | |
| 1253 // Comment ClassDeclaration CompilationUnit | |
| 1254 addTestSource(''' | |
| 1255 class C2 { | |
| 1256 // normal comment | |
| 1257 // normal comment 2^ | |
| 1258 zoo(z) { } String name; }'''); | |
| 1259 await assertOpType(); | |
| 1260 } | |
| 1261 | |
| 1262 test_MethodDeclaration_inLineDocComment() async { | |
| 1263 // Comment MethodDeclaration ClassDeclaration CompilationUnit | |
| 1264 addTestSource(''' | |
| 1265 class C2 { | |
| 1266 /// some dartdoc ^ | |
| 1267 zoo(z) { } String name; }'''); | |
| 1268 await assertOpType(); | |
| 1269 } | |
| 1270 | |
| 1271 test_MethodDeclaration_inLineDocComment2() async { | |
| 1272 // Comment MethodDeclaration ClassDeclaration CompilationUnit | |
| 1273 addTestSource(''' | |
| 1274 class C2 { | |
| 1275 /// some ^dartdoc | |
| 1276 zoo(z) { } String name; }'''); | |
| 1277 await assertOpType(); | |
| 1278 } | |
| 1279 | |
| 1280 test_MethodDeclaration_inStarComment() async { | |
| 1281 // Comment ClassDeclaration CompilationUnit | |
| 1282 addTestSource('class C2 {/* ^ */ zoo(z) {} String name;}'); | |
| 1283 await assertOpType(); | |
| 1284 } | |
| 1285 | |
| 1286 test_MethodDeclaration_inStarComment2() async { | |
| 1287 // Comment ClassDeclaration CompilationUnit | |
| 1288 addTestSource('class C2 {/* *^/ zoo(z) {} String name;}'); | |
| 1289 await assertOpType(); | |
| 1290 } | |
| 1291 | |
| 1292 test_MethodDeclaration_inStarDocComment() async { | |
| 1293 // Comment MethodDeclaration ClassDeclaration CompilationUnit | |
| 1294 addTestSource('class C2 {/** ^ */ zoo(z) { } String name; }'); | |
| 1295 await assertOpType(); | |
| 1296 } | |
| 1297 | |
| 1298 test_MethodDeclaration_inStarDocComment2() async { | |
| 1299 // Comment MethodDeclaration ClassDeclaration CompilationUnit | |
| 1300 addTestSource('class C2 {/** *^/ zoo(z) { } String name; }'); | |
| 1301 await assertOpType(); | |
| 1302 } | |
| 1303 | |
| 1304 test_MethodDeclaration_returnType() async { | |
| 1305 // ClassDeclaration CompilationUnit | |
| 1306 addTestSource('class C2 {^ zoo(z) { } String name; }'); | |
| 1307 await assertOpType(typeNames: true); | |
| 1308 } | |
| 1309 | |
| 1310 test_MethodDeclaration_returnType_afterLineComment() async { | |
| 1311 // MethodDeclaration ClassDeclaration CompilationUnit | |
| 1312 addTestSource(''' | |
| 1313 class C2 { | |
| 1314 // normal comment | |
| 1315 ^ zoo(z) {} String name;}'''); | |
| 1316 await assertOpType(typeNames: true); | |
| 1317 } | |
| 1318 | |
| 1319 test_MethodDeclaration_returnType_afterLineComment2() async { | |
| 1320 // MethodDeclaration ClassDeclaration CompilationUnit | |
| 1321 // TOD(danrubel) left align all test source | |
| 1322 addTestSource(''' | |
| 1323 class C2 { | |
| 1324 // normal comment | |
| 1325 ^ zoo(z) {} String name;}'''); | |
| 1326 await assertOpType(typeNames: true); | |
| 1327 } | |
| 1328 | |
| 1329 test_MethodDeclaration_returnType_afterLineDocComment() async { | |
| 1330 // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit | |
| 1331 addTestSource(''' | |
| 1332 class C2 { | |
| 1333 /// some dartdoc | |
| 1334 ^ zoo(z) { } String name; }'''); | |
| 1335 await assertOpType(typeNames: true); | |
| 1336 } | |
| 1337 | |
| 1338 test_MethodDeclaration_returnType_afterLineDocComment2() async { | |
| 1339 // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit | |
| 1340 addTestSource(''' | |
| 1341 class C2 { | |
| 1342 /// some dartdoc | |
| 1343 ^ zoo(z) { } String name; }'''); | |
| 1344 await assertOpType(typeNames: true); | |
| 1345 } | |
| 1346 | |
| 1347 test_MethodDeclaration_returnType_afterStarComment() async { | |
| 1348 // ClassDeclaration CompilationUnit | |
| 1349 addTestSource('class C2 {/* */ ^ zoo(z) { } String name; }'); | |
| 1350 await assertOpType(typeNames: true); | |
| 1351 } | |
| 1352 | |
| 1353 test_MethodDeclaration_returnType_afterStarComment2() async { | |
| 1354 // ClassDeclaration CompilationUnit | |
| 1355 addTestSource('class C2 {/* */^ zoo(z) { } String name; }'); | |
| 1356 await assertOpType(typeNames: true); | |
| 1357 } | |
| 1358 | |
| 1359 test_MethodDeclaration_returnType_afterStarDocComment() async { | |
| 1360 // MethodDeclaration ClassDeclaration CompilationUnit | |
| 1361 addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }'); | |
| 1362 await assertOpType(typeNames: true); | |
| 1363 } | |
| 1364 | |
| 1365 test_MethodDeclaration_returnType_afterStarDocComment2() async { | |
| 1366 // MethodDeclaration ClassDeclaration CompilationUnit | |
| 1367 addTestSource('class C2 {/** */^ zoo(z) { } String name; }'); | |
| 1368 await assertOpType(typeNames: true); | |
| 1369 } | |
| 1370 | |
| 1371 test_MethodInvocation_no_semicolon() async { | |
| 1372 // MethodInvocation ExpressionStatement Block | |
| 1373 addTestSource(''' | |
| 1374 class A implements I { | |
| 1375 // no semicolon between completion point and next statement | |
| 1376 set _s2(I x) {x.^ m(null);} | |
| 1377 }'''); | |
| 1378 await assertOpType( | |
| 1379 returnValue: true, typeNames: true, voidReturn: true, prefixed: true); | |
| 1380 } | |
| 1381 | |
| 1382 test_PostfixExpression() async { | |
| 1383 // SimpleIdentifier PostfixExpression ForStatement | |
| 1384 addTestSource('int x = 0; main() {ax+^+;}'); | |
| 1385 await assertOpType(returnValue: true, typeNames: true); | |
| 1386 } | |
| 1387 | |
| 1388 test_PrefixedIdentifier_class_const() async { | |
| 1389 // SimpleIdentifier PrefixedIdentifier ExpressionStatement Block | |
| 1390 addTestSource('main() {A.^}'); | |
| 1391 await assertOpType( | |
| 1392 returnValue: true, typeNames: true, voidReturn: true, prefixed: true); | |
| 1393 } | |
| 1394 | |
| 1395 test_PrefixedIdentifier_class_imported() async { | |
| 1396 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 1397 addTestSource('main() {A a; a.^}'); | |
| 1398 await assertOpType( | |
| 1399 returnValue: true, typeNames: true, voidReturn: true, prefixed: true); | |
| 1400 } | |
| 1401 | |
| 1402 test_PrefixedIdentifier_prefix() async { | |
| 1403 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | |
| 1404 addTestSource('class X {foo(){A^.bar}}'); | |
| 1405 await assertOpType(typeNames: true, returnValue: true, voidReturn: true); | |
| 1406 } | |
| 1407 | |
| 1408 test_PropertyAccess_expression() async { | |
| 1409 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement | |
| 1410 addTestSource('class A {a() {"hello".to^String().length}}'); | |
| 1411 await assertOpType( | |
| 1412 returnValue: true, typeNames: true, voidReturn: true, prefixed: true); | |
| 1413 } | |
| 1414 | |
| 1415 test_PropertyAccess_noTarget() async { | |
| 1416 // SimpleIdentifier PropertyAccess ExpressionStatement | |
| 1417 addTestSource('main() {.^}'); | |
| 1418 await assertOpType(); | |
| 1419 } | |
| 1420 | |
| 1421 test_PropertyAccess_noTarget2() async { | |
| 1422 // SimpleIdentifier PropertyAccess CascadeExpressions | |
| 1423 addTestSource('main() {.^.}'); | |
| 1424 await assertOpType(); | |
| 1425 } | |
| 1426 | |
| 1427 test_PropertyAccess_noTarget3() async { | |
| 1428 // SimpleIdentifier PropertyAccess CascadeExpressions | |
| 1429 addTestSource('main() {..^}'); | |
| 1430 await assertOpType(); | |
| 1431 } | |
| 1432 | |
| 1433 test_PropertyAccess_selector() async { | |
| 1434 // SimpleIdentifier PropertyAccess ExpressionStatement Block | |
| 1435 addTestSource('class A {a() {"hello".length.^}}'); | |
| 1436 await assertOpType( | |
| 1437 returnValue: true, typeNames: true, voidReturn: true, prefixed: true); | |
| 1438 } | |
| 1439 | |
| 1440 test_ReturnStatement() async { | |
| 1441 // ReturnStatement Block | |
| 1442 addTestSource('f() { var vvv = 42; return ^ }'); | |
| 1443 await assertOpType(returnValue: true, typeNames: true); | |
| 1444 } | |
| 1445 | |
| 1446 test_SimpleFormalParameter_closure() async { | |
| 1447 // SimpleIdentifier SimpleFormalParameter FormalParameterList | |
| 1448 addTestSource('mth() { PNGS.sort((String a, Str^) => a.compareTo(b)); }'); | |
| 1449 await assertOpType(typeNames: true); | |
| 1450 } | |
| 1451 | |
| 1452 test_SimpleFormalParameter_name1() async { | |
| 1453 // SimpleIdentifier SimpleFormalParameter FormalParameterList | |
| 1454 addTestSource('m(String na^) {}'); | |
| 1455 await assertOpType(typeNames: false); | |
| 1456 } | |
| 1457 | |
| 1458 test_SimpleFormalParameter_name2() async { | |
| 1459 // SimpleIdentifier SimpleFormalParameter FormalParameterList | |
| 1460 addTestSource('m(int first, String na^) {}'); | |
| 1461 await assertOpType(typeNames: false); | |
| 1462 } | |
| 1463 | |
| 1464 test_SimpleFormalParameter_type_optionalNamed() async { | |
| 1465 // SimpleIdentifier DefaultFormalParameter FormalParameterList | |
| 1466 addTestSource('m({Str^}) {}'); | |
| 1467 await assertOpType(typeNames: true); | |
| 1468 } | |
| 1469 | |
| 1470 test_SimpleFormalParameter_type_optionalPositional() async { | |
| 1471 // SimpleIdentifier DefaultFormalParameter FormalParameterList | |
| 1472 addTestSource('m([Str^]) {}'); | |
| 1473 await assertOpType(typeNames: true); | |
| 1474 } | |
| 1475 | |
| 1476 test_SimpleFormalParameter_type_withName() async { | |
| 1477 // SimpleIdentifier SimpleFormalParameter FormalParameterList | |
| 1478 addTestSource('m(Str^ name) {}'); | |
| 1479 await assertOpType(typeNames: true); | |
| 1480 } | |
| 1481 | |
| 1482 test_SimpleFormalParameter_type_withoutName1() async { | |
| 1483 // SimpleIdentifier SimpleFormalParameter FormalParameterList | |
| 1484 addTestSource('m(Str^) {}'); | |
| 1485 await assertOpType(typeNames: true); | |
| 1486 } | |
| 1487 | |
| 1488 test_SimpleFormalParameter_type_withoutName2() async { | |
| 1489 // FormalParameterList | |
| 1490 addTestSource('m(^) {}'); | |
| 1491 await assertOpType(typeNames: true); | |
| 1492 } | |
| 1493 | |
| 1494 test_SimpleFormalParameter_type_withoutName3() async { | |
| 1495 // SimpleIdentifier SimpleFormalParameter FormalParameterList | |
| 1496 addTestSource('m(int first, Str^) {}'); | |
| 1497 await assertOpType(typeNames: true); | |
| 1498 } | |
| 1499 | |
| 1500 test_SwitchCase_before() async { | |
| 1501 // SwitchCase SwitchStatement Block | |
| 1502 addTestSource('main() {switch(k) {^case 1:}}'); | |
| 1503 await assertOpType(); | |
| 1504 } | |
| 1505 | |
| 1506 test_SwitchCase_between() async { | |
| 1507 // SwitchCase SwitchStatement Block | |
| 1508 addTestSource('main() {switch(k) {case 1: ^ case 2: return}}'); | |
| 1509 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1510 } | |
| 1511 | |
| 1512 test_SwitchCase_expression1() async { | |
| 1513 // SimpleIdentifier SwitchCase SwitchStatement | |
| 1514 addTestSource('''m() {switch (x) {case ^D: return;}}'''); | |
| 1515 await assertOpType(returnValue: true, typeNames: true); | |
| 1516 } | |
| 1517 | |
| 1518 test_SwitchCase_expression2() async { | |
| 1519 // SimpleIdentifier SwitchCase SwitchStatement | |
| 1520 addTestSource('''m() {switch (x) {case ^}}'''); | |
| 1521 await assertOpType(returnValue: true, typeNames: true); | |
| 1522 } | |
| 1523 | |
| 1524 test_SwitchDefault_before() async { | |
| 1525 // SwitchDefault SwitchStatement Block | |
| 1526 addTestSource('main() {switch(k) { ^ default: return;}}'); | |
| 1527 await assertOpType(); | |
| 1528 } | |
| 1529 | |
| 1530 test_SwitchDefault_between() async { | |
| 1531 // SwitchDefault SwitchStatement Block | |
| 1532 addTestSource('main() {switch(k) {case 1: ^ default: return;}}'); | |
| 1533 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1534 } | |
| 1535 | |
| 1536 test_SwitchStatement_body_empty() async { | |
| 1537 // Token('}') SwitchStatement Block | |
| 1538 addTestSource('main() {switch(k) {^}}'); | |
| 1539 await assertOpType(); | |
| 1540 } | |
| 1541 | |
| 1542 test_SwitchStatement_body_end() async { | |
| 1543 // Token('}') SwitchStatement Block | |
| 1544 addTestSource('main() {switch(k) {case 1:^}}'); | |
| 1545 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1546 } | |
| 1547 | |
| 1548 test_SwitchStatement_body_end2() async { | |
| 1549 addTestSource('main() {switch(k) {case 1:as^}}'); | |
| 1550 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1551 } | |
| 1552 | |
| 1553 test_SwitchStatement_expression1() async { | |
| 1554 // SimpleIdentifier SwitchStatement Block | |
| 1555 addTestSource('main() {switch(^k) {case 1:{}}}'); | |
| 1556 await assertOpType(returnValue: true, typeNames: true); | |
| 1557 } | |
| 1558 | |
| 1559 test_SwitchStatement_expression2() async { | |
| 1560 // SimpleIdentifier SwitchStatement Block | |
| 1561 addTestSource('main() {switch(k^) {case 1:{}}}'); | |
| 1562 await assertOpType(returnValue: true, typeNames: true); | |
| 1563 } | |
| 1564 | |
| 1565 test_SwitchStatement_expression_empty() async { | |
| 1566 // SimpleIdentifier SwitchStatement Block | |
| 1567 addTestSource('main() {switch(^) {case 1:{}}}'); | |
| 1568 await assertOpType(returnValue: true, typeNames: true); | |
| 1569 } | |
| 1570 | |
| 1571 test_ThisExpression_block() async { | |
| 1572 // MethodInvocation ExpressionStatement Block | |
| 1573 addTestSource(''' | |
| 1574 class A implements I { | |
| 1575 // no semicolon between completion point and next statement | |
| 1576 set s1(I x) {} set _s2(I x) {this.^ m(null);} | |
| 1577 }'''); | |
| 1578 await assertOpType(returnValue: true, voidReturn: true, prefixed: true); | |
| 1579 } | |
| 1580 | |
| 1581 test_ThisExpression_constructor() async { | |
| 1582 // SimpleIdentifier PropertyAccess ExpressionStatement | |
| 1583 addTestSource(''' | |
| 1584 class A implements I { | |
| 1585 A() {this.^} | |
| 1586 }'''); | |
| 1587 await assertOpType(returnValue: true, voidReturn: true, prefixed: true); | |
| 1588 } | |
| 1589 | |
| 1590 test_ThisExpression_constructor_param() async { | |
| 1591 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 1592 addTestSource(''' | |
| 1593 class A implements I { | |
| 1594 A(this.^) {} | |
| 1595 }'''); | |
| 1596 await assertOpType(prefixed: true); | |
| 1597 } | |
| 1598 | |
| 1599 test_ThisExpression_constructor_param2() async { | |
| 1600 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 1601 addTestSource(''' | |
| 1602 class A implements I { | |
| 1603 A(this.f^) {} | |
| 1604 }'''); | |
| 1605 await assertOpType(prefixed: true); | |
| 1606 } | |
| 1607 | |
| 1608 test_ThisExpression_constructor_param3() async { | |
| 1609 // SimpleIdentifier FieldFormalParameter FormalParameterList | |
| 1610 addTestSource(''' | |
| 1611 class A implements I { | |
| 1612 A(this.^f) {} | |
| 1613 }'''); | |
| 1614 await assertOpType(prefixed: true); | |
| 1615 } | |
| 1616 | |
| 1617 test_ThisExpression_constructor_param4() async { | |
| 1618 // FieldFormalParameter FormalParameterList ConstructorDeclaration | |
| 1619 addTestSource(''' | |
| 1620 class A implements I { | |
| 1621 A(Str^ this.foo) {} | |
| 1622 }'''); | |
| 1623 await assertOpType(typeNames: true); | |
| 1624 } | |
| 1625 | |
| 1626 test_ThrowExpression() async { | |
| 1627 // SimpleIdentifier ThrowExpression ExpressionStatement | |
| 1628 addTestSource('main() {throw ^;}'); | |
| 1629 await assertOpType(returnValue: true, typeNames: true); | |
| 1630 } | |
| 1631 | |
| 1632 test_TopLevelVariableDeclaration_typed_name() async { | |
| 1633 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1634 // TopLevelVariableDeclaration | |
| 1635 // _OpTypeAstVisitor.visitVariableDeclarationList is executed with this | |
| 1636 // source, but _OpTypeAstVisitor.visitTopLevelVariableDeclaration is called | |
| 1637 // for test_TopLevelVariableDeclaration_typed_name_semicolon | |
| 1638 addTestSource('class A {} B ^'); | |
| 1639 await assertOpType(varNames: true); | |
| 1640 } | |
| 1641 | |
| 1642 test_TopLevelVariableDeclaration_typed_name_semicolon() async { | |
| 1643 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1644 // TopLevelVariableDeclaration | |
| 1645 // See comment in test_TopLevelVariableDeclaration_typed_name | |
| 1646 addTestSource('class A {} B ^;'); | |
| 1647 await assertOpType(varNames: true); | |
| 1648 } | |
| 1649 | |
| 1650 test_TopLevelVariableDeclaration_untyped_name() async { | |
| 1651 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1652 // TopLevelVariableDeclaration | |
| 1653 addTestSource('class A {} var ^'); | |
| 1654 await assertOpType(); | |
| 1655 } | |
| 1656 | |
| 1657 test_TypeArgumentList() async { | |
| 1658 // SimpleIdentifier BinaryExpression ExpressionStatement | |
| 1659 addTestSource('main() { C<^> c; }'); | |
| 1660 await assertOpType(typeNames: true); | |
| 1661 } | |
| 1662 | |
| 1663 test_TypeArgumentList2() async { | |
| 1664 // TypeName TypeArgumentList TypeName | |
| 1665 addTestSource('main() { C<C^> c; }'); | |
| 1666 await assertOpType(typeNames: true); | |
| 1667 } | |
| 1668 | |
| 1669 test_TypeParameter() async { | |
| 1670 // SimpleIdentifier TypeParameter TypeParameterList | |
| 1671 addTestSource('class tezetst <String, ^List> {}'); | |
| 1672 await assertOpType(); | |
| 1673 } | |
| 1674 | |
| 1675 test_TypeParameterList_empty() async { | |
| 1676 // SimpleIdentifier TypeParameter TypeParameterList | |
| 1677 addTestSource('class tezetst <^> {}'); | |
| 1678 await assertOpType(); | |
| 1679 } | |
| 1680 | |
| 1681 test_VariableDeclaration_name() async { | |
| 1682 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1683 // VariableDeclarationStatement Block | |
| 1684 addTestSource('main() {var ^}'); | |
| 1685 await assertOpType(); | |
| 1686 } | |
| 1687 | |
| 1688 test_VariableDeclaration_name_hasSome_parameterizedType() async { | |
| 1689 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1690 // VariableDeclarationStatement Block | |
| 1691 addTestSource('main() {List<int> m^}'); | |
| 1692 await assertOpType(varNames: true); | |
| 1693 } | |
| 1694 | |
| 1695 test_VariableDeclaration_name_hasSome_simpleType() async { | |
| 1696 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1697 // VariableDeclarationStatement Block | |
| 1698 addTestSource('main() {String m^}'); | |
| 1699 await assertOpType(varNames: true); | |
| 1700 } | |
| 1701 | |
| 1702 test_VariableDeclarationList_final() async { | |
| 1703 // VariableDeclarationList VariableDeclarationStatement Block | |
| 1704 addTestSource('main() {final ^}'); | |
| 1705 await assertOpType(typeNames: true); | |
| 1706 } | |
| 1707 | |
| 1708 test_VariableDeclarationStatement_afterSemicolon() async { | |
| 1709 // VariableDeclarationStatement Block BlockFunctionBody | |
| 1710 addTestSource('class A {var a; x() {var b;^}}'); | |
| 1711 await assertOpType(returnValue: true, typeNames: true, voidReturn: true); | |
| 1712 } | |
| 1713 | |
| 1714 test_VariableDeclarationStatement_RHS() async { | |
| 1715 // SimpleIdentifier VariableDeclaration VariableDeclarationList | |
| 1716 // VariableDeclarationStatement | |
| 1717 addTestSource('class C {bar(){var f; {var x;} var e = ^}}'); | |
| 1718 await assertOpType(returnValue: true, typeNames: true); | |
| 1719 } | |
| 1720 | |
| 1721 test_VariableDeclarationStatement_RHS_missing_semicolon() async { | |
| 1722 // VariableDeclaration VariableDeclarationList | |
| 1723 // VariableDeclarationStatement | |
| 1724 addTestSource('class C {bar(){var f; {var x;} var e = ^ var g}}'); | |
| 1725 await assertOpType(returnValue: true, typeNames: true); | |
| 1726 } | |
| 1727 | |
| 1728 test_WhileStatement() async { | |
| 1729 // SimpleIdentifier WhileStatement Block | |
| 1730 addTestSource('mth() { while (b^) {} }}'); | |
| 1731 await assertOpType(returnValue: true, typeNames: true); | |
| 1732 } | |
| 1733 | |
| 1734 test_WithClause() async { | |
| 1735 // WithClause ClassDeclaration | |
| 1736 addTestSource('class x extends Object with ^\n{}'); | |
| 1737 await assertOpType(typeNames: true); | |
| 1738 } | |
| 1739 } | |
| OLD | NEW |