OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.generated.element_resolver_test; | 5 library analyzer.test.generated.element_resolver_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
11 import 'package:analyzer/file_system/memory_file_system.dart'; | 11 import 'package:analyzer/file_system/memory_file_system.dart'; |
12 import 'package:analyzer/src/dart/element/element.dart'; | 12 import 'package:analyzer/src/dart/element/element.dart'; |
13 import 'package:analyzer/src/generated/element_resolver.dart'; | 13 import 'package:analyzer/src/generated/element_resolver.dart'; |
14 import 'package:analyzer/src/generated/engine.dart'; | 14 import 'package:analyzer/src/generated/engine.dart'; |
15 import 'package:analyzer/src/generated/resolver.dart'; | 15 import 'package:analyzer/src/generated/resolver.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
18 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
19 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 19 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
20 import 'package:analyzer/src/source/source_resource.dart'; | 20 import 'package:analyzer/src/source/source_resource.dart'; |
21 import 'package:test/test.dart'; | 21 import 'package:test/test.dart'; |
22 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 22 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
23 | 23 |
24 import 'analysis_context_factory.dart'; | 24 import 'analysis_context_factory.dart'; |
25 import 'resolver_test_case.dart'; | 25 import 'resolver_test_case.dart'; |
26 import 'test_support.dart'; | 26 import 'test_support.dart'; |
27 | 27 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 /** | 324 /** |
325 * The resolver being used to resolve the test cases. | 325 * The resolver being used to resolve the test cases. |
326 */ | 326 */ |
327 ElementResolver _resolver; | 327 ElementResolver _resolver; |
328 | 328 |
329 void fail_visitExportDirective_combinators() { | 329 void fail_visitExportDirective_combinators() { |
330 fail("Not yet tested"); | 330 fail("Not yet tested"); |
331 // Need to set up the exported library so that the identifier can be | 331 // Need to set up the exported library so that the identifier can be |
332 // resolved. | 332 // resolved. |
333 ExportDirective directive = AstFactory.exportDirective2(null, [ | 333 ExportDirective directive = AstTestFactory.exportDirective2(null, [ |
334 AstFactory.hideCombinator2(["A"]) | 334 AstTestFactory.hideCombinator2(["A"]) |
335 ]); | 335 ]); |
336 _resolveNode(directive); | 336 _resolveNode(directive); |
337 _listener.assertNoErrors(); | 337 _listener.assertNoErrors(); |
338 } | 338 } |
339 | 339 |
340 void fail_visitFunctionExpressionInvocation() { | 340 void fail_visitFunctionExpressionInvocation() { |
341 fail("Not yet tested"); | 341 fail("Not yet tested"); |
342 _listener.assertNoErrors(); | 342 _listener.assertNoErrors(); |
343 } | 343 } |
344 | 344 |
345 void fail_visitImportDirective_combinators_noPrefix() { | 345 void fail_visitImportDirective_combinators_noPrefix() { |
346 fail("Not yet tested"); | 346 fail("Not yet tested"); |
347 // Need to set up the imported library so that the identifier can be | 347 // Need to set up the imported library so that the identifier can be |
348 // resolved. | 348 // resolved. |
349 ImportDirective directive = AstFactory.importDirective3(null, null, [ | 349 ImportDirective directive = AstTestFactory.importDirective3(null, null, [ |
350 AstFactory.showCombinator2(["A"]) | 350 AstTestFactory.showCombinator2(["A"]) |
351 ]); | 351 ]); |
352 _resolveNode(directive); | 352 _resolveNode(directive); |
353 _listener.assertNoErrors(); | 353 _listener.assertNoErrors(); |
354 } | 354 } |
355 | 355 |
356 void fail_visitImportDirective_combinators_prefix() { | 356 void fail_visitImportDirective_combinators_prefix() { |
357 fail("Not yet tested"); | 357 fail("Not yet tested"); |
358 // Need to set up the imported library so that the identifiers can be | 358 // Need to set up the imported library so that the identifiers can be |
359 // resolved. | 359 // resolved. |
360 String prefixName = "p"; | 360 String prefixName = "p"; |
361 _definingLibrary.imports = <ImportElement>[ | 361 _definingLibrary.imports = <ImportElement>[ |
362 ElementFactory.importFor(null, ElementFactory.prefix(prefixName)) | 362 ElementFactory.importFor(null, ElementFactory.prefix(prefixName)) |
363 ]; | 363 ]; |
364 ImportDirective directive = AstFactory.importDirective3(null, prefixName, [ | 364 ImportDirective directive = |
365 AstFactory.showCombinator2(["A"]), | 365 AstTestFactory.importDirective3(null, prefixName, [ |
366 AstFactory.hideCombinator2(["B"]) | 366 AstTestFactory.showCombinator2(["A"]), |
| 367 AstTestFactory.hideCombinator2(["B"]) |
367 ]); | 368 ]); |
368 _resolveNode(directive); | 369 _resolveNode(directive); |
369 _listener.assertNoErrors(); | 370 _listener.assertNoErrors(); |
370 } | 371 } |
371 | 372 |
372 void fail_visitRedirectingConstructorInvocation() { | 373 void fail_visitRedirectingConstructorInvocation() { |
373 fail("Not yet tested"); | 374 fail("Not yet tested"); |
374 _listener.assertNoErrors(); | 375 _listener.assertNoErrors(); |
375 } | 376 } |
376 | 377 |
(...skipping 25 matching lines...) Expand all Loading... |
402 ClassElementImpl classC = ElementFactory.classElement2("C"); | 403 ClassElementImpl classC = ElementFactory.classElement2("C"); |
403 classC.mixins = <InterfaceType>[classB.type]; | 404 classC.mixins = <InterfaceType>[classB.type]; |
404 // | 405 // |
405 // class D extends C {} | 406 // class D extends C {} |
406 // | 407 // |
407 ClassElementImpl classD = ElementFactory.classElement("D", classC.type); | 408 ClassElementImpl classD = ElementFactory.classElement("D", classC.type); |
408 // | 409 // |
409 // D a; | 410 // D a; |
410 // a[i]; | 411 // a[i]; |
411 // | 412 // |
412 SimpleIdentifier array = AstFactory.identifier3("a"); | 413 SimpleIdentifier array = AstTestFactory.identifier3("a"); |
413 array.staticType = classD.type; | 414 array.staticType = classD.type; |
414 IndexExpression expression = | 415 IndexExpression expression = |
415 AstFactory.indexExpression(array, AstFactory.identifier3("i")); | 416 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); |
416 expect(_resolveIndexExpression(expression), same(operator)); | 417 expect(_resolveIndexExpression(expression), same(operator)); |
417 _listener.assertNoErrors(); | 418 _listener.assertNoErrors(); |
418 } | 419 } |
419 | 420 |
420 void test_visitAssignmentExpression_compound() { | 421 void test_visitAssignmentExpression_compound() { |
421 InterfaceType intType = _typeProvider.intType; | 422 InterfaceType intType = _typeProvider.intType; |
422 SimpleIdentifier leftHandSide = AstFactory.identifier3("a"); | 423 SimpleIdentifier leftHandSide = AstTestFactory.identifier3("a"); |
423 leftHandSide.staticType = intType; | 424 leftHandSide.staticType = intType; |
424 AssignmentExpression assignment = AstFactory.assignmentExpression( | 425 AssignmentExpression assignment = AstTestFactory.assignmentExpression( |
425 leftHandSide, TokenType.PLUS_EQ, AstFactory.integer(1)); | 426 leftHandSide, TokenType.PLUS_EQ, AstTestFactory.integer(1)); |
426 _resolveNode(assignment); | 427 _resolveNode(assignment); |
427 expect( | 428 expect( |
428 assignment.staticElement, same(getMethod(_typeProvider.numType, "+"))); | 429 assignment.staticElement, same(getMethod(_typeProvider.numType, "+"))); |
429 _listener.assertNoErrors(); | 430 _listener.assertNoErrors(); |
430 } | 431 } |
431 | 432 |
432 void test_visitAssignmentExpression_simple() { | 433 void test_visitAssignmentExpression_simple() { |
433 AssignmentExpression expression = AstFactory.assignmentExpression( | 434 AssignmentExpression expression = AstTestFactory.assignmentExpression( |
434 AstFactory.identifier3("x"), TokenType.EQ, AstFactory.integer(0)); | 435 AstTestFactory.identifier3("x"), |
| 436 TokenType.EQ, |
| 437 AstTestFactory.integer(0)); |
435 _resolveNode(expression); | 438 _resolveNode(expression); |
436 expect(expression.staticElement, isNull); | 439 expect(expression.staticElement, isNull); |
437 _listener.assertNoErrors(); | 440 _listener.assertNoErrors(); |
438 } | 441 } |
439 | 442 |
440 void test_visitBinaryExpression_bangEq() { | 443 void test_visitBinaryExpression_bangEq() { |
441 // String i; | 444 // String i; |
442 // var j; | 445 // var j; |
443 // i == j | 446 // i == j |
444 InterfaceType stringType = _typeProvider.stringType; | 447 InterfaceType stringType = _typeProvider.stringType; |
445 SimpleIdentifier left = AstFactory.identifier3("i"); | 448 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
446 left.staticType = stringType; | 449 left.staticType = stringType; |
447 BinaryExpression expression = AstFactory.binaryExpression( | 450 BinaryExpression expression = AstTestFactory.binaryExpression( |
448 left, TokenType.BANG_EQ, AstFactory.identifier3("j")); | 451 left, TokenType.BANG_EQ, AstTestFactory.identifier3("j")); |
449 _resolveNode(expression); | 452 _resolveNode(expression); |
450 var stringElement = stringType.element; | 453 var stringElement = stringType.element; |
451 expect(expression.staticElement, isNotNull); | 454 expect(expression.staticElement, isNotNull); |
452 expect( | 455 expect( |
453 expression.staticElement, | 456 expression.staticElement, |
454 stringElement.lookUpMethod( | 457 stringElement.lookUpMethod( |
455 TokenType.EQ_EQ.lexeme, stringElement.library)); | 458 TokenType.EQ_EQ.lexeme, stringElement.library)); |
456 expect(expression.propagatedElement, isNull); | 459 expect(expression.propagatedElement, isNull); |
457 _listener.assertNoErrors(); | 460 _listener.assertNoErrors(); |
458 } | 461 } |
459 | 462 |
460 void test_visitBinaryExpression_eq() { | 463 void test_visitBinaryExpression_eq() { |
461 // String i; | 464 // String i; |
462 // var j; | 465 // var j; |
463 // i == j | 466 // i == j |
464 InterfaceType stringType = _typeProvider.stringType; | 467 InterfaceType stringType = _typeProvider.stringType; |
465 SimpleIdentifier left = AstFactory.identifier3("i"); | 468 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
466 left.staticType = stringType; | 469 left.staticType = stringType; |
467 BinaryExpression expression = AstFactory.binaryExpression( | 470 BinaryExpression expression = AstTestFactory.binaryExpression( |
468 left, TokenType.EQ_EQ, AstFactory.identifier3("j")); | 471 left, TokenType.EQ_EQ, AstTestFactory.identifier3("j")); |
469 _resolveNode(expression); | 472 _resolveNode(expression); |
470 var stringElement = stringType.element; | 473 var stringElement = stringType.element; |
471 expect( | 474 expect( |
472 expression.staticElement, | 475 expression.staticElement, |
473 stringElement.lookUpMethod( | 476 stringElement.lookUpMethod( |
474 TokenType.EQ_EQ.lexeme, stringElement.library)); | 477 TokenType.EQ_EQ.lexeme, stringElement.library)); |
475 expect(expression.propagatedElement, isNull); | 478 expect(expression.propagatedElement, isNull); |
476 _listener.assertNoErrors(); | 479 _listener.assertNoErrors(); |
477 } | 480 } |
478 | 481 |
479 void test_visitBinaryExpression_plus() { | 482 void test_visitBinaryExpression_plus() { |
480 // num i; | 483 // num i; |
481 // var j; | 484 // var j; |
482 // i + j | 485 // i + j |
483 InterfaceType numType = _typeProvider.numType; | 486 InterfaceType numType = _typeProvider.numType; |
484 SimpleIdentifier left = AstFactory.identifier3("i"); | 487 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
485 left.staticType = numType; | 488 left.staticType = numType; |
486 BinaryExpression expression = AstFactory.binaryExpression( | 489 BinaryExpression expression = AstTestFactory.binaryExpression( |
487 left, TokenType.PLUS, AstFactory.identifier3("j")); | 490 left, TokenType.PLUS, AstTestFactory.identifier3("j")); |
488 _resolveNode(expression); | 491 _resolveNode(expression); |
489 expect(expression.staticElement, getMethod(numType, "+")); | 492 expect(expression.staticElement, getMethod(numType, "+")); |
490 expect(expression.propagatedElement, isNull); | 493 expect(expression.propagatedElement, isNull); |
491 _listener.assertNoErrors(); | 494 _listener.assertNoErrors(); |
492 } | 495 } |
493 | 496 |
494 void test_visitBinaryExpression_plus_propagatedElement() { | 497 void test_visitBinaryExpression_plus_propagatedElement() { |
495 // var i = 1; | 498 // var i = 1; |
496 // var j; | 499 // var j; |
497 // i + j | 500 // i + j |
498 InterfaceType numType = _typeProvider.numType; | 501 InterfaceType numType = _typeProvider.numType; |
499 SimpleIdentifier left = AstFactory.identifier3("i"); | 502 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
500 left.propagatedType = numType; | 503 left.propagatedType = numType; |
501 BinaryExpression expression = AstFactory.binaryExpression( | 504 BinaryExpression expression = AstTestFactory.binaryExpression( |
502 left, TokenType.PLUS, AstFactory.identifier3("j")); | 505 left, TokenType.PLUS, AstTestFactory.identifier3("j")); |
503 _resolveNode(expression); | 506 _resolveNode(expression); |
504 expect(expression.staticElement, isNull); | 507 expect(expression.staticElement, isNull); |
505 expect(expression.propagatedElement, getMethod(numType, "+")); | 508 expect(expression.propagatedElement, getMethod(numType, "+")); |
506 _listener.assertNoErrors(); | 509 _listener.assertNoErrors(); |
507 } | 510 } |
508 | 511 |
509 void test_visitBreakStatement_withLabel() { | 512 void test_visitBreakStatement_withLabel() { |
510 // loop: while (true) { | 513 // loop: while (true) { |
511 // break loop; | 514 // break loop; |
512 // } | 515 // } |
513 String label = "loop"; | 516 String label = "loop"; |
514 LabelElementImpl labelElement = new LabelElementImpl.forNode( | 517 LabelElementImpl labelElement = new LabelElementImpl.forNode( |
515 AstFactory.identifier3(label), false, false); | 518 AstTestFactory.identifier3(label), false, false); |
516 BreakStatement breakStatement = AstFactory.breakStatement2(label); | 519 BreakStatement breakStatement = AstTestFactory.breakStatement2(label); |
517 Expression condition = AstFactory.booleanLiteral(true); | 520 Expression condition = AstTestFactory.booleanLiteral(true); |
518 WhileStatement whileStatement = | 521 WhileStatement whileStatement = |
519 AstFactory.whileStatement(condition, breakStatement); | 522 AstTestFactory.whileStatement(condition, breakStatement); |
520 expect(_resolveBreak(breakStatement, labelElement, whileStatement), | 523 expect(_resolveBreak(breakStatement, labelElement, whileStatement), |
521 same(labelElement)); | 524 same(labelElement)); |
522 expect(breakStatement.target, same(whileStatement)); | 525 expect(breakStatement.target, same(whileStatement)); |
523 _listener.assertNoErrors(); | 526 _listener.assertNoErrors(); |
524 } | 527 } |
525 | 528 |
526 void test_visitBreakStatement_withoutLabel() { | 529 void test_visitBreakStatement_withoutLabel() { |
527 BreakStatement statement = AstFactory.breakStatement(); | 530 BreakStatement statement = AstTestFactory.breakStatement(); |
528 _resolveStatement(statement, null, null); | 531 _resolveStatement(statement, null, null); |
529 _listener.assertNoErrors(); | 532 _listener.assertNoErrors(); |
530 } | 533 } |
531 | 534 |
532 void test_visitCommentReference_prefixedIdentifier_class_getter() { | 535 void test_visitCommentReference_prefixedIdentifier_class_getter() { |
533 ClassElementImpl classA = ElementFactory.classElement2("A"); | 536 ClassElementImpl classA = ElementFactory.classElement2("A"); |
534 // set accessors | 537 // set accessors |
535 String propName = "p"; | 538 String propName = "p"; |
536 PropertyAccessorElement getter = | 539 PropertyAccessorElement getter = |
537 ElementFactory.getterElement(propName, false, _typeProvider.intType); | 540 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
538 PropertyAccessorElement setter = | 541 PropertyAccessorElement setter = |
539 ElementFactory.setterElement(propName, false, _typeProvider.intType); | 542 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
540 classA.accessors = <PropertyAccessorElement>[getter, setter]; | 543 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
541 // set name scope | 544 // set name scope |
542 _visitor.nameScope = new EnclosedScope(null) | 545 _visitor.nameScope = new EnclosedScope(null) |
543 ..defineNameWithoutChecking('A', classA); | 546 ..defineNameWithoutChecking('A', classA); |
544 // prepare "A.p" | 547 // prepare "A.p" |
545 PrefixedIdentifier prefixed = AstFactory.identifier5('A', 'p'); | 548 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p'); |
546 CommentReference commentReference = new CommentReference(null, prefixed); | 549 CommentReference commentReference = new CommentReference(null, prefixed); |
547 // resolve | 550 // resolve |
548 _resolveNode(commentReference); | 551 _resolveNode(commentReference); |
549 expect(prefixed.prefix.staticElement, classA); | 552 expect(prefixed.prefix.staticElement, classA); |
550 expect(prefixed.identifier.staticElement, getter); | 553 expect(prefixed.identifier.staticElement, getter); |
551 _listener.assertNoErrors(); | 554 _listener.assertNoErrors(); |
552 } | 555 } |
553 | 556 |
554 void test_visitCommentReference_prefixedIdentifier_class_method() { | 557 void test_visitCommentReference_prefixedIdentifier_class_method() { |
555 ClassElementImpl classA = ElementFactory.classElement2("A"); | 558 ClassElementImpl classA = ElementFactory.classElement2("A"); |
556 // set method | 559 // set method |
557 MethodElement method = | 560 MethodElement method = |
558 ElementFactory.methodElement("m", _typeProvider.intType); | 561 ElementFactory.methodElement("m", _typeProvider.intType); |
559 classA.methods = <MethodElement>[method]; | 562 classA.methods = <MethodElement>[method]; |
560 // set name scope | 563 // set name scope |
561 _visitor.nameScope = new EnclosedScope(null) | 564 _visitor.nameScope = new EnclosedScope(null) |
562 ..defineNameWithoutChecking('A', classA); | 565 ..defineNameWithoutChecking('A', classA); |
563 // prepare "A.m" | 566 // prepare "A.m" |
564 PrefixedIdentifier prefixed = AstFactory.identifier5('A', 'm'); | 567 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm'); |
565 CommentReference commentReference = new CommentReference(null, prefixed); | 568 CommentReference commentReference = new CommentReference(null, prefixed); |
566 // resolve | 569 // resolve |
567 _resolveNode(commentReference); | 570 _resolveNode(commentReference); |
568 expect(prefixed.prefix.staticElement, classA); | 571 expect(prefixed.prefix.staticElement, classA); |
569 expect(prefixed.identifier.staticElement, method); | 572 expect(prefixed.identifier.staticElement, method); |
570 _listener.assertNoErrors(); | 573 _listener.assertNoErrors(); |
571 } | 574 } |
572 | 575 |
573 void test_visitCommentReference_prefixedIdentifier_class_operator() { | 576 void test_visitCommentReference_prefixedIdentifier_class_operator() { |
574 ClassElementImpl classA = ElementFactory.classElement2("A"); | 577 ClassElementImpl classA = ElementFactory.classElement2("A"); |
575 // set method | 578 // set method |
576 MethodElement method = | 579 MethodElement method = |
577 ElementFactory.methodElement("==", _typeProvider.boolType); | 580 ElementFactory.methodElement("==", _typeProvider.boolType); |
578 classA.methods = <MethodElement>[method]; | 581 classA.methods = <MethodElement>[method]; |
579 // set name scope | 582 // set name scope |
580 _visitor.nameScope = new EnclosedScope(null) | 583 _visitor.nameScope = new EnclosedScope(null) |
581 ..defineNameWithoutChecking('A', classA); | 584 ..defineNameWithoutChecking('A', classA); |
582 // prepare "A.==" | 585 // prepare "A.==" |
583 PrefixedIdentifier prefixed = AstFactory.identifier5('A', '=='); | 586 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '=='); |
584 CommentReference commentReference = new CommentReference(null, prefixed); | 587 CommentReference commentReference = new CommentReference(null, prefixed); |
585 // resolve | 588 // resolve |
586 _resolveNode(commentReference); | 589 _resolveNode(commentReference); |
587 expect(prefixed.prefix.staticElement, classA); | 590 expect(prefixed.prefix.staticElement, classA); |
588 expect(prefixed.identifier.staticElement, method); | 591 expect(prefixed.identifier.staticElement, method); |
589 _listener.assertNoErrors(); | 592 _listener.assertNoErrors(); |
590 } | 593 } |
591 | 594 |
592 void test_visitConstructorName_named() { | 595 void test_visitConstructorName_named() { |
593 ClassElementImpl classA = ElementFactory.classElement2("A"); | 596 ClassElementImpl classA = ElementFactory.classElement2("A"); |
594 String constructorName = "a"; | 597 String constructorName = "a"; |
595 ConstructorElement constructor = | 598 ConstructorElement constructor = |
596 ElementFactory.constructorElement2(classA, constructorName); | 599 ElementFactory.constructorElement2(classA, constructorName); |
597 classA.constructors = <ConstructorElement>[constructor]; | 600 classA.constructors = <ConstructorElement>[constructor]; |
598 ConstructorName name = AstFactory.constructorName( | 601 ConstructorName name = AstTestFactory.constructorName( |
599 AstFactory.typeName(classA), constructorName); | 602 AstTestFactory.typeName(classA), constructorName); |
600 _resolveNode(name); | 603 _resolveNode(name); |
601 expect(name.staticElement, same(constructor)); | 604 expect(name.staticElement, same(constructor)); |
602 _listener.assertNoErrors(); | 605 _listener.assertNoErrors(); |
603 } | 606 } |
604 | 607 |
605 void test_visitConstructorName_unnamed() { | 608 void test_visitConstructorName_unnamed() { |
606 ClassElementImpl classA = ElementFactory.classElement2("A"); | 609 ClassElementImpl classA = ElementFactory.classElement2("A"); |
607 String constructorName = null; | 610 String constructorName = null; |
608 ConstructorElement constructor = | 611 ConstructorElement constructor = |
609 ElementFactory.constructorElement2(classA, constructorName); | 612 ElementFactory.constructorElement2(classA, constructorName); |
610 classA.constructors = <ConstructorElement>[constructor]; | 613 classA.constructors = <ConstructorElement>[constructor]; |
611 ConstructorName name = AstFactory.constructorName( | 614 ConstructorName name = AstTestFactory.constructorName( |
612 AstFactory.typeName(classA), constructorName); | 615 AstTestFactory.typeName(classA), constructorName); |
613 _resolveNode(name); | 616 _resolveNode(name); |
614 expect(name.staticElement, same(constructor)); | 617 expect(name.staticElement, same(constructor)); |
615 _listener.assertNoErrors(); | 618 _listener.assertNoErrors(); |
616 } | 619 } |
617 | 620 |
618 void test_visitContinueStatement_withLabel() { | 621 void test_visitContinueStatement_withLabel() { |
619 // loop: while (true) { | 622 // loop: while (true) { |
620 // continue loop; | 623 // continue loop; |
621 // } | 624 // } |
622 String label = "loop"; | 625 String label = "loop"; |
623 LabelElementImpl labelElement = new LabelElementImpl.forNode( | 626 LabelElementImpl labelElement = new LabelElementImpl.forNode( |
624 AstFactory.identifier3(label), false, false); | 627 AstTestFactory.identifier3(label), false, false); |
625 ContinueStatement continueStatement = AstFactory.continueStatement(label); | 628 ContinueStatement continueStatement = |
626 Expression condition = AstFactory.booleanLiteral(true); | 629 AstTestFactory.continueStatement(label); |
| 630 Expression condition = AstTestFactory.booleanLiteral(true); |
627 WhileStatement whileStatement = | 631 WhileStatement whileStatement = |
628 AstFactory.whileStatement(condition, continueStatement); | 632 AstTestFactory.whileStatement(condition, continueStatement); |
629 expect(_resolveContinue(continueStatement, labelElement, whileStatement), | 633 expect(_resolveContinue(continueStatement, labelElement, whileStatement), |
630 same(labelElement)); | 634 same(labelElement)); |
631 expect(continueStatement.target, same(whileStatement)); | 635 expect(continueStatement.target, same(whileStatement)); |
632 _listener.assertNoErrors(); | 636 _listener.assertNoErrors(); |
633 } | 637 } |
634 | 638 |
635 void test_visitContinueStatement_withoutLabel() { | 639 void test_visitContinueStatement_withoutLabel() { |
636 ContinueStatement statement = AstFactory.continueStatement(); | 640 ContinueStatement statement = AstTestFactory.continueStatement(); |
637 _resolveStatement(statement, null, null); | 641 _resolveStatement(statement, null, null); |
638 _listener.assertNoErrors(); | 642 _listener.assertNoErrors(); |
639 } | 643 } |
640 | 644 |
641 void test_visitEnumDeclaration() { | 645 void test_visitEnumDeclaration() { |
642 CompilationUnitElementImpl compilationUnitElement = | 646 CompilationUnitElementImpl compilationUnitElement = |
643 ElementFactory.compilationUnit('foo.dart'); | 647 ElementFactory.compilationUnit('foo.dart'); |
644 EnumElementImpl enumElement = | 648 EnumElementImpl enumElement = |
645 ElementFactory.enumElement(_typeProvider, ('E')); | 649 ElementFactory.enumElement(_typeProvider, ('E')); |
646 compilationUnitElement.enums = <ClassElement>[enumElement]; | 650 compilationUnitElement.enums = <ClassElement>[enumElement]; |
647 EnumDeclaration enumNode = AstFactory.enumDeclaration2('E', []); | 651 EnumDeclaration enumNode = AstTestFactory.enumDeclaration2('E', []); |
648 Annotation annotationNode = | 652 Annotation annotationNode = |
649 AstFactory.annotation(AstFactory.identifier3('a')); | 653 AstTestFactory.annotation(AstTestFactory.identifier3('a')); |
650 annotationNode.element = ElementFactory.classElement2('A'); | 654 annotationNode.element = ElementFactory.classElement2('A'); |
651 annotationNode.elementAnnotation = | 655 annotationNode.elementAnnotation = |
652 new ElementAnnotationImpl(compilationUnitElement); | 656 new ElementAnnotationImpl(compilationUnitElement); |
653 enumNode.metadata.add(annotationNode); | 657 enumNode.metadata.add(annotationNode); |
654 enumNode.name.staticElement = enumElement; | 658 enumNode.name.staticElement = enumElement; |
655 List<ElementAnnotation> metadata = <ElementAnnotation>[ | 659 List<ElementAnnotation> metadata = <ElementAnnotation>[ |
656 annotationNode.elementAnnotation | 660 annotationNode.elementAnnotation |
657 ]; | 661 ]; |
658 _resolveNode(enumNode); | 662 _resolveNode(enumNode); |
659 expect(metadata[0].element, annotationNode.element); | 663 expect(metadata[0].element, annotationNode.element); |
660 } | 664 } |
661 | 665 |
662 void test_visitExportDirective_noCombinators() { | 666 void test_visitExportDirective_noCombinators() { |
663 ExportDirective directive = AstFactory.exportDirective2(null); | 667 ExportDirective directive = AstTestFactory.exportDirective2(null); |
664 directive.element = ElementFactory | 668 directive.element = ElementFactory |
665 .exportFor(ElementFactory.library(_definingLibrary.context, "lib")); | 669 .exportFor(ElementFactory.library(_definingLibrary.context, "lib")); |
666 _resolveNode(directive); | 670 _resolveNode(directive); |
667 _listener.assertNoErrors(); | 671 _listener.assertNoErrors(); |
668 } | 672 } |
669 | 673 |
670 void test_visitFieldFormalParameter() { | 674 void test_visitFieldFormalParameter() { |
671 String fieldName = "f"; | 675 String fieldName = "f"; |
672 InterfaceType intType = _typeProvider.intType; | 676 InterfaceType intType = _typeProvider.intType; |
673 FieldElementImpl fieldElement = | 677 FieldElementImpl fieldElement = |
674 ElementFactory.fieldElement(fieldName, false, false, false, intType); | 678 ElementFactory.fieldElement(fieldName, false, false, false, intType); |
675 ClassElementImpl classA = ElementFactory.classElement2("A"); | 679 ClassElementImpl classA = ElementFactory.classElement2("A"); |
676 classA.fields = <FieldElement>[fieldElement]; | 680 classA.fields = <FieldElement>[fieldElement]; |
677 FieldFormalParameter parameter = | 681 FieldFormalParameter parameter = |
678 AstFactory.fieldFormalParameter2(fieldName); | 682 AstTestFactory.fieldFormalParameter2(fieldName); |
679 FieldFormalParameterElementImpl parameterElement = | 683 FieldFormalParameterElementImpl parameterElement = |
680 ElementFactory.fieldFormalParameter(parameter.identifier); | 684 ElementFactory.fieldFormalParameter(parameter.identifier); |
681 parameterElement.field = fieldElement; | 685 parameterElement.field = fieldElement; |
682 parameterElement.type = intType; | 686 parameterElement.type = intType; |
683 parameter.identifier.staticElement = parameterElement; | 687 parameter.identifier.staticElement = parameterElement; |
684 _resolveInClass(parameter, classA); | 688 _resolveInClass(parameter, classA); |
685 expect(parameter.element.type, same(intType)); | 689 expect(parameter.element.type, same(intType)); |
686 } | 690 } |
687 | 691 |
688 void test_visitImportDirective_noCombinators_noPrefix() { | 692 void test_visitImportDirective_noCombinators_noPrefix() { |
689 ImportDirective directive = AstFactory.importDirective3(null, null); | 693 ImportDirective directive = AstTestFactory.importDirective3(null, null); |
690 directive.element = ElementFactory.importFor( | 694 directive.element = ElementFactory.importFor( |
691 ElementFactory.library(_definingLibrary.context, "lib"), null); | 695 ElementFactory.library(_definingLibrary.context, "lib"), null); |
692 _resolveNode(directive); | 696 _resolveNode(directive); |
693 _listener.assertNoErrors(); | 697 _listener.assertNoErrors(); |
694 } | 698 } |
695 | 699 |
696 void test_visitImportDirective_noCombinators_prefix() { | 700 void test_visitImportDirective_noCombinators_prefix() { |
697 String prefixName = "p"; | 701 String prefixName = "p"; |
698 ImportElement importElement = ElementFactory.importFor( | 702 ImportElement importElement = ElementFactory.importFor( |
699 ElementFactory.library(_definingLibrary.context, "lib"), | 703 ElementFactory.library(_definingLibrary.context, "lib"), |
700 ElementFactory.prefix(prefixName)); | 704 ElementFactory.prefix(prefixName)); |
701 _definingLibrary.imports = <ImportElement>[importElement]; | 705 _definingLibrary.imports = <ImportElement>[importElement]; |
702 ImportDirective directive = AstFactory.importDirective3(null, prefixName); | 706 ImportDirective directive = |
| 707 AstTestFactory.importDirective3(null, prefixName); |
703 directive.element = importElement; | 708 directive.element = importElement; |
704 _resolveNode(directive); | 709 _resolveNode(directive); |
705 _listener.assertNoErrors(); | 710 _listener.assertNoErrors(); |
706 } | 711 } |
707 | 712 |
708 void test_visitImportDirective_withCombinators() { | 713 void test_visitImportDirective_withCombinators() { |
709 ShowCombinator combinator = AstFactory.showCombinator2(["A", "B", "C"]); | 714 ShowCombinator combinator = AstTestFactory.showCombinator2(["A", "B", "C"]); |
710 ImportDirective directive = | 715 ImportDirective directive = |
711 AstFactory.importDirective3(null, null, [combinator]); | 716 AstTestFactory.importDirective3(null, null, [combinator]); |
712 LibraryElementImpl library = | 717 LibraryElementImpl library = |
713 ElementFactory.library(_definingLibrary.context, "lib"); | 718 ElementFactory.library(_definingLibrary.context, "lib"); |
714 TopLevelVariableElementImpl varA = | 719 TopLevelVariableElementImpl varA = |
715 ElementFactory.topLevelVariableElement2("A"); | 720 ElementFactory.topLevelVariableElement2("A"); |
716 TopLevelVariableElementImpl varB = | 721 TopLevelVariableElementImpl varB = |
717 ElementFactory.topLevelVariableElement2("B"); | 722 ElementFactory.topLevelVariableElement2("B"); |
718 TopLevelVariableElementImpl varC = | 723 TopLevelVariableElementImpl varC = |
719 ElementFactory.topLevelVariableElement2("C"); | 724 ElementFactory.topLevelVariableElement2("C"); |
720 CompilationUnitElementImpl unit = | 725 CompilationUnitElementImpl unit = |
721 library.definingCompilationUnit as CompilationUnitElementImpl; | 726 library.definingCompilationUnit as CompilationUnitElementImpl; |
(...skipping 11 matching lines...) Expand all Loading... |
733 expect(combinator.shownNames[2].staticElement, same(varC)); | 738 expect(combinator.shownNames[2].staticElement, same(varC)); |
734 _listener.assertNoErrors(); | 739 _listener.assertNoErrors(); |
735 } | 740 } |
736 | 741 |
737 void test_visitIndexExpression_get() { | 742 void test_visitIndexExpression_get() { |
738 ClassElementImpl classA = ElementFactory.classElement2("A"); | 743 ClassElementImpl classA = ElementFactory.classElement2("A"); |
739 InterfaceType intType = _typeProvider.intType; | 744 InterfaceType intType = _typeProvider.intType; |
740 MethodElement getter = | 745 MethodElement getter = |
741 ElementFactory.methodElement("[]", intType, [intType]); | 746 ElementFactory.methodElement("[]", intType, [intType]); |
742 classA.methods = <MethodElement>[getter]; | 747 classA.methods = <MethodElement>[getter]; |
743 SimpleIdentifier array = AstFactory.identifier3("a"); | 748 SimpleIdentifier array = AstTestFactory.identifier3("a"); |
744 array.staticType = classA.type; | 749 array.staticType = classA.type; |
745 IndexExpression expression = | 750 IndexExpression expression = |
746 AstFactory.indexExpression(array, AstFactory.identifier3("i")); | 751 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); |
747 expect(_resolveIndexExpression(expression), same(getter)); | 752 expect(_resolveIndexExpression(expression), same(getter)); |
748 _listener.assertNoErrors(); | 753 _listener.assertNoErrors(); |
749 } | 754 } |
750 | 755 |
751 void test_visitIndexExpression_set() { | 756 void test_visitIndexExpression_set() { |
752 ClassElementImpl classA = ElementFactory.classElement2("A"); | 757 ClassElementImpl classA = ElementFactory.classElement2("A"); |
753 InterfaceType intType = _typeProvider.intType; | 758 InterfaceType intType = _typeProvider.intType; |
754 MethodElement setter = | 759 MethodElement setter = |
755 ElementFactory.methodElement("[]=", intType, [intType]); | 760 ElementFactory.methodElement("[]=", intType, [intType]); |
756 classA.methods = <MethodElement>[setter]; | 761 classA.methods = <MethodElement>[setter]; |
757 SimpleIdentifier array = AstFactory.identifier3("a"); | 762 SimpleIdentifier array = AstTestFactory.identifier3("a"); |
758 array.staticType = classA.type; | 763 array.staticType = classA.type; |
759 IndexExpression expression = | 764 IndexExpression expression = |
760 AstFactory.indexExpression(array, AstFactory.identifier3("i")); | 765 AstTestFactory.indexExpression(array, AstTestFactory.identifier3("i")); |
761 AstFactory.assignmentExpression( | 766 AstTestFactory.assignmentExpression( |
762 expression, TokenType.EQ, AstFactory.integer(0)); | 767 expression, TokenType.EQ, AstTestFactory.integer(0)); |
763 expect(_resolveIndexExpression(expression), same(setter)); | 768 expect(_resolveIndexExpression(expression), same(setter)); |
764 _listener.assertNoErrors(); | 769 _listener.assertNoErrors(); |
765 } | 770 } |
766 | 771 |
767 void test_visitInstanceCreationExpression_named() { | 772 void test_visitInstanceCreationExpression_named() { |
768 ClassElementImpl classA = ElementFactory.classElement2("A"); | 773 ClassElementImpl classA = ElementFactory.classElement2("A"); |
769 String constructorName = "a"; | 774 String constructorName = "a"; |
770 ConstructorElement constructor = | 775 ConstructorElement constructor = |
771 ElementFactory.constructorElement2(classA, constructorName); | 776 ElementFactory.constructorElement2(classA, constructorName); |
772 classA.constructors = <ConstructorElement>[constructor]; | 777 classA.constructors = <ConstructorElement>[constructor]; |
773 ConstructorName name = AstFactory.constructorName( | 778 ConstructorName name = AstTestFactory.constructorName( |
774 AstFactory.typeName(classA), constructorName); | 779 AstTestFactory.typeName(classA), constructorName); |
775 name.staticElement = constructor; | 780 name.staticElement = constructor; |
776 InstanceCreationExpression creation = | 781 InstanceCreationExpression creation = |
777 AstFactory.instanceCreationExpression(Keyword.NEW, name); | 782 AstTestFactory.instanceCreationExpression(Keyword.NEW, name); |
778 _resolveNode(creation); | 783 _resolveNode(creation); |
779 expect(creation.staticElement, same(constructor)); | 784 expect(creation.staticElement, same(constructor)); |
780 _listener.assertNoErrors(); | 785 _listener.assertNoErrors(); |
781 } | 786 } |
782 | 787 |
783 void test_visitInstanceCreationExpression_unnamed() { | 788 void test_visitInstanceCreationExpression_unnamed() { |
784 ClassElementImpl classA = ElementFactory.classElement2("A"); | 789 ClassElementImpl classA = ElementFactory.classElement2("A"); |
785 String constructorName = null; | 790 String constructorName = null; |
786 ConstructorElement constructor = | 791 ConstructorElement constructor = |
787 ElementFactory.constructorElement2(classA, constructorName); | 792 ElementFactory.constructorElement2(classA, constructorName); |
788 classA.constructors = <ConstructorElement>[constructor]; | 793 classA.constructors = <ConstructorElement>[constructor]; |
789 ConstructorName name = AstFactory.constructorName( | 794 ConstructorName name = AstTestFactory.constructorName( |
790 AstFactory.typeName(classA), constructorName); | 795 AstTestFactory.typeName(classA), constructorName); |
791 name.staticElement = constructor; | 796 name.staticElement = constructor; |
792 InstanceCreationExpression creation = | 797 InstanceCreationExpression creation = |
793 AstFactory.instanceCreationExpression(Keyword.NEW, name); | 798 AstTestFactory.instanceCreationExpression(Keyword.NEW, name); |
794 _resolveNode(creation); | 799 _resolveNode(creation); |
795 expect(creation.staticElement, same(constructor)); | 800 expect(creation.staticElement, same(constructor)); |
796 _listener.assertNoErrors(); | 801 _listener.assertNoErrors(); |
797 } | 802 } |
798 | 803 |
799 void test_visitInstanceCreationExpression_unnamed_namedParameter() { | 804 void test_visitInstanceCreationExpression_unnamed_namedParameter() { |
800 ClassElementImpl classA = ElementFactory.classElement2("A"); | 805 ClassElementImpl classA = ElementFactory.classElement2("A"); |
801 String constructorName = null; | 806 String constructorName = null; |
802 ConstructorElementImpl constructor = | 807 ConstructorElementImpl constructor = |
803 ElementFactory.constructorElement2(classA, constructorName); | 808 ElementFactory.constructorElement2(classA, constructorName); |
804 String parameterName = "a"; | 809 String parameterName = "a"; |
805 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 810 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
806 constructor.parameters = <ParameterElement>[parameter]; | 811 constructor.parameters = <ParameterElement>[parameter]; |
807 classA.constructors = <ConstructorElement>[constructor]; | 812 classA.constructors = <ConstructorElement>[constructor]; |
808 ConstructorName name = AstFactory.constructorName( | 813 ConstructorName name = AstTestFactory.constructorName( |
809 AstFactory.typeName(classA), constructorName); | 814 AstTestFactory.typeName(classA), constructorName); |
810 name.staticElement = constructor; | 815 name.staticElement = constructor; |
811 InstanceCreationExpression creation = AstFactory.instanceCreationExpression( | 816 InstanceCreationExpression creation = AstTestFactory |
812 Keyword.NEW, | 817 .instanceCreationExpression(Keyword.NEW, name, [ |
813 name, | 818 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) |
814 [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]); | 819 ]); |
815 _resolveNode(creation); | 820 _resolveNode(creation); |
816 expect(creation.staticElement, same(constructor)); | 821 expect(creation.staticElement, same(constructor)); |
817 expect( | 822 expect( |
818 (creation.argumentList.arguments[0] as NamedExpression) | 823 (creation.argumentList.arguments[0] as NamedExpression) |
819 .name | 824 .name |
820 .label | 825 .label |
821 .staticElement, | 826 .staticElement, |
822 same(parameter)); | 827 same(parameter)); |
823 _listener.assertNoErrors(); | 828 _listener.assertNoErrors(); |
824 } | 829 } |
825 | 830 |
826 void test_visitMethodInvocation() { | 831 void test_visitMethodInvocation() { |
827 InterfaceType numType = _typeProvider.numType; | 832 InterfaceType numType = _typeProvider.numType; |
828 SimpleIdentifier left = AstFactory.identifier3("i"); | 833 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
829 left.staticType = numType; | 834 left.staticType = numType; |
830 String methodName = "abs"; | 835 String methodName = "abs"; |
831 MethodInvocation invocation = AstFactory.methodInvocation(left, methodName); | 836 MethodInvocation invocation = |
| 837 AstTestFactory.methodInvocation(left, methodName); |
832 _resolveNode(invocation); | 838 _resolveNode(invocation); |
833 expect(invocation.methodName.staticElement, | 839 expect(invocation.methodName.staticElement, |
834 same(getMethod(numType, methodName))); | 840 same(getMethod(numType, methodName))); |
835 _listener.assertNoErrors(); | 841 _listener.assertNoErrors(); |
836 } | 842 } |
837 | 843 |
838 void test_visitMethodInvocation_namedParameter() { | 844 void test_visitMethodInvocation_namedParameter() { |
839 ClassElementImpl classA = ElementFactory.classElement2("A"); | 845 ClassElementImpl classA = ElementFactory.classElement2("A"); |
840 String methodName = "m"; | 846 String methodName = "m"; |
841 String parameterName = "p"; | 847 String parameterName = "p"; |
842 MethodElementImpl method = ElementFactory.methodElement(methodName, null); | 848 MethodElementImpl method = ElementFactory.methodElement(methodName, null); |
843 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 849 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
844 method.parameters = <ParameterElement>[parameter]; | 850 method.parameters = <ParameterElement>[parameter]; |
845 classA.methods = <MethodElement>[method]; | 851 classA.methods = <MethodElement>[method]; |
846 SimpleIdentifier left = AstFactory.identifier3("i"); | 852 SimpleIdentifier left = AstTestFactory.identifier3("i"); |
847 left.staticType = classA.type; | 853 left.staticType = classA.type; |
848 MethodInvocation invocation = AstFactory.methodInvocation(left, methodName, | 854 MethodInvocation invocation = AstTestFactory.methodInvocation( |
849 [AstFactory.namedExpression2(parameterName, AstFactory.integer(0))]); | 855 left, methodName, [ |
| 856 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) |
| 857 ]); |
850 _resolveNode(invocation); | 858 _resolveNode(invocation); |
851 expect(invocation.methodName.staticElement, same(method)); | 859 expect(invocation.methodName.staticElement, same(method)); |
852 expect( | 860 expect( |
853 (invocation.argumentList.arguments[0] as NamedExpression) | 861 (invocation.argumentList.arguments[0] as NamedExpression) |
854 .name | 862 .name |
855 .label | 863 .label |
856 .staticElement, | 864 .staticElement, |
857 same(parameter)); | 865 same(parameter)); |
858 _listener.assertNoErrors(); | 866 _listener.assertNoErrors(); |
859 } | 867 } |
860 | 868 |
861 void test_visitPostfixExpression() { | 869 void test_visitPostfixExpression() { |
862 InterfaceType numType = _typeProvider.numType; | 870 InterfaceType numType = _typeProvider.numType; |
863 SimpleIdentifier operand = AstFactory.identifier3("i"); | 871 SimpleIdentifier operand = AstTestFactory.identifier3("i"); |
864 operand.staticType = numType; | 872 operand.staticType = numType; |
865 PostfixExpression expression = | 873 PostfixExpression expression = |
866 AstFactory.postfixExpression(operand, TokenType.PLUS_PLUS); | 874 AstTestFactory.postfixExpression(operand, TokenType.PLUS_PLUS); |
867 _resolveNode(expression); | 875 _resolveNode(expression); |
868 expect(expression.staticElement, getMethod(numType, "+")); | 876 expect(expression.staticElement, getMethod(numType, "+")); |
869 _listener.assertNoErrors(); | 877 _listener.assertNoErrors(); |
870 } | 878 } |
871 | 879 |
872 void test_visitPrefixedIdentifier_dynamic() { | 880 void test_visitPrefixedIdentifier_dynamic() { |
873 DartType dynamicType = _typeProvider.dynamicType; | 881 DartType dynamicType = _typeProvider.dynamicType; |
874 SimpleIdentifier target = AstFactory.identifier3("a"); | 882 SimpleIdentifier target = AstTestFactory.identifier3("a"); |
875 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 883 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
876 variable.type = dynamicType; | 884 variable.type = dynamicType; |
877 target.staticElement = variable; | 885 target.staticElement = variable; |
878 target.staticType = dynamicType; | 886 target.staticType = dynamicType; |
879 PrefixedIdentifier identifier = | 887 PrefixedIdentifier identifier = |
880 AstFactory.identifier(target, AstFactory.identifier3("b")); | 888 AstTestFactory.identifier(target, AstTestFactory.identifier3("b")); |
881 _resolveNode(identifier); | 889 _resolveNode(identifier); |
882 expect(identifier.staticElement, isNull); | 890 expect(identifier.staticElement, isNull); |
883 expect(identifier.identifier.staticElement, isNull); | 891 expect(identifier.identifier.staticElement, isNull); |
884 _listener.assertNoErrors(); | 892 _listener.assertNoErrors(); |
885 } | 893 } |
886 | 894 |
887 void test_visitPrefixedIdentifier_nonDynamic() { | 895 void test_visitPrefixedIdentifier_nonDynamic() { |
888 ClassElementImpl classA = ElementFactory.classElement2("A"); | 896 ClassElementImpl classA = ElementFactory.classElement2("A"); |
889 String getterName = "b"; | 897 String getterName = "b"; |
890 PropertyAccessorElement getter = | 898 PropertyAccessorElement getter = |
891 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 899 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
892 classA.accessors = <PropertyAccessorElement>[getter]; | 900 classA.accessors = <PropertyAccessorElement>[getter]; |
893 SimpleIdentifier target = AstFactory.identifier3("a"); | 901 SimpleIdentifier target = AstTestFactory.identifier3("a"); |
894 VariableElementImpl variable = ElementFactory.localVariableElement(target); | 902 VariableElementImpl variable = ElementFactory.localVariableElement(target); |
895 variable.type = classA.type; | 903 variable.type = classA.type; |
896 target.staticElement = variable; | 904 target.staticElement = variable; |
897 target.staticType = classA.type; | 905 target.staticType = classA.type; |
898 PrefixedIdentifier identifier = | 906 PrefixedIdentifier identifier = AstTestFactory.identifier( |
899 AstFactory.identifier(target, AstFactory.identifier3(getterName)); | 907 target, AstTestFactory.identifier3(getterName)); |
900 _resolveNode(identifier); | 908 _resolveNode(identifier); |
901 expect(identifier.staticElement, same(getter)); | 909 expect(identifier.staticElement, same(getter)); |
902 expect(identifier.identifier.staticElement, same(getter)); | 910 expect(identifier.identifier.staticElement, same(getter)); |
903 _listener.assertNoErrors(); | 911 _listener.assertNoErrors(); |
904 } | 912 } |
905 | 913 |
906 void test_visitPrefixedIdentifier_staticClassMember_getter() { | 914 void test_visitPrefixedIdentifier_staticClassMember_getter() { |
907 ClassElementImpl classA = ElementFactory.classElement2("A"); | 915 ClassElementImpl classA = ElementFactory.classElement2("A"); |
908 // set accessors | 916 // set accessors |
909 String propName = "b"; | 917 String propName = "b"; |
910 PropertyAccessorElement getter = | 918 PropertyAccessorElement getter = |
911 ElementFactory.getterElement(propName, false, _typeProvider.intType); | 919 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
912 PropertyAccessorElement setter = | 920 PropertyAccessorElement setter = |
913 ElementFactory.setterElement(propName, false, _typeProvider.intType); | 921 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
914 classA.accessors = <PropertyAccessorElement>[getter, setter]; | 922 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
915 // prepare "A.m" | 923 // prepare "A.m" |
916 SimpleIdentifier target = AstFactory.identifier3("A"); | 924 SimpleIdentifier target = AstTestFactory.identifier3("A"); |
917 target.staticElement = classA; | 925 target.staticElement = classA; |
918 target.staticType = classA.type; | 926 target.staticType = classA.type; |
919 PrefixedIdentifier identifier = | 927 PrefixedIdentifier identifier = |
920 AstFactory.identifier(target, AstFactory.identifier3(propName)); | 928 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); |
921 // resolve | 929 // resolve |
922 _resolveNode(identifier); | 930 _resolveNode(identifier); |
923 expect(identifier.staticElement, same(getter)); | 931 expect(identifier.staticElement, same(getter)); |
924 expect(identifier.identifier.staticElement, same(getter)); | 932 expect(identifier.identifier.staticElement, same(getter)); |
925 _listener.assertNoErrors(); | 933 _listener.assertNoErrors(); |
926 } | 934 } |
927 | 935 |
928 void test_visitPrefixedIdentifier_staticClassMember_method() { | 936 void test_visitPrefixedIdentifier_staticClassMember_method() { |
929 ClassElementImpl classA = ElementFactory.classElement2("A"); | 937 ClassElementImpl classA = ElementFactory.classElement2("A"); |
930 // set methods | 938 // set methods |
931 String propName = "m"; | 939 String propName = "m"; |
932 MethodElement method = | 940 MethodElement method = |
933 ElementFactory.methodElement("m", _typeProvider.intType); | 941 ElementFactory.methodElement("m", _typeProvider.intType); |
934 classA.methods = <MethodElement>[method]; | 942 classA.methods = <MethodElement>[method]; |
935 // prepare "A.m" | 943 // prepare "A.m" |
936 SimpleIdentifier target = AstFactory.identifier3("A"); | 944 SimpleIdentifier target = AstTestFactory.identifier3("A"); |
937 target.staticElement = classA; | 945 target.staticElement = classA; |
938 target.staticType = classA.type; | 946 target.staticType = classA.type; |
939 PrefixedIdentifier identifier = | 947 PrefixedIdentifier identifier = |
940 AstFactory.identifier(target, AstFactory.identifier3(propName)); | 948 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); |
941 AstFactory.assignmentExpression( | 949 AstTestFactory.assignmentExpression( |
942 identifier, TokenType.EQ, AstFactory.nullLiteral()); | 950 identifier, TokenType.EQ, AstTestFactory.nullLiteral()); |
943 // resolve | 951 // resolve |
944 _resolveNode(identifier); | 952 _resolveNode(identifier); |
945 expect(identifier.staticElement, same(method)); | 953 expect(identifier.staticElement, same(method)); |
946 expect(identifier.identifier.staticElement, same(method)); | 954 expect(identifier.identifier.staticElement, same(method)); |
947 _listener.assertNoErrors(); | 955 _listener.assertNoErrors(); |
948 } | 956 } |
949 | 957 |
950 void test_visitPrefixedIdentifier_staticClassMember_setter() { | 958 void test_visitPrefixedIdentifier_staticClassMember_setter() { |
951 ClassElementImpl classA = ElementFactory.classElement2("A"); | 959 ClassElementImpl classA = ElementFactory.classElement2("A"); |
952 // set accessors | 960 // set accessors |
953 String propName = "b"; | 961 String propName = "b"; |
954 PropertyAccessorElement getter = | 962 PropertyAccessorElement getter = |
955 ElementFactory.getterElement(propName, false, _typeProvider.intType); | 963 ElementFactory.getterElement(propName, false, _typeProvider.intType); |
956 PropertyAccessorElement setter = | 964 PropertyAccessorElement setter = |
957 ElementFactory.setterElement(propName, false, _typeProvider.intType); | 965 ElementFactory.setterElement(propName, false, _typeProvider.intType); |
958 classA.accessors = <PropertyAccessorElement>[getter, setter]; | 966 classA.accessors = <PropertyAccessorElement>[getter, setter]; |
959 // prepare "A.b = null" | 967 // prepare "A.b = null" |
960 SimpleIdentifier target = AstFactory.identifier3("A"); | 968 SimpleIdentifier target = AstTestFactory.identifier3("A"); |
961 target.staticElement = classA; | 969 target.staticElement = classA; |
962 target.staticType = classA.type; | 970 target.staticType = classA.type; |
963 PrefixedIdentifier identifier = | 971 PrefixedIdentifier identifier = |
964 AstFactory.identifier(target, AstFactory.identifier3(propName)); | 972 AstTestFactory.identifier(target, AstTestFactory.identifier3(propName)); |
965 AstFactory.assignmentExpression( | 973 AstTestFactory.assignmentExpression( |
966 identifier, TokenType.EQ, AstFactory.nullLiteral()); | 974 identifier, TokenType.EQ, AstTestFactory.nullLiteral()); |
967 // resolve | 975 // resolve |
968 _resolveNode(identifier); | 976 _resolveNode(identifier); |
969 expect(identifier.staticElement, same(setter)); | 977 expect(identifier.staticElement, same(setter)); |
970 expect(identifier.identifier.staticElement, same(setter)); | 978 expect(identifier.identifier.staticElement, same(setter)); |
971 _listener.assertNoErrors(); | 979 _listener.assertNoErrors(); |
972 } | 980 } |
973 | 981 |
974 void test_visitPrefixExpression() { | 982 void test_visitPrefixExpression() { |
975 InterfaceType numType = _typeProvider.numType; | 983 InterfaceType numType = _typeProvider.numType; |
976 SimpleIdentifier operand = AstFactory.identifier3("i"); | 984 SimpleIdentifier operand = AstTestFactory.identifier3("i"); |
977 operand.staticType = numType; | 985 operand.staticType = numType; |
978 PrefixExpression expression = | 986 PrefixExpression expression = |
979 AstFactory.prefixExpression(TokenType.PLUS_PLUS, operand); | 987 AstTestFactory.prefixExpression(TokenType.PLUS_PLUS, operand); |
980 _resolveNode(expression); | 988 _resolveNode(expression); |
981 expect(expression.staticElement, getMethod(numType, "+")); | 989 expect(expression.staticElement, getMethod(numType, "+")); |
982 _listener.assertNoErrors(); | 990 _listener.assertNoErrors(); |
983 } | 991 } |
984 | 992 |
985 void test_visitPropertyAccess_getter_identifier() { | 993 void test_visitPropertyAccess_getter_identifier() { |
986 ClassElementImpl classA = ElementFactory.classElement2("A"); | 994 ClassElementImpl classA = ElementFactory.classElement2("A"); |
987 String getterName = "b"; | 995 String getterName = "b"; |
988 PropertyAccessorElement getter = | 996 PropertyAccessorElement getter = |
989 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 997 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
990 classA.accessors = <PropertyAccessorElement>[getter]; | 998 classA.accessors = <PropertyAccessorElement>[getter]; |
991 SimpleIdentifier target = AstFactory.identifier3("a"); | 999 SimpleIdentifier target = AstTestFactory.identifier3("a"); |
992 target.staticType = classA.type; | 1000 target.staticType = classA.type; |
993 PropertyAccess access = AstFactory.propertyAccess2(target, getterName); | 1001 PropertyAccess access = AstTestFactory.propertyAccess2(target, getterName); |
994 _resolveNode(access); | 1002 _resolveNode(access); |
995 expect(access.propertyName.staticElement, same(getter)); | 1003 expect(access.propertyName.staticElement, same(getter)); |
996 _listener.assertNoErrors(); | 1004 _listener.assertNoErrors(); |
997 } | 1005 } |
998 | 1006 |
999 void test_visitPropertyAccess_getter_super() { | 1007 void test_visitPropertyAccess_getter_super() { |
1000 // | 1008 // |
1001 // class A { | 1009 // class A { |
1002 // int get b; | 1010 // int get b; |
1003 // } | 1011 // } |
1004 // class B { | 1012 // class B { |
1005 // ... super.m ... | 1013 // ... super.m ... |
1006 // } | 1014 // } |
1007 // | 1015 // |
1008 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1016 ClassElementImpl classA = ElementFactory.classElement2("A"); |
1009 String getterName = "b"; | 1017 String getterName = "b"; |
1010 PropertyAccessorElement getter = | 1018 PropertyAccessorElement getter = |
1011 ElementFactory.getterElement(getterName, false, _typeProvider.intType); | 1019 ElementFactory.getterElement(getterName, false, _typeProvider.intType); |
1012 classA.accessors = <PropertyAccessorElement>[getter]; | 1020 classA.accessors = <PropertyAccessorElement>[getter]; |
1013 SuperExpression target = AstFactory.superExpression(); | 1021 SuperExpression target = AstTestFactory.superExpression(); |
1014 target.staticType = ElementFactory.classElement("B", classA.type).type; | 1022 target.staticType = ElementFactory.classElement("B", classA.type).type; |
1015 PropertyAccess access = AstFactory.propertyAccess2(target, getterName); | 1023 PropertyAccess access = AstTestFactory.propertyAccess2(target, getterName); |
1016 AstFactory.methodDeclaration2( | 1024 AstTestFactory.methodDeclaration2( |
1017 null, | 1025 null, |
1018 null, | 1026 null, |
1019 null, | 1027 null, |
1020 null, | 1028 null, |
1021 AstFactory.identifier3("m"), | 1029 AstTestFactory.identifier3("m"), |
1022 AstFactory.formalParameterList(), | 1030 AstTestFactory.formalParameterList(), |
1023 AstFactory.expressionFunctionBody(access)); | 1031 AstTestFactory.expressionFunctionBody(access)); |
1024 _resolveNode(access); | 1032 _resolveNode(access); |
1025 expect(access.propertyName.staticElement, same(getter)); | 1033 expect(access.propertyName.staticElement, same(getter)); |
1026 _listener.assertNoErrors(); | 1034 _listener.assertNoErrors(); |
1027 } | 1035 } |
1028 | 1036 |
1029 void test_visitPropertyAccess_setter_this() { | 1037 void test_visitPropertyAccess_setter_this() { |
1030 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1038 ClassElementImpl classA = ElementFactory.classElement2("A"); |
1031 String setterName = "b"; | 1039 String setterName = "b"; |
1032 PropertyAccessorElement setter = | 1040 PropertyAccessorElement setter = |
1033 ElementFactory.setterElement(setterName, false, _typeProvider.intType); | 1041 ElementFactory.setterElement(setterName, false, _typeProvider.intType); |
1034 classA.accessors = <PropertyAccessorElement>[setter]; | 1042 classA.accessors = <PropertyAccessorElement>[setter]; |
1035 ThisExpression target = AstFactory.thisExpression(); | 1043 ThisExpression target = AstTestFactory.thisExpression(); |
1036 target.staticType = classA.type; | 1044 target.staticType = classA.type; |
1037 PropertyAccess access = AstFactory.propertyAccess2(target, setterName); | 1045 PropertyAccess access = AstTestFactory.propertyAccess2(target, setterName); |
1038 AstFactory.assignmentExpression( | 1046 AstTestFactory.assignmentExpression( |
1039 access, TokenType.EQ, AstFactory.integer(0)); | 1047 access, TokenType.EQ, AstTestFactory.integer(0)); |
1040 _resolveNode(access); | 1048 _resolveNode(access); |
1041 expect(access.propertyName.staticElement, same(setter)); | 1049 expect(access.propertyName.staticElement, same(setter)); |
1042 _listener.assertNoErrors(); | 1050 _listener.assertNoErrors(); |
1043 } | 1051 } |
1044 | 1052 |
1045 void test_visitSimpleIdentifier_classScope() { | 1053 void test_visitSimpleIdentifier_classScope() { |
1046 InterfaceType doubleType = _typeProvider.doubleType; | 1054 InterfaceType doubleType = _typeProvider.doubleType; |
1047 String fieldName = "NAN"; | 1055 String fieldName = "NAN"; |
1048 SimpleIdentifier node = AstFactory.identifier3(fieldName); | 1056 SimpleIdentifier node = AstTestFactory.identifier3(fieldName); |
1049 _resolveInClass(node, doubleType.element); | 1057 _resolveInClass(node, doubleType.element); |
1050 expect(node.staticElement, getGetter(doubleType, fieldName)); | 1058 expect(node.staticElement, getGetter(doubleType, fieldName)); |
1051 _listener.assertNoErrors(); | 1059 _listener.assertNoErrors(); |
1052 } | 1060 } |
1053 | 1061 |
1054 void test_visitSimpleIdentifier_dynamic() { | 1062 void test_visitSimpleIdentifier_dynamic() { |
1055 SimpleIdentifier node = AstFactory.identifier3("dynamic"); | 1063 SimpleIdentifier node = AstTestFactory.identifier3("dynamic"); |
1056 _resolveIdentifier(node); | 1064 _resolveIdentifier(node); |
1057 expect(node.staticElement, same(_typeProvider.dynamicType.element)); | 1065 expect(node.staticElement, same(_typeProvider.dynamicType.element)); |
1058 expect(node.staticType, same(_typeProvider.typeType)); | 1066 expect(node.staticType, same(_typeProvider.typeType)); |
1059 _listener.assertNoErrors(); | 1067 _listener.assertNoErrors(); |
1060 } | 1068 } |
1061 | 1069 |
1062 void test_visitSimpleIdentifier_lexicalScope() { | 1070 void test_visitSimpleIdentifier_lexicalScope() { |
1063 SimpleIdentifier node = AstFactory.identifier3("i"); | 1071 SimpleIdentifier node = AstTestFactory.identifier3("i"); |
1064 VariableElementImpl element = ElementFactory.localVariableElement(node); | 1072 VariableElementImpl element = ElementFactory.localVariableElement(node); |
1065 expect(_resolveIdentifier(node, [element]), same(element)); | 1073 expect(_resolveIdentifier(node, [element]), same(element)); |
1066 _listener.assertNoErrors(); | 1074 _listener.assertNoErrors(); |
1067 } | 1075 } |
1068 | 1076 |
1069 void test_visitSimpleIdentifier_lexicalScope_field_setter() { | 1077 void test_visitSimpleIdentifier_lexicalScope_field_setter() { |
1070 InterfaceType intType = _typeProvider.intType; | 1078 InterfaceType intType = _typeProvider.intType; |
1071 ClassElementImpl classA = ElementFactory.classElement2("A"); | 1079 ClassElementImpl classA = ElementFactory.classElement2("A"); |
1072 String fieldName = "a"; | 1080 String fieldName = "a"; |
1073 FieldElement field = | 1081 FieldElement field = |
1074 ElementFactory.fieldElement(fieldName, false, false, false, intType); | 1082 ElementFactory.fieldElement(fieldName, false, false, false, intType); |
1075 classA.fields = <FieldElement>[field]; | 1083 classA.fields = <FieldElement>[field]; |
1076 classA.accessors = <PropertyAccessorElement>[field.getter, field.setter]; | 1084 classA.accessors = <PropertyAccessorElement>[field.getter, field.setter]; |
1077 SimpleIdentifier node = AstFactory.identifier3(fieldName); | 1085 SimpleIdentifier node = AstTestFactory.identifier3(fieldName); |
1078 AstFactory.assignmentExpression(node, TokenType.EQ, AstFactory.integer(0)); | 1086 AstTestFactory.assignmentExpression( |
| 1087 node, TokenType.EQ, AstTestFactory.integer(0)); |
1079 _resolveInClass(node, classA); | 1088 _resolveInClass(node, classA); |
1080 Element element = node.staticElement; | 1089 Element element = node.staticElement; |
1081 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, | 1090 EngineTestCase.assertInstanceOf((obj) => obj is PropertyAccessorElement, |
1082 PropertyAccessorElement, element); | 1091 PropertyAccessorElement, element); |
1083 expect((element as PropertyAccessorElement).isSetter, isTrue); | 1092 expect((element as PropertyAccessorElement).isSetter, isTrue); |
1084 _listener.assertNoErrors(); | 1093 _listener.assertNoErrors(); |
1085 } | 1094 } |
1086 | 1095 |
1087 void test_visitSuperConstructorInvocation() { | 1096 void test_visitSuperConstructorInvocation() { |
1088 ClassElementImpl superclass = ElementFactory.classElement2("A"); | 1097 ClassElementImpl superclass = ElementFactory.classElement2("A"); |
1089 ConstructorElementImpl superConstructor = | 1098 ConstructorElementImpl superConstructor = |
1090 ElementFactory.constructorElement2(superclass, null); | 1099 ElementFactory.constructorElement2(superclass, null); |
1091 superclass.constructors = <ConstructorElement>[superConstructor]; | 1100 superclass.constructors = <ConstructorElement>[superConstructor]; |
1092 ClassElementImpl subclass = | 1101 ClassElementImpl subclass = |
1093 ElementFactory.classElement("B", superclass.type); | 1102 ElementFactory.classElement("B", superclass.type); |
1094 ConstructorElementImpl subConstructor = | 1103 ConstructorElementImpl subConstructor = |
1095 ElementFactory.constructorElement2(subclass, null); | 1104 ElementFactory.constructorElement2(subclass, null); |
1096 subclass.constructors = <ConstructorElement>[subConstructor]; | 1105 subclass.constructors = <ConstructorElement>[subConstructor]; |
1097 SuperConstructorInvocation invocation = | 1106 SuperConstructorInvocation invocation = |
1098 AstFactory.superConstructorInvocation(); | 1107 AstTestFactory.superConstructorInvocation(); |
1099 AstFactory.classDeclaration(null, 'C', null, null, null, null, [ | 1108 AstTestFactory.classDeclaration(null, 'C', null, null, null, null, [ |
1100 AstFactory.constructorDeclaration(null, 'C', null, [invocation]) | 1109 AstTestFactory.constructorDeclaration(null, 'C', null, [invocation]) |
1101 ]); | 1110 ]); |
1102 _resolveInClass(invocation, subclass); | 1111 _resolveInClass(invocation, subclass); |
1103 expect(invocation.staticElement, superConstructor); | 1112 expect(invocation.staticElement, superConstructor); |
1104 _listener.assertNoErrors(); | 1113 _listener.assertNoErrors(); |
1105 } | 1114 } |
1106 | 1115 |
1107 void test_visitSuperConstructorInvocation_namedParameter() { | 1116 void test_visitSuperConstructorInvocation_namedParameter() { |
1108 ClassElementImpl superclass = ElementFactory.classElement2("A"); | 1117 ClassElementImpl superclass = ElementFactory.classElement2("A"); |
1109 ConstructorElementImpl superConstructor = | 1118 ConstructorElementImpl superConstructor = |
1110 ElementFactory.constructorElement2(superclass, null); | 1119 ElementFactory.constructorElement2(superclass, null); |
1111 String parameterName = "p"; | 1120 String parameterName = "p"; |
1112 ParameterElement parameter = ElementFactory.namedParameter(parameterName); | 1121 ParameterElement parameter = ElementFactory.namedParameter(parameterName); |
1113 superConstructor.parameters = <ParameterElement>[parameter]; | 1122 superConstructor.parameters = <ParameterElement>[parameter]; |
1114 superclass.constructors = <ConstructorElement>[superConstructor]; | 1123 superclass.constructors = <ConstructorElement>[superConstructor]; |
1115 ClassElementImpl subclass = | 1124 ClassElementImpl subclass = |
1116 ElementFactory.classElement("B", superclass.type); | 1125 ElementFactory.classElement("B", superclass.type); |
1117 ConstructorElementImpl subConstructor = | 1126 ConstructorElementImpl subConstructor = |
1118 ElementFactory.constructorElement2(subclass, null); | 1127 ElementFactory.constructorElement2(subclass, null); |
1119 subclass.constructors = <ConstructorElement>[subConstructor]; | 1128 subclass.constructors = <ConstructorElement>[subConstructor]; |
1120 SuperConstructorInvocation invocation = AstFactory | 1129 SuperConstructorInvocation invocation = AstTestFactory |
1121 .superConstructorInvocation([ | 1130 .superConstructorInvocation([ |
1122 AstFactory.namedExpression2(parameterName, AstFactory.integer(0)) | 1131 AstTestFactory.namedExpression2(parameterName, AstTestFactory.integer(0)) |
1123 ]); | 1132 ]); |
1124 AstFactory.classDeclaration(null, 'C', null, null, null, null, [ | 1133 AstTestFactory.classDeclaration(null, 'C', null, null, null, null, [ |
1125 AstFactory.constructorDeclaration(null, 'C', null, [invocation]) | 1134 AstTestFactory.constructorDeclaration(null, 'C', null, [invocation]) |
1126 ]); | 1135 ]); |
1127 _resolveInClass(invocation, subclass); | 1136 _resolveInClass(invocation, subclass); |
1128 expect(invocation.staticElement, superConstructor); | 1137 expect(invocation.staticElement, superConstructor); |
1129 expect( | 1138 expect( |
1130 (invocation.argumentList.arguments[0] as NamedExpression) | 1139 (invocation.argumentList.arguments[0] as NamedExpression) |
1131 .name | 1140 .name |
1132 .label | 1141 .label |
1133 .staticElement, | 1142 .staticElement, |
1134 same(parameter)); | 1143 same(parameter)); |
1135 _listener.assertNoErrors(); | 1144 _listener.assertNoErrors(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 innerScope = new LabelScope( | 1286 innerScope = new LabelScope( |
1278 outerScope, labelElement.name, labelTarget, labelElement); | 1287 outerScope, labelElement.name, labelTarget, labelElement); |
1279 } | 1288 } |
1280 _visitor.labelScope = innerScope; | 1289 _visitor.labelScope = innerScope; |
1281 statement.accept(_resolver); | 1290 statement.accept(_resolver); |
1282 } finally { | 1291 } finally { |
1283 _visitor.labelScope = outerScope; | 1292 _visitor.labelScope = outerScope; |
1284 } | 1293 } |
1285 } | 1294 } |
1286 } | 1295 } |
OLD | NEW |