| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 engine.incremental_resolver_test; | 5 library engine.incremental_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
| 10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
| 11 import 'package:analyzer/src/generated/incremental_logger.dart' as log; | 11 import 'package:analyzer/src/generated/incremental_logger.dart' as log; |
| 12 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; |
| 12 import 'package:analyzer/src/generated/incremental_resolver.dart'; | 13 import 'package:analyzer/src/generated/incremental_resolver.dart'; |
| 13 import 'package:analyzer/src/generated/java_engine.dart'; | 14 import 'package:analyzer/src/generated/java_engine.dart'; |
| 14 import 'package:analyzer/src/generated/parser.dart'; | 15 import 'package:analyzer/src/generated/parser.dart'; |
| 15 import 'package:analyzer/src/generated/resolver.dart'; | 16 import 'package:analyzer/src/generated/resolver.dart'; |
| 16 import 'package:analyzer/src/generated/scanner.dart'; | 17 import 'package:analyzer/src/generated/scanner.dart'; |
| 17 import 'package:analyzer/src/generated/source_io.dart'; | 18 import 'package:analyzer/src/generated/source_io.dart'; |
| 18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 19 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 19 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 20 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 20 import 'package:unittest/unittest.dart'; | 21 import 'package:unittest/unittest.dart'; |
| 21 | 22 |
| (...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 expect(success, isTrue); | 2282 expect(success, isTrue); |
| 2282 List<AnalysisError> newErrors = analysisContext.getErrors(source).errors; | 2283 List<AnalysisError> newErrors = analysisContext.getErrors(source).errors; |
| 2283 // resolve "newCode" from scratch | 2284 // resolve "newCode" from scratch |
| 2284 CompilationUnit fullNewUnit; | 2285 CompilationUnit fullNewUnit; |
| 2285 { | 2286 { |
| 2286 source = addSource(newCode); | 2287 source = addSource(newCode); |
| 2287 _runTasks(); | 2288 _runTasks(); |
| 2288 LibraryElement library = resolve(source); | 2289 LibraryElement library = resolve(source); |
| 2289 fullNewUnit = resolveCompilationUnit(source, library); | 2290 fullNewUnit = resolveCompilationUnit(source, library); |
| 2290 } | 2291 } |
| 2291 _SameResolutionValidator.assertSameResolution(unit, fullNewUnit); | 2292 assertSameResolution(unit, fullNewUnit, fail); |
| 2292 // errors | 2293 // errors |
| 2293 List<AnalysisError> newFullErrors = | 2294 List<AnalysisError> newFullErrors = |
| 2294 analysisContext.getErrors(source).errors; | 2295 analysisContext.getErrors(source).errors; |
| 2295 _assertEqualErrors(newErrors, newFullErrors); | 2296 _assertEqualErrors(newErrors, newFullErrors); |
| 2296 // prepare for the next cycle | 2297 // prepare for the next cycle |
| 2297 code = newCode; | 2298 code = newCode; |
| 2298 } | 2299 } |
| 2299 | 2300 |
| 2300 void _resolveUnit(String code) { | 2301 void _resolveUnit(String code) { |
| 2301 this.code = code; | 2302 this.code = code; |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3072 ChangeNotice notice = analysisResult.changeNotices[0]; | 3073 ChangeNotice notice = analysisResult.changeNotices[0]; |
| 3073 expect(notice.compilationUnit, same(newUnit)); | 3074 expect(notice.compilationUnit, same(newUnit)); |
| 3074 // Resolve "newCode" from scratch. | 3075 // Resolve "newCode" from scratch. |
| 3075 if (compareWithFull) { | 3076 if (compareWithFull) { |
| 3076 _resetWithIncremental(false); | 3077 _resetWithIncremental(false); |
| 3077 source = addSource(newCode); | 3078 source = addSource(newCode); |
| 3078 _runTasks(); | 3079 _runTasks(); |
| 3079 LibraryElement library = resolve(source); | 3080 LibraryElement library = resolve(source); |
| 3080 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); | 3081 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); |
| 3081 // Validate that "incremental" and "full" units have the same resolution. | 3082 // Validate that "incremental" and "full" units have the same resolution. |
| 3082 _SameResolutionValidator.assertSameResolution(newUnit, fullNewUnit); | 3083 assertSameResolution(newUnit, fullNewUnit, fail); |
| 3083 _assertEqualTokens(newUnit, fullNewUnit); | 3084 _assertEqualTokens(newUnit, fullNewUnit); |
| 3084 List<AnalysisError> newFullErrors = | 3085 List<AnalysisError> newFullErrors = |
| 3085 analysisContext.getErrors(source).errors; | 3086 analysisContext.getErrors(source).errors; |
| 3086 _assertEqualErrors(newErrors, newFullErrors); | 3087 _assertEqualErrors(newErrors, newFullErrors); |
| 3087 // TODO(scheglov) check line info | 3088 // TODO(scheglov) check line info |
| 3088 } | 3089 } |
| 3089 } | 3090 } |
| 3090 | 3091 |
| 3091 static void _assertEqualToken(Token incrToken, Token fullToken) { | 3092 static void _assertEqualToken(Token incrToken, Token fullToken) { |
| 3092 expect(incrToken.type, fullToken.type); | 3093 expect(incrToken.type, fullToken.type); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3363 } | 3364 } |
| 3364 } | 3365 } |
| 3365 | 3366 |
| 3366 | 3367 |
| 3367 class _Edit { | 3368 class _Edit { |
| 3368 final int offset; | 3369 final int offset; |
| 3369 final int length; | 3370 final int length; |
| 3370 final String replacement; | 3371 final String replacement; |
| 3371 _Edit(this.offset, this.length, this.replacement); | 3372 _Edit(this.offset, this.length, this.replacement); |
| 3372 } | 3373 } |
| 3373 | |
| 3374 | |
| 3375 class _SameResolutionValidator implements AstVisitor { | |
| 3376 AstNode other; | |
| 3377 | |
| 3378 _SameResolutionValidator(this.other); | |
| 3379 | |
| 3380 @override | |
| 3381 visitAdjacentStrings(AdjacentStrings node) { | |
| 3382 } | |
| 3383 | |
| 3384 @override | |
| 3385 visitAnnotation(Annotation node) { | |
| 3386 Annotation other = this.other; | |
| 3387 _visitNode(node.name, other.name); | |
| 3388 _visitNode(node.constructorName, other.constructorName); | |
| 3389 _visitNode(node.arguments, other.arguments); | |
| 3390 _verifyElement(node.element, other.element); | |
| 3391 } | |
| 3392 | |
| 3393 @override | |
| 3394 visitArgumentList(ArgumentList node) { | |
| 3395 ArgumentList other = this.other; | |
| 3396 _visitList(node.arguments, other.arguments); | |
| 3397 } | |
| 3398 | |
| 3399 @override | |
| 3400 visitAsExpression(AsExpression node) { | |
| 3401 AsExpression other = this.other; | |
| 3402 _visitExpression(node, other); | |
| 3403 _visitNode(node.expression, other.expression); | |
| 3404 _visitNode(node.type, other.type); | |
| 3405 } | |
| 3406 | |
| 3407 @override | |
| 3408 visitAssertStatement(AssertStatement node) { | |
| 3409 AssertStatement other = this.other; | |
| 3410 _visitNode(node.condition, other.condition); | |
| 3411 } | |
| 3412 | |
| 3413 @override | |
| 3414 visitAssignmentExpression(AssignmentExpression node) { | |
| 3415 AssignmentExpression other = this.other; | |
| 3416 _visitExpression(node, other); | |
| 3417 _verifyElement(node.staticElement, other.staticElement); | |
| 3418 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3419 _visitNode(node.leftHandSide, other.leftHandSide); | |
| 3420 _visitNode(node.rightHandSide, other.rightHandSide); | |
| 3421 } | |
| 3422 | |
| 3423 @override | |
| 3424 visitAwaitExpression(AwaitExpression node) { | |
| 3425 AwaitExpression other = this.other; | |
| 3426 _visitExpression(node, other); | |
| 3427 _visitNode(node.expression, other.expression); | |
| 3428 } | |
| 3429 | |
| 3430 @override | |
| 3431 visitBinaryExpression(BinaryExpression node) { | |
| 3432 BinaryExpression other = this.other; | |
| 3433 _visitExpression(node, other); | |
| 3434 _verifyElement(node.staticElement, other.staticElement); | |
| 3435 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3436 _visitNode(node.leftOperand, other.leftOperand); | |
| 3437 _visitNode(node.rightOperand, other.rightOperand); | |
| 3438 } | |
| 3439 | |
| 3440 @override | |
| 3441 visitBlock(Block node) { | |
| 3442 Block other = this.other; | |
| 3443 _visitList(node.statements, other.statements); | |
| 3444 } | |
| 3445 | |
| 3446 @override | |
| 3447 visitBlockFunctionBody(BlockFunctionBody node) { | |
| 3448 BlockFunctionBody other = this.other; | |
| 3449 _visitNode(node.block, other.block); | |
| 3450 } | |
| 3451 | |
| 3452 @override | |
| 3453 visitBooleanLiteral(BooleanLiteral node) { | |
| 3454 BooleanLiteral other = this.other; | |
| 3455 _visitExpression(node, other); | |
| 3456 } | |
| 3457 | |
| 3458 @override | |
| 3459 visitBreakStatement(BreakStatement node) { | |
| 3460 BreakStatement other = this.other; | |
| 3461 _visitNode(node.label, other.label); | |
| 3462 } | |
| 3463 | |
| 3464 @override | |
| 3465 visitCascadeExpression(CascadeExpression node) { | |
| 3466 CascadeExpression other = this.other; | |
| 3467 _visitExpression(node, other); | |
| 3468 _visitNode(node.target, other.target); | |
| 3469 _visitList(node.cascadeSections, other.cascadeSections); | |
| 3470 } | |
| 3471 | |
| 3472 @override | |
| 3473 visitCatchClause(CatchClause node) { | |
| 3474 CatchClause other = this.other; | |
| 3475 _visitNode(node.exceptionType, other.exceptionType); | |
| 3476 _visitNode(node.exceptionParameter, other.exceptionParameter); | |
| 3477 _visitNode(node.stackTraceParameter, other.stackTraceParameter); | |
| 3478 _visitNode(node.body, other.body); | |
| 3479 } | |
| 3480 | |
| 3481 @override | |
| 3482 visitClassDeclaration(ClassDeclaration node) { | |
| 3483 ClassDeclaration other = this.other; | |
| 3484 _visitDeclaration(node, other); | |
| 3485 _visitNode(node.name, other.name); | |
| 3486 _visitNode(node.typeParameters, other.typeParameters); | |
| 3487 _visitNode(node.extendsClause, other.extendsClause); | |
| 3488 _visitNode(node.implementsClause, other.implementsClause); | |
| 3489 _visitNode(node.withClause, other.withClause); | |
| 3490 _visitList(node.members, other.members); | |
| 3491 } | |
| 3492 | |
| 3493 @override | |
| 3494 visitClassTypeAlias(ClassTypeAlias node) { | |
| 3495 ClassTypeAlias other = this.other; | |
| 3496 _visitDeclaration(node, other); | |
| 3497 _visitNode(node.name, other.name); | |
| 3498 _visitNode(node.typeParameters, other.typeParameters); | |
| 3499 _visitNode(node.superclass, other.superclass); | |
| 3500 _visitNode(node.withClause, other.withClause); | |
| 3501 } | |
| 3502 | |
| 3503 @override | |
| 3504 visitComment(Comment node) { | |
| 3505 Comment other = this.other; | |
| 3506 _visitList(node.references, other.references); | |
| 3507 } | |
| 3508 | |
| 3509 @override | |
| 3510 visitCommentReference(CommentReference node) { | |
| 3511 CommentReference other = this.other; | |
| 3512 _visitNode(node.identifier, other.identifier); | |
| 3513 } | |
| 3514 | |
| 3515 @override | |
| 3516 visitCompilationUnit(CompilationUnit node) { | |
| 3517 CompilationUnit other = this.other; | |
| 3518 _verifyElement(node.element, other.element); | |
| 3519 _visitList(node.directives, other.directives); | |
| 3520 _visitList(node.declarations, other.declarations); | |
| 3521 } | |
| 3522 | |
| 3523 @override | |
| 3524 visitConditionalExpression(ConditionalExpression node) { | |
| 3525 ConditionalExpression other = this.other; | |
| 3526 _visitExpression(node, other); | |
| 3527 _visitNode(node.condition, other.condition); | |
| 3528 _visitNode(node.thenExpression, other.thenExpression); | |
| 3529 _visitNode(node.elseExpression, other.elseExpression); | |
| 3530 } | |
| 3531 | |
| 3532 @override | |
| 3533 visitConstructorDeclaration(ConstructorDeclaration node) { | |
| 3534 ConstructorDeclaration other = this.other; | |
| 3535 _visitDeclaration(node, other); | |
| 3536 _visitNode(node.returnType, other.returnType); | |
| 3537 _visitNode(node.name, other.name); | |
| 3538 _visitNode(node.parameters, other.parameters); | |
| 3539 _visitNode(node.redirectedConstructor, other.redirectedConstructor); | |
| 3540 _visitList(node.initializers, other.initializers); | |
| 3541 } | |
| 3542 | |
| 3543 @override | |
| 3544 visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | |
| 3545 ConstructorFieldInitializer other = this.other; | |
| 3546 _visitNode(node.fieldName, other.fieldName); | |
| 3547 _visitNode(node.expression, other.expression); | |
| 3548 } | |
| 3549 | |
| 3550 @override | |
| 3551 visitConstructorName(ConstructorName node) { | |
| 3552 ConstructorName other = this.other; | |
| 3553 _verifyElement(node.staticElement, other.staticElement); | |
| 3554 _visitNode(node.type, other.type); | |
| 3555 _visitNode(node.name, other.name); | |
| 3556 } | |
| 3557 | |
| 3558 @override | |
| 3559 visitContinueStatement(ContinueStatement node) { | |
| 3560 ContinueStatement other = this.other; | |
| 3561 _visitNode(node.label, other.label); | |
| 3562 } | |
| 3563 | |
| 3564 @override | |
| 3565 visitDeclaredIdentifier(DeclaredIdentifier node) { | |
| 3566 DeclaredIdentifier other = this.other; | |
| 3567 _visitNode(node.type, other.type); | |
| 3568 _visitNode(node.identifier, other.identifier); | |
| 3569 } | |
| 3570 | |
| 3571 @override | |
| 3572 visitDefaultFormalParameter(DefaultFormalParameter node) { | |
| 3573 DefaultFormalParameter other = this.other; | |
| 3574 _visitNode(node.parameter, other.parameter); | |
| 3575 _visitNode(node.defaultValue, other.defaultValue); | |
| 3576 } | |
| 3577 | |
| 3578 @override | |
| 3579 visitDoStatement(DoStatement node) { | |
| 3580 DoStatement other = this.other; | |
| 3581 _visitNode(node.condition, other.condition); | |
| 3582 _visitNode(node.body, other.body); | |
| 3583 } | |
| 3584 | |
| 3585 @override | |
| 3586 visitDoubleLiteral(DoubleLiteral node) { | |
| 3587 DoubleLiteral other = this.other; | |
| 3588 _visitExpression(node, other); | |
| 3589 } | |
| 3590 | |
| 3591 @override | |
| 3592 visitEmptyFunctionBody(EmptyFunctionBody node) { | |
| 3593 } | |
| 3594 | |
| 3595 @override | |
| 3596 visitEmptyStatement(EmptyStatement node) { | |
| 3597 } | |
| 3598 | |
| 3599 @override | |
| 3600 visitEnumConstantDeclaration(EnumConstantDeclaration node) { | |
| 3601 EnumConstantDeclaration other = this.other; | |
| 3602 _visitDeclaration(node, other); | |
| 3603 _visitNode(node.name, other.name); | |
| 3604 } | |
| 3605 | |
| 3606 @override | |
| 3607 visitEnumDeclaration(EnumDeclaration node) { | |
| 3608 EnumDeclaration other = this.other; | |
| 3609 _visitDeclaration(node, other); | |
| 3610 _visitNode(node.name, other.name); | |
| 3611 _visitList(node.constants, other.constants); | |
| 3612 } | |
| 3613 | |
| 3614 @override | |
| 3615 visitExportDirective(ExportDirective node) { | |
| 3616 ExportDirective other = this.other; | |
| 3617 _visitDirective(node, other); | |
| 3618 } | |
| 3619 | |
| 3620 @override | |
| 3621 visitExpressionFunctionBody(ExpressionFunctionBody node) { | |
| 3622 ExpressionFunctionBody other = this.other; | |
| 3623 _visitNode(node.expression, other.expression); | |
| 3624 } | |
| 3625 | |
| 3626 @override | |
| 3627 visitExpressionStatement(ExpressionStatement node) { | |
| 3628 ExpressionStatement other = this.other; | |
| 3629 _visitNode(node.expression, other.expression); | |
| 3630 } | |
| 3631 | |
| 3632 @override | |
| 3633 visitExtendsClause(ExtendsClause node) { | |
| 3634 ExtendsClause other = this.other; | |
| 3635 _visitNode(node.superclass, other.superclass); | |
| 3636 } | |
| 3637 | |
| 3638 @override | |
| 3639 visitFieldDeclaration(FieldDeclaration node) { | |
| 3640 FieldDeclaration other = this.other; | |
| 3641 _visitDeclaration(node, other); | |
| 3642 _visitNode(node.fields, other.fields); | |
| 3643 } | |
| 3644 | |
| 3645 @override | |
| 3646 visitFieldFormalParameter(FieldFormalParameter node) { | |
| 3647 FieldFormalParameter other = this.other; | |
| 3648 _visitNormalFormalParameter(node, other); | |
| 3649 _visitNode(node.type, other.type); | |
| 3650 _visitNode(node.parameters, other.parameters); | |
| 3651 } | |
| 3652 | |
| 3653 @override | |
| 3654 visitForEachStatement(ForEachStatement node) { | |
| 3655 ForEachStatement other = this.other; | |
| 3656 _visitNode(node.identifier, other.identifier); | |
| 3657 _visitNode(node.loopVariable, other.loopVariable); | |
| 3658 _visitNode(node.iterable, other.iterable); | |
| 3659 } | |
| 3660 | |
| 3661 @override | |
| 3662 visitFormalParameterList(FormalParameterList node) { | |
| 3663 FormalParameterList other = this.other; | |
| 3664 _visitList(node.parameters, other.parameters); | |
| 3665 } | |
| 3666 | |
| 3667 @override | |
| 3668 visitForStatement(ForStatement node) { | |
| 3669 ForStatement other = this.other; | |
| 3670 _visitNode(node.variables, other.variables); | |
| 3671 _visitNode(node.initialization, other.initialization); | |
| 3672 _visitNode(node.condition, other.condition); | |
| 3673 _visitList(node.updaters, other.updaters); | |
| 3674 _visitNode(node.body, other.body); | |
| 3675 } | |
| 3676 | |
| 3677 @override | |
| 3678 visitFunctionDeclaration(FunctionDeclaration node) { | |
| 3679 FunctionDeclaration other = this.other; | |
| 3680 _visitDeclaration(node, other); | |
| 3681 _visitNode(node.returnType, other.returnType); | |
| 3682 _visitNode(node.name, other.name); | |
| 3683 _visitNode(node.functionExpression, other.functionExpression); | |
| 3684 } | |
| 3685 | |
| 3686 @override | |
| 3687 visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | |
| 3688 FunctionDeclarationStatement other = this.other; | |
| 3689 _visitNode(node.functionDeclaration, other.functionDeclaration); | |
| 3690 } | |
| 3691 | |
| 3692 @override | |
| 3693 visitFunctionExpression(FunctionExpression node) { | |
| 3694 FunctionExpression other = this.other; | |
| 3695 _visitExpression(node, other); | |
| 3696 _verifyElement(node.element, other.element); | |
| 3697 _visitNode(node.parameters, other.parameters); | |
| 3698 _visitNode(node.body, other.body); | |
| 3699 } | |
| 3700 | |
| 3701 @override | |
| 3702 visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | |
| 3703 FunctionExpressionInvocation other = this.other; | |
| 3704 _visitExpression(node, other); | |
| 3705 _verifyElement(node.staticElement, other.staticElement); | |
| 3706 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3707 _visitNode(node.function, other.function); | |
| 3708 _visitNode(node.argumentList, other.argumentList); | |
| 3709 } | |
| 3710 | |
| 3711 @override | |
| 3712 visitFunctionTypeAlias(FunctionTypeAlias node) { | |
| 3713 FunctionTypeAlias other = this.other; | |
| 3714 _visitDeclaration(node, other); | |
| 3715 _visitNode(node.returnType, other.returnType); | |
| 3716 _visitNode(node.name, other.name); | |
| 3717 _visitNode(node.typeParameters, other.typeParameters); | |
| 3718 _visitNode(node.parameters, other.parameters); | |
| 3719 } | |
| 3720 | |
| 3721 @override | |
| 3722 visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | |
| 3723 FunctionTypedFormalParameter other = this.other; | |
| 3724 _visitNormalFormalParameter(node, other); | |
| 3725 _visitNode(node.returnType, other.returnType); | |
| 3726 _visitNode(node.parameters, other.parameters); | |
| 3727 } | |
| 3728 | |
| 3729 @override | |
| 3730 visitHideCombinator(HideCombinator node) { | |
| 3731 HideCombinator other = this.other; | |
| 3732 _visitList(node.hiddenNames, other.hiddenNames); | |
| 3733 } | |
| 3734 | |
| 3735 @override | |
| 3736 visitIfStatement(IfStatement node) { | |
| 3737 IfStatement other = this.other; | |
| 3738 _visitNode(node.condition, other.condition); | |
| 3739 _visitNode(node.thenStatement, other.thenStatement); | |
| 3740 _visitNode(node.elseStatement, other.elseStatement); | |
| 3741 } | |
| 3742 | |
| 3743 @override | |
| 3744 visitImplementsClause(ImplementsClause node) { | |
| 3745 ImplementsClause other = this.other; | |
| 3746 _visitList(node.interfaces, other.interfaces); | |
| 3747 } | |
| 3748 | |
| 3749 @override | |
| 3750 visitImportDirective(ImportDirective node) { | |
| 3751 ImportDirective other = this.other; | |
| 3752 _visitDirective(node, other); | |
| 3753 _visitNode(node.prefix, other.prefix); | |
| 3754 _verifyElement(node.uriElement, other.uriElement); | |
| 3755 } | |
| 3756 | |
| 3757 @override | |
| 3758 visitIndexExpression(IndexExpression node) { | |
| 3759 IndexExpression other = this.other; | |
| 3760 _visitExpression(node, other); | |
| 3761 _verifyElement(node.staticElement, other.staticElement); | |
| 3762 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3763 _visitNode(node.target, other.target); | |
| 3764 _visitNode(node.index, other.index); | |
| 3765 } | |
| 3766 | |
| 3767 @override | |
| 3768 visitInstanceCreationExpression(InstanceCreationExpression node) { | |
| 3769 InstanceCreationExpression other = this.other; | |
| 3770 _visitExpression(node, other); | |
| 3771 _verifyElement(node.staticElement, other.staticElement); | |
| 3772 _visitNode(node.constructorName, other.constructorName); | |
| 3773 _visitNode(node.argumentList, other.argumentList); | |
| 3774 } | |
| 3775 | |
| 3776 @override | |
| 3777 visitIntegerLiteral(IntegerLiteral node) { | |
| 3778 IntegerLiteral other = this.other; | |
| 3779 _visitExpression(node, other); | |
| 3780 } | |
| 3781 | |
| 3782 @override | |
| 3783 visitInterpolationExpression(InterpolationExpression node) { | |
| 3784 InterpolationExpression other = this.other; | |
| 3785 _visitNode(node.expression, other.expression); | |
| 3786 } | |
| 3787 | |
| 3788 @override | |
| 3789 visitInterpolationString(InterpolationString node) { | |
| 3790 } | |
| 3791 | |
| 3792 @override | |
| 3793 visitIsExpression(IsExpression node) { | |
| 3794 IsExpression other = this.other; | |
| 3795 _visitExpression(node, other); | |
| 3796 _visitNode(node.expression, other.expression); | |
| 3797 _visitNode(node.type, other.type); | |
| 3798 } | |
| 3799 | |
| 3800 @override | |
| 3801 visitLabel(Label node) { | |
| 3802 Label other = this.other; | |
| 3803 _visitNode(node.label, other.label); | |
| 3804 } | |
| 3805 | |
| 3806 @override | |
| 3807 visitLabeledStatement(LabeledStatement node) { | |
| 3808 LabeledStatement other = this.other; | |
| 3809 _visitList(node.labels, other.labels); | |
| 3810 _visitNode(node.statement, other.statement); | |
| 3811 } | |
| 3812 | |
| 3813 @override | |
| 3814 visitLibraryDirective(LibraryDirective node) { | |
| 3815 LibraryDirective other = this.other; | |
| 3816 _visitDirective(node, other); | |
| 3817 _visitNode(node.name, other.name); | |
| 3818 } | |
| 3819 | |
| 3820 @override | |
| 3821 visitLibraryIdentifier(LibraryIdentifier node) { | |
| 3822 LibraryIdentifier other = this.other; | |
| 3823 _visitList(node.components, other.components); | |
| 3824 } | |
| 3825 | |
| 3826 @override | |
| 3827 visitListLiteral(ListLiteral node) { | |
| 3828 ListLiteral other = this.other; | |
| 3829 _visitExpression(node, other); | |
| 3830 _visitList(node.elements, other.elements); | |
| 3831 } | |
| 3832 | |
| 3833 @override | |
| 3834 visitMapLiteral(MapLiteral node) { | |
| 3835 MapLiteral other = this.other; | |
| 3836 _visitExpression(node, other); | |
| 3837 _visitList(node.entries, other.entries); | |
| 3838 } | |
| 3839 | |
| 3840 @override | |
| 3841 visitMapLiteralEntry(MapLiteralEntry node) { | |
| 3842 MapLiteralEntry other = this.other; | |
| 3843 _visitNode(node.key, other.key); | |
| 3844 _visitNode(node.value, other.value); | |
| 3845 } | |
| 3846 | |
| 3847 @override | |
| 3848 visitMethodDeclaration(MethodDeclaration node) { | |
| 3849 MethodDeclaration other = this.other; | |
| 3850 _visitDeclaration(node, other); | |
| 3851 _visitNode(node.name, other.name); | |
| 3852 _visitNode(node.parameters, other.parameters); | |
| 3853 _visitNode(node.body, other.body); | |
| 3854 } | |
| 3855 | |
| 3856 @override | |
| 3857 visitMethodInvocation(MethodInvocation node) { | |
| 3858 MethodInvocation other = this.other; | |
| 3859 _visitNode(node.target, other.target); | |
| 3860 _visitNode(node.methodName, other.methodName); | |
| 3861 _visitNode(node.argumentList, other.argumentList); | |
| 3862 } | |
| 3863 | |
| 3864 @override | |
| 3865 visitNamedExpression(NamedExpression node) { | |
| 3866 NamedExpression other = this.other; | |
| 3867 _visitNode(node.name, other.name); | |
| 3868 _visitNode(node.expression, other.expression); | |
| 3869 } | |
| 3870 | |
| 3871 @override | |
| 3872 visitNativeClause(NativeClause node) { | |
| 3873 } | |
| 3874 | |
| 3875 @override | |
| 3876 visitNativeFunctionBody(NativeFunctionBody node) { | |
| 3877 } | |
| 3878 | |
| 3879 @override | |
| 3880 visitNullLiteral(NullLiteral node) { | |
| 3881 NullLiteral other = this.other; | |
| 3882 _visitExpression(node, other); | |
| 3883 } | |
| 3884 | |
| 3885 @override | |
| 3886 visitParenthesizedExpression(ParenthesizedExpression node) { | |
| 3887 ParenthesizedExpression other = this.other; | |
| 3888 _visitNode(node.expression, other.expression); | |
| 3889 } | |
| 3890 | |
| 3891 @override | |
| 3892 visitPartDirective(PartDirective node) { | |
| 3893 PartDirective other = this.other; | |
| 3894 _visitDirective(node, other); | |
| 3895 } | |
| 3896 | |
| 3897 @override | |
| 3898 visitPartOfDirective(PartOfDirective node) { | |
| 3899 PartOfDirective other = this.other; | |
| 3900 _visitDirective(node, other); | |
| 3901 _visitNode(node.libraryName, other.libraryName); | |
| 3902 } | |
| 3903 | |
| 3904 @override | |
| 3905 visitPostfixExpression(PostfixExpression node) { | |
| 3906 PostfixExpression other = this.other; | |
| 3907 _visitExpression(node, other); | |
| 3908 _verifyElement(node.staticElement, other.staticElement); | |
| 3909 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3910 _visitNode(node.operand, other.operand); | |
| 3911 } | |
| 3912 | |
| 3913 @override | |
| 3914 visitPrefixedIdentifier(PrefixedIdentifier node) { | |
| 3915 PrefixedIdentifier other = this.other; | |
| 3916 _visitExpression(node, other); | |
| 3917 _visitNode(node.prefix, other.prefix); | |
| 3918 _visitNode(node.identifier, other.identifier); | |
| 3919 } | |
| 3920 | |
| 3921 @override | |
| 3922 visitPrefixExpression(PrefixExpression node) { | |
| 3923 PrefixExpression other = this.other; | |
| 3924 _visitExpression(node, other); | |
| 3925 _verifyElement(node.staticElement, other.staticElement); | |
| 3926 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3927 _visitNode(node.operand, other.operand); | |
| 3928 } | |
| 3929 | |
| 3930 @override | |
| 3931 visitPropertyAccess(PropertyAccess node) { | |
| 3932 PropertyAccess other = this.other; | |
| 3933 _visitExpression(node, other); | |
| 3934 _visitNode(node.target, other.target); | |
| 3935 _visitNode(node.propertyName, other.propertyName); | |
| 3936 } | |
| 3937 | |
| 3938 @override | |
| 3939 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { | |
| 3940 RedirectingConstructorInvocation other = this.other; | |
| 3941 _verifyElement(node.staticElement, other.staticElement); | |
| 3942 _visitNode(node.constructorName, other.constructorName); | |
| 3943 _visitNode(node.argumentList, other.argumentList); | |
| 3944 } | |
| 3945 | |
| 3946 @override | |
| 3947 visitRethrowExpression(RethrowExpression node) { | |
| 3948 RethrowExpression other = this.other; | |
| 3949 _visitExpression(node, other); | |
| 3950 } | |
| 3951 | |
| 3952 @override | |
| 3953 visitReturnStatement(ReturnStatement node) { | |
| 3954 ReturnStatement other = this.other; | |
| 3955 _visitNode(node.expression, other.expression); | |
| 3956 } | |
| 3957 | |
| 3958 @override | |
| 3959 visitScriptTag(ScriptTag node) { | |
| 3960 } | |
| 3961 | |
| 3962 @override | |
| 3963 visitShowCombinator(ShowCombinator node) { | |
| 3964 ShowCombinator other = this.other; | |
| 3965 _visitList(node.shownNames, other.shownNames); | |
| 3966 } | |
| 3967 | |
| 3968 @override | |
| 3969 visitSimpleFormalParameter(SimpleFormalParameter node) { | |
| 3970 SimpleFormalParameter other = this.other; | |
| 3971 _visitNormalFormalParameter(node, other); | |
| 3972 _visitNode(node.type, other.type); | |
| 3973 } | |
| 3974 | |
| 3975 @override | |
| 3976 visitSimpleIdentifier(SimpleIdentifier node) { | |
| 3977 SimpleIdentifier other = this.other; | |
| 3978 _verifyElement(node.staticElement, other.staticElement); | |
| 3979 _verifyElement(node.propagatedElement, other.propagatedElement); | |
| 3980 _visitExpression(node, other); | |
| 3981 } | |
| 3982 | |
| 3983 @override | |
| 3984 visitSimpleStringLiteral(SimpleStringLiteral node) { | |
| 3985 } | |
| 3986 | |
| 3987 @override | |
| 3988 visitStringInterpolation(StringInterpolation node) { | |
| 3989 StringInterpolation other = this.other; | |
| 3990 _visitList(node.elements, other.elements); | |
| 3991 } | |
| 3992 | |
| 3993 @override | |
| 3994 visitSuperConstructorInvocation(SuperConstructorInvocation node) { | |
| 3995 SuperConstructorInvocation other = this.other; | |
| 3996 _verifyElement(node.staticElement, other.staticElement); | |
| 3997 _visitNode(node.constructorName, other.constructorName); | |
| 3998 _visitNode(node.argumentList, other.argumentList); | |
| 3999 } | |
| 4000 | |
| 4001 @override | |
| 4002 visitSuperExpression(SuperExpression node) { | |
| 4003 SuperExpression other = this.other; | |
| 4004 _visitExpression(node, other); | |
| 4005 } | |
| 4006 | |
| 4007 @override | |
| 4008 visitSwitchCase(SwitchCase node) { | |
| 4009 SwitchCase other = this.other; | |
| 4010 _visitList(node.labels, other.labels); | |
| 4011 _visitNode(node.expression, other.expression); | |
| 4012 _visitList(node.statements, other.statements); | |
| 4013 } | |
| 4014 | |
| 4015 @override | |
| 4016 visitSwitchDefault(SwitchDefault node) { | |
| 4017 SwitchDefault other = this.other; | |
| 4018 _visitList(node.statements, other.statements); | |
| 4019 } | |
| 4020 | |
| 4021 @override | |
| 4022 visitSwitchStatement(SwitchStatement node) { | |
| 4023 SwitchStatement other = this.other; | |
| 4024 _visitNode(node.expression, other.expression); | |
| 4025 _visitList(node.members, other.members); | |
| 4026 } | |
| 4027 | |
| 4028 @override | |
| 4029 visitSymbolLiteral(SymbolLiteral node) { | |
| 4030 } | |
| 4031 | |
| 4032 @override | |
| 4033 visitThisExpression(ThisExpression node) { | |
| 4034 ThisExpression other = this.other; | |
| 4035 _visitExpression(node, other); | |
| 4036 } | |
| 4037 | |
| 4038 @override | |
| 4039 visitThrowExpression(ThrowExpression node) { | |
| 4040 ThrowExpression other = this.other; | |
| 4041 _visitNode(node.expression, other.expression); | |
| 4042 } | |
| 4043 | |
| 4044 @override | |
| 4045 visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | |
| 4046 TopLevelVariableDeclaration other = this.other; | |
| 4047 _visitNode(node.variables, other.variables); | |
| 4048 } | |
| 4049 | |
| 4050 @override | |
| 4051 visitTryStatement(TryStatement node) { | |
| 4052 TryStatement other = this.other; | |
| 4053 _visitNode(node.body, other.body); | |
| 4054 _visitList(node.catchClauses, other.catchClauses); | |
| 4055 _visitNode(node.finallyBlock, other.finallyBlock); | |
| 4056 } | |
| 4057 | |
| 4058 @override | |
| 4059 visitTypeArgumentList(TypeArgumentList node) { | |
| 4060 TypeArgumentList other = this.other; | |
| 4061 _visitList(node.arguments, other.arguments); | |
| 4062 } | |
| 4063 | |
| 4064 @override | |
| 4065 visitTypeName(TypeName node) { | |
| 4066 TypeName other = this.other; | |
| 4067 _verifyType(node.type, other.type); | |
| 4068 _visitNode(node.name, node.name); | |
| 4069 _visitNode(node.typeArguments, other.typeArguments); | |
| 4070 } | |
| 4071 | |
| 4072 @override | |
| 4073 visitTypeParameter(TypeParameter node) { | |
| 4074 TypeParameter other = this.other; | |
| 4075 _visitNode(node.name, other.name); | |
| 4076 _visitNode(node.bound, other.bound); | |
| 4077 } | |
| 4078 | |
| 4079 @override | |
| 4080 visitTypeParameterList(TypeParameterList node) { | |
| 4081 TypeParameterList other = this.other; | |
| 4082 _visitList(node.typeParameters, other.typeParameters); | |
| 4083 } | |
| 4084 | |
| 4085 @override | |
| 4086 visitVariableDeclaration(VariableDeclaration node) { | |
| 4087 VariableDeclaration other = this.other; | |
| 4088 _visitDeclaration(node, other); | |
| 4089 _visitNode(node.name, other.name); | |
| 4090 _visitNode(node.initializer, other.initializer); | |
| 4091 } | |
| 4092 | |
| 4093 @override | |
| 4094 visitVariableDeclarationList(VariableDeclarationList node) { | |
| 4095 VariableDeclarationList other = this.other; | |
| 4096 _visitNode(node.type, other.type); | |
| 4097 _visitList(node.variables, other.variables); | |
| 4098 } | |
| 4099 | |
| 4100 @override | |
| 4101 visitVariableDeclarationStatement(VariableDeclarationStatement node) { | |
| 4102 VariableDeclarationStatement other = this.other; | |
| 4103 _visitNode(node.variables, other.variables); | |
| 4104 } | |
| 4105 | |
| 4106 @override | |
| 4107 visitWhileStatement(WhileStatement node) { | |
| 4108 WhileStatement other = this.other; | |
| 4109 _visitNode(node.condition, other.condition); | |
| 4110 _visitNode(node.body, other.body); | |
| 4111 } | |
| 4112 | |
| 4113 @override | |
| 4114 visitWithClause(WithClause node) { | |
| 4115 WithClause other = this.other; | |
| 4116 _visitList(node.mixinTypes, other.mixinTypes); | |
| 4117 } | |
| 4118 | |
| 4119 @override | |
| 4120 visitYieldStatement(YieldStatement node) { | |
| 4121 YieldStatement other = this.other; | |
| 4122 _visitNode(node.expression, other.expression); | |
| 4123 } | |
| 4124 | |
| 4125 void _verifyElement(Element a, Element b) { | |
| 4126 if (a != b) { | |
| 4127 print(a.location); | |
| 4128 print(b.location); | |
| 4129 fail('Expected: $b\n Actual: $a'); | |
| 4130 } | |
| 4131 if (a == null && b == null) { | |
| 4132 return; | |
| 4133 } | |
| 4134 if (a.nameOffset != b.nameOffset) { | |
| 4135 fail('Expected: ${b.nameOffset}\n Actual: ${a.nameOffset}'); | |
| 4136 } | |
| 4137 } | |
| 4138 | |
| 4139 void _verifyType(DartType a, DartType b) { | |
| 4140 if (a != b) { | |
| 4141 fail('Expected: $b\n Actual: $a'); | |
| 4142 } | |
| 4143 } | |
| 4144 | |
| 4145 void _visitAnnotatedNode(AnnotatedNode node, AnnotatedNode other) { | |
| 4146 _visitNode(node.documentationComment, other.documentationComment); | |
| 4147 _visitList(node.metadata, other.metadata); | |
| 4148 } | |
| 4149 | |
| 4150 _visitDeclaration(Declaration node, Declaration other) { | |
| 4151 _verifyElement(node.element, other.element); | |
| 4152 _visitAnnotatedNode(node, other); | |
| 4153 } | |
| 4154 | |
| 4155 _visitDirective(Directive node, Directive other) { | |
| 4156 _verifyElement(node.element, other.element); | |
| 4157 _visitAnnotatedNode(node, other); | |
| 4158 } | |
| 4159 | |
| 4160 void _visitExpression(Expression a, Expression b) { | |
| 4161 _verifyType(a.staticType, b.staticType); | |
| 4162 _verifyType(a.propagatedType, b.propagatedType); | |
| 4163 _verifyElement(a.staticParameterElement, b.staticParameterElement); | |
| 4164 _verifyElement(a.propagatedParameterElement, b.propagatedParameterElement); | |
| 4165 } | |
| 4166 | |
| 4167 void _visitList(NodeList nodeList, NodeList otherList) { | |
| 4168 int length = nodeList.length; | |
| 4169 expect(otherList, hasLength(length)); | |
| 4170 for (int i = 0; i < length; i++) { | |
| 4171 _visitNode(nodeList[i], otherList[i]); | |
| 4172 } | |
| 4173 } | |
| 4174 | |
| 4175 void _visitNode(AstNode node, AstNode other) { | |
| 4176 if (node == null) { | |
| 4177 expect(other, isNull); | |
| 4178 } else { | |
| 4179 this.other = other; | |
| 4180 expect(node.offset, other.offset); | |
| 4181 expect(node.length, other.length); | |
| 4182 node.accept(this); | |
| 4183 } | |
| 4184 } | |
| 4185 | |
| 4186 void _visitNormalFormalParameter(NormalFormalParameter node, | |
| 4187 NormalFormalParameter other) { | |
| 4188 _verifyElement(node.element, other.element); | |
| 4189 _visitNode(node.documentationComment, other.documentationComment); | |
| 4190 _visitList(node.metadata, other.metadata); | |
| 4191 _visitNode(node.identifier, other.identifier); | |
| 4192 } | |
| 4193 | |
| 4194 static void assertSameResolution(CompilationUnit actual, | |
| 4195 CompilationUnit expected) { | |
| 4196 _SameResolutionValidator validator = new _SameResolutionValidator(expected); | |
| 4197 actual.accept(validator); | |
| 4198 } | |
| 4199 } | |
| OLD | NEW |