| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library engine.incremental_resolution_validator; |
| 6 |
| 7 import 'package:analyzer/src/generated/ast.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 |
| 10 |
| 11 void assertSameResolution(CompilationUnit actual, CompilationUnit expected, |
| 12 FailHandler failHandler) { |
| 13 _SameResolutionValidator validator = |
| 14 new _SameResolutionValidator(failHandler, expected); |
| 15 actual.accept(validator); |
| 16 } |
| 17 |
| 18 |
| 19 typedef FailHandler(String reason); |
| 20 |
| 21 |
| 22 class _SameResolutionValidator implements AstVisitor { |
| 23 final FailHandler failHandler; |
| 24 AstNode other; |
| 25 |
| 26 _SameResolutionValidator(this.failHandler, this.other); |
| 27 |
| 28 @override |
| 29 visitAdjacentStrings(AdjacentStrings node) { |
| 30 } |
| 31 |
| 32 @override |
| 33 visitAnnotation(Annotation node) { |
| 34 Annotation other = this.other; |
| 35 _visitNode(node.name, other.name); |
| 36 _visitNode(node.constructorName, other.constructorName); |
| 37 _visitNode(node.arguments, other.arguments); |
| 38 _verifyElement(node.element, other.element); |
| 39 } |
| 40 |
| 41 @override |
| 42 visitArgumentList(ArgumentList node) { |
| 43 ArgumentList other = this.other; |
| 44 _visitList(node.arguments, other.arguments); |
| 45 } |
| 46 |
| 47 @override |
| 48 visitAsExpression(AsExpression node) { |
| 49 AsExpression other = this.other; |
| 50 _visitExpression(node, other); |
| 51 _visitNode(node.expression, other.expression); |
| 52 _visitNode(node.type, other.type); |
| 53 } |
| 54 |
| 55 @override |
| 56 visitAssertStatement(AssertStatement node) { |
| 57 AssertStatement other = this.other; |
| 58 _visitNode(node.condition, other.condition); |
| 59 } |
| 60 |
| 61 @override |
| 62 visitAssignmentExpression(AssignmentExpression node) { |
| 63 AssignmentExpression other = this.other; |
| 64 _visitExpression(node, other); |
| 65 _verifyElement(node.staticElement, other.staticElement); |
| 66 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 67 _visitNode(node.leftHandSide, other.leftHandSide); |
| 68 _visitNode(node.rightHandSide, other.rightHandSide); |
| 69 } |
| 70 |
| 71 @override |
| 72 visitAwaitExpression(AwaitExpression node) { |
| 73 AwaitExpression other = this.other; |
| 74 _visitExpression(node, other); |
| 75 _visitNode(node.expression, other.expression); |
| 76 } |
| 77 |
| 78 @override |
| 79 visitBinaryExpression(BinaryExpression node) { |
| 80 BinaryExpression other = this.other; |
| 81 _visitExpression(node, other); |
| 82 _verifyElement(node.staticElement, other.staticElement); |
| 83 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 84 _visitNode(node.leftOperand, other.leftOperand); |
| 85 _visitNode(node.rightOperand, other.rightOperand); |
| 86 } |
| 87 |
| 88 @override |
| 89 visitBlock(Block node) { |
| 90 Block other = this.other; |
| 91 _visitList(node.statements, other.statements); |
| 92 } |
| 93 |
| 94 @override |
| 95 visitBlockFunctionBody(BlockFunctionBody node) { |
| 96 BlockFunctionBody other = this.other; |
| 97 _visitNode(node.block, other.block); |
| 98 } |
| 99 |
| 100 @override |
| 101 visitBooleanLiteral(BooleanLiteral node) { |
| 102 BooleanLiteral other = this.other; |
| 103 _visitExpression(node, other); |
| 104 } |
| 105 |
| 106 @override |
| 107 visitBreakStatement(BreakStatement node) { |
| 108 BreakStatement other = this.other; |
| 109 _visitNode(node.label, other.label); |
| 110 } |
| 111 |
| 112 @override |
| 113 visitCascadeExpression(CascadeExpression node) { |
| 114 CascadeExpression other = this.other; |
| 115 _visitExpression(node, other); |
| 116 _visitNode(node.target, other.target); |
| 117 _visitList(node.cascadeSections, other.cascadeSections); |
| 118 } |
| 119 |
| 120 @override |
| 121 visitCatchClause(CatchClause node) { |
| 122 CatchClause other = this.other; |
| 123 _visitNode(node.exceptionType, other.exceptionType); |
| 124 _visitNode(node.exceptionParameter, other.exceptionParameter); |
| 125 _visitNode(node.stackTraceParameter, other.stackTraceParameter); |
| 126 _visitNode(node.body, other.body); |
| 127 } |
| 128 |
| 129 @override |
| 130 visitClassDeclaration(ClassDeclaration node) { |
| 131 ClassDeclaration other = this.other; |
| 132 _visitDeclaration(node, other); |
| 133 _visitNode(node.name, other.name); |
| 134 _visitNode(node.typeParameters, other.typeParameters); |
| 135 _visitNode(node.extendsClause, other.extendsClause); |
| 136 _visitNode(node.implementsClause, other.implementsClause); |
| 137 _visitNode(node.withClause, other.withClause); |
| 138 _visitList(node.members, other.members); |
| 139 } |
| 140 |
| 141 @override |
| 142 visitClassTypeAlias(ClassTypeAlias node) { |
| 143 ClassTypeAlias other = this.other; |
| 144 _visitDeclaration(node, other); |
| 145 _visitNode(node.name, other.name); |
| 146 _visitNode(node.typeParameters, other.typeParameters); |
| 147 _visitNode(node.superclass, other.superclass); |
| 148 _visitNode(node.withClause, other.withClause); |
| 149 } |
| 150 |
| 151 @override |
| 152 visitComment(Comment node) { |
| 153 Comment other = this.other; |
| 154 _visitList(node.references, other.references); |
| 155 } |
| 156 |
| 157 @override |
| 158 visitCommentReference(CommentReference node) { |
| 159 CommentReference other = this.other; |
| 160 _visitNode(node.identifier, other.identifier); |
| 161 } |
| 162 |
| 163 @override |
| 164 visitCompilationUnit(CompilationUnit node) { |
| 165 CompilationUnit other = this.other; |
| 166 _verifyElement(node.element, other.element); |
| 167 _visitList(node.directives, other.directives); |
| 168 _visitList(node.declarations, other.declarations); |
| 169 } |
| 170 |
| 171 @override |
| 172 visitConditionalExpression(ConditionalExpression node) { |
| 173 ConditionalExpression other = this.other; |
| 174 _visitExpression(node, other); |
| 175 _visitNode(node.condition, other.condition); |
| 176 _visitNode(node.thenExpression, other.thenExpression); |
| 177 _visitNode(node.elseExpression, other.elseExpression); |
| 178 } |
| 179 |
| 180 @override |
| 181 visitConstructorDeclaration(ConstructorDeclaration node) { |
| 182 ConstructorDeclaration other = this.other; |
| 183 _visitDeclaration(node, other); |
| 184 _visitNode(node.returnType, other.returnType); |
| 185 _visitNode(node.name, other.name); |
| 186 _visitNode(node.parameters, other.parameters); |
| 187 _visitNode(node.redirectedConstructor, other.redirectedConstructor); |
| 188 _visitList(node.initializers, other.initializers); |
| 189 } |
| 190 |
| 191 @override |
| 192 visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 193 ConstructorFieldInitializer other = this.other; |
| 194 _visitNode(node.fieldName, other.fieldName); |
| 195 _visitNode(node.expression, other.expression); |
| 196 } |
| 197 |
| 198 @override |
| 199 visitConstructorName(ConstructorName node) { |
| 200 ConstructorName other = this.other; |
| 201 _verifyElement(node.staticElement, other.staticElement); |
| 202 _visitNode(node.type, other.type); |
| 203 _visitNode(node.name, other.name); |
| 204 } |
| 205 |
| 206 @override |
| 207 visitContinueStatement(ContinueStatement node) { |
| 208 ContinueStatement other = this.other; |
| 209 _visitNode(node.label, other.label); |
| 210 } |
| 211 |
| 212 @override |
| 213 visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 214 DeclaredIdentifier other = this.other; |
| 215 _visitNode(node.type, other.type); |
| 216 _visitNode(node.identifier, other.identifier); |
| 217 } |
| 218 |
| 219 @override |
| 220 visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 221 DefaultFormalParameter other = this.other; |
| 222 _visitNode(node.parameter, other.parameter); |
| 223 _visitNode(node.defaultValue, other.defaultValue); |
| 224 } |
| 225 |
| 226 @override |
| 227 visitDoStatement(DoStatement node) { |
| 228 DoStatement other = this.other; |
| 229 _visitNode(node.condition, other.condition); |
| 230 _visitNode(node.body, other.body); |
| 231 } |
| 232 |
| 233 @override |
| 234 visitDoubleLiteral(DoubleLiteral node) { |
| 235 DoubleLiteral other = this.other; |
| 236 _visitExpression(node, other); |
| 237 } |
| 238 |
| 239 @override |
| 240 visitEmptyFunctionBody(EmptyFunctionBody node) { |
| 241 } |
| 242 |
| 243 @override |
| 244 visitEmptyStatement(EmptyStatement node) { |
| 245 } |
| 246 |
| 247 @override |
| 248 visitEnumConstantDeclaration(EnumConstantDeclaration node) { |
| 249 EnumConstantDeclaration other = this.other; |
| 250 _visitDeclaration(node, other); |
| 251 _visitNode(node.name, other.name); |
| 252 } |
| 253 |
| 254 @override |
| 255 visitEnumDeclaration(EnumDeclaration node) { |
| 256 EnumDeclaration other = this.other; |
| 257 _visitDeclaration(node, other); |
| 258 _visitNode(node.name, other.name); |
| 259 _visitList(node.constants, other.constants); |
| 260 } |
| 261 |
| 262 @override |
| 263 visitExportDirective(ExportDirective node) { |
| 264 ExportDirective other = this.other; |
| 265 _visitDirective(node, other); |
| 266 } |
| 267 |
| 268 @override |
| 269 visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 270 ExpressionFunctionBody other = this.other; |
| 271 _visitNode(node.expression, other.expression); |
| 272 } |
| 273 |
| 274 @override |
| 275 visitExpressionStatement(ExpressionStatement node) { |
| 276 ExpressionStatement other = this.other; |
| 277 _visitNode(node.expression, other.expression); |
| 278 } |
| 279 |
| 280 @override |
| 281 visitExtendsClause(ExtendsClause node) { |
| 282 ExtendsClause other = this.other; |
| 283 _visitNode(node.superclass, other.superclass); |
| 284 } |
| 285 |
| 286 @override |
| 287 visitFieldDeclaration(FieldDeclaration node) { |
| 288 FieldDeclaration other = this.other; |
| 289 _visitDeclaration(node, other); |
| 290 _visitNode(node.fields, other.fields); |
| 291 } |
| 292 |
| 293 @override |
| 294 visitFieldFormalParameter(FieldFormalParameter node) { |
| 295 FieldFormalParameter other = this.other; |
| 296 _visitNormalFormalParameter(node, other); |
| 297 _visitNode(node.type, other.type); |
| 298 _visitNode(node.parameters, other.parameters); |
| 299 } |
| 300 |
| 301 @override |
| 302 visitForEachStatement(ForEachStatement node) { |
| 303 ForEachStatement other = this.other; |
| 304 _visitNode(node.identifier, other.identifier); |
| 305 _visitNode(node.loopVariable, other.loopVariable); |
| 306 _visitNode(node.iterable, other.iterable); |
| 307 } |
| 308 |
| 309 @override |
| 310 visitFormalParameterList(FormalParameterList node) { |
| 311 FormalParameterList other = this.other; |
| 312 _visitList(node.parameters, other.parameters); |
| 313 } |
| 314 |
| 315 @override |
| 316 visitForStatement(ForStatement node) { |
| 317 ForStatement other = this.other; |
| 318 _visitNode(node.variables, other.variables); |
| 319 _visitNode(node.initialization, other.initialization); |
| 320 _visitNode(node.condition, other.condition); |
| 321 _visitList(node.updaters, other.updaters); |
| 322 _visitNode(node.body, other.body); |
| 323 } |
| 324 |
| 325 @override |
| 326 visitFunctionDeclaration(FunctionDeclaration node) { |
| 327 FunctionDeclaration other = this.other; |
| 328 _visitDeclaration(node, other); |
| 329 _visitNode(node.returnType, other.returnType); |
| 330 _visitNode(node.name, other.name); |
| 331 _visitNode(node.functionExpression, other.functionExpression); |
| 332 } |
| 333 |
| 334 @override |
| 335 visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 336 FunctionDeclarationStatement other = this.other; |
| 337 _visitNode(node.functionDeclaration, other.functionDeclaration); |
| 338 } |
| 339 |
| 340 @override |
| 341 visitFunctionExpression(FunctionExpression node) { |
| 342 FunctionExpression other = this.other; |
| 343 _visitExpression(node, other); |
| 344 _verifyElement(node.element, other.element); |
| 345 _visitNode(node.parameters, other.parameters); |
| 346 _visitNode(node.body, other.body); |
| 347 } |
| 348 |
| 349 @override |
| 350 visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 351 FunctionExpressionInvocation other = this.other; |
| 352 _visitExpression(node, other); |
| 353 _verifyElement(node.staticElement, other.staticElement); |
| 354 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 355 _visitNode(node.function, other.function); |
| 356 _visitNode(node.argumentList, other.argumentList); |
| 357 } |
| 358 |
| 359 @override |
| 360 visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 361 FunctionTypeAlias other = this.other; |
| 362 _visitDeclaration(node, other); |
| 363 _visitNode(node.returnType, other.returnType); |
| 364 _visitNode(node.name, other.name); |
| 365 _visitNode(node.typeParameters, other.typeParameters); |
| 366 _visitNode(node.parameters, other.parameters); |
| 367 } |
| 368 |
| 369 @override |
| 370 visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 371 FunctionTypedFormalParameter other = this.other; |
| 372 _visitNormalFormalParameter(node, other); |
| 373 _visitNode(node.returnType, other.returnType); |
| 374 _visitNode(node.parameters, other.parameters); |
| 375 } |
| 376 |
| 377 @override |
| 378 visitHideCombinator(HideCombinator node) { |
| 379 HideCombinator other = this.other; |
| 380 _visitList(node.hiddenNames, other.hiddenNames); |
| 381 } |
| 382 |
| 383 @override |
| 384 visitIfStatement(IfStatement node) { |
| 385 IfStatement other = this.other; |
| 386 _visitNode(node.condition, other.condition); |
| 387 _visitNode(node.thenStatement, other.thenStatement); |
| 388 _visitNode(node.elseStatement, other.elseStatement); |
| 389 } |
| 390 |
| 391 @override |
| 392 visitImplementsClause(ImplementsClause node) { |
| 393 ImplementsClause other = this.other; |
| 394 _visitList(node.interfaces, other.interfaces); |
| 395 } |
| 396 |
| 397 @override |
| 398 visitImportDirective(ImportDirective node) { |
| 399 ImportDirective other = this.other; |
| 400 _visitDirective(node, other); |
| 401 _visitNode(node.prefix, other.prefix); |
| 402 _verifyElement(node.uriElement, other.uriElement); |
| 403 } |
| 404 |
| 405 @override |
| 406 visitIndexExpression(IndexExpression node) { |
| 407 IndexExpression other = this.other; |
| 408 _visitExpression(node, other); |
| 409 _verifyElement(node.staticElement, other.staticElement); |
| 410 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 411 _visitNode(node.target, other.target); |
| 412 _visitNode(node.index, other.index); |
| 413 } |
| 414 |
| 415 @override |
| 416 visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 417 InstanceCreationExpression other = this.other; |
| 418 _visitExpression(node, other); |
| 419 _verifyElement(node.staticElement, other.staticElement); |
| 420 _visitNode(node.constructorName, other.constructorName); |
| 421 _visitNode(node.argumentList, other.argumentList); |
| 422 } |
| 423 |
| 424 @override |
| 425 visitIntegerLiteral(IntegerLiteral node) { |
| 426 IntegerLiteral other = this.other; |
| 427 _visitExpression(node, other); |
| 428 } |
| 429 |
| 430 @override |
| 431 visitInterpolationExpression(InterpolationExpression node) { |
| 432 InterpolationExpression other = this.other; |
| 433 _visitNode(node.expression, other.expression); |
| 434 } |
| 435 |
| 436 @override |
| 437 visitInterpolationString(InterpolationString node) { |
| 438 } |
| 439 |
| 440 @override |
| 441 visitIsExpression(IsExpression node) { |
| 442 IsExpression other = this.other; |
| 443 _visitExpression(node, other); |
| 444 _visitNode(node.expression, other.expression); |
| 445 _visitNode(node.type, other.type); |
| 446 } |
| 447 |
| 448 @override |
| 449 visitLabel(Label node) { |
| 450 Label other = this.other; |
| 451 _visitNode(node.label, other.label); |
| 452 } |
| 453 |
| 454 @override |
| 455 visitLabeledStatement(LabeledStatement node) { |
| 456 LabeledStatement other = this.other; |
| 457 _visitList(node.labels, other.labels); |
| 458 _visitNode(node.statement, other.statement); |
| 459 } |
| 460 |
| 461 @override |
| 462 visitLibraryDirective(LibraryDirective node) { |
| 463 LibraryDirective other = this.other; |
| 464 _visitDirective(node, other); |
| 465 _visitNode(node.name, other.name); |
| 466 } |
| 467 |
| 468 @override |
| 469 visitLibraryIdentifier(LibraryIdentifier node) { |
| 470 LibraryIdentifier other = this.other; |
| 471 _visitList(node.components, other.components); |
| 472 } |
| 473 |
| 474 @override |
| 475 visitListLiteral(ListLiteral node) { |
| 476 ListLiteral other = this.other; |
| 477 _visitExpression(node, other); |
| 478 _visitList(node.elements, other.elements); |
| 479 } |
| 480 |
| 481 @override |
| 482 visitMapLiteral(MapLiteral node) { |
| 483 MapLiteral other = this.other; |
| 484 _visitExpression(node, other); |
| 485 _visitList(node.entries, other.entries); |
| 486 } |
| 487 |
| 488 @override |
| 489 visitMapLiteralEntry(MapLiteralEntry node) { |
| 490 MapLiteralEntry other = this.other; |
| 491 _visitNode(node.key, other.key); |
| 492 _visitNode(node.value, other.value); |
| 493 } |
| 494 |
| 495 @override |
| 496 visitMethodDeclaration(MethodDeclaration node) { |
| 497 MethodDeclaration other = this.other; |
| 498 _visitDeclaration(node, other); |
| 499 _visitNode(node.name, other.name); |
| 500 _visitNode(node.parameters, other.parameters); |
| 501 _visitNode(node.body, other.body); |
| 502 } |
| 503 |
| 504 @override |
| 505 visitMethodInvocation(MethodInvocation node) { |
| 506 MethodInvocation other = this.other; |
| 507 _visitNode(node.target, other.target); |
| 508 _visitNode(node.methodName, other.methodName); |
| 509 _visitNode(node.argumentList, other.argumentList); |
| 510 } |
| 511 |
| 512 @override |
| 513 visitNamedExpression(NamedExpression node) { |
| 514 NamedExpression other = this.other; |
| 515 _visitNode(node.name, other.name); |
| 516 _visitNode(node.expression, other.expression); |
| 517 } |
| 518 |
| 519 @override |
| 520 visitNativeClause(NativeClause node) { |
| 521 } |
| 522 |
| 523 @override |
| 524 visitNativeFunctionBody(NativeFunctionBody node) { |
| 525 } |
| 526 |
| 527 @override |
| 528 visitNullLiteral(NullLiteral node) { |
| 529 NullLiteral other = this.other; |
| 530 _visitExpression(node, other); |
| 531 } |
| 532 |
| 533 @override |
| 534 visitParenthesizedExpression(ParenthesizedExpression node) { |
| 535 ParenthesizedExpression other = this.other; |
| 536 _visitNode(node.expression, other.expression); |
| 537 } |
| 538 |
| 539 @override |
| 540 visitPartDirective(PartDirective node) { |
| 541 PartDirective other = this.other; |
| 542 _visitDirective(node, other); |
| 543 } |
| 544 |
| 545 @override |
| 546 visitPartOfDirective(PartOfDirective node) { |
| 547 PartOfDirective other = this.other; |
| 548 _visitDirective(node, other); |
| 549 _visitNode(node.libraryName, other.libraryName); |
| 550 } |
| 551 |
| 552 @override |
| 553 visitPostfixExpression(PostfixExpression node) { |
| 554 PostfixExpression other = this.other; |
| 555 _visitExpression(node, other); |
| 556 _verifyElement(node.staticElement, other.staticElement); |
| 557 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 558 _visitNode(node.operand, other.operand); |
| 559 } |
| 560 |
| 561 @override |
| 562 visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 563 PrefixedIdentifier other = this.other; |
| 564 _visitExpression(node, other); |
| 565 _visitNode(node.prefix, other.prefix); |
| 566 _visitNode(node.identifier, other.identifier); |
| 567 } |
| 568 |
| 569 @override |
| 570 visitPrefixExpression(PrefixExpression node) { |
| 571 PrefixExpression other = this.other; |
| 572 _visitExpression(node, other); |
| 573 _verifyElement(node.staticElement, other.staticElement); |
| 574 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 575 _visitNode(node.operand, other.operand); |
| 576 } |
| 577 |
| 578 @override |
| 579 visitPropertyAccess(PropertyAccess node) { |
| 580 PropertyAccess other = this.other; |
| 581 _visitExpression(node, other); |
| 582 _visitNode(node.target, other.target); |
| 583 _visitNode(node.propertyName, other.propertyName); |
| 584 } |
| 585 |
| 586 @override |
| 587 visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { |
| 588 RedirectingConstructorInvocation other = this.other; |
| 589 _verifyElement(node.staticElement, other.staticElement); |
| 590 _visitNode(node.constructorName, other.constructorName); |
| 591 _visitNode(node.argumentList, other.argumentList); |
| 592 } |
| 593 |
| 594 @override |
| 595 visitRethrowExpression(RethrowExpression node) { |
| 596 RethrowExpression other = this.other; |
| 597 _visitExpression(node, other); |
| 598 } |
| 599 |
| 600 @override |
| 601 visitReturnStatement(ReturnStatement node) { |
| 602 ReturnStatement other = this.other; |
| 603 _visitNode(node.expression, other.expression); |
| 604 } |
| 605 |
| 606 @override |
| 607 visitScriptTag(ScriptTag node) { |
| 608 } |
| 609 |
| 610 @override |
| 611 visitShowCombinator(ShowCombinator node) { |
| 612 ShowCombinator other = this.other; |
| 613 _visitList(node.shownNames, other.shownNames); |
| 614 } |
| 615 |
| 616 @override |
| 617 visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 618 SimpleFormalParameter other = this.other; |
| 619 _visitNormalFormalParameter(node, other); |
| 620 _visitNode(node.type, other.type); |
| 621 } |
| 622 |
| 623 @override |
| 624 visitSimpleIdentifier(SimpleIdentifier node) { |
| 625 SimpleIdentifier other = this.other; |
| 626 _verifyElement(node.staticElement, other.staticElement); |
| 627 _verifyElement(node.propagatedElement, other.propagatedElement); |
| 628 _visitExpression(node, other); |
| 629 } |
| 630 |
| 631 @override |
| 632 visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 633 } |
| 634 |
| 635 @override |
| 636 visitStringInterpolation(StringInterpolation node) { |
| 637 StringInterpolation other = this.other; |
| 638 _visitList(node.elements, other.elements); |
| 639 } |
| 640 |
| 641 @override |
| 642 visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 643 SuperConstructorInvocation other = this.other; |
| 644 _verifyElement(node.staticElement, other.staticElement); |
| 645 _visitNode(node.constructorName, other.constructorName); |
| 646 _visitNode(node.argumentList, other.argumentList); |
| 647 } |
| 648 |
| 649 @override |
| 650 visitSuperExpression(SuperExpression node) { |
| 651 SuperExpression other = this.other; |
| 652 _visitExpression(node, other); |
| 653 } |
| 654 |
| 655 @override |
| 656 visitSwitchCase(SwitchCase node) { |
| 657 SwitchCase other = this.other; |
| 658 _visitList(node.labels, other.labels); |
| 659 _visitNode(node.expression, other.expression); |
| 660 _visitList(node.statements, other.statements); |
| 661 } |
| 662 |
| 663 @override |
| 664 visitSwitchDefault(SwitchDefault node) { |
| 665 SwitchDefault other = this.other; |
| 666 _visitList(node.statements, other.statements); |
| 667 } |
| 668 |
| 669 @override |
| 670 visitSwitchStatement(SwitchStatement node) { |
| 671 SwitchStatement other = this.other; |
| 672 _visitNode(node.expression, other.expression); |
| 673 _visitList(node.members, other.members); |
| 674 } |
| 675 |
| 676 @override |
| 677 visitSymbolLiteral(SymbolLiteral node) { |
| 678 } |
| 679 |
| 680 @override |
| 681 visitThisExpression(ThisExpression node) { |
| 682 ThisExpression other = this.other; |
| 683 _visitExpression(node, other); |
| 684 } |
| 685 |
| 686 @override |
| 687 visitThrowExpression(ThrowExpression node) { |
| 688 ThrowExpression other = this.other; |
| 689 _visitNode(node.expression, other.expression); |
| 690 } |
| 691 |
| 692 @override |
| 693 visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 694 TopLevelVariableDeclaration other = this.other; |
| 695 _visitNode(node.variables, other.variables); |
| 696 } |
| 697 |
| 698 @override |
| 699 visitTryStatement(TryStatement node) { |
| 700 TryStatement other = this.other; |
| 701 _visitNode(node.body, other.body); |
| 702 _visitList(node.catchClauses, other.catchClauses); |
| 703 _visitNode(node.finallyBlock, other.finallyBlock); |
| 704 } |
| 705 |
| 706 @override |
| 707 visitTypeArgumentList(TypeArgumentList node) { |
| 708 TypeArgumentList other = this.other; |
| 709 _visitList(node.arguments, other.arguments); |
| 710 } |
| 711 |
| 712 @override |
| 713 visitTypeName(TypeName node) { |
| 714 TypeName other = this.other; |
| 715 _verifyType(node.type, other.type); |
| 716 _visitNode(node.name, node.name); |
| 717 _visitNode(node.typeArguments, other.typeArguments); |
| 718 } |
| 719 |
| 720 @override |
| 721 visitTypeParameter(TypeParameter node) { |
| 722 TypeParameter other = this.other; |
| 723 _visitNode(node.name, other.name); |
| 724 _visitNode(node.bound, other.bound); |
| 725 } |
| 726 |
| 727 @override |
| 728 visitTypeParameterList(TypeParameterList node) { |
| 729 TypeParameterList other = this.other; |
| 730 _visitList(node.typeParameters, other.typeParameters); |
| 731 } |
| 732 |
| 733 @override |
| 734 visitVariableDeclaration(VariableDeclaration node) { |
| 735 VariableDeclaration other = this.other; |
| 736 _visitDeclaration(node, other); |
| 737 _visitNode(node.name, other.name); |
| 738 _visitNode(node.initializer, other.initializer); |
| 739 } |
| 740 |
| 741 @override |
| 742 visitVariableDeclarationList(VariableDeclarationList node) { |
| 743 VariableDeclarationList other = this.other; |
| 744 _visitNode(node.type, other.type); |
| 745 _visitList(node.variables, other.variables); |
| 746 } |
| 747 |
| 748 @override |
| 749 visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 750 VariableDeclarationStatement other = this.other; |
| 751 _visitNode(node.variables, other.variables); |
| 752 } |
| 753 |
| 754 @override |
| 755 visitWhileStatement(WhileStatement node) { |
| 756 WhileStatement other = this.other; |
| 757 _visitNode(node.condition, other.condition); |
| 758 _visitNode(node.body, other.body); |
| 759 } |
| 760 |
| 761 @override |
| 762 visitWithClause(WithClause node) { |
| 763 WithClause other = this.other; |
| 764 _visitList(node.mixinTypes, other.mixinTypes); |
| 765 } |
| 766 |
| 767 @override |
| 768 visitYieldStatement(YieldStatement node) { |
| 769 YieldStatement other = this.other; |
| 770 _visitNode(node.expression, other.expression); |
| 771 } |
| 772 |
| 773 void _expectEquals(actual, expected) { |
| 774 if (actual != expected) { |
| 775 String message = ''; |
| 776 message += 'Expected: $expected\n'; |
| 777 message += ' Actual: $actual\n'; |
| 778 failHandler(message); |
| 779 } |
| 780 } |
| 781 |
| 782 void _expectIsNull(obj) { |
| 783 if (obj != null) { |
| 784 String message = ''; |
| 785 message += 'Expected: null\n'; |
| 786 message += ' Actual: $obj\n'; |
| 787 failHandler(message); |
| 788 } |
| 789 } |
| 790 |
| 791 void _expectLength(List actualList, int expected) { |
| 792 String message = ''; |
| 793 message += 'Expected length: $expected\n'; |
| 794 if (actualList == null) { |
| 795 message += 'but null found.'; |
| 796 failHandler(message); |
| 797 } |
| 798 int actual = actualList.length; |
| 799 if (actual != expected) { |
| 800 message += 'but $actual found\n'; |
| 801 message += 'in $actualList'; |
| 802 failHandler(message); |
| 803 } |
| 804 } |
| 805 |
| 806 void _verifyElement(Element a, Element b) { |
| 807 if (a != b) { |
| 808 print(a.location); |
| 809 print(b.location); |
| 810 failHandler('Expected: $b\n Actual: $a'); |
| 811 } |
| 812 if (a == null && b == null) { |
| 813 return; |
| 814 } |
| 815 if (a.nameOffset != b.nameOffset) { |
| 816 failHandler('Expected: ${b.nameOffset}\n Actual: ${a.nameOffset}'); |
| 817 } |
| 818 } |
| 819 |
| 820 void _verifyType(DartType a, DartType b) { |
| 821 if (a != b) { |
| 822 failHandler('Expected: $b\n Actual: $a'); |
| 823 } |
| 824 } |
| 825 |
| 826 void _visitAnnotatedNode(AnnotatedNode node, AnnotatedNode other) { |
| 827 _visitNode(node.documentationComment, other.documentationComment); |
| 828 _visitList(node.metadata, other.metadata); |
| 829 } |
| 830 |
| 831 _visitDeclaration(Declaration node, Declaration other) { |
| 832 _verifyElement(node.element, other.element); |
| 833 _visitAnnotatedNode(node, other); |
| 834 } |
| 835 |
| 836 _visitDirective(Directive node, Directive other) { |
| 837 _verifyElement(node.element, other.element); |
| 838 _visitAnnotatedNode(node, other); |
| 839 } |
| 840 |
| 841 void _visitExpression(Expression a, Expression b) { |
| 842 _verifyType(a.staticType, b.staticType); |
| 843 _verifyType(a.propagatedType, b.propagatedType); |
| 844 _verifyElement(a.staticParameterElement, b.staticParameterElement); |
| 845 _verifyElement(a.propagatedParameterElement, b.propagatedParameterElement); |
| 846 } |
| 847 |
| 848 void _visitList(NodeList nodeList, NodeList otherList) { |
| 849 int length = nodeList.length; |
| 850 _expectLength(otherList, length); |
| 851 for (int i = 0; i < length; i++) { |
| 852 _visitNode(nodeList[i], otherList[i]); |
| 853 } |
| 854 } |
| 855 |
| 856 void _visitNode(AstNode node, AstNode other) { |
| 857 if (node == null) { |
| 858 _expectIsNull(other); |
| 859 } else { |
| 860 this.other = other; |
| 861 _expectEquals(node.offset, other.offset); |
| 862 _expectEquals(node.length, other.length); |
| 863 node.accept(this); |
| 864 } |
| 865 } |
| 866 |
| 867 void _visitNormalFormalParameter(NormalFormalParameter node, |
| 868 NormalFormalParameter other) { |
| 869 _verifyElement(node.element, other.element); |
| 870 _visitNode(node.documentationComment, other.documentationComment); |
| 871 _visitList(node.metadata, other.metadata); |
| 872 _visitNode(node.identifier, other.identifier); |
| 873 } |
| 874 } |
| OLD | NEW |