OLD | NEW |
1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
3 library engine.parser; | 3 library engine.parser; |
4 import 'dart:collection'; | 4 import 'dart:collection'; |
5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
6 import 'instrumentation.dart'; | 6 import 'instrumentation.dart'; |
7 import 'error.dart'; | 7 import 'error.dart'; |
8 import 'source.dart'; | 8 import 'source.dart'; |
9 import 'scanner.dart'; | 9 import 'scanner.dart'; |
10 import 'ast.dart'; | 10 import 'ast.dart'; |
11 import 'utilities_dart.dart'; | 11 import 'utilities_dart.dart'; |
12 import 'engine.dart' show AnalysisEngine; | 12 import 'engine.dart' show AnalysisEngine; |
| 13 import 'utilities_collection.dart' show TokenMap; |
13 /** | 14 /** |
14 * Instances of the class `CommentAndMetadata` implement a simple data-holder fo
r a method | 15 * Instances of the class `CommentAndMetadata` implement a simple data-holder fo
r a method |
15 * that needs to return multiple values. | 16 * that needs to return multiple values. |
16 * | 17 * |
17 * @coverage dart.engine.parser | 18 * @coverage dart.engine.parser |
18 */ | 19 */ |
19 class CommentAndMetadata { | 20 class CommentAndMetadata { |
20 | 21 |
21 /** | 22 /** |
22 * The documentation comment that was parsed, or `null` if none was given. | 23 * The documentation comment that was parsed, or `null` if none was given. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 if (needsSpace) { | 137 if (needsSpace) { |
137 builder.appendChar(0x20); | 138 builder.appendChar(0x20); |
138 } | 139 } |
139 builder.append(keyword.lexeme); | 140 builder.append(keyword.lexeme); |
140 return true; | 141 return true; |
141 } | 142 } |
142 return needsSpace; | 143 return needsSpace; |
143 } | 144 } |
144 } | 145 } |
145 /** | 146 /** |
| 147 * Instances of the class `IncrementalParseDispatcher` implement a dispatcher th
at will invoke |
| 148 * the right parse method when re-parsing a specified child of the visited node.
All of the methods |
| 149 * in this class assume that the parser is positioned to parse the replacement f
or the node. All of |
| 150 * the methods will throw an [IncrementalParseException] if the node could not b
e parsed for |
| 151 * some reason. |
| 152 */ |
| 153 class IncrementalParseDispatcher implements ASTVisitor<ASTNode> { |
| 154 |
| 155 /** |
| 156 * The parser used to parse the replacement for the node. |
| 157 */ |
| 158 Parser _parser; |
| 159 |
| 160 /** |
| 161 * The node that is to be replaced. |
| 162 */ |
| 163 ASTNode _oldNode; |
| 164 |
| 165 /** |
| 166 * Initialize a newly created dispatcher to parse a single node that will repl
ace the given node. |
| 167 * |
| 168 * @param parser the parser used to parse the replacement for the node |
| 169 * @param oldNode the node that is to be replaced |
| 170 */ |
| 171 IncrementalParseDispatcher(Parser parser, ASTNode oldNode) { |
| 172 this._parser = parser; |
| 173 this._oldNode = oldNode; |
| 174 } |
| 175 ASTNode visitAdjacentStrings(AdjacentStrings node) { |
| 176 if (node.strings.contains(_oldNode)) { |
| 177 return _parser.parseStringLiteral(); |
| 178 } |
| 179 return notAChild(node); |
| 180 } |
| 181 ASTNode visitAnnotation(Annotation node) { |
| 182 if (identical(_oldNode, node.name)) { |
| 183 throw new InsufficientContextException(); |
| 184 } else if (identical(_oldNode, node.constructorName)) { |
| 185 throw new InsufficientContextException(); |
| 186 } else if (identical(_oldNode, node.arguments)) { |
| 187 return _parser.parseArgumentList(); |
| 188 } |
| 189 return notAChild(node); |
| 190 } |
| 191 ASTNode visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 192 if (identical(_oldNode, node.identifier)) { |
| 193 return _parser.parseSimpleIdentifier(); |
| 194 } |
| 195 return notAChild(node); |
| 196 } |
| 197 ASTNode visitArgumentList(ArgumentList node) { |
| 198 if (node.arguments.contains(_oldNode)) { |
| 199 return _parser.parseArgument(); |
| 200 } |
| 201 return notAChild(node); |
| 202 } |
| 203 ASTNode visitAsExpression(AsExpression node) { |
| 204 if (identical(_oldNode, node.expression)) { |
| 205 return _parser.parseBitwiseOrExpression(); |
| 206 } else if (identical(_oldNode, node.type)) { |
| 207 return _parser.parseTypeName(); |
| 208 } |
| 209 return notAChild(node); |
| 210 } |
| 211 ASTNode visitAssertStatement(AssertStatement node) { |
| 212 if (identical(_oldNode, node.condition)) { |
| 213 return _parser.parseExpression2(); |
| 214 } |
| 215 return notAChild(node); |
| 216 } |
| 217 ASTNode visitAssignmentExpression(AssignmentExpression node) { |
| 218 if (identical(_oldNode, node.leftHandSide)) { |
| 219 throw new InsufficientContextException(); |
| 220 } else if (identical(_oldNode, node.rightHandSide)) { |
| 221 if (isCascadeAllowed(node)) { |
| 222 return _parser.parseExpression2(); |
| 223 } |
| 224 return _parser.parseExpressionWithoutCascade(); |
| 225 } |
| 226 return notAChild(node); |
| 227 } |
| 228 ASTNode visitBinaryExpression(BinaryExpression node) { |
| 229 if (identical(_oldNode, node.leftOperand)) { |
| 230 throw new InsufficientContextException(); |
| 231 } else if (identical(_oldNode, node.rightOperand)) { |
| 232 throw new InsufficientContextException(); |
| 233 } |
| 234 return notAChild(node); |
| 235 } |
| 236 ASTNode visitBlock(Block node) { |
| 237 if (node.statements.contains(_oldNode)) { |
| 238 return _parser.parseStatement2(); |
| 239 } |
| 240 return notAChild(node); |
| 241 } |
| 242 ASTNode visitBlockFunctionBody(BlockFunctionBody node) { |
| 243 if (identical(_oldNode, node.block)) { |
| 244 return _parser.parseBlock(); |
| 245 } |
| 246 return notAChild(node); |
| 247 } |
| 248 ASTNode visitBooleanLiteral(BooleanLiteral node) => notAChild(node); |
| 249 ASTNode visitBreakStatement(BreakStatement node) { |
| 250 if (identical(_oldNode, node.label)) { |
| 251 return _parser.parseSimpleIdentifier(); |
| 252 } |
| 253 return notAChild(node); |
| 254 } |
| 255 ASTNode visitCascadeExpression(CascadeExpression node) { |
| 256 if (identical(_oldNode, node.target)) { |
| 257 return _parser.parseConditionalExpression(); |
| 258 } else if (node.cascadeSections.contains(_oldNode)) { |
| 259 throw new InsufficientContextException(); |
| 260 } |
| 261 return notAChild(node); |
| 262 } |
| 263 ASTNode visitCatchClause(CatchClause node) { |
| 264 if (identical(_oldNode, node.exceptionType)) { |
| 265 return _parser.parseTypeName(); |
| 266 } else if (identical(_oldNode, node.exceptionParameter)) { |
| 267 return _parser.parseSimpleIdentifier(); |
| 268 } else if (identical(_oldNode, node.stackTraceParameter)) { |
| 269 return _parser.parseSimpleIdentifier(); |
| 270 } else if (identical(_oldNode, node.body)) { |
| 271 return _parser.parseBlock(); |
| 272 } |
| 273 return notAChild(node); |
| 274 } |
| 275 ASTNode visitClassDeclaration(ClassDeclaration node) { |
| 276 if (identical(_oldNode, node.documentationComment)) { |
| 277 throw new InsufficientContextException(); |
| 278 } else if (node.metadata.contains(_oldNode)) { |
| 279 return _parser.parseAnnotation(); |
| 280 } else if (identical(_oldNode, node.name)) { |
| 281 return _parser.parseSimpleIdentifier(); |
| 282 } else if (identical(_oldNode, node.typeParameters)) { |
| 283 return _parser.parseTypeParameterList(); |
| 284 } else if (identical(_oldNode, node.extendsClause)) { |
| 285 return _parser.parseExtendsClause(); |
| 286 } else if (identical(_oldNode, node.withClause)) { |
| 287 return _parser.parseWithClause(); |
| 288 } else if (identical(_oldNode, node.implementsClause)) { |
| 289 return _parser.parseImplementsClause(); |
| 290 } else if (node.members.contains(_oldNode)) { |
| 291 return _parser.parseClassMember(node.name.name); |
| 292 } |
| 293 return notAChild(node); |
| 294 } |
| 295 ASTNode visitClassTypeAlias(ClassTypeAlias node) { |
| 296 if (identical(_oldNode, node.documentationComment)) { |
| 297 throw new InsufficientContextException(); |
| 298 } else if (node.metadata.contains(_oldNode)) { |
| 299 return _parser.parseAnnotation(); |
| 300 } else if (identical(_oldNode, node.name)) { |
| 301 return _parser.parseSimpleIdentifier(); |
| 302 } else if (identical(_oldNode, node.typeParameters)) { |
| 303 return _parser.parseTypeParameterList(); |
| 304 } else if (identical(_oldNode, node.superclass)) { |
| 305 return _parser.parseTypeName(); |
| 306 } else if (identical(_oldNode, node.withClause)) { |
| 307 return _parser.parseWithClause(); |
| 308 } else if (identical(_oldNode, node.implementsClause)) { |
| 309 return _parser.parseImplementsClause(); |
| 310 } |
| 311 return notAChild(node); |
| 312 } |
| 313 ASTNode visitComment(Comment node) { |
| 314 throw new InsufficientContextException(); |
| 315 } |
| 316 ASTNode visitCommentReference(CommentReference node) { |
| 317 if (identical(_oldNode, node.identifier)) { |
| 318 return _parser.parsePrefixedIdentifier(); |
| 319 } |
| 320 return notAChild(node); |
| 321 } |
| 322 ASTNode visitCompilationUnit(CompilationUnit node) { |
| 323 throw new InsufficientContextException(); |
| 324 } |
| 325 ASTNode visitConditionalExpression(ConditionalExpression node) { |
| 326 if (identical(_oldNode, node.condition)) { |
| 327 return _parser.parseLogicalOrExpression(); |
| 328 } else if (identical(_oldNode, node.thenExpression)) { |
| 329 return _parser.parseExpressionWithoutCascade(); |
| 330 } else if (identical(_oldNode, node.elseExpression)) { |
| 331 return _parser.parseExpressionWithoutCascade(); |
| 332 } |
| 333 return notAChild(node); |
| 334 } |
| 335 ASTNode visitConstructorDeclaration(ConstructorDeclaration node) { |
| 336 if (identical(_oldNode, node.documentationComment)) { |
| 337 throw new InsufficientContextException(); |
| 338 } else if (node.metadata.contains(_oldNode)) { |
| 339 return _parser.parseAnnotation(); |
| 340 } else if (identical(_oldNode, node.returnType)) { |
| 341 throw new InsufficientContextException(); |
| 342 } else if (identical(_oldNode, node.name)) { |
| 343 throw new InsufficientContextException(); |
| 344 } else if (identical(_oldNode, node.parameters)) { |
| 345 return _parser.parseFormalParameterList(); |
| 346 } else if (identical(_oldNode, node.redirectedConstructor)) { |
| 347 throw new InsufficientContextException(); |
| 348 } else if (node.initializers.contains(_oldNode)) { |
| 349 throw new InsufficientContextException(); |
| 350 } else if (identical(_oldNode, node.body)) { |
| 351 throw new InsufficientContextException(); |
| 352 } |
| 353 return notAChild(node); |
| 354 } |
| 355 ASTNode visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 356 if (identical(_oldNode, node.fieldName)) { |
| 357 return _parser.parseSimpleIdentifier(); |
| 358 } else if (identical(_oldNode, node.expression)) { |
| 359 throw new InsufficientContextException(); |
| 360 } |
| 361 return notAChild(node); |
| 362 } |
| 363 ASTNode visitConstructorName(ConstructorName node) { |
| 364 if (identical(_oldNode, node.type)) { |
| 365 return _parser.parseTypeName(); |
| 366 } else if (identical(_oldNode, node.name)) { |
| 367 return _parser.parseSimpleIdentifier(); |
| 368 } |
| 369 return notAChild(node); |
| 370 } |
| 371 ASTNode visitContinueStatement(ContinueStatement node) { |
| 372 if (identical(_oldNode, node.label)) { |
| 373 return _parser.parseSimpleIdentifier(); |
| 374 } |
| 375 return notAChild(node); |
| 376 } |
| 377 ASTNode visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 378 if (identical(_oldNode, node.documentationComment)) { |
| 379 throw new InsufficientContextException(); |
| 380 } else if (node.metadata.contains(_oldNode)) { |
| 381 return _parser.parseAnnotation(); |
| 382 } else if (identical(_oldNode, node.type)) { |
| 383 throw new InsufficientContextException(); |
| 384 } else if (identical(_oldNode, node.identifier)) { |
| 385 return _parser.parseSimpleIdentifier(); |
| 386 } |
| 387 return notAChild(node); |
| 388 } |
| 389 ASTNode visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 390 if (identical(_oldNode, node.parameter)) { |
| 391 return _parser.parseNormalFormalParameter(); |
| 392 } else if (identical(_oldNode, node.defaultValue)) { |
| 393 return _parser.parseExpression2(); |
| 394 } |
| 395 return notAChild(node); |
| 396 } |
| 397 ASTNode visitDoStatement(DoStatement node) { |
| 398 if (identical(_oldNode, node.body)) { |
| 399 return _parser.parseStatement2(); |
| 400 } else if (identical(_oldNode, node.condition)) { |
| 401 return _parser.parseExpression2(); |
| 402 } |
| 403 return notAChild(node); |
| 404 } |
| 405 ASTNode visitDoubleLiteral(DoubleLiteral node) => notAChild(node); |
| 406 ASTNode visitEmptyFunctionBody(EmptyFunctionBody node) => notAChild(node); |
| 407 ASTNode visitEmptyStatement(EmptyStatement node) => notAChild(node); |
| 408 ASTNode visitExportDirective(ExportDirective node) { |
| 409 if (identical(_oldNode, node.documentationComment)) { |
| 410 throw new InsufficientContextException(); |
| 411 } else if (node.metadata.contains(_oldNode)) { |
| 412 return _parser.parseAnnotation(); |
| 413 } else if (identical(_oldNode, node.uri)) { |
| 414 return _parser.parseStringLiteral(); |
| 415 } else if (node.combinators.contains(_oldNode)) { |
| 416 throw new IncrementalParseException(); |
| 417 } |
| 418 return notAChild(node); |
| 419 } |
| 420 ASTNode visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 421 if (identical(_oldNode, node.expression)) { |
| 422 return _parser.parseExpression2(); |
| 423 } |
| 424 return notAChild(node); |
| 425 } |
| 426 ASTNode visitExpressionStatement(ExpressionStatement node) { |
| 427 if (identical(_oldNode, node.expression)) { |
| 428 return _parser.parseExpression2(); |
| 429 } |
| 430 return notAChild(node); |
| 431 } |
| 432 ASTNode visitExtendsClause(ExtendsClause node) { |
| 433 if (identical(_oldNode, node.superclass)) { |
| 434 return _parser.parseTypeName(); |
| 435 } |
| 436 return notAChild(node); |
| 437 } |
| 438 ASTNode visitFieldDeclaration(FieldDeclaration node) { |
| 439 if (identical(_oldNode, node.documentationComment)) { |
| 440 throw new InsufficientContextException(); |
| 441 } else if (node.metadata.contains(_oldNode)) { |
| 442 return _parser.parseAnnotation(); |
| 443 } else if (identical(_oldNode, node.fields)) { |
| 444 throw new InsufficientContextException(); |
| 445 } |
| 446 return notAChild(node); |
| 447 } |
| 448 ASTNode visitFieldFormalParameter(FieldFormalParameter node) { |
| 449 if (identical(_oldNode, node.documentationComment)) { |
| 450 throw new InsufficientContextException(); |
| 451 } else if (node.metadata.contains(_oldNode)) { |
| 452 return _parser.parseAnnotation(); |
| 453 } else if (identical(_oldNode, node.type)) { |
| 454 return _parser.parseTypeName(); |
| 455 } else if (identical(_oldNode, node.identifier)) { |
| 456 return _parser.parseSimpleIdentifier(); |
| 457 } else if (identical(_oldNode, node.parameters)) { |
| 458 return _parser.parseFormalParameterList(); |
| 459 } |
| 460 return notAChild(node); |
| 461 } |
| 462 ASTNode visitForEachStatement(ForEachStatement node) { |
| 463 if (identical(_oldNode, node.loopVariable)) { |
| 464 throw new InsufficientContextException(); |
| 465 } else if (identical(_oldNode, node.identifier)) { |
| 466 return _parser.parseSimpleIdentifier(); |
| 467 } else if (identical(_oldNode, node.body)) { |
| 468 return _parser.parseStatement2(); |
| 469 } |
| 470 return notAChild(node); |
| 471 } |
| 472 ASTNode visitFormalParameterList(FormalParameterList node) { |
| 473 throw new InsufficientContextException(); |
| 474 } |
| 475 ASTNode visitForStatement(ForStatement node) { |
| 476 if (identical(_oldNode, node.variables)) { |
| 477 throw new InsufficientContextException(); |
| 478 } else if (identical(_oldNode, node.initialization)) { |
| 479 throw new InsufficientContextException(); |
| 480 } else if (identical(_oldNode, node.condition)) { |
| 481 return _parser.parseExpression2(); |
| 482 } else if (node.updaters.contains(_oldNode)) { |
| 483 return _parser.parseExpression2(); |
| 484 } else if (identical(_oldNode, node.body)) { |
| 485 return _parser.parseStatement2(); |
| 486 } |
| 487 return notAChild(node); |
| 488 } |
| 489 ASTNode visitFunctionDeclaration(FunctionDeclaration node) { |
| 490 if (identical(_oldNode, node.documentationComment)) { |
| 491 throw new InsufficientContextException(); |
| 492 } else if (node.metadata.contains(_oldNode)) { |
| 493 return _parser.parseAnnotation(); |
| 494 } else if (identical(_oldNode, node.returnType)) { |
| 495 return _parser.parseReturnType(); |
| 496 } else if (identical(_oldNode, node.name)) { |
| 497 return _parser.parseSimpleIdentifier(); |
| 498 } else if (identical(_oldNode, node.functionExpression)) { |
| 499 throw new InsufficientContextException(); |
| 500 } |
| 501 return notAChild(node); |
| 502 } |
| 503 ASTNode visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 504 if (identical(_oldNode, node.functionDeclaration)) { |
| 505 throw new InsufficientContextException(); |
| 506 } |
| 507 return notAChild(node); |
| 508 } |
| 509 ASTNode visitFunctionExpression(FunctionExpression node) { |
| 510 if (identical(_oldNode, node.parameters)) { |
| 511 return _parser.parseFormalParameterList(); |
| 512 } else if (identical(_oldNode, node.body)) { |
| 513 throw new InsufficientContextException(); |
| 514 } |
| 515 return notAChild(node); |
| 516 } |
| 517 ASTNode visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 518 if (identical(_oldNode, node.function)) { |
| 519 throw new InsufficientContextException(); |
| 520 } else if (identical(_oldNode, node.argumentList)) { |
| 521 return _parser.parseArgumentList(); |
| 522 } |
| 523 return notAChild(node); |
| 524 } |
| 525 ASTNode visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 526 if (identical(_oldNode, node.documentationComment)) { |
| 527 throw new InsufficientContextException(); |
| 528 } else if (node.metadata.contains(_oldNode)) { |
| 529 return _parser.parseAnnotation(); |
| 530 } else if (identical(_oldNode, node.returnType)) { |
| 531 return _parser.parseReturnType(); |
| 532 } else if (identical(_oldNode, node.name)) { |
| 533 return _parser.parseSimpleIdentifier(); |
| 534 } else if (identical(_oldNode, node.typeParameters)) { |
| 535 return _parser.parseTypeParameterList(); |
| 536 } else if (identical(_oldNode, node.parameters)) { |
| 537 return _parser.parseFormalParameterList(); |
| 538 } |
| 539 return notAChild(node); |
| 540 } |
| 541 ASTNode visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 542 if (identical(_oldNode, node.documentationComment)) { |
| 543 throw new InsufficientContextException(); |
| 544 } else if (node.metadata.contains(_oldNode)) { |
| 545 return _parser.parseAnnotation(); |
| 546 } else if (identical(_oldNode, node.returnType)) { |
| 547 return _parser.parseReturnType(); |
| 548 } else if (identical(_oldNode, node.identifier)) { |
| 549 return _parser.parseSimpleIdentifier(); |
| 550 } else if (identical(_oldNode, node.parameters)) { |
| 551 return _parser.parseFormalParameterList(); |
| 552 } |
| 553 return notAChild(node); |
| 554 } |
| 555 ASTNode visitHideCombinator(HideCombinator node) { |
| 556 if (node.hiddenNames.contains(_oldNode)) { |
| 557 return _parser.parseSimpleIdentifier(); |
| 558 } |
| 559 return notAChild(node); |
| 560 } |
| 561 ASTNode visitIfStatement(IfStatement node) { |
| 562 if (identical(_oldNode, node.condition)) { |
| 563 return _parser.parseExpression2(); |
| 564 } else if (identical(_oldNode, node.thenStatement)) { |
| 565 return _parser.parseStatement2(); |
| 566 } else if (identical(_oldNode, node.elseStatement)) { |
| 567 return _parser.parseStatement2(); |
| 568 } |
| 569 return notAChild(node); |
| 570 } |
| 571 ASTNode visitImplementsClause(ImplementsClause node) { |
| 572 if (node.interfaces.contains(node)) { |
| 573 return _parser.parseTypeName(); |
| 574 } |
| 575 return notAChild(node); |
| 576 } |
| 577 ASTNode visitImportDirective(ImportDirective node) { |
| 578 if (identical(_oldNode, node.documentationComment)) { |
| 579 throw new InsufficientContextException(); |
| 580 } else if (node.metadata.contains(_oldNode)) { |
| 581 return _parser.parseAnnotation(); |
| 582 } else if (identical(_oldNode, node.uri)) { |
| 583 return _parser.parseStringLiteral(); |
| 584 } else if (identical(_oldNode, node.prefix)) { |
| 585 return _parser.parseSimpleIdentifier(); |
| 586 } else if (node.combinators.contains(_oldNode)) { |
| 587 throw new IncrementalParseException(); |
| 588 } |
| 589 return notAChild(node); |
| 590 } |
| 591 ASTNode visitIndexExpression(IndexExpression node) { |
| 592 if (identical(_oldNode, node.target)) { |
| 593 throw new InsufficientContextException(); |
| 594 } else if (identical(_oldNode, node.index)) { |
| 595 return _parser.parseExpression2(); |
| 596 } |
| 597 return notAChild(node); |
| 598 } |
| 599 ASTNode visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 600 if (identical(_oldNode, node.constructorName)) { |
| 601 return _parser.parseConstructorName(); |
| 602 } else if (identical(_oldNode, node.argumentList)) { |
| 603 return _parser.parseArgumentList(); |
| 604 } |
| 605 return notAChild(node); |
| 606 } |
| 607 ASTNode visitIntegerLiteral(IntegerLiteral node) => notAChild(node); |
| 608 ASTNode visitInterpolationExpression(InterpolationExpression node) { |
| 609 if (identical(_oldNode, node.expression)) { |
| 610 if (node.leftBracket == null) { |
| 611 throw new InsufficientContextException(); |
| 612 } |
| 613 return _parser.parseExpression2(); |
| 614 } |
| 615 return notAChild(node); |
| 616 } |
| 617 ASTNode visitInterpolationString(InterpolationString node) { |
| 618 throw new InsufficientContextException(); |
| 619 } |
| 620 ASTNode visitIsExpression(IsExpression node) { |
| 621 if (identical(_oldNode, node.expression)) { |
| 622 return _parser.parseBitwiseOrExpression(); |
| 623 } else if (identical(_oldNode, node.type)) { |
| 624 return _parser.parseTypeName(); |
| 625 } |
| 626 return notAChild(node); |
| 627 } |
| 628 ASTNode visitLabel(Label node) { |
| 629 if (identical(_oldNode, node.label)) { |
| 630 return _parser.parseSimpleIdentifier(); |
| 631 } |
| 632 return notAChild(node); |
| 633 } |
| 634 ASTNode visitLabeledStatement(LabeledStatement node) { |
| 635 if (node.labels.contains(_oldNode)) { |
| 636 return _parser.parseLabel(); |
| 637 } else if (identical(_oldNode, node.statement)) { |
| 638 return _parser.parseStatement2(); |
| 639 } |
| 640 return notAChild(node); |
| 641 } |
| 642 ASTNode visitLibraryDirective(LibraryDirective node) { |
| 643 if (identical(_oldNode, node.documentationComment)) { |
| 644 throw new InsufficientContextException(); |
| 645 } else if (node.metadata.contains(_oldNode)) { |
| 646 return _parser.parseAnnotation(); |
| 647 } else if (identical(_oldNode, node.name)) { |
| 648 return _parser.parseLibraryIdentifier(); |
| 649 } |
| 650 return notAChild(node); |
| 651 } |
| 652 ASTNode visitLibraryIdentifier(LibraryIdentifier node) { |
| 653 if (node.components.contains(_oldNode)) { |
| 654 return _parser.parseSimpleIdentifier(); |
| 655 } |
| 656 return notAChild(node); |
| 657 } |
| 658 ASTNode visitListLiteral(ListLiteral node) { |
| 659 if (identical(_oldNode, node.typeArguments)) { |
| 660 return _parser.parseTypeArgumentList(); |
| 661 } else if (node.elements.contains(_oldNode)) { |
| 662 return _parser.parseExpression2(); |
| 663 } |
| 664 return notAChild(node); |
| 665 } |
| 666 ASTNode visitMapLiteral(MapLiteral node) { |
| 667 if (identical(_oldNode, node.typeArguments)) { |
| 668 return _parser.parseTypeArgumentList(); |
| 669 } else if (node.entries.contains(_oldNode)) { |
| 670 return _parser.parseMapLiteralEntry(); |
| 671 } |
| 672 return notAChild(node); |
| 673 } |
| 674 ASTNode visitMapLiteralEntry(MapLiteralEntry node) { |
| 675 if (identical(_oldNode, node.key)) { |
| 676 return _parser.parseExpression2(); |
| 677 } else if (identical(_oldNode, node.value)) { |
| 678 return _parser.parseExpression2(); |
| 679 } |
| 680 return notAChild(node); |
| 681 } |
| 682 ASTNode visitMethodDeclaration(MethodDeclaration node) { |
| 683 if (identical(_oldNode, node.documentationComment)) { |
| 684 throw new InsufficientContextException(); |
| 685 } else if (node.metadata.contains(_oldNode)) { |
| 686 return _parser.parseAnnotation(); |
| 687 } else if (identical(_oldNode, node.returnType)) { |
| 688 throw new InsufficientContextException(); |
| 689 } else if (identical(_oldNode, node.name)) { |
| 690 if (node.operatorKeyword != null) { |
| 691 throw new InsufficientContextException(); |
| 692 } |
| 693 return _parser.parseSimpleIdentifier(); |
| 694 } else if (identical(_oldNode, node.body)) { |
| 695 throw new InsufficientContextException(); |
| 696 } |
| 697 return notAChild(node); |
| 698 } |
| 699 ASTNode visitMethodInvocation(MethodInvocation node) { |
| 700 if (identical(_oldNode, node.target)) { |
| 701 throw new IncrementalParseException(); |
| 702 } else if (identical(_oldNode, node.methodName)) { |
| 703 return _parser.parseSimpleIdentifier(); |
| 704 } else if (identical(_oldNode, node.argumentList)) { |
| 705 return _parser.parseArgumentList(); |
| 706 } |
| 707 return notAChild(node); |
| 708 } |
| 709 ASTNode visitNamedExpression(NamedExpression node) { |
| 710 if (identical(_oldNode, node.name)) { |
| 711 return _parser.parseLabel(); |
| 712 } else if (identical(_oldNode, node.expression)) { |
| 713 return _parser.parseExpression2(); |
| 714 } |
| 715 return notAChild(node); |
| 716 } |
| 717 ASTNode visitNativeClause(NativeClause node) { |
| 718 if (identical(_oldNode, node.name)) { |
| 719 return _parser.parseStringLiteral(); |
| 720 } |
| 721 return notAChild(node); |
| 722 } |
| 723 ASTNode visitNativeFunctionBody(NativeFunctionBody node) { |
| 724 if (identical(_oldNode, node.stringLiteral)) { |
| 725 return _parser.parseStringLiteral(); |
| 726 } |
| 727 return notAChild(node); |
| 728 } |
| 729 ASTNode visitNullLiteral(NullLiteral node) => notAChild(node); |
| 730 ASTNode visitParenthesizedExpression(ParenthesizedExpression node) { |
| 731 if (identical(_oldNode, node.expression)) { |
| 732 return _parser.parseExpression2(); |
| 733 } |
| 734 return notAChild(node); |
| 735 } |
| 736 ASTNode visitPartDirective(PartDirective node) { |
| 737 if (identical(_oldNode, node.documentationComment)) { |
| 738 throw new InsufficientContextException(); |
| 739 } else if (node.metadata.contains(_oldNode)) { |
| 740 return _parser.parseAnnotation(); |
| 741 } else if (identical(_oldNode, node.uri)) { |
| 742 return _parser.parseStringLiteral(); |
| 743 } |
| 744 return notAChild(node); |
| 745 } |
| 746 ASTNode visitPartOfDirective(PartOfDirective node) { |
| 747 if (identical(_oldNode, node.documentationComment)) { |
| 748 throw new InsufficientContextException(); |
| 749 } else if (node.metadata.contains(_oldNode)) { |
| 750 return _parser.parseAnnotation(); |
| 751 } else if (identical(_oldNode, node.libraryName)) { |
| 752 return _parser.parseLibraryIdentifier(); |
| 753 } |
| 754 return notAChild(node); |
| 755 } |
| 756 ASTNode visitPostfixExpression(PostfixExpression node) { |
| 757 if (identical(_oldNode, node.operand)) { |
| 758 throw new InsufficientContextException(); |
| 759 } |
| 760 return notAChild(node); |
| 761 } |
| 762 ASTNode visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 763 if (identical(_oldNode, node.prefix)) { |
| 764 return _parser.parseSimpleIdentifier(); |
| 765 } else if (identical(_oldNode, node.identifier)) { |
| 766 return _parser.parseSimpleIdentifier(); |
| 767 } |
| 768 return notAChild(node); |
| 769 } |
| 770 ASTNode visitPrefixExpression(PrefixExpression node) { |
| 771 if (identical(_oldNode, node.operand)) { |
| 772 throw new InsufficientContextException(); |
| 773 } |
| 774 return notAChild(node); |
| 775 } |
| 776 ASTNode visitPropertyAccess(PropertyAccess node) { |
| 777 if (identical(_oldNode, node.target)) { |
| 778 throw new InsufficientContextException(); |
| 779 } else if (identical(_oldNode, node.propertyName)) { |
| 780 return _parser.parseSimpleIdentifier(); |
| 781 } |
| 782 return notAChild(node); |
| 783 } |
| 784 ASTNode visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 785 if (identical(_oldNode, node.constructorName)) { |
| 786 return _parser.parseSimpleIdentifier(); |
| 787 } else if (identical(_oldNode, node.argumentList)) { |
| 788 return _parser.parseArgumentList(); |
| 789 } |
| 790 return notAChild(node); |
| 791 } |
| 792 ASTNode visitRethrowExpression(RethrowExpression node) => notAChild(node); |
| 793 ASTNode visitReturnStatement(ReturnStatement node) { |
| 794 if (identical(_oldNode, node.expression)) { |
| 795 return _parser.parseExpression2(); |
| 796 } |
| 797 return notAChild(node); |
| 798 } |
| 799 ASTNode visitScriptTag(ScriptTag node) => notAChild(node); |
| 800 ASTNode visitShowCombinator(ShowCombinator node) { |
| 801 if (node.shownNames.contains(_oldNode)) { |
| 802 return _parser.parseSimpleIdentifier(); |
| 803 } |
| 804 return notAChild(node); |
| 805 } |
| 806 ASTNode visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 807 if (identical(_oldNode, node.documentationComment)) { |
| 808 throw new InsufficientContextException(); |
| 809 } else if (node.metadata.contains(_oldNode)) { |
| 810 return _parser.parseAnnotation(); |
| 811 } else if (identical(_oldNode, node.type)) { |
| 812 throw new InsufficientContextException(); |
| 813 } else if (identical(_oldNode, node.identifier)) { |
| 814 throw new InsufficientContextException(); |
| 815 } |
| 816 return notAChild(node); |
| 817 } |
| 818 ASTNode visitSimpleIdentifier(SimpleIdentifier node) => notAChild(node); |
| 819 ASTNode visitSimpleStringLiteral(SimpleStringLiteral node) => notAChild(node); |
| 820 ASTNode visitStringInterpolation(StringInterpolation node) { |
| 821 if (node.elements.contains(_oldNode)) { |
| 822 throw new InsufficientContextException(); |
| 823 } |
| 824 return notAChild(node); |
| 825 } |
| 826 ASTNode visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 827 if (identical(_oldNode, node.constructorName)) { |
| 828 return _parser.parseSimpleIdentifier(); |
| 829 } else if (identical(_oldNode, node.argumentList)) { |
| 830 return _parser.parseArgumentList(); |
| 831 } |
| 832 return notAChild(node); |
| 833 } |
| 834 ASTNode visitSuperExpression(SuperExpression node) => notAChild(node); |
| 835 ASTNode visitSwitchCase(SwitchCase node) { |
| 836 if (node.labels.contains(_oldNode)) { |
| 837 return _parser.parseLabel(); |
| 838 } else if (identical(_oldNode, node.expression)) { |
| 839 return _parser.parseExpression2(); |
| 840 } else if (node.statements.contains(_oldNode)) { |
| 841 return _parser.parseStatement2(); |
| 842 } |
| 843 return notAChild(node); |
| 844 } |
| 845 ASTNode visitSwitchDefault(SwitchDefault node) { |
| 846 if (node.labels.contains(_oldNode)) { |
| 847 return _parser.parseLabel(); |
| 848 } else if (node.statements.contains(_oldNode)) { |
| 849 return _parser.parseStatement2(); |
| 850 } |
| 851 return notAChild(node); |
| 852 } |
| 853 ASTNode visitSwitchStatement(SwitchStatement node) { |
| 854 if (identical(_oldNode, node.expression)) { |
| 855 return _parser.parseExpression2(); |
| 856 } else if (node.members.contains(_oldNode)) { |
| 857 throw new InsufficientContextException(); |
| 858 } |
| 859 return notAChild(node); |
| 860 } |
| 861 ASTNode visitSymbolLiteral(SymbolLiteral node) => notAChild(node); |
| 862 ASTNode visitThisExpression(ThisExpression node) => notAChild(node); |
| 863 ASTNode visitThrowExpression(ThrowExpression node) { |
| 864 if (identical(_oldNode, node.expression)) { |
| 865 if (isCascadeAllowed2(node)) { |
| 866 return _parser.parseExpression2(); |
| 867 } |
| 868 return _parser.parseExpressionWithoutCascade(); |
| 869 } |
| 870 return notAChild(node); |
| 871 } |
| 872 ASTNode visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 873 if (identical(_oldNode, node.documentationComment)) { |
| 874 throw new InsufficientContextException(); |
| 875 } else if (node.metadata.contains(_oldNode)) { |
| 876 return _parser.parseAnnotation(); |
| 877 } else if (identical(_oldNode, node.variables)) { |
| 878 throw new InsufficientContextException(); |
| 879 } |
| 880 return notAChild(node); |
| 881 } |
| 882 ASTNode visitTryStatement(TryStatement node) { |
| 883 if (identical(_oldNode, node.body)) { |
| 884 return _parser.parseBlock(); |
| 885 } else if (node.catchClauses.contains(_oldNode)) { |
| 886 throw new InsufficientContextException(); |
| 887 } else if (identical(_oldNode, node.finallyBlock)) { |
| 888 throw new InsufficientContextException(); |
| 889 } |
| 890 return notAChild(node); |
| 891 } |
| 892 ASTNode visitTypeArgumentList(TypeArgumentList node) { |
| 893 if (node.arguments.contains(_oldNode)) { |
| 894 return _parser.parseTypeName(); |
| 895 } |
| 896 return notAChild(node); |
| 897 } |
| 898 ASTNode visitTypeName(TypeName node) { |
| 899 if (identical(_oldNode, node.name)) { |
| 900 return _parser.parsePrefixedIdentifier(); |
| 901 } else if (identical(_oldNode, node.typeArguments)) { |
| 902 return _parser.parseTypeArgumentList(); |
| 903 } |
| 904 return notAChild(node); |
| 905 } |
| 906 ASTNode visitTypeParameter(TypeParameter node) { |
| 907 if (identical(_oldNode, node.documentationComment)) { |
| 908 throw new InsufficientContextException(); |
| 909 } else if (node.metadata.contains(_oldNode)) { |
| 910 return _parser.parseAnnotation(); |
| 911 } else if (identical(_oldNode, node.name)) { |
| 912 return _parser.parseSimpleIdentifier(); |
| 913 } else if (identical(_oldNode, node.bound)) { |
| 914 return _parser.parseTypeName(); |
| 915 } |
| 916 return notAChild(node); |
| 917 } |
| 918 ASTNode visitTypeParameterList(TypeParameterList node) { |
| 919 if (node.typeParameters.contains(node)) { |
| 920 return _parser.parseTypeParameter(); |
| 921 } |
| 922 return notAChild(node); |
| 923 } |
| 924 ASTNode visitVariableDeclaration(VariableDeclaration node) { |
| 925 if (identical(_oldNode, node.documentationComment)) { |
| 926 throw new InsufficientContextException(); |
| 927 } else if (node.metadata.contains(_oldNode)) { |
| 928 return _parser.parseAnnotation(); |
| 929 } else if (identical(_oldNode, node.name)) { |
| 930 throw new InsufficientContextException(); |
| 931 } else if (identical(_oldNode, node.initializer)) { |
| 932 throw new InsufficientContextException(); |
| 933 } |
| 934 return notAChild(node); |
| 935 } |
| 936 ASTNode visitVariableDeclarationList(VariableDeclarationList node) { |
| 937 if (identical(_oldNode, node.documentationComment)) { |
| 938 throw new InsufficientContextException(); |
| 939 } else if (node.metadata.contains(_oldNode)) { |
| 940 return _parser.parseAnnotation(); |
| 941 } else if (node.variables.contains(_oldNode)) { |
| 942 throw new InsufficientContextException(); |
| 943 } |
| 944 return notAChild(node); |
| 945 } |
| 946 ASTNode visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 947 if (identical(_oldNode, node.variables)) { |
| 948 throw new InsufficientContextException(); |
| 949 } |
| 950 return notAChild(node); |
| 951 } |
| 952 ASTNode visitWhileStatement(WhileStatement node) { |
| 953 if (identical(_oldNode, node.condition)) { |
| 954 return _parser.parseExpression2(); |
| 955 } else if (identical(_oldNode, node.body)) { |
| 956 return _parser.parseStatement2(); |
| 957 } |
| 958 return notAChild(node); |
| 959 } |
| 960 ASTNode visitWithClause(WithClause node) { |
| 961 if (node.mixinTypes.contains(node)) { |
| 962 return _parser.parseTypeName(); |
| 963 } |
| 964 return notAChild(node); |
| 965 } |
| 966 |
| 967 /** |
| 968 * Return `true` if the given assignment expression can have a cascade express
ion on the |
| 969 * right-hand side. |
| 970 * |
| 971 * @param node the assignment expression being tested |
| 972 * @return `true` if the right-hand side can be a cascade expression |
| 973 */ |
| 974 bool isCascadeAllowed(AssignmentExpression node) { |
| 975 throw new InsufficientContextException(); |
| 976 } |
| 977 |
| 978 /** |
| 979 * Return `true` if the given throw expression can have a cascade expression. |
| 980 * |
| 981 * @param node the throw expression being tested |
| 982 * @return `true` if the expression can be a cascade expression |
| 983 */ |
| 984 bool isCascadeAllowed2(ThrowExpression node) { |
| 985 throw new InsufficientContextException(); |
| 986 } |
| 987 |
| 988 /** |
| 989 * Throw an exception indicating that the visited node was not the parent of t
he node to be |
| 990 * replaced. |
| 991 * |
| 992 * @param visitedNode the visited node that should have been the parent of the
node to be replaced |
| 993 */ |
| 994 ASTNode notAChild(ASTNode visitedNode) { |
| 995 throw new IncrementalParseException.con1("Internal error: the visited node (
a ${visitedNode.runtimeType.toString()}) was not the parent of the node to be re
placed (a ${_oldNode.runtimeType.toString()})"); |
| 996 } |
| 997 } |
| 998 /** |
| 999 * Instances of the class `IncrementalParseException` represent an exception tha
t occurred |
| 1000 * while attempting to parse a replacement for a specified node in an existing A
ST structure. |
| 1001 */ |
| 1002 class IncrementalParseException extends RuntimeException { |
| 1003 |
| 1004 /** |
| 1005 * Initialize a newly created exception to have no message and to be its own c
ause. |
| 1006 */ |
| 1007 IncrementalParseException() : super(); |
| 1008 |
| 1009 /** |
| 1010 * Initialize a newly created exception to have the given message and to be it
s own cause. |
| 1011 * |
| 1012 * @param message the message describing the reason for the exception |
| 1013 */ |
| 1014 IncrementalParseException.con1(String message) : super(message: message); |
| 1015 |
| 1016 /** |
| 1017 * Initialize a newly created exception to have no message and to have the giv
en cause. |
| 1018 * |
| 1019 * @param cause the exception that caused this exception |
| 1020 */ |
| 1021 IncrementalParseException.con2(Exception cause) : super(cause: cause); |
| 1022 } |
| 1023 /** |
| 1024 * Instances of the class `IncrementalParser` re-parse a single AST structure wi
thin a larger |
| 1025 * AST structure. |
| 1026 */ |
| 1027 class IncrementalParser { |
| 1028 |
| 1029 /** |
| 1030 * The source being parsed. |
| 1031 */ |
| 1032 Source _source; |
| 1033 |
| 1034 /** |
| 1035 * A map from old tokens to new tokens used during the cloning process. |
| 1036 */ |
| 1037 TokenMap _tokenMap; |
| 1038 |
| 1039 /** |
| 1040 * The error listener that will be informed of any errors that are found durin
g the parse. |
| 1041 */ |
| 1042 AnalysisErrorListener _errorListener; |
| 1043 |
| 1044 /** |
| 1045 * Initialize a newly created incremental parser to parse a portion of the con
tent of the given |
| 1046 * source. |
| 1047 * |
| 1048 * @param source the source being parsed |
| 1049 * @param tokenMap a map from old tokens to new tokens used during the cloning
process |
| 1050 * @param errorListener the error listener that will be informed of any errors
that are found |
| 1051 * during the parse |
| 1052 */ |
| 1053 IncrementalParser(Source source, TokenMap tokenMap, AnalysisErrorListener erro
rListener) { |
| 1054 this._source = source; |
| 1055 this._tokenMap = tokenMap; |
| 1056 this._errorListener = errorListener; |
| 1057 } |
| 1058 |
| 1059 /** |
| 1060 * Given a range of tokens that were re-scanned, re-parse the minimimum number
of tokens to |
| 1061 * produce a consistent AST structure. The range is represented by the first a
nd last tokens in |
| 1062 * the range. The tokens are assumed to be contained in the same token stream. |
| 1063 * |
| 1064 * @param firstToken the first token in the range of tokens that were re-scann
ed or `null` |
| 1065 * if no new tokens were inserted |
| 1066 * @param lastToken the last token in the range of tokens that were re-scanned
or `null` if |
| 1067 * no new tokens were inserted |
| 1068 * @param originalStart the offset in the original source of the first charact
er that was modified |
| 1069 * @param originalEnd the offset in the original source of the last character
that was modified |
| 1070 */ |
| 1071 ASTNode reparse(ASTNode originalStructure, Token firstToken, Token lastToken,
int originalStart, int originalEnd) { |
| 1072 ASTNode oldNode = null; |
| 1073 ASTNode newNode = null; |
| 1074 if (firstToken != null) { |
| 1075 if (originalEnd < originalStart) { |
| 1076 oldNode = new NodeLocator.con1(originalStart).searchWithin(originalStruc
ture); |
| 1077 } else { |
| 1078 oldNode = new NodeLocator.con2(originalStart, originalEnd).searchWithin(
originalStructure); |
| 1079 } |
| 1080 int originalOffset = oldNode.offset; |
| 1081 Token parseToken = findTokenAt(firstToken, originalOffset); |
| 1082 if (parseToken == null) { |
| 1083 return null; |
| 1084 } |
| 1085 Parser parser = new Parser(_source, _errorListener); |
| 1086 parser.currentToken = parseToken; |
| 1087 while (newNode == null) { |
| 1088 ASTNode parent = oldNode.parent; |
| 1089 if (parent == null) { |
| 1090 parseToken = findFirstToken(parseToken); |
| 1091 parser.currentToken = parseToken; |
| 1092 return parser.parseCompilationUnit2() as ASTNode; |
| 1093 } |
| 1094 try { |
| 1095 IncrementalParseDispatcher dispatcher = new IncrementalParseDispatcher
(parser, oldNode); |
| 1096 newNode = parent.accept(dispatcher); |
| 1097 } on InsufficientContextException catch (exception) { |
| 1098 oldNode = parent; |
| 1099 originalOffset = oldNode.offset; |
| 1100 parseToken = findTokenAt(parseToken, originalOffset); |
| 1101 parser.currentToken = parseToken; |
| 1102 } on JavaException catch (exception) { |
| 1103 return null; |
| 1104 } |
| 1105 } |
| 1106 if (newNode.offset != originalOffset) { |
| 1107 return null; |
| 1108 } |
| 1109 if (identical(oldNode, originalStructure)) { |
| 1110 return newNode as ASTNode; |
| 1111 } |
| 1112 ResolutionCopier.copyResolutionData(oldNode, newNode); |
| 1113 } |
| 1114 IncrementalASTCloner cloner = new IncrementalASTCloner(oldNode, newNode, _to
kenMap); |
| 1115 return originalStructure.accept(cloner) as ASTNode; |
| 1116 } |
| 1117 |
| 1118 /** |
| 1119 * Return the first (non-EOF) token in the token stream containing the given t
oken. |
| 1120 * |
| 1121 * @param firstToken the token from which the search is to begin |
| 1122 * @return the first token in the token stream containing the given token |
| 1123 */ |
| 1124 Token findFirstToken(Token firstToken) { |
| 1125 while (firstToken.type != TokenType.EOF) { |
| 1126 firstToken = firstToken.previous; |
| 1127 } |
| 1128 return firstToken.next; |
| 1129 } |
| 1130 |
| 1131 /** |
| 1132 * Find the token at or before the given token with the given offset, or `null
` if there is |
| 1133 * no such token. |
| 1134 * |
| 1135 * @param firstToken the token from which the search is to begin |
| 1136 * @param offset the offset of the token to be returned |
| 1137 * @return the token with the given offset |
| 1138 */ |
| 1139 Token findTokenAt(Token firstToken, int offset) { |
| 1140 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) { |
| 1141 firstToken = firstToken.previous; |
| 1142 } |
| 1143 if (firstToken.offset == offset) { |
| 1144 return firstToken; |
| 1145 } |
| 1146 return null; |
| 1147 } |
| 1148 } |
| 1149 /** |
| 1150 * Instances of the class `InsufficientContextException` represent a situation i
n which an AST |
| 1151 * node cannot be re-parsed because there is not enough context to know how to r
e-parse the node. |
| 1152 * Clients can attempt to re-parse the parent of the node. |
| 1153 */ |
| 1154 class InsufficientContextException extends IncrementalParseException { |
| 1155 |
| 1156 /** |
| 1157 * Initialize a newly created exception to have no message and to be its own c
ause. |
| 1158 */ |
| 1159 InsufficientContextException() : super(); |
| 1160 |
| 1161 /** |
| 1162 * Initialize a newly created exception to have the given message and to be it
s own cause. |
| 1163 * |
| 1164 * @param message the message describing the reason for the exception |
| 1165 */ |
| 1166 InsufficientContextException.con1(String message) : super.con1(message); |
| 1167 |
| 1168 /** |
| 1169 * Initialize a newly created exception to have no message and to have the giv
en cause. |
| 1170 * |
| 1171 * @param cause the exception that caused this exception |
| 1172 */ |
| 1173 InsufficientContextException.con2(Exception cause) : super.con2(cause); |
| 1174 } |
| 1175 /** |
146 * Instances of the class `Parser` are used to parse tokens into an AST structur
e. | 1176 * Instances of the class `Parser` are used to parse tokens into an AST structur
e. |
147 * | 1177 * |
148 * @coverage dart.engine.parser | 1178 * @coverage dart.engine.parser |
149 */ | 1179 */ |
150 class Parser { | 1180 class Parser { |
151 | 1181 |
152 /** | 1182 /** |
153 * The source being parsed. | 1183 * The source being parsed. |
154 */ | 1184 */ |
155 Source _source; | 1185 Source _source; |
(...skipping 13 matching lines...) Expand all Loading... |
169 */ | 1199 */ |
170 bool _inLoop = false; | 1200 bool _inLoop = false; |
171 | 1201 |
172 /** | 1202 /** |
173 * A flag indicating whether the parser is currently in a switch statement. | 1203 * A flag indicating whether the parser is currently in a switch statement. |
174 */ | 1204 */ |
175 bool _inSwitch = false; | 1205 bool _inSwitch = false; |
176 static String _HIDE = "hide"; | 1206 static String _HIDE = "hide"; |
177 static String _OF = "of"; | 1207 static String _OF = "of"; |
178 static String _ON = "on"; | 1208 static String _ON = "on"; |
| 1209 static String _NATIVE = "native"; |
179 static String _SHOW = "show"; | 1210 static String _SHOW = "show"; |
180 static String _NATIVE = "native"; | |
181 | 1211 |
182 /** | 1212 /** |
183 * Initialize a newly created parser. | 1213 * Initialize a newly created parser. |
184 * | 1214 * |
185 * @param source the source being parsed | 1215 * @param source the source being parsed |
186 * @param errorListener the error listener that will be informed of any errors
that are found | 1216 * @param errorListener the error listener that will be informed of any errors
that are found |
187 * during the parse | 1217 * during the parse |
188 */ | 1218 */ |
189 Parser(Source source, AnalysisErrorListener errorListener) { | 1219 Parser(Source source, AnalysisErrorListener errorListener) { |
190 this._source = source; | 1220 this._source = source; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 */ | 1282 */ |
253 List<Statement> parseStatements(Token token) { | 1283 List<Statement> parseStatements(Token token) { |
254 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.Parser.parseStatements"); | 1284 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.Parser.parseStatements"); |
255 try { | 1285 try { |
256 _currentToken = token; | 1286 _currentToken = token; |
257 return parseStatements2(); | 1287 return parseStatements2(); |
258 } finally { | 1288 } finally { |
259 instrumentation.log(); | 1289 instrumentation.log(); |
260 } | 1290 } |
261 } | 1291 } |
| 1292 |
| 1293 /** |
| 1294 * Parse an annotation. |
| 1295 * |
| 1296 * <pre> |
| 1297 * annotation ::= |
| 1298 * '@' qualified ('.' identifier)? arguments? |
| 1299 * </pre> |
| 1300 * |
| 1301 * @return the annotation that was parsed |
| 1302 */ |
| 1303 Annotation parseAnnotation() { |
| 1304 Token atSign = expect2(TokenType.AT); |
| 1305 Identifier name = parsePrefixedIdentifier(); |
| 1306 Token period = null; |
| 1307 SimpleIdentifier constructorName = null; |
| 1308 if (matches5(TokenType.PERIOD)) { |
| 1309 period = andAdvance; |
| 1310 constructorName = parseSimpleIdentifier(); |
| 1311 } |
| 1312 ArgumentList arguments = null; |
| 1313 if (matches5(TokenType.OPEN_PAREN)) { |
| 1314 arguments = parseArgumentList(); |
| 1315 } |
| 1316 return new Annotation.full(atSign, name, period, constructorName, arguments)
; |
| 1317 } |
| 1318 |
| 1319 /** |
| 1320 * Parse an argument. |
| 1321 * |
| 1322 * <pre> |
| 1323 * argument ::= |
| 1324 * namedArgument |
| 1325 * | expression |
| 1326 * |
| 1327 * namedArgument ::= |
| 1328 * label expression |
| 1329 * </pre> |
| 1330 * |
| 1331 * @return the argument that was parsed |
| 1332 */ |
| 1333 Expression parseArgument() { |
| 1334 if (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { |
| 1335 return new NamedExpression.full(parseLabel(), parseExpression2()); |
| 1336 } else { |
| 1337 return parseExpression2(); |
| 1338 } |
| 1339 } |
| 1340 |
| 1341 /** |
| 1342 * Parse a list of arguments. |
| 1343 * |
| 1344 * <pre> |
| 1345 * arguments ::= |
| 1346 * '(' argumentList? ')' |
| 1347 * |
| 1348 * argumentList ::= |
| 1349 * namedArgument (',' namedArgument)* |
| 1350 * | expressionList (',' namedArgument)* |
| 1351 * </pre> |
| 1352 * |
| 1353 * @return the argument list that was parsed |
| 1354 */ |
| 1355 ArgumentList parseArgumentList() { |
| 1356 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); |
| 1357 List<Expression> arguments = new List<Expression>(); |
| 1358 if (matches5(TokenType.CLOSE_PAREN)) { |
| 1359 return new ArgumentList.full(leftParenthesis, arguments, andAdvance); |
| 1360 } |
| 1361 Expression argument = parseArgument(); |
| 1362 arguments.add(argument); |
| 1363 bool foundNamedArgument = argument is NamedExpression; |
| 1364 bool generatedError = false; |
| 1365 while (optional(TokenType.COMMA)) { |
| 1366 argument = parseArgument(); |
| 1367 arguments.add(argument); |
| 1368 if (foundNamedArgument) { |
| 1369 if (!generatedError && argument is! NamedExpression) { |
| 1370 reportError8(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, []); |
| 1371 generatedError = true; |
| 1372 } |
| 1373 } else if (argument is NamedExpression) { |
| 1374 foundNamedArgument = true; |
| 1375 } |
| 1376 } |
| 1377 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 1378 return new ArgumentList.full(leftParenthesis, arguments, rightParenthesis); |
| 1379 } |
| 1380 |
| 1381 /** |
| 1382 * Parse a bitwise or expression. |
| 1383 * |
| 1384 * <pre> |
| 1385 * bitwiseOrExpression ::= |
| 1386 * bitwiseXorExpression ('|' bitwiseXorExpression)* |
| 1387 * | 'super' ('|' bitwiseXorExpression)+ |
| 1388 * </pre> |
| 1389 * |
| 1390 * @return the bitwise or expression that was parsed |
| 1391 */ |
| 1392 Expression parseBitwiseOrExpression() { |
| 1393 Expression expression; |
| 1394 if (matches(Keyword.SUPER) && matches4(peek(), TokenType.BAR)) { |
| 1395 expression = new SuperExpression.full(andAdvance); |
| 1396 } else { |
| 1397 expression = parseBitwiseXorExpression(); |
| 1398 } |
| 1399 while (matches5(TokenType.BAR)) { |
| 1400 Token operator = andAdvance; |
| 1401 expression = new BinaryExpression.full(expression, operator, parseBitwiseX
orExpression()); |
| 1402 } |
| 1403 return expression; |
| 1404 } |
| 1405 |
| 1406 /** |
| 1407 * Parse a block. |
| 1408 * |
| 1409 * <pre> |
| 1410 * block ::= |
| 1411 * '{' statements '}' |
| 1412 * </pre> |
| 1413 * |
| 1414 * @return the block that was parsed |
| 1415 */ |
| 1416 Block parseBlock() { |
| 1417 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); |
| 1418 List<Statement> statements = new List<Statement>(); |
| 1419 Token statementStart = _currentToken; |
| 1420 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET))
{ |
| 1421 Statement statement = parseStatement2(); |
| 1422 if (statement != null) { |
| 1423 statements.add(statement); |
| 1424 } |
| 1425 if (identical(_currentToken, statementStart)) { |
| 1426 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1427 advance(); |
| 1428 } |
| 1429 statementStart = _currentToken; |
| 1430 } |
| 1431 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); |
| 1432 return new Block.full(leftBracket, statements, rightBracket); |
| 1433 } |
| 1434 |
| 1435 /** |
| 1436 * Parse a class member. |
| 1437 * |
| 1438 * <pre> |
| 1439 * classMemberDefinition ::= |
| 1440 * declaration ';' |
| 1441 * | methodSignature functionBody |
| 1442 * </pre> |
| 1443 * |
| 1444 * @param className the name of the class containing the member being parsed |
| 1445 * @return the class member that was parsed, or `null` if what was found was n
ot a valid |
| 1446 * class member |
| 1447 */ |
| 1448 ClassMember parseClassMember(String className) { |
| 1449 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 1450 Modifiers modifiers = parseModifiers(); |
| 1451 if (matches(Keyword.VOID)) { |
| 1452 TypeName returnType = parseReturnType(); |
| 1453 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { |
| 1454 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1455 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifi
ers.staticKeyword, returnType); |
| 1456 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { |
| 1457 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1458 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifi
ers.staticKeyword, returnType); |
| 1459 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { |
| 1460 validateModifiersForOperator(modifiers); |
| 1461 return parseOperator(commentAndMetadata, modifiers.externalKeyword, retu
rnType); |
| 1462 } else if (matchesIdentifier() && matchesAny(peek(), [ |
| 1463 TokenType.OPEN_PAREN, |
| 1464 TokenType.OPEN_CURLY_BRACKET, |
| 1465 TokenType.FUNCTION])) { |
| 1466 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1467 return parseMethodDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, modifiers.staticKeyword, returnType); |
| 1468 } else { |
| 1469 if (matchesIdentifier()) { |
| 1470 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { |
| 1471 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); |
| 1472 return parseInitializedIdentifierList(commentAndMetadata, modifiers.
staticKeyword, validateModifiersForField(modifiers), returnType); |
| 1473 } |
| 1474 } |
| 1475 if (isOperator(_currentToken)) { |
| 1476 validateModifiersForOperator(modifiers); |
| 1477 return parseOperator(commentAndMetadata, modifiers.externalKeyword, re
turnType); |
| 1478 } |
| 1479 reportError9(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); |
| 1480 return null; |
| 1481 } |
| 1482 } else if (matches(Keyword.GET) && matchesIdentifier2(peek())) { |
| 1483 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1484 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); |
| 1485 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { |
| 1486 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1487 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); |
| 1488 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { |
| 1489 validateModifiersForOperator(modifiers); |
| 1490 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null); |
| 1491 } else if (!matchesIdentifier()) { |
| 1492 if (isOperator(_currentToken)) { |
| 1493 validateModifiersForOperator(modifiers); |
| 1494 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null
); |
| 1495 } |
| 1496 reportError9(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); |
| 1497 return null; |
| 1498 } else if (matches4(peek(), TokenType.PERIOD) && matchesIdentifier2(peek2(2)
) && matches4(peek2(3), TokenType.OPEN_PAREN)) { |
| 1499 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); |
| 1500 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { |
| 1501 SimpleIdentifier methodName = parseSimpleIdentifier(); |
| 1502 FormalParameterList parameters = parseFormalParameterList(); |
| 1503 if (matches5(TokenType.COLON) || modifiers.factoryKeyword != null || metho
dName.name == className) { |
| 1504 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); |
| 1505 } |
| 1506 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1507 validateFormalParameterList(parameters); |
| 1508 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo
rd, modifiers.staticKeyword, null, methodName, parameters); |
| 1509 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { |
| 1510 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo
difiers.varKeyword == null) { |
| 1511 reportError8(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); |
| 1512 } |
| 1513 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static
Keyword, validateModifiersForField(modifiers), null); |
| 1514 } |
| 1515 TypeName type = parseTypeName(); |
| 1516 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { |
| 1517 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1518 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); |
| 1519 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { |
| 1520 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1521 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); |
| 1522 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { |
| 1523 validateModifiersForOperator(modifiers); |
| 1524 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type); |
| 1525 } else if (!matchesIdentifier()) { |
| 1526 if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { |
| 1527 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat
icKeyword, validateModifiersForField(modifiers), type); |
| 1528 } |
| 1529 if (isOperator(_currentToken)) { |
| 1530 validateModifiersForOperator(modifiers); |
| 1531 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type
); |
| 1532 } |
| 1533 reportError9(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); |
| 1534 return null; |
| 1535 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { |
| 1536 SimpleIdentifier methodName = parseSimpleIdentifier(); |
| 1537 FormalParameterList parameters = parseFormalParameterList(); |
| 1538 if (methodName.name == className) { |
| 1539 reportError(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type, []); |
| 1540 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); |
| 1541 } |
| 1542 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1543 validateFormalParameterList(parameters); |
| 1544 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo
rd, modifiers.staticKeyword, type, methodName, parameters); |
| 1545 } |
| 1546 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe
yword, validateModifiersForField(modifiers), type); |
| 1547 } |
| 1548 |
| 1549 /** |
| 1550 * Parse a compilation unit. |
| 1551 * |
| 1552 * Specified: |
| 1553 * |
| 1554 * <pre> |
| 1555 * compilationUnit ::= |
| 1556 * scriptTag? directive* topLevelDeclaration* |
| 1557 * </pre> |
| 1558 * Actual: |
| 1559 * |
| 1560 * <pre> |
| 1561 * compilationUnit ::= |
| 1562 * scriptTag? topLevelElement* |
| 1563 * |
| 1564 * topLevelElement ::= |
| 1565 * directive |
| 1566 * | topLevelDeclaration |
| 1567 * </pre> |
| 1568 * |
| 1569 * @return the compilation unit that was parsed |
| 1570 */ |
| 1571 CompilationUnit parseCompilationUnit2() { |
| 1572 Token firstToken = _currentToken; |
| 1573 ScriptTag scriptTag = null; |
| 1574 if (matches5(TokenType.SCRIPT_TAG)) { |
| 1575 scriptTag = new ScriptTag.full(andAdvance); |
| 1576 } |
| 1577 bool libraryDirectiveFound = false; |
| 1578 bool partOfDirectiveFound = false; |
| 1579 bool partDirectiveFound = false; |
| 1580 bool directiveFoundAfterDeclaration = false; |
| 1581 List<Directive> directives = new List<Directive>(); |
| 1582 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; |
| 1583 Token memberStart = _currentToken; |
| 1584 while (!matches5(TokenType.EOF)) { |
| 1585 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 1586 if ((matches(Keyword.IMPORT) || matches(Keyword.EXPORT) || matches(Keyword
.LIBRARY) || matches(Keyword.PART)) && !matches4(peek(), TokenType.PERIOD) && !m
atches4(peek(), TokenType.LT)) { |
| 1587 Directive directive = parseDirective(commentAndMetadata); |
| 1588 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { |
| 1589 reportError8(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, []); |
| 1590 directiveFoundAfterDeclaration = true; |
| 1591 } |
| 1592 if (directive is LibraryDirective) { |
| 1593 if (libraryDirectiveFound) { |
| 1594 reportError8(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, []); |
| 1595 } else { |
| 1596 if (directives.length > 0) { |
| 1597 reportError8(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, []); |
| 1598 } |
| 1599 libraryDirectiveFound = true; |
| 1600 } |
| 1601 } else if (directive is PartDirective) { |
| 1602 partDirectiveFound = true; |
| 1603 } else if (partDirectiveFound) { |
| 1604 if (directive is ExportDirective) { |
| 1605 reportError9(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
((directive as NamespaceDirective)).keyword, []); |
| 1606 } else if (directive is ImportDirective) { |
| 1607 reportError9(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
((directive as NamespaceDirective)).keyword, []); |
| 1608 } |
| 1609 } |
| 1610 if (directive is PartOfDirective) { |
| 1611 if (partOfDirectiveFound) { |
| 1612 reportError8(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []); |
| 1613 } else { |
| 1614 for (Directive precedingDirective in directives) { |
| 1615 reportError9(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, preced
ingDirective.keyword, []); |
| 1616 } |
| 1617 partOfDirectiveFound = true; |
| 1618 } |
| 1619 } else { |
| 1620 if (partOfDirectiveFound) { |
| 1621 reportError9(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directiv
e.keyword, []); |
| 1622 } |
| 1623 } |
| 1624 directives.add(directive); |
| 1625 } else if (matches5(TokenType.SEMICOLON)) { |
| 1626 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1627 advance(); |
| 1628 } else { |
| 1629 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta
data); |
| 1630 if (member != null) { |
| 1631 declarations.add(member); |
| 1632 } |
| 1633 } |
| 1634 if (identical(_currentToken, memberStart)) { |
| 1635 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1636 advance(); |
| 1637 while (!matches5(TokenType.EOF) && !couldBeStartOfCompilationUnitMember(
)) { |
| 1638 advance(); |
| 1639 } |
| 1640 } |
| 1641 memberStart = _currentToken; |
| 1642 } |
| 1643 return new CompilationUnit.full(firstToken, scriptTag, directives, declarati
ons, _currentToken); |
| 1644 } |
| 1645 |
| 1646 /** |
| 1647 * Parse a conditional expression. |
| 1648 * |
| 1649 * <pre> |
| 1650 * conditionalExpression ::= |
| 1651 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithout
Cascade)? |
| 1652 * </pre> |
| 1653 * |
| 1654 * @return the conditional expression that was parsed |
| 1655 */ |
| 1656 Expression parseConditionalExpression() { |
| 1657 Expression condition = parseLogicalOrExpression(); |
| 1658 if (!matches5(TokenType.QUESTION)) { |
| 1659 return condition; |
| 1660 } |
| 1661 Token question = andAdvance; |
| 1662 Expression thenExpression = parseExpressionWithoutCascade(); |
| 1663 Token colon = expect2(TokenType.COLON); |
| 1664 Expression elseExpression = parseExpressionWithoutCascade(); |
| 1665 return new ConditionalExpression.full(condition, question, thenExpression, c
olon, elseExpression); |
| 1666 } |
| 1667 |
| 1668 /** |
| 1669 * Parse the name of a constructor. |
| 1670 * |
| 1671 * <pre> |
| 1672 * constructorName: |
| 1673 * type ('.' identifier)? |
| 1674 * </pre> |
| 1675 * |
| 1676 * @return the constructor name that was parsed |
| 1677 */ |
| 1678 ConstructorName parseConstructorName() { |
| 1679 TypeName type = parseTypeName(); |
| 1680 Token period = null; |
| 1681 SimpleIdentifier name = null; |
| 1682 if (matches5(TokenType.PERIOD)) { |
| 1683 period = andAdvance; |
| 1684 name = parseSimpleIdentifier(); |
| 1685 } |
| 1686 return new ConstructorName.full(type, period, name); |
| 1687 } |
| 1688 |
| 1689 /** |
| 1690 * Parse an expression that does not contain any cascades. |
| 1691 * |
| 1692 * <pre> |
| 1693 * expression ::= |
| 1694 * assignableExpression assignmentOperator expression |
| 1695 * | conditionalExpression cascadeSection* |
| 1696 * | throwExpression |
| 1697 * </pre> |
| 1698 * |
| 1699 * @return the expression that was parsed |
| 1700 */ |
| 1701 Expression parseExpression2() { |
| 1702 if (matches(Keyword.THROW)) { |
| 1703 return parseThrowExpression(); |
| 1704 } else if (matches(Keyword.RETHROW)) { |
| 1705 return parseRethrowExpression(); |
| 1706 } |
| 1707 Expression expression = parseConditionalExpression(); |
| 1708 TokenType tokenType = _currentToken.type; |
| 1709 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { |
| 1710 List<Expression> cascadeSections = new List<Expression>(); |
| 1711 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { |
| 1712 Expression section = parseCascadeSection(); |
| 1713 if (section != null) { |
| 1714 cascadeSections.add(section); |
| 1715 } |
| 1716 tokenType = _currentToken.type; |
| 1717 } |
| 1718 return new CascadeExpression.full(expression, cascadeSections); |
| 1719 } else if (tokenType.isAssignmentOperator) { |
| 1720 Token operator = andAdvance; |
| 1721 ensureAssignable(expression); |
| 1722 return new AssignmentExpression.full(expression, operator, parseExpression
2()); |
| 1723 } |
| 1724 return expression; |
| 1725 } |
| 1726 |
| 1727 /** |
| 1728 * Parse an expression that does not contain any cascades. |
| 1729 * |
| 1730 * <pre> |
| 1731 * expressionWithoutCascade ::= |
| 1732 * assignableExpression assignmentOperator expressionWithoutCascade |
| 1733 * | conditionalExpression |
| 1734 * | throwExpressionWithoutCascade |
| 1735 * </pre> |
| 1736 * |
| 1737 * @return the expression that was parsed |
| 1738 */ |
| 1739 Expression parseExpressionWithoutCascade() { |
| 1740 if (matches(Keyword.THROW)) { |
| 1741 return parseThrowExpressionWithoutCascade(); |
| 1742 } else if (matches(Keyword.RETHROW)) { |
| 1743 return parseRethrowExpression(); |
| 1744 } |
| 1745 Expression expression = parseConditionalExpression(); |
| 1746 if (_currentToken.type.isAssignmentOperator) { |
| 1747 Token operator = andAdvance; |
| 1748 ensureAssignable(expression); |
| 1749 expression = new AssignmentExpression.full(expression, operator, parseExpr
essionWithoutCascade()); |
| 1750 } |
| 1751 return expression; |
| 1752 } |
| 1753 |
| 1754 /** |
| 1755 * Parse a class extends clause. |
| 1756 * |
| 1757 * <pre> |
| 1758 * classExtendsClause ::= |
| 1759 * 'extends' type |
| 1760 * </pre> |
| 1761 * |
| 1762 * @return the class extends clause that was parsed |
| 1763 */ |
| 1764 ExtendsClause parseExtendsClause() { |
| 1765 Token keyword = expect(Keyword.EXTENDS); |
| 1766 TypeName superclass = parseTypeName(); |
| 1767 return new ExtendsClause.full(keyword, superclass); |
| 1768 } |
| 1769 |
| 1770 /** |
| 1771 * Parse a list of formal parameters. |
| 1772 * |
| 1773 * <pre> |
| 1774 * formalParameterList ::= |
| 1775 * '(' ')' |
| 1776 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')' |
| 1777 * | '(' optionalFormalParameters ')' |
| 1778 * |
| 1779 * normalFormalParameters ::= |
| 1780 * normalFormalParameter (',' normalFormalParameter)* |
| 1781 * |
| 1782 * optionalFormalParameters ::= |
| 1783 * optionalPositionalFormalParameters |
| 1784 * | namedFormalParameters |
| 1785 * |
| 1786 * optionalPositionalFormalParameters ::= |
| 1787 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' |
| 1788 * |
| 1789 * namedFormalParameters ::= |
| 1790 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' |
| 1791 * </pre> |
| 1792 * |
| 1793 * @return the formal parameters that were parsed |
| 1794 */ |
| 1795 FormalParameterList parseFormalParameterList() { |
| 1796 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); |
| 1797 if (matches5(TokenType.CLOSE_PAREN)) { |
| 1798 return new FormalParameterList.full(leftParenthesis, null, null, null, and
Advance); |
| 1799 } |
| 1800 List<FormalParameter> parameters = new List<FormalParameter>(); |
| 1801 List<FormalParameter> normalParameters = new List<FormalParameter>(); |
| 1802 List<FormalParameter> positionalParameters = new List<FormalParameter>(); |
| 1803 List<FormalParameter> namedParameters = new List<FormalParameter>(); |
| 1804 List<FormalParameter> currentParameters = normalParameters; |
| 1805 Token leftSquareBracket = null; |
| 1806 Token rightSquareBracket = null; |
| 1807 Token leftCurlyBracket = null; |
| 1808 Token rightCurlyBracket = null; |
| 1809 ParameterKind kind = ParameterKind.REQUIRED; |
| 1810 bool firstParameter = true; |
| 1811 bool reportedMuliplePositionalGroups = false; |
| 1812 bool reportedMulipleNamedGroups = false; |
| 1813 bool reportedMixedGroups = false; |
| 1814 bool wasOptionalParameter = false; |
| 1815 Token initialToken = null; |
| 1816 do { |
| 1817 if (firstParameter) { |
| 1818 firstParameter = false; |
| 1819 } else if (!optional(TokenType.COMMA)) { |
| 1820 if (getEndToken(leftParenthesis) != null) { |
| 1821 reportError8(ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme])
; |
| 1822 } else { |
| 1823 reportError9(ParserErrorCode.MISSING_CLOSING_PARENTHESIS, _currentToke
n.previous, []); |
| 1824 break; |
| 1825 } |
| 1826 } |
| 1827 initialToken = _currentToken; |
| 1828 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { |
| 1829 wasOptionalParameter = true; |
| 1830 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { |
| 1831 reportError8(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, [])
; |
| 1832 reportedMuliplePositionalGroups = true; |
| 1833 } |
| 1834 if (leftCurlyBracket != null && !reportedMixedGroups) { |
| 1835 reportError8(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); |
| 1836 reportedMixedGroups = true; |
| 1837 } |
| 1838 leftSquareBracket = andAdvance; |
| 1839 currentParameters = positionalParameters; |
| 1840 kind = ParameterKind.POSITIONAL; |
| 1841 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 1842 wasOptionalParameter = true; |
| 1843 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { |
| 1844 reportError8(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, []); |
| 1845 reportedMulipleNamedGroups = true; |
| 1846 } |
| 1847 if (leftSquareBracket != null && !reportedMixedGroups) { |
| 1848 reportError8(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); |
| 1849 reportedMixedGroups = true; |
| 1850 } |
| 1851 leftCurlyBracket = andAdvance; |
| 1852 currentParameters = namedParameters; |
| 1853 kind = ParameterKind.NAMED; |
| 1854 } |
| 1855 FormalParameter parameter = parseFormalParameter(kind); |
| 1856 parameters.add(parameter); |
| 1857 currentParameters.add(parameter); |
| 1858 if (identical(kind, ParameterKind.REQUIRED) && wasOptionalParameter) { |
| 1859 reportError(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, parameter
, []); |
| 1860 } |
| 1861 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { |
| 1862 rightSquareBracket = andAdvance; |
| 1863 currentParameters = normalParameters; |
| 1864 if (leftSquareBracket == null) { |
| 1865 if (leftCurlyBracket != null) { |
| 1866 reportError8(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [
"}"]); |
| 1867 rightCurlyBracket = rightSquareBracket; |
| 1868 rightSquareBracket = null; |
| 1869 } else { |
| 1870 reportError8(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO
UP, ["["]); |
| 1871 } |
| 1872 } |
| 1873 kind = ParameterKind.REQUIRED; |
| 1874 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { |
| 1875 rightCurlyBracket = andAdvance; |
| 1876 currentParameters = normalParameters; |
| 1877 if (leftCurlyBracket == null) { |
| 1878 if (leftSquareBracket != null) { |
| 1879 reportError8(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [
"]"]); |
| 1880 rightSquareBracket = rightCurlyBracket; |
| 1881 rightCurlyBracket = null; |
| 1882 } else { |
| 1883 reportError8(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO
UP, ["{"]); |
| 1884 } |
| 1885 } |
| 1886 kind = ParameterKind.REQUIRED; |
| 1887 } |
| 1888 } while (!matches5(TokenType.CLOSE_PAREN) && initialToken != _currentToken); |
| 1889 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 1890 if (leftSquareBracket != null && rightSquareBracket == null) { |
| 1891 reportError8(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]
); |
| 1892 } |
| 1893 if (leftCurlyBracket != null && rightCurlyBracket == null) { |
| 1894 reportError8(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]
); |
| 1895 } |
| 1896 if (leftSquareBracket == null) { |
| 1897 leftSquareBracket = leftCurlyBracket; |
| 1898 } |
| 1899 if (rightSquareBracket == null) { |
| 1900 rightSquareBracket = rightCurlyBracket; |
| 1901 } |
| 1902 return new FormalParameterList.full(leftParenthesis, parameters, leftSquareB
racket, rightSquareBracket, rightParenthesis); |
| 1903 } |
| 1904 |
| 1905 /** |
| 1906 * Parse a function expression. |
| 1907 * |
| 1908 * <pre> |
| 1909 * functionExpression ::= |
| 1910 * formalParameterList functionExpressionBody |
| 1911 * </pre> |
| 1912 * |
| 1913 * @return the function expression that was parsed |
| 1914 */ |
| 1915 FunctionExpression parseFunctionExpression() { |
| 1916 FormalParameterList parameters = parseFormalParameterList(); |
| 1917 validateFormalParameterList(parameters); |
| 1918 FunctionBody body = parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTIO
N_BODY, true); |
| 1919 return new FunctionExpression.full(parameters, body); |
| 1920 } |
| 1921 |
| 1922 /** |
| 1923 * Parse an implements clause. |
| 1924 * |
| 1925 * <pre> |
| 1926 * implementsClause ::= |
| 1927 * 'implements' type (',' type)* |
| 1928 * </pre> |
| 1929 * |
| 1930 * @return the implements clause that was parsed |
| 1931 */ |
| 1932 ImplementsClause parseImplementsClause() { |
| 1933 Token keyword = expect(Keyword.IMPLEMENTS); |
| 1934 List<TypeName> interfaces = new List<TypeName>(); |
| 1935 interfaces.add(parseTypeName()); |
| 1936 while (optional(TokenType.COMMA)) { |
| 1937 interfaces.add(parseTypeName()); |
| 1938 } |
| 1939 return new ImplementsClause.full(keyword, interfaces); |
| 1940 } |
| 1941 |
| 1942 /** |
| 1943 * Parse a label. |
| 1944 * |
| 1945 * <pre> |
| 1946 * label ::= |
| 1947 * identifier ':' |
| 1948 * </pre> |
| 1949 * |
| 1950 * @return the label that was parsed |
| 1951 */ |
| 1952 Label parseLabel() { |
| 1953 SimpleIdentifier label = parseSimpleIdentifier(); |
| 1954 Token colon = expect2(TokenType.COLON); |
| 1955 return new Label.full(label, colon); |
| 1956 } |
| 1957 |
| 1958 /** |
| 1959 * Parse a library identifier. |
| 1960 * |
| 1961 * <pre> |
| 1962 * libraryIdentifier ::= |
| 1963 * identifier ('.' identifier)* |
| 1964 * </pre> |
| 1965 * |
| 1966 * @return the library identifier that was parsed |
| 1967 */ |
| 1968 LibraryIdentifier parseLibraryIdentifier() { |
| 1969 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); |
| 1970 components.add(parseSimpleIdentifier()); |
| 1971 while (matches5(TokenType.PERIOD)) { |
| 1972 advance(); |
| 1973 components.add(parseSimpleIdentifier()); |
| 1974 } |
| 1975 return new LibraryIdentifier.full(components); |
| 1976 } |
| 1977 |
| 1978 /** |
| 1979 * Parse a logical or expression. |
| 1980 * |
| 1981 * <pre> |
| 1982 * logicalOrExpression ::= |
| 1983 * logicalAndExpression ('||' logicalAndExpression)* |
| 1984 * </pre> |
| 1985 * |
| 1986 * @return the logical or expression that was parsed |
| 1987 */ |
| 1988 Expression parseLogicalOrExpression() { |
| 1989 Expression expression = parseLogicalAndExpression(); |
| 1990 while (matches5(TokenType.BAR_BAR)) { |
| 1991 Token operator = andAdvance; |
| 1992 expression = new BinaryExpression.full(expression, operator, parseLogicalA
ndExpression()); |
| 1993 } |
| 1994 return expression; |
| 1995 } |
| 1996 |
| 1997 /** |
| 1998 * Parse a map literal entry. |
| 1999 * |
| 2000 * <pre> |
| 2001 * mapLiteralEntry ::= |
| 2002 * expression ':' expression |
| 2003 * </pre> |
| 2004 * |
| 2005 * @return the map literal entry that was parsed |
| 2006 */ |
| 2007 MapLiteralEntry parseMapLiteralEntry() { |
| 2008 Expression key = parseExpression2(); |
| 2009 Token separator = expect2(TokenType.COLON); |
| 2010 Expression value = parseExpression2(); |
| 2011 return new MapLiteralEntry.full(key, separator, value); |
| 2012 } |
| 2013 |
| 2014 /** |
| 2015 * Parse a normal formal parameter. |
| 2016 * |
| 2017 * <pre> |
| 2018 * normalFormalParameter ::= |
| 2019 * functionSignature |
| 2020 * | fieldFormalParameter |
| 2021 * | simpleFormalParameter |
| 2022 * |
| 2023 * functionSignature: |
| 2024 * metadata returnType? identifier formalParameterList |
| 2025 * |
| 2026 * fieldFormalParameter ::= |
| 2027 * metadata finalConstVarOrType? 'this' '.' identifier |
| 2028 * |
| 2029 * simpleFormalParameter ::= |
| 2030 * declaredIdentifier |
| 2031 * | metadata identifier |
| 2032 * </pre> |
| 2033 * |
| 2034 * @return the normal formal parameter that was parsed |
| 2035 */ |
| 2036 NormalFormalParameter parseNormalFormalParameter() { |
| 2037 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 2038 FinalConstVarOrType holder = parseFinalConstVarOrType(true); |
| 2039 Token thisKeyword = null; |
| 2040 Token period = null; |
| 2041 if (matches(Keyword.THIS)) { |
| 2042 thisKeyword = andAdvance; |
| 2043 period = expect2(TokenType.PERIOD); |
| 2044 } |
| 2045 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 2046 if (matches5(TokenType.OPEN_PAREN)) { |
| 2047 FormalParameterList parameters = parseFormalParameterList(); |
| 2048 if (thisKeyword == null) { |
| 2049 if (holder.keyword != null) { |
| 2050 reportError9(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyw
ord, []); |
| 2051 } |
| 2052 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment,
commentAndMetadata.metadata, holder.type, identifier, parameters); |
| 2053 } else { |
| 2054 return new FieldFormalParameter.full(commentAndMetadata.comment, comment
AndMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifi
er, parameters); |
| 2055 } |
| 2056 } |
| 2057 TypeName type = holder.type; |
| 2058 if (type != null) { |
| 2059 if (matches3(type.name.beginToken, Keyword.VOID)) { |
| 2060 reportError9(ParserErrorCode.VOID_PARAMETER, type.name.beginToken, []); |
| 2061 } else if (holder.keyword != null && matches3(holder.keyword, Keyword.VAR)
) { |
| 2062 reportError9(ParserErrorCode.VAR_AND_TYPE, holder.keyword, []); |
| 2063 } |
| 2064 } |
| 2065 if (thisKeyword != null) { |
| 2066 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier
, null); |
| 2067 } |
| 2068 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd
Metadata.metadata, holder.keyword, holder.type, identifier); |
| 2069 } |
| 2070 |
| 2071 /** |
| 2072 * Parse a prefixed identifier. |
| 2073 * |
| 2074 * <pre> |
| 2075 * prefixedIdentifier ::= |
| 2076 * identifier ('.' identifier)? |
| 2077 * </pre> |
| 2078 * |
| 2079 * @return the prefixed identifier that was parsed |
| 2080 */ |
| 2081 Identifier parsePrefixedIdentifier() { |
| 2082 SimpleIdentifier qualifier = parseSimpleIdentifier(); |
| 2083 if (!matches5(TokenType.PERIOD)) { |
| 2084 return qualifier; |
| 2085 } |
| 2086 Token period = andAdvance; |
| 2087 SimpleIdentifier qualified = parseSimpleIdentifier(); |
| 2088 return new PrefixedIdentifier.full(qualifier, period, qualified); |
| 2089 } |
| 2090 |
| 2091 /** |
| 2092 * Parse a return type. |
| 2093 * |
| 2094 * <pre> |
| 2095 * returnType ::= |
| 2096 * 'void' |
| 2097 * | type |
| 2098 * </pre> |
| 2099 * |
| 2100 * @return the return type that was parsed |
| 2101 */ |
| 2102 TypeName parseReturnType() { |
| 2103 if (matches(Keyword.VOID)) { |
| 2104 return new TypeName.full(new SimpleIdentifier.full(andAdvance), null); |
| 2105 } else { |
| 2106 return parseTypeName(); |
| 2107 } |
| 2108 } |
| 2109 |
| 2110 /** |
| 2111 * Parse a simple identifier. |
| 2112 * |
| 2113 * <pre> |
| 2114 * identifier ::= |
| 2115 * IDENTIFIER |
| 2116 * </pre> |
| 2117 * |
| 2118 * @return the simple identifier that was parsed |
| 2119 */ |
| 2120 SimpleIdentifier parseSimpleIdentifier() { |
| 2121 if (matchesIdentifier()) { |
| 2122 return new SimpleIdentifier.full(andAdvance); |
| 2123 } |
| 2124 reportError8(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 2125 return createSyntheticIdentifier(); |
| 2126 } |
| 2127 |
| 2128 /** |
| 2129 * Parse a statement. |
| 2130 * |
| 2131 * <pre> |
| 2132 * statement ::= |
| 2133 * label* nonLabeledStatement |
| 2134 * </pre> |
| 2135 * |
| 2136 * @return the statement that was parsed |
| 2137 */ |
| 2138 Statement parseStatement2() { |
| 2139 List<Label> labels = new List<Label>(); |
| 2140 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { |
| 2141 labels.add(parseLabel()); |
| 2142 } |
| 2143 Statement statement = parseNonLabeledStatement(); |
| 2144 if (labels.isEmpty) { |
| 2145 return statement; |
| 2146 } |
| 2147 return new LabeledStatement.full(labels, statement); |
| 2148 } |
| 2149 |
| 2150 /** |
| 2151 * Parse a string literal. |
| 2152 * |
| 2153 * <pre> |
| 2154 * stringLiteral ::= |
| 2155 * MULTI_LINE_STRING+ |
| 2156 * | SINGLE_LINE_STRING+ |
| 2157 * </pre> |
| 2158 * |
| 2159 * @return the string literal that was parsed |
| 2160 */ |
| 2161 StringLiteral parseStringLiteral() { |
| 2162 List<StringLiteral> strings = new List<StringLiteral>(); |
| 2163 while (matches5(TokenType.STRING)) { |
| 2164 Token string = andAdvance; |
| 2165 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches5(TokenT
ype.STRING_INTERPOLATION_IDENTIFIER)) { |
| 2166 strings.add(parseStringInterpolation(string)); |
| 2167 } else { |
| 2168 strings.add(new SimpleStringLiteral.full(string, computeStringValue(stri
ng.lexeme, true, true))); |
| 2169 } |
| 2170 } |
| 2171 if (strings.length < 1) { |
| 2172 reportError8(ParserErrorCode.EXPECTED_STRING_LITERAL, []); |
| 2173 return createSyntheticStringLiteral(); |
| 2174 } else if (strings.length == 1) { |
| 2175 return strings[0]; |
| 2176 } else { |
| 2177 return new AdjacentStrings.full(strings); |
| 2178 } |
| 2179 } |
| 2180 |
| 2181 /** |
| 2182 * Parse a list of type arguments. |
| 2183 * |
| 2184 * <pre> |
| 2185 * typeArguments ::= |
| 2186 * '<' typeList '>' |
| 2187 * |
| 2188 * typeList ::= |
| 2189 * type (',' type)* |
| 2190 * </pre> |
| 2191 * |
| 2192 * @return the type argument list that was parsed |
| 2193 */ |
| 2194 TypeArgumentList parseTypeArgumentList() { |
| 2195 Token leftBracket = expect2(TokenType.LT); |
| 2196 List<TypeName> arguments = new List<TypeName>(); |
| 2197 arguments.add(parseTypeName()); |
| 2198 while (optional(TokenType.COMMA)) { |
| 2199 arguments.add(parseTypeName()); |
| 2200 } |
| 2201 Token rightBracket = expect2(TokenType.GT); |
| 2202 return new TypeArgumentList.full(leftBracket, arguments, rightBracket); |
| 2203 } |
| 2204 |
| 2205 /** |
| 2206 * Parse a type name. |
| 2207 * |
| 2208 * <pre> |
| 2209 * type ::= |
| 2210 * qualified typeArguments? |
| 2211 * </pre> |
| 2212 * |
| 2213 * @return the type name that was parsed |
| 2214 */ |
| 2215 TypeName parseTypeName() { |
| 2216 Identifier typeName; |
| 2217 if (matches(Keyword.VAR)) { |
| 2218 reportError8(ParserErrorCode.VAR_AS_TYPE_NAME, []); |
| 2219 typeName = new SimpleIdentifier.full(andAdvance); |
| 2220 } else if (matchesIdentifier()) { |
| 2221 typeName = parsePrefixedIdentifier(); |
| 2222 } else { |
| 2223 typeName = createSyntheticIdentifier(); |
| 2224 reportError8(ParserErrorCode.EXPECTED_TYPE_NAME, []); |
| 2225 } |
| 2226 TypeArgumentList typeArguments = null; |
| 2227 if (matches5(TokenType.LT)) { |
| 2228 typeArguments = parseTypeArgumentList(); |
| 2229 } |
| 2230 return new TypeName.full(typeName, typeArguments); |
| 2231 } |
| 2232 |
| 2233 /** |
| 2234 * Parse a type parameter. |
| 2235 * |
| 2236 * <pre> |
| 2237 * typeParameter ::= |
| 2238 * metadata name ('extends' bound)? |
| 2239 * </pre> |
| 2240 * |
| 2241 * @return the type parameter that was parsed |
| 2242 */ |
| 2243 TypeParameter parseTypeParameter() { |
| 2244 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 2245 SimpleIdentifier name = parseSimpleIdentifier(); |
| 2246 if (matches(Keyword.EXTENDS)) { |
| 2247 Token keyword = andAdvance; |
| 2248 TypeName bound = parseTypeName(); |
| 2249 return new TypeParameter.full(commentAndMetadata.comment, commentAndMetada
ta.metadata, name, keyword, bound); |
| 2250 } |
| 2251 return new TypeParameter.full(commentAndMetadata.comment, commentAndMetadata
.metadata, name, null, null); |
| 2252 } |
| 2253 |
| 2254 /** |
| 2255 * Parse a list of type parameters. |
| 2256 * |
| 2257 * <pre> |
| 2258 * typeParameterList ::= |
| 2259 * '<' typeParameter (',' typeParameter)* '>' |
| 2260 * </pre> |
| 2261 * |
| 2262 * @return the list of type parameters that were parsed |
| 2263 */ |
| 2264 TypeParameterList parseTypeParameterList() { |
| 2265 Token leftBracket = expect2(TokenType.LT); |
| 2266 List<TypeParameter> typeParameters = new List<TypeParameter>(); |
| 2267 typeParameters.add(parseTypeParameter()); |
| 2268 while (optional(TokenType.COMMA)) { |
| 2269 typeParameters.add(parseTypeParameter()); |
| 2270 } |
| 2271 Token rightBracket = expect2(TokenType.GT); |
| 2272 return new TypeParameterList.full(leftBracket, typeParameters, rightBracket)
; |
| 2273 } |
| 2274 |
| 2275 /** |
| 2276 * Parse a with clause. |
| 2277 * |
| 2278 * <pre> |
| 2279 * withClause ::= |
| 2280 * 'with' typeName (',' typeName)* |
| 2281 * </pre> |
| 2282 * |
| 2283 * @return the with clause that was parsed |
| 2284 */ |
| 2285 WithClause parseWithClause() { |
| 2286 Token with2 = expect(Keyword.WITH); |
| 2287 List<TypeName> types = new List<TypeName>(); |
| 2288 types.add(parseTypeName()); |
| 2289 while (optional(TokenType.COMMA)) { |
| 2290 types.add(parseTypeName()); |
| 2291 } |
| 2292 return new WithClause.full(with2, types); |
| 2293 } |
262 void set currentToken(Token currentToken) { | 2294 void set currentToken(Token currentToken) { |
263 this._currentToken = currentToken; | 2295 this._currentToken = currentToken; |
264 } | 2296 } |
265 | 2297 |
266 /** | 2298 /** |
267 * Advance to the next token in the token stream. | 2299 * Advance to the next token in the token stream. |
268 */ | 2300 */ |
269 void advance() { | 2301 void advance() { |
270 _currentToken = _currentToken.next; | 2302 _currentToken = _currentToken.next; |
271 } | 2303 } |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 expression = parseMultiplicativeExpression(); | 2977 expression = parseMultiplicativeExpression(); |
946 } | 2978 } |
947 while (_currentToken.type.isAdditiveOperator) { | 2979 while (_currentToken.type.isAdditiveOperator) { |
948 Token operator = andAdvance; | 2980 Token operator = andAdvance; |
949 expression = new BinaryExpression.full(expression, operator, parseMultipli
cativeExpression()); | 2981 expression = new BinaryExpression.full(expression, operator, parseMultipli
cativeExpression()); |
950 } | 2982 } |
951 return expression; | 2983 return expression; |
952 } | 2984 } |
953 | 2985 |
954 /** | 2986 /** |
955 * Parse an annotation. | |
956 * | |
957 * <pre> | |
958 * annotation ::= | |
959 * '@' qualified ('.' identifier)? arguments? | |
960 * </pre> | |
961 * | |
962 * @return the annotation that was parsed | |
963 */ | |
964 Annotation parseAnnotation() { | |
965 Token atSign = expect2(TokenType.AT); | |
966 Identifier name = parsePrefixedIdentifier(); | |
967 Token period = null; | |
968 SimpleIdentifier constructorName = null; | |
969 if (matches5(TokenType.PERIOD)) { | |
970 period = andAdvance; | |
971 constructorName = parseSimpleIdentifier(); | |
972 } | |
973 ArgumentList arguments = null; | |
974 if (matches5(TokenType.OPEN_PAREN)) { | |
975 arguments = parseArgumentList(); | |
976 } | |
977 return new Annotation.full(atSign, name, period, constructorName, arguments)
; | |
978 } | |
979 | |
980 /** | |
981 * Parse an argument. | |
982 * | |
983 * <pre> | |
984 * argument ::= | |
985 * namedArgument | |
986 * | expression | |
987 * | |
988 * namedArgument ::= | |
989 * label expression | |
990 * </pre> | |
991 * | |
992 * @return the argument that was parsed | |
993 */ | |
994 Expression parseArgument() { | |
995 if (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { | |
996 SimpleIdentifier label = new SimpleIdentifier.full(andAdvance); | |
997 Label name = new Label.full(label, andAdvance); | |
998 return new NamedExpression.full(name, parseExpression2()); | |
999 } else { | |
1000 return parseExpression2(); | |
1001 } | |
1002 } | |
1003 | |
1004 /** | |
1005 * Parse an argument definition test. | 2987 * Parse an argument definition test. |
1006 * | 2988 * |
1007 * <pre> | 2989 * <pre> |
1008 * argumentDefinitionTest ::= | 2990 * argumentDefinitionTest ::= |
1009 * '?' identifier | 2991 * '?' identifier |
1010 * </pre> | 2992 * </pre> |
1011 * | 2993 * |
1012 * @return the argument definition test that was parsed | 2994 * @return the argument definition test that was parsed |
1013 */ | 2995 */ |
1014 ArgumentDefinitionTest parseArgumentDefinitionTest() { | 2996 ArgumentDefinitionTest parseArgumentDefinitionTest() { |
1015 Token question = expect2(TokenType.QUESTION); | 2997 Token question = expect2(TokenType.QUESTION); |
1016 SimpleIdentifier identifier = parseSimpleIdentifier(); | 2998 SimpleIdentifier identifier = parseSimpleIdentifier(); |
1017 reportError9(ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, question,
[]); | 2999 reportError9(ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, question,
[]); |
1018 return new ArgumentDefinitionTest.full(question, identifier); | 3000 return new ArgumentDefinitionTest.full(question, identifier); |
1019 } | 3001 } |
1020 | 3002 |
1021 /** | 3003 /** |
1022 * Parse a list of arguments. | |
1023 * | |
1024 * <pre> | |
1025 * arguments ::= | |
1026 * '(' argumentList? ')' | |
1027 * | |
1028 * argumentList ::= | |
1029 * namedArgument (',' namedArgument)* | |
1030 * | expressionList (',' namedArgument)* | |
1031 * </pre> | |
1032 * | |
1033 * @return the argument list that was parsed | |
1034 */ | |
1035 ArgumentList parseArgumentList() { | |
1036 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); | |
1037 List<Expression> arguments = new List<Expression>(); | |
1038 if (matches5(TokenType.CLOSE_PAREN)) { | |
1039 return new ArgumentList.full(leftParenthesis, arguments, andAdvance); | |
1040 } | |
1041 Expression argument = parseArgument(); | |
1042 arguments.add(argument); | |
1043 bool foundNamedArgument = argument is NamedExpression; | |
1044 bool generatedError = false; | |
1045 while (optional(TokenType.COMMA)) { | |
1046 argument = parseArgument(); | |
1047 arguments.add(argument); | |
1048 if (foundNamedArgument) { | |
1049 if (!generatedError && argument is! NamedExpression) { | |
1050 reportError8(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, []); | |
1051 generatedError = true; | |
1052 } | |
1053 } else if (argument is NamedExpression) { | |
1054 foundNamedArgument = true; | |
1055 } | |
1056 } | |
1057 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | |
1058 return new ArgumentList.full(leftParenthesis, arguments, rightParenthesis); | |
1059 } | |
1060 | |
1061 /** | |
1062 * Parse an assert statement. | 3004 * Parse an assert statement. |
1063 * | 3005 * |
1064 * <pre> | 3006 * <pre> |
1065 * assertStatement ::= | 3007 * assertStatement ::= |
1066 * 'assert' '(' conditionalExpression ')' ';' | 3008 * 'assert' '(' conditionalExpression ')' ';' |
1067 * </pre> | 3009 * </pre> |
1068 * | 3010 * |
1069 * @return the assert statement | 3011 * @return the assert statement |
1070 */ | 3012 */ |
1071 AssertStatement parseAssertStatement() { | 3013 AssertStatement parseAssertStatement() { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1186 expression = parseShiftExpression(); | 3128 expression = parseShiftExpression(); |
1187 } | 3129 } |
1188 while (matches5(TokenType.AMPERSAND)) { | 3130 while (matches5(TokenType.AMPERSAND)) { |
1189 Token operator = andAdvance; | 3131 Token operator = andAdvance; |
1190 expression = new BinaryExpression.full(expression, operator, parseShiftExp
ression()); | 3132 expression = new BinaryExpression.full(expression, operator, parseShiftExp
ression()); |
1191 } | 3133 } |
1192 return expression; | 3134 return expression; |
1193 } | 3135 } |
1194 | 3136 |
1195 /** | 3137 /** |
1196 * Parse a bitwise or expression. | |
1197 * | |
1198 * <pre> | |
1199 * bitwiseOrExpression ::= | |
1200 * bitwiseXorExpression ('|' bitwiseXorExpression)* | |
1201 * | 'super' ('|' bitwiseXorExpression)+ | |
1202 * </pre> | |
1203 * | |
1204 * @return the bitwise or expression that was parsed | |
1205 */ | |
1206 Expression parseBitwiseOrExpression() { | |
1207 Expression expression; | |
1208 if (matches(Keyword.SUPER) && matches4(peek(), TokenType.BAR)) { | |
1209 expression = new SuperExpression.full(andAdvance); | |
1210 } else { | |
1211 expression = parseBitwiseXorExpression(); | |
1212 } | |
1213 while (matches5(TokenType.BAR)) { | |
1214 Token operator = andAdvance; | |
1215 expression = new BinaryExpression.full(expression, operator, parseBitwiseX
orExpression()); | |
1216 } | |
1217 return expression; | |
1218 } | |
1219 | |
1220 /** | |
1221 * Parse a bitwise exclusive-or expression. | 3138 * Parse a bitwise exclusive-or expression. |
1222 * | 3139 * |
1223 * <pre> | 3140 * <pre> |
1224 * bitwiseXorExpression ::= | 3141 * bitwiseXorExpression ::= |
1225 * bitwiseAndExpression ('^' bitwiseAndExpression)* | 3142 * bitwiseAndExpression ('^' bitwiseAndExpression)* |
1226 * | 'super' ('^' bitwiseAndExpression)+ | 3143 * | 'super' ('^' bitwiseAndExpression)+ |
1227 * </pre> | 3144 * </pre> |
1228 * | 3145 * |
1229 * @return the bitwise exclusive-or expression that was parsed | 3146 * @return the bitwise exclusive-or expression that was parsed |
1230 */ | 3147 */ |
1231 Expression parseBitwiseXorExpression() { | 3148 Expression parseBitwiseXorExpression() { |
1232 Expression expression; | 3149 Expression expression; |
1233 if (matches(Keyword.SUPER) && matches4(peek(), TokenType.CARET)) { | 3150 if (matches(Keyword.SUPER) && matches4(peek(), TokenType.CARET)) { |
1234 expression = new SuperExpression.full(andAdvance); | 3151 expression = new SuperExpression.full(andAdvance); |
1235 } else { | 3152 } else { |
1236 expression = parseBitwiseAndExpression(); | 3153 expression = parseBitwiseAndExpression(); |
1237 } | 3154 } |
1238 while (matches5(TokenType.CARET)) { | 3155 while (matches5(TokenType.CARET)) { |
1239 Token operator = andAdvance; | 3156 Token operator = andAdvance; |
1240 expression = new BinaryExpression.full(expression, operator, parseBitwiseA
ndExpression()); | 3157 expression = new BinaryExpression.full(expression, operator, parseBitwiseA
ndExpression()); |
1241 } | 3158 } |
1242 return expression; | 3159 return expression; |
1243 } | 3160 } |
1244 | 3161 |
1245 /** | 3162 /** |
1246 * Parse a block. | |
1247 * | |
1248 * <pre> | |
1249 * block ::= | |
1250 * '{' statements '}' | |
1251 * </pre> | |
1252 * | |
1253 * @return the block that was parsed | |
1254 */ | |
1255 Block parseBlock() { | |
1256 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); | |
1257 List<Statement> statements = new List<Statement>(); | |
1258 Token statementStart = _currentToken; | |
1259 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET))
{ | |
1260 Statement statement = parseStatement2(); | |
1261 if (statement != null) { | |
1262 statements.add(statement); | |
1263 } | |
1264 if (identical(_currentToken, statementStart)) { | |
1265 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | |
1266 advance(); | |
1267 } | |
1268 statementStart = _currentToken; | |
1269 } | |
1270 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); | |
1271 return new Block.full(leftBracket, statements, rightBracket); | |
1272 } | |
1273 | |
1274 /** | |
1275 * Parse a break statement. | 3163 * Parse a break statement. |
1276 * | 3164 * |
1277 * <pre> | 3165 * <pre> |
1278 * breakStatement ::= | 3166 * breakStatement ::= |
1279 * 'break' identifier? ';' | 3167 * 'break' identifier? ';' |
1280 * </pre> | 3168 * </pre> |
1281 * | 3169 * |
1282 * @return the break statement that was parsed | 3170 * @return the break statement that was parsed |
1283 */ | 3171 */ |
1284 Statement parseBreakStatement() { | 3172 Statement parseBreakStatement() { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 period = null; | 3232 period = null; |
1345 } | 3233 } |
1346 bool progress = true; | 3234 bool progress = true; |
1347 while (progress) { | 3235 while (progress) { |
1348 progress = false; | 3236 progress = false; |
1349 Expression selector = parseAssignableSelector(expression, true); | 3237 Expression selector = parseAssignableSelector(expression, true); |
1350 if (selector != expression) { | 3238 if (selector != expression) { |
1351 expression = selector; | 3239 expression = selector; |
1352 progress = true; | 3240 progress = true; |
1353 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 3241 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
1354 expression = new FunctionExpressionInvocation.full(expression, parseAr
gumentList()); | 3242 if (expression is PropertyAccess) { |
| 3243 PropertyAccess propertyAccess = expression as PropertyAccess; |
| 3244 expression = new MethodInvocation.full(propertyAccess.target, proper
tyAccess.operator, propertyAccess.propertyName, parseArgumentList()); |
| 3245 } else { |
| 3246 expression = new FunctionExpressionInvocation.full(expression, parse
ArgumentList()); |
| 3247 } |
1355 } | 3248 } |
1356 } | 3249 } |
1357 } | 3250 } |
1358 if (_currentToken.type.isAssignmentOperator) { | 3251 if (_currentToken.type.isAssignmentOperator) { |
1359 Token operator = andAdvance; | 3252 Token operator = andAdvance; |
1360 ensureAssignable(expression); | 3253 ensureAssignable(expression); |
1361 expression = new AssignmentExpression.full(expression, operator, parseExpr
essionWithoutCascade()); | 3254 expression = new AssignmentExpression.full(expression, operator, parseExpr
essionWithoutCascade()); |
1362 } | 3255 } |
1363 return expression; | 3256 return expression; |
1364 } | 3257 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 leftBracket = createSyntheticToken2(TokenType.OPEN_CURLY_BRACKET); | 3345 leftBracket = createSyntheticToken2(TokenType.OPEN_CURLY_BRACKET); |
1453 rightBracket = createSyntheticToken2(TokenType.CLOSE_CURLY_BRACKET); | 3346 rightBracket = createSyntheticToken2(TokenType.CLOSE_CURLY_BRACKET); |
1454 reportError8(ParserErrorCode.MISSING_CLASS_BODY, []); | 3347 reportError8(ParserErrorCode.MISSING_CLASS_BODY, []); |
1455 } | 3348 } |
1456 ClassDeclaration classDeclaration = new ClassDeclaration.full(commentAndMeta
data.comment, commentAndMetadata.metadata, abstractKeyword, keyword, name, typeP
arameters, extendsClause, withClause, implementsClause, leftBracket, members, ri
ghtBracket); | 3349 ClassDeclaration classDeclaration = new ClassDeclaration.full(commentAndMeta
data.comment, commentAndMetadata.metadata, abstractKeyword, keyword, name, typeP
arameters, extendsClause, withClause, implementsClause, leftBracket, members, ri
ghtBracket); |
1457 classDeclaration.nativeClause = nativeClause; | 3350 classDeclaration.nativeClause = nativeClause; |
1458 return classDeclaration; | 3351 return classDeclaration; |
1459 } | 3352 } |
1460 | 3353 |
1461 /** | 3354 /** |
1462 * Parse a class member. | |
1463 * | |
1464 * <pre> | |
1465 * classMemberDefinition ::= | |
1466 * declaration ';' | |
1467 * | methodSignature functionBody | |
1468 * </pre> | |
1469 * | |
1470 * @param className the name of the class containing the member being parsed | |
1471 * @return the class member that was parsed, or `null` if what was found was n
ot a valid | |
1472 * class member | |
1473 */ | |
1474 ClassMember parseClassMember(String className) { | |
1475 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | |
1476 Modifiers modifiers = parseModifiers(); | |
1477 if (matches(Keyword.VOID)) { | |
1478 TypeName returnType = parseReturnType(); | |
1479 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { | |
1480 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1481 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifi
ers.staticKeyword, returnType); | |
1482 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { | |
1483 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1484 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifi
ers.staticKeyword, returnType); | |
1485 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { | |
1486 validateModifiersForOperator(modifiers); | |
1487 return parseOperator(commentAndMetadata, modifiers.externalKeyword, retu
rnType); | |
1488 } else if (matchesIdentifier() && matchesAny(peek(), [ | |
1489 TokenType.OPEN_PAREN, | |
1490 TokenType.OPEN_CURLY_BRACKET, | |
1491 TokenType.FUNCTION])) { | |
1492 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1493 return parseMethodDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, modifiers.staticKeyword, returnType); | |
1494 } else { | |
1495 if (matchesIdentifier()) { | |
1496 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { | |
1497 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); | |
1498 return parseInitializedIdentifierList(commentAndMetadata, modifiers.
staticKeyword, validateModifiersForField(modifiers), returnType); | |
1499 } | |
1500 } | |
1501 if (isOperator(_currentToken)) { | |
1502 validateModifiersForOperator(modifiers); | |
1503 return parseOperator(commentAndMetadata, modifiers.externalKeyword, re
turnType); | |
1504 } | |
1505 reportError9(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); | |
1506 return null; | |
1507 } | |
1508 } else if (matches(Keyword.GET) && matchesIdentifier2(peek())) { | |
1509 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1510 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); | |
1511 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { | |
1512 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1513 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); | |
1514 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { | |
1515 validateModifiersForOperator(modifiers); | |
1516 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null); | |
1517 } else if (!matchesIdentifier()) { | |
1518 if (isOperator(_currentToken)) { | |
1519 validateModifiersForOperator(modifiers); | |
1520 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null
); | |
1521 } | |
1522 reportError9(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); | |
1523 return null; | |
1524 } else if (matches4(peek(), TokenType.PERIOD) && matchesIdentifier2(peek2(2)
) && matches4(peek2(3), TokenType.OPEN_PAREN)) { | |
1525 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); | |
1526 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { | |
1527 SimpleIdentifier methodName = parseSimpleIdentifier(); | |
1528 FormalParameterList parameters = parseFormalParameterList(); | |
1529 if (matches5(TokenType.COLON) || modifiers.factoryKeyword != null || metho
dName.name == className) { | |
1530 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); | |
1531 } | |
1532 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1533 validateFormalParameterList(parameters); | |
1534 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo
rd, modifiers.staticKeyword, null, methodName, parameters); | |
1535 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { | |
1536 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo
difiers.varKeyword == null) { | |
1537 reportError8(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); | |
1538 } | |
1539 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static
Keyword, validateModifiersForField(modifiers), null); | |
1540 } | |
1541 TypeName type = parseTypeName(); | |
1542 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { | |
1543 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1544 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); | |
1545 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { | |
1546 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1547 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); | |
1548 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { | |
1549 validateModifiersForOperator(modifiers); | |
1550 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type); | |
1551 } else if (!matchesIdentifier()) { | |
1552 if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { | |
1553 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat
icKeyword, validateModifiersForField(modifiers), type); | |
1554 } | |
1555 if (isOperator(_currentToken)) { | |
1556 validateModifiersForOperator(modifiers); | |
1557 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type
); | |
1558 } | |
1559 reportError9(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); | |
1560 return null; | |
1561 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { | |
1562 SimpleIdentifier methodName = parseSimpleIdentifier(); | |
1563 FormalParameterList parameters = parseFormalParameterList(); | |
1564 if (methodName.name == className) { | |
1565 reportError(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type, []); | |
1566 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); | |
1567 } | |
1568 validateModifiersForGetterOrSetterOrMethod(modifiers); | |
1569 validateFormalParameterList(parameters); | |
1570 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo
rd, modifiers.staticKeyword, type, methodName, parameters); | |
1571 } | |
1572 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe
yword, validateModifiersForField(modifiers), type); | |
1573 } | |
1574 | |
1575 /** | |
1576 * Parse a list of class members. | 3355 * Parse a list of class members. |
1577 * | 3356 * |
1578 * <pre> | 3357 * <pre> |
1579 * classMembers ::= | 3358 * classMembers ::= |
1580 * (metadata memberDefinition)* | 3359 * (metadata memberDefinition)* |
1581 * </pre> | 3360 * </pre> |
1582 * | 3361 * |
1583 * @param className the name of the class whose members are being parsed | 3362 * @param className the name of the class whose members are being parsed |
1584 * @param closingBracket the closing bracket for the class, or `null` if the c
losing bracket | 3363 * @param closingBracket the closing bracket for the class, or `null` if the c
losing bracket |
1585 * is missing | 3364 * is missing |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 leftIndex = JavaString.indexOf(comment, '[', rightIndex); | 3586 leftIndex = JavaString.indexOf(comment, '[', rightIndex); |
1808 } else { | 3587 } else { |
1809 leftIndex = JavaString.indexOf(comment, '[', range[1] + 1); | 3588 leftIndex = JavaString.indexOf(comment, '[', range[1] + 1); |
1810 } | 3589 } |
1811 } | 3590 } |
1812 } | 3591 } |
1813 return references; | 3592 return references; |
1814 } | 3593 } |
1815 | 3594 |
1816 /** | 3595 /** |
1817 * Parse a compilation unit. | |
1818 * | |
1819 * Specified: | |
1820 * | |
1821 * <pre> | |
1822 * compilationUnit ::= | |
1823 * scriptTag? directive* topLevelDeclaration* | |
1824 * </pre> | |
1825 * Actual: | |
1826 * | |
1827 * <pre> | |
1828 * compilationUnit ::= | |
1829 * scriptTag? topLevelElement* | |
1830 * | |
1831 * topLevelElement ::= | |
1832 * directive | |
1833 * | topLevelDeclaration | |
1834 * </pre> | |
1835 * | |
1836 * @return the compilation unit that was parsed | |
1837 */ | |
1838 CompilationUnit parseCompilationUnit2() { | |
1839 Token firstToken = _currentToken; | |
1840 ScriptTag scriptTag = null; | |
1841 if (matches5(TokenType.SCRIPT_TAG)) { | |
1842 scriptTag = new ScriptTag.full(andAdvance); | |
1843 } | |
1844 bool libraryDirectiveFound = false; | |
1845 bool partOfDirectiveFound = false; | |
1846 bool partDirectiveFound = false; | |
1847 bool directiveFoundAfterDeclaration = false; | |
1848 List<Directive> directives = new List<Directive>(); | |
1849 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; | |
1850 Token memberStart = _currentToken; | |
1851 while (!matches5(TokenType.EOF)) { | |
1852 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | |
1853 if ((matches(Keyword.IMPORT) || matches(Keyword.EXPORT) || matches(Keyword
.LIBRARY) || matches(Keyword.PART)) && !matches4(peek(), TokenType.PERIOD) && !m
atches4(peek(), TokenType.LT)) { | |
1854 Directive directive = parseDirective(commentAndMetadata); | |
1855 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { | |
1856 reportError8(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, []); | |
1857 directiveFoundAfterDeclaration = true; | |
1858 } | |
1859 if (directive is LibraryDirective) { | |
1860 if (libraryDirectiveFound) { | |
1861 reportError8(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, []); | |
1862 } else { | |
1863 if (directives.length > 0) { | |
1864 reportError8(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, []); | |
1865 } | |
1866 libraryDirectiveFound = true; | |
1867 } | |
1868 } else if (directive is PartDirective) { | |
1869 partDirectiveFound = true; | |
1870 } else if (partDirectiveFound) { | |
1871 if (directive is ExportDirective) { | |
1872 reportError9(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
((directive as NamespaceDirective)).keyword, []); | |
1873 } else if (directive is ImportDirective) { | |
1874 reportError9(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
((directive as NamespaceDirective)).keyword, []); | |
1875 } | |
1876 } | |
1877 if (directive is PartOfDirective) { | |
1878 if (partOfDirectiveFound) { | |
1879 reportError8(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []); | |
1880 } else { | |
1881 for (Directive precedingDirective in directives) { | |
1882 reportError9(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, preced
ingDirective.keyword, []); | |
1883 } | |
1884 partOfDirectiveFound = true; | |
1885 } | |
1886 } else { | |
1887 if (partOfDirectiveFound) { | |
1888 reportError9(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directiv
e.keyword, []); | |
1889 } | |
1890 } | |
1891 directives.add(directive); | |
1892 } else if (matches5(TokenType.SEMICOLON)) { | |
1893 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | |
1894 advance(); | |
1895 } else { | |
1896 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta
data); | |
1897 if (member != null) { | |
1898 declarations.add(member); | |
1899 } | |
1900 } | |
1901 if (identical(_currentToken, memberStart)) { | |
1902 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | |
1903 advance(); | |
1904 while (!matches5(TokenType.EOF) && !couldBeStartOfCompilationUnitMember(
)) { | |
1905 advance(); | |
1906 } | |
1907 } | |
1908 memberStart = _currentToken; | |
1909 } | |
1910 return new CompilationUnit.full(firstToken, scriptTag, directives, declarati
ons, _currentToken); | |
1911 } | |
1912 | |
1913 /** | |
1914 * Parse a compilation unit member. | 3596 * Parse a compilation unit member. |
1915 * | 3597 * |
1916 * <pre> | 3598 * <pre> |
1917 * compilationUnitMember ::= | 3599 * compilationUnitMember ::= |
1918 * classDefinition | 3600 * classDefinition |
1919 * | functionTypeAlias | 3601 * | functionTypeAlias |
1920 * | external functionSignature | 3602 * | external functionSignature |
1921 * | external getterSignature | 3603 * | external getterSignature |
1922 * | external setterSignature | 3604 * | external setterSignature |
1923 * | functionSignature functionBody | 3605 * | functionSignature functionBody |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 TokenType.OPEN_PAREN, | 3687 TokenType.OPEN_PAREN, |
2006 TokenType.FUNCTION, | 3688 TokenType.FUNCTION, |
2007 TokenType.OPEN_CURLY_BRACKET])) { | 3689 TokenType.OPEN_CURLY_BRACKET])) { |
2008 validateModifiersForTopLevelFunction(modifiers); | 3690 validateModifiersForTopLevelFunction(modifiers); |
2009 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType); | 3691 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType); |
2010 } | 3692 } |
2011 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, comm
entAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiersFo
rTopLevelVariable(modifiers), returnType), expect2(TokenType.SEMICOLON)); | 3693 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, comm
entAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiersFo
rTopLevelVariable(modifiers), returnType), expect2(TokenType.SEMICOLON)); |
2012 } | 3694 } |
2013 | 3695 |
2014 /** | 3696 /** |
2015 * Parse a conditional expression. | |
2016 * | |
2017 * <pre> | |
2018 * conditionalExpression ::= | |
2019 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithout
Cascade)? | |
2020 * </pre> | |
2021 * | |
2022 * @return the conditional expression that was parsed | |
2023 */ | |
2024 Expression parseConditionalExpression() { | |
2025 Expression condition = parseLogicalOrExpression(); | |
2026 if (!matches5(TokenType.QUESTION)) { | |
2027 return condition; | |
2028 } | |
2029 Token question = andAdvance; | |
2030 Expression thenExpression = parseExpressionWithoutCascade(); | |
2031 Token colon = expect2(TokenType.COLON); | |
2032 Expression elseExpression = parseExpressionWithoutCascade(); | |
2033 return new ConditionalExpression.full(condition, question, thenExpression, c
olon, elseExpression); | |
2034 } | |
2035 | |
2036 /** | |
2037 * Parse a const expression. | 3697 * Parse a const expression. |
2038 * | 3698 * |
2039 * <pre> | 3699 * <pre> |
2040 * constExpression ::= | 3700 * constExpression ::= |
2041 * instanceCreationExpression | 3701 * instanceCreationExpression |
2042 * | listLiteral | 3702 * | listLiteral |
2043 * | mapLiteral | 3703 * | mapLiteral |
2044 * </pre> | 3704 * </pre> |
2045 * | 3705 * |
2046 * @return the const expression that was parsed | 3706 * @return the const expression that was parsed |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2138 cascadeSections.add(section); | 3798 cascadeSections.add(section); |
2139 } | 3799 } |
2140 tokenType = _currentToken.type; | 3800 tokenType = _currentToken.type; |
2141 } | 3801 } |
2142 expression = new CascadeExpression.full(expression, cascadeSections); | 3802 expression = new CascadeExpression.full(expression, cascadeSections); |
2143 } | 3803 } |
2144 return new ConstructorFieldInitializer.full(keyword, period, fieldName, equa
ls, expression); | 3804 return new ConstructorFieldInitializer.full(keyword, period, fieldName, equa
ls, expression); |
2145 } | 3805 } |
2146 | 3806 |
2147 /** | 3807 /** |
2148 * Parse the name of a constructor. | |
2149 * | |
2150 * <pre> | |
2151 * constructorName: | |
2152 * type ('.' identifier)? | |
2153 * </pre> | |
2154 * | |
2155 * @return the constructor name that was parsed | |
2156 */ | |
2157 ConstructorName parseConstructorName() { | |
2158 TypeName type = parseTypeName(); | |
2159 Token period = null; | |
2160 SimpleIdentifier name = null; | |
2161 if (matches5(TokenType.PERIOD)) { | |
2162 period = andAdvance; | |
2163 name = parseSimpleIdentifier(); | |
2164 } | |
2165 return new ConstructorName.full(type, period, name); | |
2166 } | |
2167 | |
2168 /** | |
2169 * Parse a continue statement. | 3808 * Parse a continue statement. |
2170 * | 3809 * |
2171 * <pre> | 3810 * <pre> |
2172 * continueStatement ::= | 3811 * continueStatement ::= |
2173 * 'continue' identifier? ';' | 3812 * 'continue' identifier? ';' |
2174 * </pre> | 3813 * </pre> |
2175 * | 3814 * |
2176 * @return the continue statement that was parsed | 3815 * @return the continue statement that was parsed |
2177 */ | 3816 */ |
2178 Statement parseContinueStatement() { | 3817 Statement parseContinueStatement() { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 */ | 3978 */ |
2340 ExportDirective parseExportDirective(CommentAndMetadata commentAndMetadata) { | 3979 ExportDirective parseExportDirective(CommentAndMetadata commentAndMetadata) { |
2341 Token exportKeyword = expect(Keyword.EXPORT); | 3980 Token exportKeyword = expect(Keyword.EXPORT); |
2342 StringLiteral libraryUri = parseStringLiteral(); | 3981 StringLiteral libraryUri = parseStringLiteral(); |
2343 List<Combinator> combinators = parseCombinators(); | 3982 List<Combinator> combinators = parseCombinators(); |
2344 Token semicolon = expect2(TokenType.SEMICOLON); | 3983 Token semicolon = expect2(TokenType.SEMICOLON); |
2345 return new ExportDirective.full(commentAndMetadata.comment, commentAndMetada
ta.metadata, exportKeyword, libraryUri, combinators, semicolon); | 3984 return new ExportDirective.full(commentAndMetadata.comment, commentAndMetada
ta.metadata, exportKeyword, libraryUri, combinators, semicolon); |
2346 } | 3985 } |
2347 | 3986 |
2348 /** | 3987 /** |
2349 * Parse an expression that does not contain any cascades. | |
2350 * | |
2351 * <pre> | |
2352 * expression ::= | |
2353 * assignableExpression assignmentOperator expression | |
2354 * | conditionalExpression cascadeSection* | |
2355 * | throwExpression | |
2356 * </pre> | |
2357 * | |
2358 * @return the expression that was parsed | |
2359 */ | |
2360 Expression parseExpression2() { | |
2361 if (matches(Keyword.THROW)) { | |
2362 return parseThrowExpression(); | |
2363 } else if (matches(Keyword.RETHROW)) { | |
2364 return parseRethrowExpression(); | |
2365 } | |
2366 Expression expression = parseConditionalExpression(); | |
2367 TokenType tokenType = _currentToken.type; | |
2368 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { | |
2369 List<Expression> cascadeSections = new List<Expression>(); | |
2370 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { | |
2371 Expression section = parseCascadeSection(); | |
2372 if (section != null) { | |
2373 cascadeSections.add(section); | |
2374 } | |
2375 tokenType = _currentToken.type; | |
2376 } | |
2377 return new CascadeExpression.full(expression, cascadeSections); | |
2378 } else if (tokenType.isAssignmentOperator) { | |
2379 Token operator = andAdvance; | |
2380 ensureAssignable(expression); | |
2381 return new AssignmentExpression.full(expression, operator, parseExpression
2()); | |
2382 } | |
2383 return expression; | |
2384 } | |
2385 | |
2386 /** | |
2387 * Parse a list of expressions. | 3988 * Parse a list of expressions. |
2388 * | 3989 * |
2389 * <pre> | 3990 * <pre> |
2390 * expressionList ::= | 3991 * expressionList ::= |
2391 * expression (',' expression)* | 3992 * expression (',' expression)* |
2392 * </pre> | 3993 * </pre> |
2393 * | 3994 * |
2394 * @return the expression that was parsed | 3995 * @return the expression that was parsed |
2395 */ | 3996 */ |
2396 List<Expression> parseExpressionList() { | 3997 List<Expression> parseExpressionList() { |
2397 List<Expression> expressions = new List<Expression>(); | 3998 List<Expression> expressions = new List<Expression>(); |
2398 expressions.add(parseExpression2()); | 3999 expressions.add(parseExpression2()); |
2399 while (optional(TokenType.COMMA)) { | 4000 while (optional(TokenType.COMMA)) { |
2400 expressions.add(parseExpression2()); | 4001 expressions.add(parseExpression2()); |
2401 } | 4002 } |
2402 return expressions; | 4003 return expressions; |
2403 } | 4004 } |
2404 | 4005 |
2405 /** | 4006 /** |
2406 * Parse an expression that does not contain any cascades. | |
2407 * | |
2408 * <pre> | |
2409 * expressionWithoutCascade ::= | |
2410 * assignableExpression assignmentOperator expressionWithoutCascade | |
2411 * | conditionalExpression | |
2412 * | throwExpressionWithoutCascade | |
2413 * </pre> | |
2414 * | |
2415 * @return the expression that was parsed | |
2416 */ | |
2417 Expression parseExpressionWithoutCascade() { | |
2418 if (matches(Keyword.THROW)) { | |
2419 return parseThrowExpressionWithoutCascade(); | |
2420 } else if (matches(Keyword.RETHROW)) { | |
2421 return parseRethrowExpression(); | |
2422 } | |
2423 Expression expression = parseConditionalExpression(); | |
2424 if (_currentToken.type.isAssignmentOperator) { | |
2425 Token operator = andAdvance; | |
2426 ensureAssignable(expression); | |
2427 expression = new AssignmentExpression.full(expression, operator, parseExpr
essionWithoutCascade()); | |
2428 } | |
2429 return expression; | |
2430 } | |
2431 | |
2432 /** | |
2433 * Parse a class extends clause. | |
2434 * | |
2435 * <pre> | |
2436 * classExtendsClause ::= | |
2437 * 'extends' type | |
2438 * </pre> | |
2439 * | |
2440 * @return the class extends clause that was parsed | |
2441 */ | |
2442 ExtendsClause parseExtendsClause() { | |
2443 Token keyword = expect(Keyword.EXTENDS); | |
2444 TypeName superclass = parseTypeName(); | |
2445 return new ExtendsClause.full(keyword, superclass); | |
2446 } | |
2447 | |
2448 /** | |
2449 * Parse the 'final', 'const', 'var' or type preceding a variable declaration. | 4007 * Parse the 'final', 'const', 'var' or type preceding a variable declaration. |
2450 * | 4008 * |
2451 * <pre> | 4009 * <pre> |
2452 * finalConstVarOrType ::= | 4010 * finalConstVarOrType ::= |
2453 * | 'final' type? | 4011 * | 'final' type? |
2454 * | 'const' type? | 4012 * | 'const' type? |
2455 * | 'var' | 4013 * | 'var' |
2456 * | type | 4014 * | type |
2457 * </pre> | 4015 * </pre> |
2458 * | 4016 * |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 reportError(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, []
); | 4073 reportError(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, []
); |
2516 } | 4074 } |
2517 return new DefaultFormalParameter.full(parameter, kind, seperator, default
Value); | 4075 return new DefaultFormalParameter.full(parameter, kind, seperator, default
Value); |
2518 } else if (kind != ParameterKind.REQUIRED) { | 4076 } else if (kind != ParameterKind.REQUIRED) { |
2519 return new DefaultFormalParameter.full(parameter, kind, null, null); | 4077 return new DefaultFormalParameter.full(parameter, kind, null, null); |
2520 } | 4078 } |
2521 return parameter; | 4079 return parameter; |
2522 } | 4080 } |
2523 | 4081 |
2524 /** | 4082 /** |
2525 * Parse a list of formal parameters. | |
2526 * | |
2527 * <pre> | |
2528 * formalParameterList ::= | |
2529 * '(' ')' | |
2530 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')' | |
2531 * | '(' optionalFormalParameters ')' | |
2532 * | |
2533 * normalFormalParameters ::= | |
2534 * normalFormalParameter (',' normalFormalParameter)* | |
2535 * | |
2536 * optionalFormalParameters ::= | |
2537 * optionalPositionalFormalParameters | |
2538 * | namedFormalParameters | |
2539 * | |
2540 * optionalPositionalFormalParameters ::= | |
2541 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' | |
2542 * | |
2543 * namedFormalParameters ::= | |
2544 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' | |
2545 * </pre> | |
2546 * | |
2547 * @return the formal parameters that were parsed | |
2548 */ | |
2549 FormalParameterList parseFormalParameterList() { | |
2550 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); | |
2551 if (matches5(TokenType.CLOSE_PAREN)) { | |
2552 return new FormalParameterList.full(leftParenthesis, null, null, null, and
Advance); | |
2553 } | |
2554 List<FormalParameter> parameters = new List<FormalParameter>(); | |
2555 List<FormalParameter> normalParameters = new List<FormalParameter>(); | |
2556 List<FormalParameter> positionalParameters = new List<FormalParameter>(); | |
2557 List<FormalParameter> namedParameters = new List<FormalParameter>(); | |
2558 List<FormalParameter> currentParameters = normalParameters; | |
2559 Token leftSquareBracket = null; | |
2560 Token rightSquareBracket = null; | |
2561 Token leftCurlyBracket = null; | |
2562 Token rightCurlyBracket = null; | |
2563 ParameterKind kind = ParameterKind.REQUIRED; | |
2564 bool firstParameter = true; | |
2565 bool reportedMuliplePositionalGroups = false; | |
2566 bool reportedMulipleNamedGroups = false; | |
2567 bool reportedMixedGroups = false; | |
2568 bool wasOptionalParameter = false; | |
2569 Token initialToken = null; | |
2570 do { | |
2571 if (firstParameter) { | |
2572 firstParameter = false; | |
2573 } else if (!optional(TokenType.COMMA)) { | |
2574 if (getEndToken(leftParenthesis) != null) { | |
2575 reportError8(ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme])
; | |
2576 } else { | |
2577 reportError9(ParserErrorCode.MISSING_CLOSING_PARENTHESIS, _currentToke
n.previous, []); | |
2578 break; | |
2579 } | |
2580 } | |
2581 initialToken = _currentToken; | |
2582 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { | |
2583 wasOptionalParameter = true; | |
2584 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { | |
2585 reportError8(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, [])
; | |
2586 reportedMuliplePositionalGroups = true; | |
2587 } | |
2588 if (leftCurlyBracket != null && !reportedMixedGroups) { | |
2589 reportError8(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); | |
2590 reportedMixedGroups = true; | |
2591 } | |
2592 leftSquareBracket = andAdvance; | |
2593 currentParameters = positionalParameters; | |
2594 kind = ParameterKind.POSITIONAL; | |
2595 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | |
2596 wasOptionalParameter = true; | |
2597 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { | |
2598 reportError8(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, []); | |
2599 reportedMulipleNamedGroups = true; | |
2600 } | |
2601 if (leftSquareBracket != null && !reportedMixedGroups) { | |
2602 reportError8(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); | |
2603 reportedMixedGroups = true; | |
2604 } | |
2605 leftCurlyBracket = andAdvance; | |
2606 currentParameters = namedParameters; | |
2607 kind = ParameterKind.NAMED; | |
2608 } | |
2609 FormalParameter parameter = parseFormalParameter(kind); | |
2610 parameters.add(parameter); | |
2611 currentParameters.add(parameter); | |
2612 if (identical(kind, ParameterKind.REQUIRED) && wasOptionalParameter) { | |
2613 reportError(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, parameter
, []); | |
2614 } | |
2615 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { | |
2616 rightSquareBracket = andAdvance; | |
2617 currentParameters = normalParameters; | |
2618 if (leftSquareBracket == null) { | |
2619 if (leftCurlyBracket != null) { | |
2620 reportError8(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [
"}"]); | |
2621 rightCurlyBracket = rightSquareBracket; | |
2622 rightSquareBracket = null; | |
2623 } else { | |
2624 reportError8(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO
UP, ["["]); | |
2625 } | |
2626 } | |
2627 kind = ParameterKind.REQUIRED; | |
2628 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { | |
2629 rightCurlyBracket = andAdvance; | |
2630 currentParameters = normalParameters; | |
2631 if (leftCurlyBracket == null) { | |
2632 if (leftSquareBracket != null) { | |
2633 reportError8(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [
"]"]); | |
2634 rightSquareBracket = rightCurlyBracket; | |
2635 rightCurlyBracket = null; | |
2636 } else { | |
2637 reportError8(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO
UP, ["{"]); | |
2638 } | |
2639 } | |
2640 kind = ParameterKind.REQUIRED; | |
2641 } | |
2642 } while (!matches5(TokenType.CLOSE_PAREN) && initialToken != _currentToken); | |
2643 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | |
2644 if (leftSquareBracket != null && rightSquareBracket == null) { | |
2645 reportError8(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]
); | |
2646 } | |
2647 if (leftCurlyBracket != null && rightCurlyBracket == null) { | |
2648 reportError8(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]
); | |
2649 } | |
2650 if (leftSquareBracket == null) { | |
2651 leftSquareBracket = leftCurlyBracket; | |
2652 } | |
2653 if (rightSquareBracket == null) { | |
2654 rightSquareBracket = rightCurlyBracket; | |
2655 } | |
2656 return new FormalParameterList.full(leftParenthesis, parameters, leftSquareB
racket, rightSquareBracket, rightParenthesis); | |
2657 } | |
2658 | |
2659 /** | |
2660 * Parse a for statement. | 4083 * Parse a for statement. |
2661 * | 4084 * |
2662 * <pre> | 4085 * <pre> |
2663 * forStatement ::= | 4086 * forStatement ::= |
2664 * 'for' '(' forLoopParts ')' statement | 4087 * 'for' '(' forLoopParts ')' statement |
2665 * | 4088 * |
2666 * forLoopParts ::= | 4089 * forLoopParts ::= |
2667 * forInitializerStatement expression? ';' expressionList? | 4090 * forInitializerStatement expression? ';' expressionList? |
2668 * | declaredIdentifier 'in' expression | 4091 * | declaredIdentifier 'in' expression |
2669 * | identifier 'in' expression | 4092 * | identifier 'in' expression |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2887 if (identical(((propertyKeyword as KeywordToken)).keyword, Keyword.GET)) { | 4310 if (identical(((propertyKeyword as KeywordToken)).keyword, Keyword.GET)) { |
2888 reportError9(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword, []); | 4311 reportError9(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword, []); |
2889 } else { | 4312 } else { |
2890 reportError9(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword, []); | 4313 reportError9(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword, []); |
2891 } | 4314 } |
2892 } | 4315 } |
2893 return new FunctionDeclarationStatement.full(declaration); | 4316 return new FunctionDeclarationStatement.full(declaration); |
2894 } | 4317 } |
2895 | 4318 |
2896 /** | 4319 /** |
2897 * Parse a function expression. | |
2898 * | |
2899 * <pre> | |
2900 * functionExpression ::= | |
2901 * formalParameterList functionExpressionBody | |
2902 * </pre> | |
2903 * | |
2904 * @return the function expression that was parsed | |
2905 */ | |
2906 FunctionExpression parseFunctionExpression() { | |
2907 FormalParameterList parameters = parseFormalParameterList(); | |
2908 validateFormalParameterList(parameters); | |
2909 FunctionBody body = parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTIO
N_BODY, true); | |
2910 return new FunctionExpression.full(parameters, body); | |
2911 } | |
2912 | |
2913 /** | |
2914 * Parse a function type alias. | 4320 * Parse a function type alias. |
2915 * | 4321 * |
2916 * <pre> | 4322 * <pre> |
2917 * functionTypeAlias ::= | 4323 * functionTypeAlias ::= |
2918 * functionPrefix typeParameterList? formalParameterList ';' | 4324 * functionPrefix typeParameterList? formalParameterList ';' |
2919 * | 4325 * |
2920 * functionPrefix ::= | 4326 * functionPrefix ::= |
2921 * returnType? name | 4327 * returnType? name |
2922 * </pre> | 4328 * </pre> |
2923 * | 4329 * |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 Token elseKeyword = null; | 4429 Token elseKeyword = null; |
3024 Statement elseStatement = null; | 4430 Statement elseStatement = null; |
3025 if (matches(Keyword.ELSE)) { | 4431 if (matches(Keyword.ELSE)) { |
3026 elseKeyword = andAdvance; | 4432 elseKeyword = andAdvance; |
3027 elseStatement = parseStatement2(); | 4433 elseStatement = parseStatement2(); |
3028 } | 4434 } |
3029 return new IfStatement.full(ifKeyword, leftParenthesis, condition, rightPare
nthesis, thenStatement, elseKeyword, elseStatement); | 4435 return new IfStatement.full(ifKeyword, leftParenthesis, condition, rightPare
nthesis, thenStatement, elseKeyword, elseStatement); |
3030 } | 4436 } |
3031 | 4437 |
3032 /** | 4438 /** |
3033 * Parse an implements clause. | |
3034 * | |
3035 * <pre> | |
3036 * implementsClause ::= | |
3037 * 'implements' type (',' type)* | |
3038 * </pre> | |
3039 * | |
3040 * @return the implements clause that was parsed | |
3041 */ | |
3042 ImplementsClause parseImplementsClause() { | |
3043 Token keyword = expect(Keyword.IMPLEMENTS); | |
3044 List<TypeName> interfaces = new List<TypeName>(); | |
3045 interfaces.add(parseTypeName()); | |
3046 while (optional(TokenType.COMMA)) { | |
3047 interfaces.add(parseTypeName()); | |
3048 } | |
3049 return new ImplementsClause.full(keyword, interfaces); | |
3050 } | |
3051 | |
3052 /** | |
3053 * Parse an import directive. | 4439 * Parse an import directive. |
3054 * | 4440 * |
3055 * <pre> | 4441 * <pre> |
3056 * importDirective ::= | 4442 * importDirective ::= |
3057 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' | 4443 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' |
3058 * </pre> | 4444 * </pre> |
3059 * | 4445 * |
3060 * @param commentAndMetadata the metadata to be associated with the directive | 4446 * @param commentAndMetadata the metadata to be associated with the directive |
3061 * @return the import directive that was parsed | 4447 * @return the import directive that was parsed |
3062 */ | 4448 */ |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3131 * @return the library directive that was parsed | 4517 * @return the library directive that was parsed |
3132 */ | 4518 */ |
3133 LibraryDirective parseLibraryDirective(CommentAndMetadata commentAndMetadata)
{ | 4519 LibraryDirective parseLibraryDirective(CommentAndMetadata commentAndMetadata)
{ |
3134 Token keyword = expect(Keyword.LIBRARY); | 4520 Token keyword = expect(Keyword.LIBRARY); |
3135 LibraryIdentifier libraryName = parseLibraryName(ParserErrorCode.MISSING_NAM
E_IN_LIBRARY_DIRECTIVE, keyword); | 4521 LibraryIdentifier libraryName = parseLibraryName(ParserErrorCode.MISSING_NAM
E_IN_LIBRARY_DIRECTIVE, keyword); |
3136 Token semicolon = expect2(TokenType.SEMICOLON); | 4522 Token semicolon = expect2(TokenType.SEMICOLON); |
3137 return new LibraryDirective.full(commentAndMetadata.comment, commentAndMetad
ata.metadata, keyword, libraryName, semicolon); | 4523 return new LibraryDirective.full(commentAndMetadata.comment, commentAndMetad
ata.metadata, keyword, libraryName, semicolon); |
3138 } | 4524 } |
3139 | 4525 |
3140 /** | 4526 /** |
3141 * Parse a library identifier. | |
3142 * | |
3143 * <pre> | |
3144 * libraryIdentifier ::= | |
3145 * identifier ('.' identifier)* | |
3146 * </pre> | |
3147 * | |
3148 * @return the library identifier that was parsed | |
3149 */ | |
3150 LibraryIdentifier parseLibraryIdentifier() { | |
3151 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); | |
3152 components.add(parseSimpleIdentifier()); | |
3153 while (matches5(TokenType.PERIOD)) { | |
3154 advance(); | |
3155 components.add(parseSimpleIdentifier()); | |
3156 } | |
3157 return new LibraryIdentifier.full(components); | |
3158 } | |
3159 | |
3160 /** | |
3161 * Parse a library name. | 4527 * Parse a library name. |
3162 * | 4528 * |
3163 * <pre> | 4529 * <pre> |
3164 * libraryName ::= | 4530 * libraryName ::= |
3165 * libraryIdentifier | 4531 * libraryIdentifier |
3166 * </pre> | 4532 * </pre> |
3167 * | 4533 * |
3168 * @param missingNameError the error code to be used if the library name is mi
ssing | 4534 * @param missingNameError the error code to be used if the library name is mi
ssing |
3169 * @param missingNameToken the token associated with the error produced if the
library name is | 4535 * @param missingNameToken the token associated with the error produced if the
library name is |
3170 * missing | 4536 * missing |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3265 Expression parseLogicalAndExpression() { | 4631 Expression parseLogicalAndExpression() { |
3266 Expression expression = parseEqualityExpression(); | 4632 Expression expression = parseEqualityExpression(); |
3267 while (matches5(TokenType.AMPERSAND_AMPERSAND)) { | 4633 while (matches5(TokenType.AMPERSAND_AMPERSAND)) { |
3268 Token operator = andAdvance; | 4634 Token operator = andAdvance; |
3269 expression = new BinaryExpression.full(expression, operator, parseEquality
Expression()); | 4635 expression = new BinaryExpression.full(expression, operator, parseEquality
Expression()); |
3270 } | 4636 } |
3271 return expression; | 4637 return expression; |
3272 } | 4638 } |
3273 | 4639 |
3274 /** | 4640 /** |
3275 * Parse a logical or expression. | |
3276 * | |
3277 * <pre> | |
3278 * logicalOrExpression ::= | |
3279 * logicalAndExpression ('||' logicalAndExpression)* | |
3280 * </pre> | |
3281 * | |
3282 * @return the logical or expression that was parsed | |
3283 */ | |
3284 Expression parseLogicalOrExpression() { | |
3285 Expression expression = parseLogicalAndExpression(); | |
3286 while (matches5(TokenType.BAR_BAR)) { | |
3287 Token operator = andAdvance; | |
3288 expression = new BinaryExpression.full(expression, operator, parseLogicalA
ndExpression()); | |
3289 } | |
3290 return expression; | |
3291 } | |
3292 | |
3293 /** | |
3294 * Parse a map literal. | 4641 * Parse a map literal. |
3295 * | 4642 * |
3296 * <pre> | 4643 * <pre> |
3297 * mapLiteral ::= | 4644 * mapLiteral ::= |
3298 * 'const'? typeArguments? '{' (mapLiteralEntry (',' mapLiteralEntry)* ','
?)? '}' | 4645 * 'const'? typeArguments? '{' (mapLiteralEntry (',' mapLiteralEntry)* ','
?)? '}' |
3299 * </pre> | 4646 * </pre> |
3300 * | 4647 * |
3301 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is | 4648 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is |
3302 * no modifier | 4649 * no modifier |
3303 * @param typeArguments the type arguments that were declared, or `null` if th
ere are no | 4650 * @param typeArguments the type arguments that were declared, or `null` if th
ere are no |
(...skipping 11 matching lines...) Expand all Loading... |
3315 if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { | 4662 if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { |
3316 return new MapLiteral.full(modifier, typeArguments, leftBracket, entries
, andAdvance); | 4663 return new MapLiteral.full(modifier, typeArguments, leftBracket, entries
, andAdvance); |
3317 } | 4664 } |
3318 entries.add(parseMapLiteralEntry()); | 4665 entries.add(parseMapLiteralEntry()); |
3319 } | 4666 } |
3320 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); | 4667 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); |
3321 return new MapLiteral.full(modifier, typeArguments, leftBracket, entries, ri
ghtBracket); | 4668 return new MapLiteral.full(modifier, typeArguments, leftBracket, entries, ri
ghtBracket); |
3322 } | 4669 } |
3323 | 4670 |
3324 /** | 4671 /** |
3325 * Parse a map literal entry. | |
3326 * | |
3327 * <pre> | |
3328 * mapLiteralEntry ::= | |
3329 * expression ':' expression | |
3330 * </pre> | |
3331 * | |
3332 * @return the map literal entry that was parsed | |
3333 */ | |
3334 MapLiteralEntry parseMapLiteralEntry() { | |
3335 Expression key = parseExpression2(); | |
3336 Token separator = expect2(TokenType.COLON); | |
3337 Expression value = parseExpression2(); | |
3338 return new MapLiteralEntry.full(key, separator, value); | |
3339 } | |
3340 | |
3341 /** | |
3342 * Parse a method declaration. | 4672 * Parse a method declaration. |
3343 * | 4673 * |
3344 * <pre> | 4674 * <pre> |
3345 * functionDeclaration ::= | 4675 * functionDeclaration ::= |
3346 * 'external'? 'static'? functionSignature functionBody | 4676 * 'external'? 'static'? functionSignature functionBody |
3347 * | 'external'? functionSignature ';' | 4677 * | 'external'? functionSignature ';' |
3348 * </pre> | 4678 * </pre> |
3349 * | 4679 * |
3350 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 4680 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
3351 * declaration | 4681 * declaration |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3629 return parseFunctionDeclarationStatement(); | 4959 return parseFunctionDeclarationStatement(); |
3630 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { | 4960 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { |
3631 reportError8(ParserErrorCode.MISSING_STATEMENT, []); | 4961 reportError8(ParserErrorCode.MISSING_STATEMENT, []); |
3632 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON))
; | 4962 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON))
; |
3633 } else { | 4963 } else { |
3634 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType.
SEMICOLON)); | 4964 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType.
SEMICOLON)); |
3635 } | 4965 } |
3636 } | 4966 } |
3637 | 4967 |
3638 /** | 4968 /** |
3639 * Parse a normal formal parameter. | |
3640 * | |
3641 * <pre> | |
3642 * normalFormalParameter ::= | |
3643 * functionSignature | |
3644 * | fieldFormalParameter | |
3645 * | simpleFormalParameter | |
3646 * | |
3647 * functionSignature: | |
3648 * metadata returnType? identifier formalParameterList | |
3649 * | |
3650 * fieldFormalParameter ::= | |
3651 * metadata finalConstVarOrType? 'this' '.' identifier | |
3652 * | |
3653 * simpleFormalParameter ::= | |
3654 * declaredIdentifier | |
3655 * | metadata identifier | |
3656 * </pre> | |
3657 * | |
3658 * @return the normal formal parameter that was parsed | |
3659 */ | |
3660 NormalFormalParameter parseNormalFormalParameter() { | |
3661 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | |
3662 FinalConstVarOrType holder = parseFinalConstVarOrType(true); | |
3663 Token thisKeyword = null; | |
3664 Token period = null; | |
3665 if (matches(Keyword.THIS)) { | |
3666 thisKeyword = andAdvance; | |
3667 period = expect2(TokenType.PERIOD); | |
3668 } | |
3669 SimpleIdentifier identifier = parseSimpleIdentifier(); | |
3670 if (matches5(TokenType.OPEN_PAREN)) { | |
3671 FormalParameterList parameters = parseFormalParameterList(); | |
3672 if (thisKeyword == null) { | |
3673 if (holder.keyword != null) { | |
3674 reportError9(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.keyw
ord, []); | |
3675 } | |
3676 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment,
commentAndMetadata.metadata, holder.type, identifier, parameters); | |
3677 } else { | |
3678 return new FieldFormalParameter.full(commentAndMetadata.comment, comment
AndMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifi
er, parameters); | |
3679 } | |
3680 } | |
3681 TypeName type = holder.type; | |
3682 if (type != null) { | |
3683 if (matches3(type.name.beginToken, Keyword.VOID)) { | |
3684 reportError9(ParserErrorCode.VOID_PARAMETER, type.name.beginToken, []); | |
3685 } else if (holder.keyword != null && matches3(holder.keyword, Keyword.VAR)
) { | |
3686 reportError9(ParserErrorCode.VAR_AND_TYPE, holder.keyword, []); | |
3687 } | |
3688 } | |
3689 if (thisKeyword != null) { | |
3690 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier
, null); | |
3691 } | |
3692 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd
Metadata.metadata, holder.keyword, holder.type, identifier); | |
3693 } | |
3694 | |
3695 /** | |
3696 * Parse an operator declaration. | 4969 * Parse an operator declaration. |
3697 * | 4970 * |
3698 * <pre> | 4971 * <pre> |
3699 * operatorDeclaration ::= | 4972 * operatorDeclaration ::= |
3700 * operatorSignature (';' | functionBody) | 4973 * operatorSignature (';' | functionBody) |
3701 * | 4974 * |
3702 * operatorSignature ::= | 4975 * operatorSignature ::= |
3703 * 'external'? returnType? 'operator' operator formalParameterList | 4976 * 'external'? returnType? 'operator' operator formalParameterList |
3704 * </pre> | 4977 * </pre> |
3705 * | 4978 * |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3818 return operand; | 5091 return operand; |
3819 } | 5092 } |
3820 if (operand is Literal || operand is FunctionExpressionInvocation) { | 5093 if (operand is Literal || operand is FunctionExpressionInvocation) { |
3821 reportError8(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); | 5094 reportError8(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); |
3822 } | 5095 } |
3823 Token operator = andAdvance; | 5096 Token operator = andAdvance; |
3824 return new PostfixExpression.full(operand, operator); | 5097 return new PostfixExpression.full(operand, operator); |
3825 } | 5098 } |
3826 | 5099 |
3827 /** | 5100 /** |
3828 * Parse a prefixed identifier. | |
3829 * | |
3830 * <pre> | |
3831 * prefixedIdentifier ::= | |
3832 * identifier ('.' identifier)? | |
3833 * </pre> | |
3834 * | |
3835 * @return the prefixed identifier that was parsed | |
3836 */ | |
3837 Identifier parsePrefixedIdentifier() { | |
3838 SimpleIdentifier qualifier = parseSimpleIdentifier(); | |
3839 if (!matches5(TokenType.PERIOD)) { | |
3840 return qualifier; | |
3841 } | |
3842 Token period = andAdvance; | |
3843 SimpleIdentifier qualified = parseSimpleIdentifier(); | |
3844 return new PrefixedIdentifier.full(qualifier, period, qualified); | |
3845 } | |
3846 | |
3847 /** | |
3848 * Parse a primary expression. | 5101 * Parse a primary expression. |
3849 * | 5102 * |
3850 * <pre> | 5103 * <pre> |
3851 * primary ::= | 5104 * primary ::= |
3852 * thisExpression | 5105 * thisExpression |
3853 * | 'super' assignableSelector | 5106 * | 'super' assignableSelector |
3854 * | functionExpression | 5107 * | functionExpression |
3855 * | literal | 5108 * | literal |
3856 * | identifier | 5109 * | identifier |
3857 * | newExpression | 5110 * | newExpression |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4026 Token returnKeyword = expect(Keyword.RETURN); | 5279 Token returnKeyword = expect(Keyword.RETURN); |
4027 if (matches5(TokenType.SEMICOLON)) { | 5280 if (matches5(TokenType.SEMICOLON)) { |
4028 return new ReturnStatement.full(returnKeyword, null, andAdvance); | 5281 return new ReturnStatement.full(returnKeyword, null, andAdvance); |
4029 } | 5282 } |
4030 Expression expression = parseExpression2(); | 5283 Expression expression = parseExpression2(); |
4031 Token semicolon = expect2(TokenType.SEMICOLON); | 5284 Token semicolon = expect2(TokenType.SEMICOLON); |
4032 return new ReturnStatement.full(returnKeyword, expression, semicolon); | 5285 return new ReturnStatement.full(returnKeyword, expression, semicolon); |
4033 } | 5286 } |
4034 | 5287 |
4035 /** | 5288 /** |
4036 * Parse a return type. | |
4037 * | |
4038 * <pre> | |
4039 * returnType ::= | |
4040 * 'void' | |
4041 * | type | |
4042 * </pre> | |
4043 * | |
4044 * @return the return type that was parsed | |
4045 */ | |
4046 TypeName parseReturnType() { | |
4047 if (matches(Keyword.VOID)) { | |
4048 return new TypeName.full(new SimpleIdentifier.full(andAdvance), null); | |
4049 } else { | |
4050 return parseTypeName(); | |
4051 } | |
4052 } | |
4053 | |
4054 /** | |
4055 * Parse a setter. | 5289 * Parse a setter. |
4056 * | 5290 * |
4057 * <pre> | 5291 * <pre> |
4058 * setter ::= | 5292 * setter ::= |
4059 * setterSignature functionBody? | 5293 * setterSignature functionBody? |
4060 * | 5294 * |
4061 * setterSignature ::= | 5295 * setterSignature ::= |
4062 * 'external'? 'static'? returnType? 'set' identifier formalParameterList | 5296 * 'external'? 'static'? returnType? 'set' identifier formalParameterList |
4063 * </pre> | 5297 * </pre> |
4064 * | 5298 * |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4101 expression = parseAdditiveExpression(); | 5335 expression = parseAdditiveExpression(); |
4102 } | 5336 } |
4103 while (_currentToken.type.isShiftOperator) { | 5337 while (_currentToken.type.isShiftOperator) { |
4104 Token operator = andAdvance; | 5338 Token operator = andAdvance; |
4105 expression = new BinaryExpression.full(expression, operator, parseAdditive
Expression()); | 5339 expression = new BinaryExpression.full(expression, operator, parseAdditive
Expression()); |
4106 } | 5340 } |
4107 return expression; | 5341 return expression; |
4108 } | 5342 } |
4109 | 5343 |
4110 /** | 5344 /** |
4111 * Parse a simple identifier. | |
4112 * | |
4113 * <pre> | |
4114 * identifier ::= | |
4115 * IDENTIFIER | |
4116 * </pre> | |
4117 * | |
4118 * @return the simple identifier that was parsed | |
4119 */ | |
4120 SimpleIdentifier parseSimpleIdentifier() { | |
4121 if (matchesIdentifier()) { | |
4122 return new SimpleIdentifier.full(andAdvance); | |
4123 } | |
4124 reportError8(ParserErrorCode.MISSING_IDENTIFIER, []); | |
4125 return createSyntheticIdentifier(); | |
4126 } | |
4127 | |
4128 /** | |
4129 * Parse a statement. | |
4130 * | |
4131 * <pre> | |
4132 * statement ::= | |
4133 * label* nonLabeledStatement | |
4134 * </pre> | |
4135 * | |
4136 * @return the statement that was parsed | |
4137 */ | |
4138 Statement parseStatement2() { | |
4139 List<Label> labels = new List<Label>(); | |
4140 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { | |
4141 SimpleIdentifier label = parseSimpleIdentifier(); | |
4142 Token colon = expect2(TokenType.COLON); | |
4143 labels.add(new Label.full(label, colon)); | |
4144 } | |
4145 Statement statement = parseNonLabeledStatement(); | |
4146 if (labels.isEmpty) { | |
4147 return statement; | |
4148 } | |
4149 return new LabeledStatement.full(labels, statement); | |
4150 } | |
4151 | |
4152 /** | |
4153 * Parse a list of statements within a switch statement. | 5345 * Parse a list of statements within a switch statement. |
4154 * | 5346 * |
4155 * <pre> | 5347 * <pre> |
4156 * statements ::= | 5348 * statements ::= |
4157 * statement* | 5349 * statement* |
4158 * </pre> | 5350 * </pre> |
4159 * | 5351 * |
4160 * @return the statements that were parsed | 5352 * @return the statements that were parsed |
4161 */ | 5353 */ |
4162 List<Statement> parseStatements2() { | 5354 List<Statement> parseStatements2() { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4201 if (matches5(TokenType.STRING)) { | 5393 if (matches5(TokenType.STRING)) { |
4202 string = andAdvance; | 5394 string = andAdvance; |
4203 hasMore = matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches
5(TokenType.STRING_INTERPOLATION_IDENTIFIER); | 5395 hasMore = matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches
5(TokenType.STRING_INTERPOLATION_IDENTIFIER); |
4204 elements.add(new InterpolationString.full(string, computeStringValue(str
ing.lexeme, false, !hasMore))); | 5396 elements.add(new InterpolationString.full(string, computeStringValue(str
ing.lexeme, false, !hasMore))); |
4205 } | 5397 } |
4206 } | 5398 } |
4207 return new StringInterpolation.full(elements); | 5399 return new StringInterpolation.full(elements); |
4208 } | 5400 } |
4209 | 5401 |
4210 /** | 5402 /** |
4211 * Parse a string literal. | |
4212 * | |
4213 * <pre> | |
4214 * stringLiteral ::= | |
4215 * MULTI_LINE_STRING+ | |
4216 * | SINGLE_LINE_STRING+ | |
4217 * </pre> | |
4218 * | |
4219 * @return the string literal that was parsed | |
4220 */ | |
4221 StringLiteral parseStringLiteral() { | |
4222 List<StringLiteral> strings = new List<StringLiteral>(); | |
4223 while (matches5(TokenType.STRING)) { | |
4224 Token string = andAdvance; | |
4225 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches5(TokenT
ype.STRING_INTERPOLATION_IDENTIFIER)) { | |
4226 strings.add(parseStringInterpolation(string)); | |
4227 } else { | |
4228 strings.add(new SimpleStringLiteral.full(string, computeStringValue(stri
ng.lexeme, true, true))); | |
4229 } | |
4230 } | |
4231 if (strings.length < 1) { | |
4232 reportError8(ParserErrorCode.EXPECTED_STRING_LITERAL, []); | |
4233 return createSyntheticStringLiteral(); | |
4234 } else if (strings.length == 1) { | |
4235 return strings[0]; | |
4236 } else { | |
4237 return new AdjacentStrings.full(strings); | |
4238 } | |
4239 } | |
4240 | |
4241 /** | |
4242 * Parse a super constructor invocation. | 5403 * Parse a super constructor invocation. |
4243 * | 5404 * |
4244 * <pre> | 5405 * <pre> |
4245 * superConstructorInvocation ::= | 5406 * superConstructorInvocation ::= |
4246 * 'super' ('.' identifier)? arguments | 5407 * 'super' ('.' identifier)? arguments |
4247 * </pre> | 5408 * </pre> |
4248 * | 5409 * |
4249 * @return the super constructor invocation that was parsed | 5410 * @return the super constructor invocation that was parsed |
4250 */ | 5411 */ |
4251 SuperConstructorInvocation parseSuperConstructorInvocation() { | 5412 SuperConstructorInvocation parseSuperConstructorInvocation() { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4508 } else if (matches4(next, TokenType.EQ)) { | 5669 } else if (matches4(next, TokenType.EQ)) { |
4509 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword); | 5670 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword); |
4510 reportError9(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []); | 5671 reportError9(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []); |
4511 return typeAlias; | 5672 return typeAlias; |
4512 } | 5673 } |
4513 } | 5674 } |
4514 return parseFunctionTypeAlias(commentAndMetadata, keyword); | 5675 return parseFunctionTypeAlias(commentAndMetadata, keyword); |
4515 } | 5676 } |
4516 | 5677 |
4517 /** | 5678 /** |
4518 * Parse a list of type arguments. | |
4519 * | |
4520 * <pre> | |
4521 * typeArguments ::= | |
4522 * '<' typeList '>' | |
4523 * | |
4524 * typeList ::= | |
4525 * type (',' type)* | |
4526 * </pre> | |
4527 * | |
4528 * @return the type argument list that was parsed | |
4529 */ | |
4530 TypeArgumentList parseTypeArgumentList() { | |
4531 Token leftBracket = expect2(TokenType.LT); | |
4532 List<TypeName> arguments = new List<TypeName>(); | |
4533 arguments.add(parseTypeName()); | |
4534 while (optional(TokenType.COMMA)) { | |
4535 arguments.add(parseTypeName()); | |
4536 } | |
4537 Token rightBracket = expect2(TokenType.GT); | |
4538 return new TypeArgumentList.full(leftBracket, arguments, rightBracket); | |
4539 } | |
4540 | |
4541 /** | |
4542 * Parse a type name. | |
4543 * | |
4544 * <pre> | |
4545 * type ::= | |
4546 * qualified typeArguments? | |
4547 * </pre> | |
4548 * | |
4549 * @return the type name that was parsed | |
4550 */ | |
4551 TypeName parseTypeName() { | |
4552 Identifier typeName; | |
4553 if (matches(Keyword.VAR)) { | |
4554 reportError8(ParserErrorCode.VAR_AS_TYPE_NAME, []); | |
4555 typeName = new SimpleIdentifier.full(andAdvance); | |
4556 } else if (matchesIdentifier()) { | |
4557 typeName = parsePrefixedIdentifier(); | |
4558 } else { | |
4559 typeName = createSyntheticIdentifier(); | |
4560 reportError8(ParserErrorCode.EXPECTED_TYPE_NAME, []); | |
4561 } | |
4562 TypeArgumentList typeArguments = null; | |
4563 if (matches5(TokenType.LT)) { | |
4564 typeArguments = parseTypeArgumentList(); | |
4565 } | |
4566 return new TypeName.full(typeName, typeArguments); | |
4567 } | |
4568 | |
4569 /** | |
4570 * Parse a type parameter. | |
4571 * | |
4572 * <pre> | |
4573 * typeParameter ::= | |
4574 * metadata name ('extends' bound)? | |
4575 * </pre> | |
4576 * | |
4577 * @return the type parameter that was parsed | |
4578 */ | |
4579 TypeParameter parseTypeParameter() { | |
4580 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | |
4581 SimpleIdentifier name = parseSimpleIdentifier(); | |
4582 if (matches(Keyword.EXTENDS)) { | |
4583 Token keyword = andAdvance; | |
4584 TypeName bound = parseTypeName(); | |
4585 return new TypeParameter.full(commentAndMetadata.comment, commentAndMetada
ta.metadata, name, keyword, bound); | |
4586 } | |
4587 return new TypeParameter.full(commentAndMetadata.comment, commentAndMetadata
.metadata, name, null, null); | |
4588 } | |
4589 | |
4590 /** | |
4591 * Parse a list of type parameters. | |
4592 * | |
4593 * <pre> | |
4594 * typeParameterList ::= | |
4595 * '<' typeParameter (',' typeParameter)* '>' | |
4596 * </pre> | |
4597 * | |
4598 * @return the list of type parameters that were parsed | |
4599 */ | |
4600 TypeParameterList parseTypeParameterList() { | |
4601 Token leftBracket = expect2(TokenType.LT); | |
4602 List<TypeParameter> typeParameters = new List<TypeParameter>(); | |
4603 typeParameters.add(parseTypeParameter()); | |
4604 while (optional(TokenType.COMMA)) { | |
4605 typeParameters.add(parseTypeParameter()); | |
4606 } | |
4607 Token rightBracket = expect2(TokenType.GT); | |
4608 return new TypeParameterList.full(leftBracket, typeParameters, rightBracket)
; | |
4609 } | |
4610 | |
4611 /** | |
4612 * Parse a unary expression. | 5679 * Parse a unary expression. |
4613 * | 5680 * |
4614 * <pre> | 5681 * <pre> |
4615 * unaryExpression ::= | 5682 * unaryExpression ::= |
4616 * prefixOperator unaryExpression | 5683 * prefixOperator unaryExpression |
4617 * | postfixExpression | 5684 * | postfixExpression |
4618 * | unaryOperator 'super' | 5685 * | unaryOperator 'super' |
4619 * | '-' 'super' | 5686 * | '-' 'super' |
4620 * | incrementOperator assignableExpression | 5687 * | incrementOperator assignableExpression |
4621 * </pre> | 5688 * </pre> |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4783 Expression condition = parseExpression2(); | 5850 Expression condition = parseExpression2(); |
4784 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 5851 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
4785 Statement body = parseStatement2(); | 5852 Statement body = parseStatement2(); |
4786 return new WhileStatement.full(keyword, leftParenthesis, condition, rightP
arenthesis, body); | 5853 return new WhileStatement.full(keyword, leftParenthesis, condition, rightP
arenthesis, body); |
4787 } finally { | 5854 } finally { |
4788 _inLoop = wasInLoop; | 5855 _inLoop = wasInLoop; |
4789 } | 5856 } |
4790 } | 5857 } |
4791 | 5858 |
4792 /** | 5859 /** |
4793 * Parse a with clause. | |
4794 * | |
4795 * <pre> | |
4796 * withClause ::= | |
4797 * 'with' typeName (',' typeName)* | |
4798 * </pre> | |
4799 * | |
4800 * @return the with clause that was parsed | |
4801 */ | |
4802 WithClause parseWithClause() { | |
4803 Token with2 = expect(Keyword.WITH); | |
4804 List<TypeName> types = new List<TypeName>(); | |
4805 types.add(parseTypeName()); | |
4806 while (optional(TokenType.COMMA)) { | |
4807 types.add(parseTypeName()); | |
4808 } | |
4809 return new WithClause.full(with2, types); | |
4810 } | |
4811 | |
4812 /** | |
4813 * Return the token that is immediately after the current token. This is equiv
alent to | 5860 * Return the token that is immediately after the current token. This is equiv
alent to |
4814 * [peek]. | 5861 * [peek]. |
4815 * | 5862 * |
4816 * @return the token that is immediately after the current token | 5863 * @return the token that is immediately after the current token |
4817 */ | 5864 */ |
4818 Token peek() => _currentToken.next; | 5865 Token peek() => _currentToken.next; |
4819 | 5866 |
4820 /** | 5867 /** |
4821 * Return the token that is the given distance after the current token. | 5868 * Return the token that is the given distance after the current token. |
4822 * | 5869 * |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5996 * | 7043 * |
5997 * @param message the message template used to create the message to be displa
yed for the error | 7044 * @param message the message template used to create the message to be displa
yed for the error |
5998 */ | 7045 */ |
5999 ParserErrorCode.con3(String name, int ordinal, String message) : this.con1(nam
e, ordinal, ErrorSeverity.ERROR, message); | 7046 ParserErrorCode.con3(String name, int ordinal, String message) : this.con1(nam
e, ordinal, ErrorSeverity.ERROR, message); |
6000 String get correction => correction8; | 7047 String get correction => correction8; |
6001 ErrorSeverity get errorSeverity => _severity; | 7048 ErrorSeverity get errorSeverity => _severity; |
6002 String get message => _message; | 7049 String get message => _message; |
6003 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 7050 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
6004 } | 7051 } |
6005 /** | 7052 /** |
| 7053 * Instances of the class `ResolutionCopier` copies resolution information from
one AST |
| 7054 * structure to another as long as the structures of the corresponding children
of a pair of nodes |
| 7055 * are the same. |
| 7056 */ |
| 7057 class ResolutionCopier implements ASTVisitor<bool> { |
| 7058 |
| 7059 /** |
| 7060 * Copy resolution data from one node to another. |
| 7061 * |
| 7062 * @param fromNode the node from which resolution information will be copied |
| 7063 * @param toNode the node to which resolution information will be copied |
| 7064 */ |
| 7065 static void copyResolutionData(ASTNode fromNode, ASTNode toNode) { |
| 7066 ResolutionCopier copier = new ResolutionCopier(); |
| 7067 copier.isEqual(fromNode, toNode); |
| 7068 } |
| 7069 |
| 7070 /** |
| 7071 * The AST node with which the node being visited is to be compared. This is o
nly valid at the |
| 7072 * beginning of each visit method (until [isEqual] is invoked). |
| 7073 */ |
| 7074 ASTNode _toNode; |
| 7075 bool visitAdjacentStrings(AdjacentStrings node) { |
| 7076 AdjacentStrings toNode = this._toNode as AdjacentStrings; |
| 7077 return isEqual2(node.strings, toNode.strings); |
| 7078 } |
| 7079 bool visitAnnotation(Annotation node) { |
| 7080 Annotation toNode = this._toNode as Annotation; |
| 7081 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(nod
e.atSign, toNode.atSign), isEqual(node.name, toNode.name)), isEqual3(node.period
, toNode.period)), isEqual(node.constructorName, toNode.constructorName)), isEqu
al(node.arguments, toNode.arguments))) { |
| 7082 toNode.element = node.element; |
| 7083 return true; |
| 7084 } |
| 7085 return false; |
| 7086 } |
| 7087 bool visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 7088 ArgumentDefinitionTest toNode = this._toNode as ArgumentDefinitionTest; |
| 7089 if (javaBooleanAnd(isEqual3(node.question, toNode.question), isEqual(node.id
entifier, toNode.identifier))) { |
| 7090 toNode.propagatedType = node.propagatedType; |
| 7091 toNode.staticType = node.staticType; |
| 7092 return true; |
| 7093 } |
| 7094 return false; |
| 7095 } |
| 7096 bool visitArgumentList(ArgumentList node) { |
| 7097 ArgumentList toNode = this._toNode as ArgumentList; |
| 7098 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.leftParenthesis, toNode.l
eftParenthesis), isEqual2(node.arguments, toNode.arguments)), isEqual3(node.righ
tParenthesis, toNode.rightParenthesis)); |
| 7099 } |
| 7100 bool visitAsExpression(AsExpression node) { |
| 7101 AsExpression toNode = this._toNode as AsExpression; |
| 7102 if (javaBooleanAnd(javaBooleanAnd(isEqual(node.expression, toNode.expression
), isEqual3(node.asOperator, toNode.asOperator)), isEqual(node.type, toNode.type
))) { |
| 7103 toNode.propagatedType = node.propagatedType; |
| 7104 toNode.staticType = node.staticType; |
| 7105 return true; |
| 7106 } |
| 7107 return false; |
| 7108 } |
| 7109 bool visitAssertStatement(AssertStatement node) { |
| 7110 AssertStatement toNode = this._toNode as AssertStatement; |
| 7111 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(
node.keyword, toNode.keyword), isEqual3(node.leftParenthesis, toNode.leftParenth
esis)), isEqual(node.condition, toNode.condition)), isEqual3(node.rightParenthes
is, toNode.rightParenthesis)), isEqual3(node.semicolon, toNode.semicolon)); |
| 7112 } |
| 7113 bool visitAssignmentExpression(AssignmentExpression node) { |
| 7114 AssignmentExpression toNode = this._toNode as AssignmentExpression; |
| 7115 if (javaBooleanAnd(javaBooleanAnd(isEqual(node.leftHandSide, toNode.leftHand
Side), isEqual3(node.operator, toNode.operator)), isEqual(node.rightHandSide, to
Node.rightHandSide))) { |
| 7116 toNode.propagatedElement = node.propagatedElement; |
| 7117 toNode.propagatedType = node.propagatedType; |
| 7118 toNode.staticElement = node.staticElement; |
| 7119 toNode.staticType = node.staticType; |
| 7120 return true; |
| 7121 } |
| 7122 return false; |
| 7123 } |
| 7124 bool visitBinaryExpression(BinaryExpression node) { |
| 7125 BinaryExpression toNode = this._toNode as BinaryExpression; |
| 7126 if (javaBooleanAnd(javaBooleanAnd(isEqual(node.leftOperand, toNode.leftOpera
nd), isEqual3(node.operator, toNode.operator)), isEqual(node.rightOperand, toNod
e.rightOperand))) { |
| 7127 toNode.propagatedElement = node.propagatedElement; |
| 7128 toNode.propagatedType = node.propagatedType; |
| 7129 toNode.staticElement = node.staticElement; |
| 7130 toNode.staticType = node.staticType; |
| 7131 return true; |
| 7132 } |
| 7133 return false; |
| 7134 } |
| 7135 bool visitBlock(Block node) { |
| 7136 Block toNode = this._toNode as Block; |
| 7137 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.leftBracket, toNode.leftB
racket), isEqual2(node.statements, toNode.statements)), isEqual3(node.rightBrack
et, toNode.rightBracket)); |
| 7138 } |
| 7139 bool visitBlockFunctionBody(BlockFunctionBody node) { |
| 7140 BlockFunctionBody toNode = this._toNode as BlockFunctionBody; |
| 7141 return isEqual(node.block, toNode.block); |
| 7142 } |
| 7143 bool visitBooleanLiteral(BooleanLiteral node) { |
| 7144 BooleanLiteral toNode = this._toNode as BooleanLiteral; |
| 7145 if (javaBooleanAnd(isEqual3(node.literal, toNode.literal), identical(node.va
lue, toNode.value))) { |
| 7146 toNode.propagatedType = node.propagatedType; |
| 7147 toNode.staticType = node.staticType; |
| 7148 return true; |
| 7149 } |
| 7150 return false; |
| 7151 } |
| 7152 bool visitBreakStatement(BreakStatement node) { |
| 7153 BreakStatement toNode = this._toNode as BreakStatement; |
| 7154 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.keyword, toNode.keyword),
isEqual(node.label, toNode.label)), isEqual3(node.semicolon, toNode.semicolon))
; |
| 7155 } |
| 7156 bool visitCascadeExpression(CascadeExpression node) { |
| 7157 CascadeExpression toNode = this._toNode as CascadeExpression; |
| 7158 if (javaBooleanAnd(isEqual(node.target, toNode.target), isEqual2(node.cascad
eSections, toNode.cascadeSections))) { |
| 7159 toNode.propagatedType = node.propagatedType; |
| 7160 toNode.staticType = node.staticType; |
| 7161 return true; |
| 7162 } |
| 7163 return false; |
| 7164 } |
| 7165 bool visitCatchClause(CatchClause node) { |
| 7166 CatchClause toNode = this._toNode as CatchClause; |
| 7167 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(node.onKeyword, toNo
de.onKeyword), isEqual(node.exceptionType, toNode.exceptionType)), isEqual3(node
.catchKeyword, toNode.catchKeyword)), isEqual3(node.leftParenthesis, toNode.left
Parenthesis)), isEqual(node.exceptionParameter, toNode.exceptionParameter)), isE
qual3(node.comma, toNode.comma)), isEqual(node.stackTraceParameter, toNode.stack
TraceParameter)), isEqual3(node.rightParenthesis, toNode.rightParenthesis)), isE
qual(node.body, toNode.body)); |
| 7168 } |
| 7169 bool visitClassDeclaration(ClassDeclaration node) { |
| 7170 ClassDeclaration toNode = this._toNode as ClassDeclaration; |
| 7171 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd
(javaBooleanAnd(isEqual(node.documentationComment, toNode.documentationComment),
isEqual2(node.metadata, toNode.metadata)), isEqual3(node.abstractKeyword, toNod
e.abstractKeyword)), isEqual3(node.classKeyword, toNode.classKeyword)), isEqual(
node.name, toNode.name)), isEqual(node.typeParameters, toNode.typeParameters)),
isEqual(node.extendsClause, toNode.extendsClause)), isEqual(node.withClause, toN
ode.withClause)), isEqual(node.implementsClause, toNode.implementsClause)), isEq
ual3(node.leftBracket, toNode.leftBracket)), isEqual2(node.members, toNode.membe
rs)), isEqual3(node.rightBracket, toNode.rightBracket)); |
| 7172 } |
| 7173 bool visitClassTypeAlias(ClassTypeAlias node) { |
| 7174 ClassTypeAlias toNode = this._toNode as ClassTypeAlias; |
| 7175 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd
(isEqual(node.documentationComment, toNode.documentationComment), isEqual2(node.
metadata, toNode.metadata)), isEqual3(node.keyword, toNode.keyword)), isEqual(no
de.name, toNode.name)), isEqual(node.typeParameters, toNode.typeParameters)), is
Equal3(node.equals, toNode.equals)), isEqual3(node.abstractKeyword, toNode.abstr
actKeyword)), isEqual(node.superclass, toNode.superclass)), isEqual(node.withCla
use, toNode.withClause)), isEqual(node.implementsClause, toNode.implementsClause
)), isEqual3(node.semicolon, toNode.semicolon)); |
| 7176 } |
| 7177 bool visitComment(Comment node) { |
| 7178 Comment toNode = this._toNode as Comment; |
| 7179 return isEqual2(node.references, toNode.references); |
| 7180 } |
| 7181 bool visitCommentReference(CommentReference node) { |
| 7182 CommentReference toNode = this._toNode as CommentReference; |
| 7183 return javaBooleanAnd(isEqual3(node.newKeyword, toNode.newKeyword), isEqual(
node.identifier, toNode.identifier)); |
| 7184 } |
| 7185 bool visitCompilationUnit(CompilationUnit node) { |
| 7186 CompilationUnit toNode = this._toNode as CompilationUnit; |
| 7187 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(nod
e.beginToken, toNode.beginToken), isEqual(node.scriptTag, toNode.scriptTag)), is
Equal2(node.directives, toNode.directives)), isEqual2(node.declarations, toNode.
declarations)), isEqual3(node.endToken, toNode.endToken))) { |
| 7188 toNode.element = node.element; |
| 7189 return true; |
| 7190 } |
| 7191 return false; |
| 7192 } |
| 7193 bool visitConditionalExpression(ConditionalExpression node) { |
| 7194 ConditionalExpression toNode = this._toNode as ConditionalExpression; |
| 7195 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node
.condition, toNode.condition), isEqual3(node.question, toNode.question)), isEqua
l(node.thenExpression, toNode.thenExpression)), isEqual3(node.colon, toNode.colo
n)), isEqual(node.elseExpression, toNode.elseExpression))) { |
| 7196 toNode.propagatedType = node.propagatedType; |
| 7197 toNode.staticType = node.staticType; |
| 7198 return true; |
| 7199 } |
| 7200 return false; |
| 7201 } |
| 7202 bool visitConstructorDeclaration(ConstructorDeclaration node) { |
| 7203 ConstructorDeclaration toNode = this._toNode as ConstructorDeclaration; |
| 7204 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(ja
vaBooleanAnd(javaBooleanAnd(isEqual(node.documentationComment, toNode.documentat
ionComment), isEqual2(node.metadata, toNode.metadata)), isEqual3(node.externalKe
yword, toNode.externalKeyword)), isEqual3(node.constKeyword, toNode.constKeyword
)), isEqual3(node.factoryKeyword, toNode.factoryKeyword)), isEqual(node.returnTy
pe, toNode.returnType)), isEqual3(node.period, toNode.period)), isEqual(node.nam
e, toNode.name)), isEqual(node.parameters, toNode.parameters)), isEqual3(node.se
parator, toNode.separator)), isEqual2(node.initializers, toNode.initializers)),
isEqual(node.redirectedConstructor, toNode.redirectedConstructor)), isEqual(node
.body, toNode.body))) { |
| 7205 toNode.element = node.element; |
| 7206 return true; |
| 7207 } |
| 7208 return false; |
| 7209 } |
| 7210 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 7211 ConstructorFieldInitializer toNode = this._toNode as ConstructorFieldInitial
izer; |
| 7212 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(
node.keyword, toNode.keyword), isEqual3(node.period, toNode.period)), isEqual(no
de.fieldName, toNode.fieldName)), isEqual3(node.equals, toNode.equals)), isEqual
(node.expression, toNode.expression)); |
| 7213 } |
| 7214 bool visitConstructorName(ConstructorName node) { |
| 7215 ConstructorName toNode = this._toNode as ConstructorName; |
| 7216 if (javaBooleanAnd(javaBooleanAnd(isEqual(node.type, toNode.type), isEqual3(
node.period, toNode.period)), isEqual(node.name, toNode.name))) { |
| 7217 toNode.staticElement = node.staticElement; |
| 7218 return true; |
| 7219 } |
| 7220 return false; |
| 7221 } |
| 7222 bool visitContinueStatement(ContinueStatement node) { |
| 7223 ContinueStatement toNode = this._toNode as ContinueStatement; |
| 7224 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.keyword, toNode.keyword),
isEqual(node.label, toNode.label)), isEqual3(node.semicolon, toNode.semicolon))
; |
| 7225 } |
| 7226 bool visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 7227 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier; |
| 7228 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual3(node.keyword, toNode.keyword)), isEqual(node.type, t
oNode.type)), isEqual(node.identifier, toNode.identifier)); |
| 7229 } |
| 7230 bool visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 7231 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter; |
| 7232 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.parameter,
toNode.parameter), identical(node.kind, toNode.kind)), isEqual3(node.separator,
toNode.separator)), isEqual(node.defaultValue, toNode.defaultValue)); |
| 7233 } |
| 7234 bool visitDoStatement(DoStatement node) { |
| 7235 DoStatement toNode = this._toNode as DoStatement; |
| 7236 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqual3(node.doKeyword, toNode.doKeyword), isEqual(node.bo
dy, toNode.body)), isEqual3(node.whileKeyword, toNode.whileKeyword)), isEqual3(n
ode.leftParenthesis, toNode.leftParenthesis)), isEqual(node.condition, toNode.co
ndition)), isEqual3(node.rightParenthesis, toNode.rightParenthesis)), isEqual3(n
ode.semicolon, toNode.semicolon)); |
| 7237 } |
| 7238 bool visitDoubleLiteral(DoubleLiteral node) { |
| 7239 DoubleLiteral toNode = this._toNode as DoubleLiteral; |
| 7240 if (javaBooleanAnd(isEqual3(node.literal, toNode.literal), node.value == toN
ode.value)) { |
| 7241 toNode.propagatedType = node.propagatedType; |
| 7242 toNode.staticType = node.staticType; |
| 7243 return true; |
| 7244 } |
| 7245 return false; |
| 7246 } |
| 7247 bool visitEmptyFunctionBody(EmptyFunctionBody node) { |
| 7248 EmptyFunctionBody toNode = this._toNode as EmptyFunctionBody; |
| 7249 return isEqual3(node.semicolon, toNode.semicolon); |
| 7250 } |
| 7251 bool visitEmptyStatement(EmptyStatement node) { |
| 7252 EmptyStatement toNode = this._toNode as EmptyStatement; |
| 7253 return isEqual3(node.semicolon, toNode.semicolon); |
| 7254 } |
| 7255 bool visitExportDirective(ExportDirective node) { |
| 7256 ExportDirective toNode = this._toNode as ExportDirective; |
| 7257 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(isEqual(node.documentationComment, toNode.documentationComment), isEqual2(nod
e.metadata, toNode.metadata)), isEqual3(node.keyword, toNode.keyword)), isEqual(
node.uri, toNode.uri)), isEqual2(node.combinators, toNode.combinators)), isEqual
3(node.semicolon, toNode.semicolon))) { |
| 7258 toNode.element = node.element; |
| 7259 return true; |
| 7260 } |
| 7261 return false; |
| 7262 } |
| 7263 bool visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 7264 ExpressionFunctionBody toNode = this._toNode as ExpressionFunctionBody; |
| 7265 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.functionDefinition, toNod
e.functionDefinition), isEqual(node.expression, toNode.expression)), isEqual3(no
de.semicolon, toNode.semicolon)); |
| 7266 } |
| 7267 bool visitExpressionStatement(ExpressionStatement node) { |
| 7268 ExpressionStatement toNode = this._toNode as ExpressionStatement; |
| 7269 return javaBooleanAnd(isEqual(node.expression, toNode.expression), isEqual3(
node.semicolon, toNode.semicolon)); |
| 7270 } |
| 7271 bool visitExtendsClause(ExtendsClause node) { |
| 7272 ExtendsClause toNode = this._toNode as ExtendsClause; |
| 7273 return javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual(node.s
uperclass, toNode.superclass)); |
| 7274 } |
| 7275 bool visitFieldDeclaration(FieldDeclaration node) { |
| 7276 FieldDeclaration toNode = this._toNode as FieldDeclaration; |
| 7277 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual3(node.staticKeyword, toNode.staticKeyword)), isEqual(
node.fields, toNode.fields)), isEqual3(node.semicolon, toNode.semicolon)); |
| 7278 } |
| 7279 bool visitFieldFormalParameter(FieldFormalParameter node) { |
| 7280 FieldFormalParameter toNode = this._toNode as FieldFormalParameter; |
| 7281 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqual(node.documentationComment, toNode.documentationComm
ent), isEqual2(node.metadata, toNode.metadata)), isEqual3(node.keyword, toNode.k
eyword)), isEqual(node.type, toNode.type)), isEqual3(node.thisToken, toNode.this
Token)), isEqual3(node.period, toNode.period)), isEqual(node.identifier, toNode.
identifier)); |
| 7282 } |
| 7283 bool visitForEachStatement(ForEachStatement node) { |
| 7284 ForEachStatement toNode = this._toNode as ForEachStatement; |
| 7285 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqual3(node.forKeyword, toNode.forKeyword), isEqual3(node
.leftParenthesis, toNode.leftParenthesis)), isEqual(node.loopVariable, toNode.lo
opVariable)), isEqual3(node.inKeyword, toNode.inKeyword)), isEqual(node.iterator
, toNode.iterator)), isEqual3(node.rightParenthesis, toNode.rightParenthesis)),
isEqual(node.body, toNode.body)); |
| 7286 } |
| 7287 bool visitFormalParameterList(FormalParameterList node) { |
| 7288 FormalParameterList toNode = this._toNode as FormalParameterList; |
| 7289 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(
node.leftParenthesis, toNode.leftParenthesis), isEqual2(node.parameters, toNode.
parameters)), isEqual3(node.leftDelimiter, toNode.leftDelimiter)), isEqual3(node
.rightDelimiter, toNode.rightDelimiter)), isEqual3(node.rightParenthesis, toNode
.rightParenthesis)); |
| 7290 } |
| 7291 bool visitForStatement(ForStatement node) { |
| 7292 ForStatement toNode = this._toNode as ForStatement; |
| 7293 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(node.
forKeyword, toNode.forKeyword), isEqual3(node.leftParenthesis, toNode.leftParent
hesis)), isEqual(node.variables, toNode.variables)), isEqual(node.initialization
, toNode.initialization)), isEqual3(node.leftSeparator, toNode.leftSeparator)),
isEqual(node.condition, toNode.condition)), isEqual3(node.rightSeparator, toNode
.rightSeparator)), isEqual2(node.updaters, toNode.updaters)), isEqual3(node.righ
tParenthesis, toNode.rightParenthesis)), isEqual(node.body, toNode.body)); |
| 7294 } |
| 7295 bool visitFunctionDeclaration(FunctionDeclaration node) { |
| 7296 FunctionDeclaration toNode = this._toNode as FunctionDeclaration; |
| 7297 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqual(node.documentationComment, toNode.documentationComm
ent), isEqual2(node.metadata, toNode.metadata)), isEqual3(node.externalKeyword,
toNode.externalKeyword)), isEqual(node.returnType, toNode.returnType)), isEqual3
(node.propertyKeyword, toNode.propertyKeyword)), isEqual(node.name, toNode.name)
), isEqual(node.functionExpression, toNode.functionExpression)); |
| 7298 } |
| 7299 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 7300 FunctionDeclarationStatement toNode = this._toNode as FunctionDeclarationSta
tement; |
| 7301 return isEqual(node.functionDeclaration, toNode.functionDeclaration); |
| 7302 } |
| 7303 bool visitFunctionExpression(FunctionExpression node) { |
| 7304 FunctionExpression toNode = this._toNode as FunctionExpression; |
| 7305 if (javaBooleanAnd(isEqual(node.parameters, toNode.parameters), isEqual(node
.body, toNode.body))) { |
| 7306 toNode.element = node.element; |
| 7307 toNode.propagatedType = node.propagatedType; |
| 7308 toNode.staticType = node.staticType; |
| 7309 return true; |
| 7310 } |
| 7311 return false; |
| 7312 } |
| 7313 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 7314 FunctionExpressionInvocation toNode = this._toNode as FunctionExpressionInvo
cation; |
| 7315 if (javaBooleanAnd(isEqual(node.function, toNode.function), isEqual(node.arg
umentList, toNode.argumentList))) { |
| 7316 toNode.propagatedElement = node.propagatedElement; |
| 7317 toNode.propagatedType = node.propagatedType; |
| 7318 toNode.staticElement = node.staticElement; |
| 7319 toNode.staticType = node.staticType; |
| 7320 return true; |
| 7321 } |
| 7322 return false; |
| 7323 } |
| 7324 bool visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 7325 FunctionTypeAlias toNode = this._toNode as FunctionTypeAlias; |
| 7326 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.documentationComment, toNode.do
cumentationComment), isEqual2(node.metadata, toNode.metadata)), isEqual3(node.ke
yword, toNode.keyword)), isEqual(node.returnType, toNode.returnType)), isEqual(n
ode.name, toNode.name)), isEqual(node.typeParameters, toNode.typeParameters)), i
sEqual(node.parameters, toNode.parameters)), isEqual3(node.semicolon, toNode.sem
icolon)); |
| 7327 } |
| 7328 bool visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 7329 FunctionTypedFormalParameter toNode = this._toNode as FunctionTypedFormalPar
ameter; |
| 7330 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual(node.returnType, toNode.returnType)), isEqual(node.id
entifier, toNode.identifier)), isEqual(node.parameters, toNode.parameters)); |
| 7331 } |
| 7332 bool visitHideCombinator(HideCombinator node) { |
| 7333 HideCombinator toNode = this._toNode as HideCombinator; |
| 7334 return javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual2(node.
hiddenNames, toNode.hiddenNames)); |
| 7335 } |
| 7336 bool visitIfStatement(IfStatement node) { |
| 7337 IfStatement toNode = this._toNode as IfStatement; |
| 7338 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqual3(node.ifKeyword, toNode.ifKeyword), isEqual3(node.l
eftParenthesis, toNode.leftParenthesis)), isEqual(node.condition, toNode.conditi
on)), isEqual3(node.rightParenthesis, toNode.rightParenthesis)), isEqual(node.th
enStatement, toNode.thenStatement)), isEqual3(node.elseKeyword, toNode.elseKeywo
rd)), isEqual(node.elseStatement, toNode.elseStatement)); |
| 7339 } |
| 7340 bool visitImplementsClause(ImplementsClause node) { |
| 7341 ImplementsClause toNode = this._toNode as ImplementsClause; |
| 7342 return javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual2(node.
interfaces, toNode.interfaces)); |
| 7343 } |
| 7344 bool visitImportDirective(ImportDirective node) { |
| 7345 ImportDirective toNode = this._toNode as ImportDirective; |
| 7346 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(javaBooleanAnd(javaBooleanAnd(isEqual(node.documentationComment, toNode.docum
entationComment), isEqual2(node.metadata, toNode.metadata)), isEqual3(node.keywo
rd, toNode.keyword)), isEqual(node.uri, toNode.uri)), isEqual3(node.asToken, toN
ode.asToken)), isEqual(node.prefix, toNode.prefix)), isEqual2(node.combinators,
toNode.combinators)), isEqual3(node.semicolon, toNode.semicolon))) { |
| 7347 toNode.element = node.element; |
| 7348 return true; |
| 7349 } |
| 7350 return false; |
| 7351 } |
| 7352 bool visitIndexExpression(IndexExpression node) { |
| 7353 IndexExpression toNode = this._toNode as IndexExpression; |
| 7354 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.target, toNode
.target), isEqual3(node.leftBracket, toNode.leftBracket)), isEqual(node.index, t
oNode.index)), isEqual3(node.rightBracket, toNode.rightBracket))) { |
| 7355 toNode.auxiliaryElements = node.auxiliaryElements; |
| 7356 toNode.propagatedElement = node.propagatedElement; |
| 7357 toNode.propagatedType = node.propagatedType; |
| 7358 toNode.staticElement = node.staticElement; |
| 7359 toNode.staticType = node.staticType; |
| 7360 return true; |
| 7361 } |
| 7362 return false; |
| 7363 } |
| 7364 bool visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 7365 InstanceCreationExpression toNode = this._toNode as InstanceCreationExpressi
on; |
| 7366 if (javaBooleanAnd(javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), is
Equal(node.constructorName, toNode.constructorName)), isEqual(node.argumentList,
toNode.argumentList))) { |
| 7367 toNode.propagatedType = node.propagatedType; |
| 7368 toNode.staticElement = node.staticElement; |
| 7369 toNode.staticType = node.staticType; |
| 7370 return true; |
| 7371 } |
| 7372 return false; |
| 7373 } |
| 7374 bool visitIntegerLiteral(IntegerLiteral node) { |
| 7375 IntegerLiteral toNode = this._toNode as IntegerLiteral; |
| 7376 if (javaBooleanAnd(isEqual3(node.literal, toNode.literal), identical(node.va
lue, toNode.value))) { |
| 7377 toNode.propagatedType = node.propagatedType; |
| 7378 toNode.staticType = node.staticType; |
| 7379 return true; |
| 7380 } |
| 7381 return false; |
| 7382 } |
| 7383 bool visitInterpolationExpression(InterpolationExpression node) { |
| 7384 InterpolationExpression toNode = this._toNode as InterpolationExpression; |
| 7385 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.leftBracket, toNode.leftB
racket), isEqual(node.expression, toNode.expression)), isEqual3(node.rightBracke
t, toNode.rightBracket)); |
| 7386 } |
| 7387 bool visitInterpolationString(InterpolationString node) { |
| 7388 InterpolationString toNode = this._toNode as InterpolationString; |
| 7389 return javaBooleanAnd(isEqual3(node.contents, toNode.contents), node.value =
= toNode.value); |
| 7390 } |
| 7391 bool visitIsExpression(IsExpression node) { |
| 7392 IsExpression toNode = this._toNode as IsExpression; |
| 7393 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.expression, to
Node.expression), isEqual3(node.isOperator, toNode.isOperator)), isEqual3(node.n
otOperator, toNode.notOperator)), isEqual(node.type, toNode.type))) { |
| 7394 toNode.propagatedType = node.propagatedType; |
| 7395 toNode.staticType = node.staticType; |
| 7396 return true; |
| 7397 } |
| 7398 return false; |
| 7399 } |
| 7400 bool visitLabel(Label node) { |
| 7401 Label toNode = this._toNode as Label; |
| 7402 return javaBooleanAnd(isEqual(node.label, toNode.label), isEqual3(node.colon
, toNode.colon)); |
| 7403 } |
| 7404 bool visitLabeledStatement(LabeledStatement node) { |
| 7405 LabeledStatement toNode = this._toNode as LabeledStatement; |
| 7406 return javaBooleanAnd(isEqual2(node.labels, toNode.labels), isEqual(node.sta
tement, toNode.statement)); |
| 7407 } |
| 7408 bool visitLibraryDirective(LibraryDirective node) { |
| 7409 LibraryDirective toNode = this._toNode as LibraryDirective; |
| 7410 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual3(node.libraryToken, toNode.libraryToken)), isEqual(no
de.name, toNode.name)), isEqual3(node.semicolon, toNode.semicolon)); |
| 7411 } |
| 7412 bool visitLibraryIdentifier(LibraryIdentifier node) { |
| 7413 LibraryIdentifier toNode = this._toNode as LibraryIdentifier; |
| 7414 if (isEqual2(node.components, toNode.components)) { |
| 7415 toNode.propagatedType = node.propagatedType; |
| 7416 toNode.staticType = node.staticType; |
| 7417 return true; |
| 7418 } |
| 7419 return false; |
| 7420 } |
| 7421 bool visitListLiteral(ListLiteral node) { |
| 7422 ListLiteral toNode = this._toNode as ListLiteral; |
| 7423 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(nod
e.constKeyword, toNode.constKeyword), isEqual(node.typeArguments, toNode.typeArg
uments)), isEqual3(node.leftBracket, toNode.leftBracket)), isEqual2(node.element
s, toNode.elements)), isEqual3(node.rightBracket, toNode.rightBracket))) { |
| 7424 toNode.propagatedType = node.propagatedType; |
| 7425 toNode.staticType = node.staticType; |
| 7426 return true; |
| 7427 } |
| 7428 return false; |
| 7429 } |
| 7430 bool visitMapLiteral(MapLiteral node) { |
| 7431 MapLiteral toNode = this._toNode as MapLiteral; |
| 7432 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(nod
e.constKeyword, toNode.constKeyword), isEqual(node.typeArguments, toNode.typeArg
uments)), isEqual3(node.leftBracket, toNode.leftBracket)), isEqual2(node.entries
, toNode.entries)), isEqual3(node.rightBracket, toNode.rightBracket))) { |
| 7433 toNode.propagatedType = node.propagatedType; |
| 7434 toNode.staticType = node.staticType; |
| 7435 return true; |
| 7436 } |
| 7437 return false; |
| 7438 } |
| 7439 bool visitMapLiteralEntry(MapLiteralEntry node) { |
| 7440 MapLiteralEntry toNode = this._toNode as MapLiteralEntry; |
| 7441 return javaBooleanAnd(javaBooleanAnd(isEqual(node.key, toNode.key), isEqual3
(node.separator, toNode.separator)), isEqual(node.value, toNode.value)); |
| 7442 } |
| 7443 bool visitMethodDeclaration(MethodDeclaration node) { |
| 7444 MethodDeclaration toNode = this._toNode as MethodDeclaration; |
| 7445 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.d
ocumentationComment, toNode.documentationComment), isEqual2(node.metadata, toNod
e.metadata)), isEqual3(node.externalKeyword, toNode.externalKeyword)), isEqual3(
node.modifierKeyword, toNode.modifierKeyword)), isEqual(node.returnType, toNode.
returnType)), isEqual3(node.propertyKeyword, toNode.propertyKeyword)), isEqual3(
node.propertyKeyword, toNode.propertyKeyword)), isEqual(node.name, toNode.name))
, isEqual(node.parameters, toNode.parameters)), isEqual(node.body, toNode.body))
; |
| 7446 } |
| 7447 bool visitMethodInvocation(MethodInvocation node) { |
| 7448 MethodInvocation toNode = this._toNode as MethodInvocation; |
| 7449 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.target, toNode
.target), isEqual3(node.period, toNode.period)), isEqual(node.methodName, toNode
.methodName)), isEqual(node.argumentList, toNode.argumentList))) { |
| 7450 toNode.propagatedType = node.propagatedType; |
| 7451 toNode.staticType = node.staticType; |
| 7452 return true; |
| 7453 } |
| 7454 return false; |
| 7455 } |
| 7456 bool visitNamedExpression(NamedExpression node) { |
| 7457 NamedExpression toNode = this._toNode as NamedExpression; |
| 7458 if (javaBooleanAnd(isEqual(node.name, toNode.name), isEqual(node.expression,
toNode.expression))) { |
| 7459 toNode.propagatedType = node.propagatedType; |
| 7460 toNode.staticType = node.staticType; |
| 7461 return true; |
| 7462 } |
| 7463 return false; |
| 7464 } |
| 7465 bool visitNativeClause(NativeClause node) { |
| 7466 NativeClause toNode = this._toNode as NativeClause; |
| 7467 return javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual(node.n
ame, toNode.name)); |
| 7468 } |
| 7469 bool visitNativeFunctionBody(NativeFunctionBody node) { |
| 7470 NativeFunctionBody toNode = this._toNode as NativeFunctionBody; |
| 7471 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.nativeToken, toNode.nativ
eToken), isEqual(node.stringLiteral, toNode.stringLiteral)), isEqual3(node.semic
olon, toNode.semicolon)); |
| 7472 } |
| 7473 bool visitNullLiteral(NullLiteral node) { |
| 7474 NullLiteral toNode = this._toNode as NullLiteral; |
| 7475 if (isEqual3(node.literal, toNode.literal)) { |
| 7476 toNode.propagatedType = node.propagatedType; |
| 7477 toNode.staticType = node.staticType; |
| 7478 return true; |
| 7479 } |
| 7480 return false; |
| 7481 } |
| 7482 bool visitParenthesizedExpression(ParenthesizedExpression node) { |
| 7483 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression; |
| 7484 if (javaBooleanAnd(javaBooleanAnd(isEqual3(node.leftParenthesis, toNode.left
Parenthesis), isEqual(node.expression, toNode.expression)), isEqual3(node.rightP
arenthesis, toNode.rightParenthesis))) { |
| 7485 toNode.propagatedType = node.propagatedType; |
| 7486 toNode.staticType = node.staticType; |
| 7487 return true; |
| 7488 } |
| 7489 return false; |
| 7490 } |
| 7491 bool visitPartDirective(PartDirective node) { |
| 7492 PartDirective toNode = this._toNode as PartDirective; |
| 7493 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node
.documentationComment, toNode.documentationComment), isEqual2(node.metadata, toN
ode.metadata)), isEqual3(node.partToken, toNode.partToken)), isEqual(node.uri, t
oNode.uri)), isEqual3(node.semicolon, toNode.semicolon))) { |
| 7494 toNode.element = node.element; |
| 7495 return true; |
| 7496 } |
| 7497 return false; |
| 7498 } |
| 7499 bool visitPartOfDirective(PartOfDirective node) { |
| 7500 PartOfDirective toNode = this._toNode as PartOfDirective; |
| 7501 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(isEqual(node.documentationComment, toNode.documentationComment), isEqual2(nod
e.metadata, toNode.metadata)), isEqual3(node.partToken, toNode.partToken)), isEq
ual3(node.ofToken, toNode.ofToken)), isEqual(node.libraryName, toNode.libraryNam
e)), isEqual3(node.semicolon, toNode.semicolon))) { |
| 7502 toNode.element = node.element; |
| 7503 return true; |
| 7504 } |
| 7505 return false; |
| 7506 } |
| 7507 bool visitPostfixExpression(PostfixExpression node) { |
| 7508 PostfixExpression toNode = this._toNode as PostfixExpression; |
| 7509 if (javaBooleanAnd(isEqual(node.operand, toNode.operand), isEqual3(node.oper
ator, toNode.operator))) { |
| 7510 toNode.propagatedElement = node.propagatedElement; |
| 7511 toNode.propagatedType = node.propagatedType; |
| 7512 toNode.staticElement = node.staticElement; |
| 7513 toNode.staticType = node.staticType; |
| 7514 return true; |
| 7515 } |
| 7516 return false; |
| 7517 } |
| 7518 bool visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 7519 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; |
| 7520 if (javaBooleanAnd(javaBooleanAnd(isEqual(node.prefix, toNode.prefix), isEqu
al3(node.period, toNode.period)), isEqual(node.identifier, toNode.identifier)))
{ |
| 7521 toNode.propagatedType = node.propagatedType; |
| 7522 toNode.staticType = node.staticType; |
| 7523 return true; |
| 7524 } |
| 7525 return false; |
| 7526 } |
| 7527 bool visitPrefixExpression(PrefixExpression node) { |
| 7528 PrefixExpression toNode = this._toNode as PrefixExpression; |
| 7529 if (javaBooleanAnd(isEqual3(node.operator, toNode.operator), isEqual(node.op
erand, toNode.operand))) { |
| 7530 toNode.propagatedElement = node.propagatedElement; |
| 7531 toNode.propagatedType = node.propagatedType; |
| 7532 toNode.staticElement = node.staticElement; |
| 7533 toNode.staticType = node.staticType; |
| 7534 return true; |
| 7535 } |
| 7536 return false; |
| 7537 } |
| 7538 bool visitPropertyAccess(PropertyAccess node) { |
| 7539 PropertyAccess toNode = this._toNode as PropertyAccess; |
| 7540 if (javaBooleanAnd(javaBooleanAnd(isEqual(node.target, toNode.target), isEqu
al3(node.operator, toNode.operator)), isEqual(node.propertyName, toNode.property
Name))) { |
| 7541 toNode.propagatedType = node.propagatedType; |
| 7542 toNode.staticType = node.staticType; |
| 7543 return true; |
| 7544 } |
| 7545 return false; |
| 7546 } |
| 7547 bool visitRedirectingConstructorInvocation(RedirectingConstructorInvocation no
de) { |
| 7548 RedirectingConstructorInvocation toNode = this._toNode as RedirectingConstru
ctorInvocation; |
| 7549 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(node.keyword, toNo
de.keyword), isEqual3(node.period, toNode.period)), isEqual(node.constructorName
, toNode.constructorName)), isEqual(node.argumentList, toNode.argumentList))) { |
| 7550 toNode.staticElement = node.staticElement; |
| 7551 return true; |
| 7552 } |
| 7553 return false; |
| 7554 } |
| 7555 bool visitRethrowExpression(RethrowExpression node) { |
| 7556 RethrowExpression toNode = this._toNode as RethrowExpression; |
| 7557 if (isEqual3(node.keyword, toNode.keyword)) { |
| 7558 toNode.propagatedType = node.propagatedType; |
| 7559 toNode.staticType = node.staticType; |
| 7560 return true; |
| 7561 } |
| 7562 return false; |
| 7563 } |
| 7564 bool visitReturnStatement(ReturnStatement node) { |
| 7565 ReturnStatement toNode = this._toNode as ReturnStatement; |
| 7566 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.keyword, toNode.keyword),
isEqual(node.expression, toNode.expression)), isEqual3(node.semicolon, toNode.s
emicolon)); |
| 7567 } |
| 7568 bool visitScriptTag(ScriptTag node) { |
| 7569 ScriptTag toNode = this._toNode as ScriptTag; |
| 7570 return isEqual3(node.scriptTag, toNode.scriptTag); |
| 7571 } |
| 7572 bool visitShowCombinator(ShowCombinator node) { |
| 7573 ShowCombinator toNode = this._toNode as ShowCombinator; |
| 7574 return javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual2(node.
shownNames, toNode.shownNames)); |
| 7575 } |
| 7576 bool visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 7577 SimpleFormalParameter toNode = this._toNode as SimpleFormalParameter; |
| 7578 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual3(node.keyword, toNode.keyword)), isEqual(node.type, t
oNode.type)), isEqual(node.identifier, toNode.identifier)); |
| 7579 } |
| 7580 bool visitSimpleIdentifier(SimpleIdentifier node) { |
| 7581 SimpleIdentifier toNode = this._toNode as SimpleIdentifier; |
| 7582 if (isEqual3(node.token, toNode.token)) { |
| 7583 toNode.staticElement = node.staticElement; |
| 7584 toNode.staticType = node.staticType; |
| 7585 toNode.propagatedElement = node.propagatedElement; |
| 7586 toNode.propagatedType = node.propagatedType; |
| 7587 toNode.auxiliaryElements = node.auxiliaryElements; |
| 7588 return true; |
| 7589 } |
| 7590 return false; |
| 7591 } |
| 7592 bool visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 7593 SimpleStringLiteral toNode = this._toNode as SimpleStringLiteral; |
| 7594 if (javaBooleanAnd(isEqual3(node.literal, toNode.literal), identical(node.va
lue, toNode.value))) { |
| 7595 toNode.propagatedType = node.propagatedType; |
| 7596 toNode.staticType = node.staticType; |
| 7597 return true; |
| 7598 } |
| 7599 return false; |
| 7600 } |
| 7601 bool visitStringInterpolation(StringInterpolation node) { |
| 7602 StringInterpolation toNode = this._toNode as StringInterpolation; |
| 7603 if (isEqual2(node.elements, toNode.elements)) { |
| 7604 toNode.propagatedType = node.propagatedType; |
| 7605 toNode.staticType = node.staticType; |
| 7606 return true; |
| 7607 } |
| 7608 return false; |
| 7609 } |
| 7610 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 7611 SuperConstructorInvocation toNode = this._toNode as SuperConstructorInvocati
on; |
| 7612 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(node.keyword, toNo
de.keyword), isEqual3(node.period, toNode.period)), isEqual(node.constructorName
, toNode.constructorName)), isEqual(node.argumentList, toNode.argumentList))) { |
| 7613 toNode.staticElement = node.staticElement; |
| 7614 return true; |
| 7615 } |
| 7616 return false; |
| 7617 } |
| 7618 bool visitSuperExpression(SuperExpression node) { |
| 7619 SuperExpression toNode = this._toNode as SuperExpression; |
| 7620 if (isEqual3(node.keyword, toNode.keyword)) { |
| 7621 toNode.propagatedType = node.propagatedType; |
| 7622 toNode.staticType = node.staticType; |
| 7623 return true; |
| 7624 } |
| 7625 return false; |
| 7626 } |
| 7627 bool visitSwitchCase(SwitchCase node) { |
| 7628 SwitchCase toNode = this._toNode as SwitchCase; |
| 7629 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual2(
node.labels, toNode.labels), isEqual3(node.keyword, toNode.keyword)), isEqual(no
de.expression, toNode.expression)), isEqual3(node.colon, toNode.colon)), isEqual
2(node.statements, toNode.statements)); |
| 7630 } |
| 7631 bool visitSwitchDefault(SwitchDefault node) { |
| 7632 SwitchDefault toNode = this._toNode as SwitchDefault; |
| 7633 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual2(node.labels, to
Node.labels), isEqual3(node.keyword, toNode.keyword)), isEqual3(node.colon, toNo
de.colon)), isEqual2(node.statements, toNode.statements)); |
| 7634 } |
| 7635 bool visitSwitchStatement(SwitchStatement node) { |
| 7636 SwitchStatement toNode = this._toNode as SwitchStatement; |
| 7637 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual3(node.leftP
arenthesis, toNode.leftParenthesis)), isEqual(node.expression, toNode.expression
)), isEqual3(node.rightParenthesis, toNode.rightParenthesis)), isEqual3(node.lef
tBracket, toNode.leftBracket)), isEqual2(node.members, toNode.members)), isEqual
3(node.rightBracket, toNode.rightBracket)); |
| 7638 } |
| 7639 bool visitSymbolLiteral(SymbolLiteral node) { |
| 7640 SymbolLiteral toNode = this._toNode as SymbolLiteral; |
| 7641 if (javaBooleanAnd(isEqual3(node.poundSign, toNode.poundSign), isEqual4(node
.components, toNode.components))) { |
| 7642 toNode.propagatedType = node.propagatedType; |
| 7643 toNode.staticType = node.staticType; |
| 7644 return true; |
| 7645 } |
| 7646 return false; |
| 7647 } |
| 7648 bool visitThisExpression(ThisExpression node) { |
| 7649 ThisExpression toNode = this._toNode as ThisExpression; |
| 7650 if (isEqual3(node.keyword, toNode.keyword)) { |
| 7651 toNode.propagatedType = node.propagatedType; |
| 7652 toNode.staticType = node.staticType; |
| 7653 return true; |
| 7654 } |
| 7655 return false; |
| 7656 } |
| 7657 bool visitThrowExpression(ThrowExpression node) { |
| 7658 ThrowExpression toNode = this._toNode as ThrowExpression; |
| 7659 if (javaBooleanAnd(isEqual3(node.keyword, toNode.keyword), isEqual(node.expr
ession, toNode.expression))) { |
| 7660 toNode.propagatedType = node.propagatedType; |
| 7661 toNode.staticType = node.staticType; |
| 7662 return true; |
| 7663 } |
| 7664 return false; |
| 7665 } |
| 7666 bool visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 7667 TopLevelVariableDeclaration toNode = this._toNode as TopLevelVariableDeclara
tion; |
| 7668 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(node.documentati
onComment, toNode.documentationComment), isEqual2(node.metadata, toNode.metadata
)), isEqual(node.variables, toNode.variables)), isEqual3(node.semicolon, toNode.
semicolon)); |
| 7669 } |
| 7670 bool visitTryStatement(TryStatement node) { |
| 7671 TryStatement toNode = this._toNode as TryStatement; |
| 7672 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(
node.tryKeyword, toNode.tryKeyword), isEqual(node.body, toNode.body)), isEqual2(
node.catchClauses, toNode.catchClauses)), isEqual3(node.finallyKeyword, toNode.f
inallyKeyword)), isEqual(node.finallyBlock, toNode.finallyBlock)); |
| 7673 } |
| 7674 bool visitTypeArgumentList(TypeArgumentList node) { |
| 7675 TypeArgumentList toNode = this._toNode as TypeArgumentList; |
| 7676 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.leftBracket, toNode.leftB
racket), isEqual2(node.arguments, toNode.arguments)), isEqual3(node.rightBracket
, toNode.rightBracket)); |
| 7677 } |
| 7678 bool visitTypeName(TypeName node) { |
| 7679 TypeName toNode = this._toNode as TypeName; |
| 7680 if (javaBooleanAnd(isEqual(node.name, toNode.name), isEqual(node.typeArgumen
ts, toNode.typeArguments))) { |
| 7681 toNode.type = node.type; |
| 7682 return true; |
| 7683 } |
| 7684 return false; |
| 7685 } |
| 7686 bool visitTypeParameter(TypeParameter node) { |
| 7687 TypeParameter toNode = this._toNode as TypeParameter; |
| 7688 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual(node.name, toNode.name)), isEqual3(node.keyword, toNo
de.keyword)), isEqual(node.bound, toNode.bound)); |
| 7689 } |
| 7690 bool visitTypeParameterList(TypeParameterList node) { |
| 7691 TypeParameterList toNode = this._toNode as TypeParameterList; |
| 7692 return javaBooleanAnd(javaBooleanAnd(isEqual3(node.leftBracket, toNode.leftB
racket), isEqual2(node.typeParameters, toNode.typeParameters)), isEqual3(node.ri
ghtBracket, toNode.rightBracket)); |
| 7693 } |
| 7694 bool visitVariableDeclaration(VariableDeclaration node) { |
| 7695 VariableDeclaration toNode = this._toNode as VariableDeclaration; |
| 7696 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual(node.name, toNode.name)), isEqual3(node.equals, toNod
e.equals)), isEqual(node.initializer, toNode.initializer)); |
| 7697 } |
| 7698 bool visitVariableDeclarationList(VariableDeclarationList node) { |
| 7699 VariableDeclarationList toNode = this._toNode as VariableDeclarationList; |
| 7700 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual(n
ode.documentationComment, toNode.documentationComment), isEqual2(node.metadata,
toNode.metadata)), isEqual3(node.keyword, toNode.keyword)), isEqual(node.type, t
oNode.type)), isEqual2(node.variables, toNode.variables)); |
| 7701 } |
| 7702 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 7703 VariableDeclarationStatement toNode = this._toNode as VariableDeclarationSta
tement; |
| 7704 return javaBooleanAnd(isEqual(node.variables, toNode.variables), isEqual3(no
de.semicolon, toNode.semicolon)); |
| 7705 } |
| 7706 bool visitWhileStatement(WhileStatement node) { |
| 7707 WhileStatement toNode = this._toNode as WhileStatement; |
| 7708 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqual3(
node.keyword, toNode.keyword), isEqual3(node.leftParenthesis, toNode.leftParenth
esis)), isEqual(node.condition, toNode.condition)), isEqual3(node.rightParenthes
is, toNode.rightParenthesis)), isEqual(node.body, toNode.body)); |
| 7709 } |
| 7710 bool visitWithClause(WithClause node) { |
| 7711 WithClause toNode = this._toNode as WithClause; |
| 7712 return javaBooleanAnd(isEqual3(node.withKeyword, toNode.withKeyword), isEqua
l2(node.mixinTypes, toNode.mixinTypes)); |
| 7713 } |
| 7714 |
| 7715 /** |
| 7716 * Return `true` if the given AST nodes have the same structure. As a side-eff
ect, if the |
| 7717 * nodes do have the same structure, any resolution data from the first node w
ill be copied to the |
| 7718 * second node. |
| 7719 * |
| 7720 * @param fromNode the node from which resolution information will be copied |
| 7721 * @param toNode the node to which resolution information will be copied |
| 7722 * @return `true` if the given AST nodes have the same structure |
| 7723 */ |
| 7724 bool isEqual(ASTNode fromNode, ASTNode toNode) { |
| 7725 if (fromNode == null) { |
| 7726 return toNode == null; |
| 7727 } else if (toNode == null) { |
| 7728 return false; |
| 7729 } else if (fromNode.runtimeType == toNode.runtimeType) { |
| 7730 this._toNode = toNode; |
| 7731 return fromNode.accept(this); |
| 7732 } |
| 7733 if (toNode is PrefixedIdentifier) { |
| 7734 SimpleIdentifier prefix = ((toNode as PrefixedIdentifier)).prefix; |
| 7735 if (fromNode.runtimeType == prefix.runtimeType) { |
| 7736 this._toNode = prefix; |
| 7737 return fromNode.accept(this); |
| 7738 } |
| 7739 } else if (toNode is PropertyAccess) { |
| 7740 Expression target = ((toNode as PropertyAccess)).target; |
| 7741 if (fromNode.runtimeType == target.runtimeType) { |
| 7742 this._toNode = target; |
| 7743 return fromNode.accept(this); |
| 7744 } |
| 7745 } |
| 7746 return false; |
| 7747 } |
| 7748 |
| 7749 /** |
| 7750 * Return `true` if the given lists of AST nodes have the same size and corres
ponding |
| 7751 * elements are equal. |
| 7752 * |
| 7753 * @param first the first node being compared |
| 7754 * @param second the second node being compared |
| 7755 * @return `true` if the given AST nodes have the same size and corresponding
elements are |
| 7756 * equal |
| 7757 */ |
| 7758 bool isEqual2(NodeList first, NodeList second) { |
| 7759 if (first == null) { |
| 7760 return second == null; |
| 7761 } else if (second == null) { |
| 7762 return false; |
| 7763 } |
| 7764 int size = first.length; |
| 7765 if (second.length != size) { |
| 7766 return false; |
| 7767 } |
| 7768 bool equal = true; |
| 7769 for (int i = 0; i < size; i++) { |
| 7770 if (!isEqual(first[i], second[i])) { |
| 7771 equal = false; |
| 7772 } |
| 7773 } |
| 7774 return equal; |
| 7775 } |
| 7776 |
| 7777 /** |
| 7778 * Return `true` if the given tokens have the same structure. |
| 7779 * |
| 7780 * @param first the first node being compared |
| 7781 * @param second the second node being compared |
| 7782 * @return `true` if the given tokens have the same structure |
| 7783 */ |
| 7784 bool isEqual3(Token first, Token second) { |
| 7785 if (first == null) { |
| 7786 return second == null; |
| 7787 } else if (second == null) { |
| 7788 return false; |
| 7789 } |
| 7790 return first.lexeme == second.lexeme; |
| 7791 } |
| 7792 |
| 7793 /** |
| 7794 * Return `true` if the given arrays of tokens have the same length and corres
ponding |
| 7795 * elements are equal. |
| 7796 * |
| 7797 * @param first the first node being compared |
| 7798 * @param second the second node being compared |
| 7799 * @return `true` if the given arrays of tokens have the same length and corre
sponding |
| 7800 * elements are equal |
| 7801 */ |
| 7802 bool isEqual4(List<Token> first, List<Token> second) { |
| 7803 int length = first.length; |
| 7804 if (second.length != length) { |
| 7805 return false; |
| 7806 } |
| 7807 for (int i = 0; i < length; i++) { |
| 7808 if (!isEqual3(first[i], second[i])) { |
| 7809 return false; |
| 7810 } |
| 7811 } |
| 7812 return true; |
| 7813 } |
| 7814 } |
| 7815 /** |
6006 * Instances of the class {link ToFormattedSourceVisitor} write a source represe
ntation of a visited | 7816 * Instances of the class {link ToFormattedSourceVisitor} write a source represe
ntation of a visited |
6007 * AST node (and all of it's children) to a writer. | 7817 * AST node (and all of it's children) to a writer. |
6008 */ | 7818 */ |
6009 class ToFormattedSourceVisitor implements ASTVisitor<Object> { | 7819 class ToFormattedSourceVisitor implements ASTVisitor<Object> { |
6010 | 7820 |
6011 /** | 7821 /** |
6012 * The writer to which the source is to be written. | 7822 * The writer to which the source is to be written. |
6013 */ | 7823 */ |
6014 PrintWriter _writer; | 7824 PrintWriter _writer; |
6015 int _indentLevel = 0; | 7825 int _indentLevel = 0; |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6945 if ("\n" == separator) { | 8755 if ("\n" == separator) { |
6946 _writer.print("\n"); | 8756 _writer.print("\n"); |
6947 indent(); | 8757 indent(); |
6948 } else if (i > 0) { | 8758 } else if (i > 0) { |
6949 _writer.print(separator); | 8759 _writer.print(separator); |
6950 } | 8760 } |
6951 _writer.print(tokens[i].lexeme); | 8761 _writer.print(tokens[i].lexeme); |
6952 } | 8762 } |
6953 } | 8763 } |
6954 } | 8764 } |
OLD | NEW |