Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: pkg/analyzer/lib/src/dart/ast/utilities.dart

Issue 1791953002: Move ResolutionCopier out of generated (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.dart.ast.utilities; 5 library analyzer.src.dart.ast.utilities;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 5010 matching lines...) Expand 10 before | Expand all | Expand 10 after
5021 if (parent == null) { 5021 if (parent == null) {
5022 throw new IllegalArgumentException( 5022 throw new IllegalArgumentException(
5023 "The old node is not a child of another node"); 5023 "The old node is not a child of another node");
5024 } 5024 }
5025 NodeReplacer replacer = new NodeReplacer(oldNode, newNode); 5025 NodeReplacer replacer = new NodeReplacer(oldNode, newNode);
5026 return parent.accept(replacer); 5026 return parent.accept(replacer);
5027 } 5027 }
5028 } 5028 }
5029 5029
5030 /** 5030 /**
5031 * An object that copies resolution information from one AST structure to
5032 * another as long as the structures of the corresponding children of a pair of
5033 * nodes are the same.
5034 */
5035 class ResolutionCopier implements AstVisitor<bool> {
5036 /**
5037 * The AST node with which the node being visited is to be compared. This is
5038 * only valid at the beginning of each visit method (until [isEqualNodes] is
5039 * invoked).
5040 */
5041 AstNode _toNode;
5042
5043 @override
5044 bool visitAdjacentStrings(AdjacentStrings node) {
5045 AdjacentStrings toNode = this._toNode as AdjacentStrings;
5046 if (_isEqualNodeLists(node.strings, toNode.strings)) {
5047 toNode.staticType = node.staticType;
5048 toNode.propagatedType = node.propagatedType;
5049 return true;
5050 }
5051 return false;
5052 }
5053
5054 @override
5055 bool visitAnnotation(Annotation node) {
5056 Annotation toNode = this._toNode as Annotation;
5057 if (_and(
5058 _isEqualTokens(node.atSign, toNode.atSign),
5059 _isEqualNodes(node.name, toNode.name),
5060 _isEqualTokens(node.period, toNode.period),
5061 _isEqualNodes(node.constructorName, toNode.constructorName),
5062 _isEqualNodes(node.arguments, toNode.arguments))) {
5063 toNode.element = node.element;
5064 return true;
5065 }
5066 return false;
5067 }
5068
5069 @override
5070 bool visitArgumentList(ArgumentList node) {
5071 ArgumentList toNode = this._toNode as ArgumentList;
5072 return _and(
5073 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5074 _isEqualNodeLists(node.arguments, toNode.arguments),
5075 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
5076 }
5077
5078 @override
5079 bool visitAsExpression(AsExpression node) {
5080 AsExpression toNode = this._toNode as AsExpression;
5081 if (_and(
5082 _isEqualNodes(node.expression, toNode.expression),
5083 _isEqualTokens(node.asOperator, toNode.asOperator),
5084 _isEqualNodes(node.type, toNode.type))) {
5085 toNode.propagatedType = node.propagatedType;
5086 toNode.staticType = node.staticType;
5087 return true;
5088 }
5089 return false;
5090 }
5091
5092 @override
5093 bool visitAssertStatement(AssertStatement node) {
5094 AssertStatement toNode = this._toNode as AssertStatement;
5095 return _and(
5096 _isEqualTokens(node.assertKeyword, toNode.assertKeyword),
5097 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5098 _isEqualNodes(node.condition, toNode.condition),
5099 _isEqualTokens(node.comma, toNode.comma),
5100 _isEqualNodes(node.message, toNode.message),
5101 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5102 _isEqualTokens(node.semicolon, toNode.semicolon));
5103 }
5104
5105 @override
5106 bool visitAssignmentExpression(AssignmentExpression node) {
5107 AssignmentExpression toNode = this._toNode as AssignmentExpression;
5108 if (_and(
5109 _isEqualNodes(node.leftHandSide, toNode.leftHandSide),
5110 _isEqualTokens(node.operator, toNode.operator),
5111 _isEqualNodes(node.rightHandSide, toNode.rightHandSide))) {
5112 toNode.propagatedElement = node.propagatedElement;
5113 toNode.propagatedType = node.propagatedType;
5114 toNode.staticElement = node.staticElement;
5115 toNode.staticType = node.staticType;
5116 return true;
5117 }
5118 return false;
5119 }
5120
5121 @override
5122 bool visitAwaitExpression(AwaitExpression node) {
5123 AwaitExpression toNode = this._toNode as AwaitExpression;
5124 if (_and(_isEqualTokens(node.awaitKeyword, toNode.awaitKeyword),
5125 _isEqualNodes(node.expression, toNode.expression))) {
5126 toNode.propagatedType = node.propagatedType;
5127 toNode.staticType = node.staticType;
5128 return true;
5129 }
5130 return false;
5131 }
5132
5133 @override
5134 bool visitBinaryExpression(BinaryExpression node) {
5135 BinaryExpression toNode = this._toNode as BinaryExpression;
5136 if (_and(
5137 _isEqualNodes(node.leftOperand, toNode.leftOperand),
5138 _isEqualTokens(node.operator, toNode.operator),
5139 _isEqualNodes(node.rightOperand, toNode.rightOperand))) {
5140 toNode.propagatedElement = node.propagatedElement;
5141 toNode.propagatedType = node.propagatedType;
5142 toNode.staticElement = node.staticElement;
5143 toNode.staticType = node.staticType;
5144 return true;
5145 }
5146 return false;
5147 }
5148
5149 @override
5150 bool visitBlock(Block node) {
5151 Block toNode = this._toNode as Block;
5152 return _and(
5153 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5154 _isEqualNodeLists(node.statements, toNode.statements),
5155 _isEqualTokens(node.rightBracket, toNode.rightBracket));
5156 }
5157
5158 @override
5159 bool visitBlockFunctionBody(BlockFunctionBody node) {
5160 BlockFunctionBody toNode = this._toNode as BlockFunctionBody;
5161 return _isEqualNodes(node.block, toNode.block);
5162 }
5163
5164 @override
5165 bool visitBooleanLiteral(BooleanLiteral node) {
5166 BooleanLiteral toNode = this._toNode as BooleanLiteral;
5167 if (_and(_isEqualTokens(node.literal, toNode.literal),
5168 node.value == toNode.value)) {
5169 toNode.propagatedType = node.propagatedType;
5170 toNode.staticType = node.staticType;
5171 return true;
5172 }
5173 return false;
5174 }
5175
5176 @override
5177 bool visitBreakStatement(BreakStatement node) {
5178 BreakStatement toNode = this._toNode as BreakStatement;
5179 if (_and(
5180 _isEqualTokens(node.breakKeyword, toNode.breakKeyword),
5181 _isEqualNodes(node.label, toNode.label),
5182 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5183 // TODO(paulberry): map node.target to toNode.target.
5184 return true;
5185 }
5186 return false;
5187 }
5188
5189 @override
5190 bool visitCascadeExpression(CascadeExpression node) {
5191 CascadeExpression toNode = this._toNode as CascadeExpression;
5192 if (_and(_isEqualNodes(node.target, toNode.target),
5193 _isEqualNodeLists(node.cascadeSections, toNode.cascadeSections))) {
5194 toNode.propagatedType = node.propagatedType;
5195 toNode.staticType = node.staticType;
5196 return true;
5197 }
5198 return false;
5199 }
5200
5201 @override
5202 bool visitCatchClause(CatchClause node) {
5203 CatchClause toNode = this._toNode as CatchClause;
5204 return _and(
5205 _isEqualTokens(node.onKeyword, toNode.onKeyword),
5206 _isEqualNodes(node.exceptionType, toNode.exceptionType),
5207 _isEqualTokens(node.catchKeyword, toNode.catchKeyword),
5208 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5209 _isEqualNodes(node.exceptionParameter, toNode.exceptionParameter),
5210 _isEqualTokens(node.comma, toNode.comma),
5211 _isEqualNodes(node.stackTraceParameter, toNode.stackTraceParameter),
5212 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5213 _isEqualNodes(node.body, toNode.body));
5214 }
5215
5216 @override
5217 bool visitClassDeclaration(ClassDeclaration node) {
5218 ClassDeclaration toNode = this._toNode as ClassDeclaration;
5219 return _and(
5220 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5221 _isEqualNodeLists(node.metadata, toNode.metadata),
5222 _isEqualTokens(node.abstractKeyword, toNode.abstractKeyword),
5223 _isEqualTokens(node.classKeyword, toNode.classKeyword),
5224 _isEqualNodes(node.name, toNode.name),
5225 _isEqualNodes(node.typeParameters, toNode.typeParameters),
5226 _isEqualNodes(node.extendsClause, toNode.extendsClause),
5227 _isEqualNodes(node.withClause, toNode.withClause),
5228 _isEqualNodes(node.implementsClause, toNode.implementsClause),
5229 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5230 _isEqualNodeLists(node.members, toNode.members),
5231 _isEqualTokens(node.rightBracket, toNode.rightBracket));
5232 }
5233
5234 @override
5235 bool visitClassTypeAlias(ClassTypeAlias node) {
5236 ClassTypeAlias toNode = this._toNode as ClassTypeAlias;
5237 return _and(
5238 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5239 _isEqualNodeLists(node.metadata, toNode.metadata),
5240 _isEqualTokens(node.typedefKeyword, toNode.typedefKeyword),
5241 _isEqualNodes(node.name, toNode.name),
5242 _isEqualNodes(node.typeParameters, toNode.typeParameters),
5243 _isEqualTokens(node.equals, toNode.equals),
5244 _isEqualTokens(node.abstractKeyword, toNode.abstractKeyword),
5245 _isEqualNodes(node.superclass, toNode.superclass),
5246 _isEqualNodes(node.withClause, toNode.withClause),
5247 _isEqualNodes(node.implementsClause, toNode.implementsClause),
5248 _isEqualTokens(node.semicolon, toNode.semicolon));
5249 }
5250
5251 @override
5252 bool visitComment(Comment node) {
5253 Comment toNode = this._toNode as Comment;
5254 return _isEqualNodeLists(node.references, toNode.references);
5255 }
5256
5257 @override
5258 bool visitCommentReference(CommentReference node) {
5259 CommentReference toNode = this._toNode as CommentReference;
5260 return _and(_isEqualTokens(node.newKeyword, toNode.newKeyword),
5261 _isEqualNodes(node.identifier, toNode.identifier));
5262 }
5263
5264 @override
5265 bool visitCompilationUnit(CompilationUnit node) {
5266 CompilationUnit toNode = this._toNode as CompilationUnit;
5267 if (_and(
5268 _isEqualTokens(node.beginToken, toNode.beginToken),
5269 _isEqualNodes(node.scriptTag, toNode.scriptTag),
5270 _isEqualNodeLists(node.directives, toNode.directives),
5271 _isEqualNodeLists(node.declarations, toNode.declarations),
5272 _isEqualTokens(node.endToken, toNode.endToken))) {
5273 toNode.element = node.element;
5274 return true;
5275 }
5276 return false;
5277 }
5278
5279 @override
5280 bool visitConditionalExpression(ConditionalExpression node) {
5281 ConditionalExpression toNode = this._toNode as ConditionalExpression;
5282 if (_and(
5283 _isEqualNodes(node.condition, toNode.condition),
5284 _isEqualTokens(node.question, toNode.question),
5285 _isEqualNodes(node.thenExpression, toNode.thenExpression),
5286 _isEqualTokens(node.colon, toNode.colon),
5287 _isEqualNodes(node.elseExpression, toNode.elseExpression))) {
5288 toNode.propagatedType = node.propagatedType;
5289 toNode.staticType = node.staticType;
5290 return true;
5291 }
5292 return false;
5293 }
5294
5295 @override
5296 bool visitConfiguration(Configuration node) {
5297 Configuration toNode = this._toNode as Configuration;
5298 if (_and(
5299 _isEqualTokens(node.ifKeyword, toNode.ifKeyword),
5300 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5301 _isEqualNodes(node.name, toNode.name),
5302 _isEqualTokens(node.equalToken, toNode.equalToken),
5303 _isEqualNodes(node.value, toNode.value),
5304 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5305 _isEqualNodes(node.libraryUri, toNode.libraryUri))) {
5306 return true;
5307 }
5308 return false;
5309 }
5310
5311 @override
5312 bool visitConstructorDeclaration(ConstructorDeclaration node) {
5313 ConstructorDeclaration toNode = this._toNode as ConstructorDeclaration;
5314 if (_and(
5315 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5316 _isEqualNodeLists(node.metadata, toNode.metadata),
5317 _isEqualTokens(node.externalKeyword, toNode.externalKeyword),
5318 _isEqualTokens(node.constKeyword, toNode.constKeyword),
5319 _isEqualTokens(node.factoryKeyword, toNode.factoryKeyword),
5320 _isEqualNodes(node.returnType, toNode.returnType),
5321 _isEqualTokens(node.period, toNode.period),
5322 _isEqualNodes(node.name, toNode.name),
5323 _isEqualNodes(node.parameters, toNode.parameters),
5324 _isEqualTokens(node.separator, toNode.separator),
5325 _isEqualNodeLists(node.initializers, toNode.initializers),
5326 _isEqualNodes(node.redirectedConstructor, toNode.redirectedConstructor),
5327 _isEqualNodes(node.body, toNode.body))) {
5328 toNode.element = node.element;
5329 return true;
5330 }
5331 return false;
5332 }
5333
5334 @override
5335 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
5336 ConstructorFieldInitializer toNode =
5337 this._toNode as ConstructorFieldInitializer;
5338 return _and(
5339 _isEqualTokens(node.thisKeyword, toNode.thisKeyword),
5340 _isEqualTokens(node.period, toNode.period),
5341 _isEqualNodes(node.fieldName, toNode.fieldName),
5342 _isEqualTokens(node.equals, toNode.equals),
5343 _isEqualNodes(node.expression, toNode.expression));
5344 }
5345
5346 @override
5347 bool visitConstructorName(ConstructorName node) {
5348 ConstructorName toNode = this._toNode as ConstructorName;
5349 if (_and(
5350 _isEqualNodes(node.type, toNode.type),
5351 _isEqualTokens(node.period, toNode.period),
5352 _isEqualNodes(node.name, toNode.name))) {
5353 toNode.staticElement = node.staticElement;
5354 return true;
5355 }
5356 return false;
5357 }
5358
5359 @override
5360 bool visitContinueStatement(ContinueStatement node) {
5361 ContinueStatement toNode = this._toNode as ContinueStatement;
5362 if (_and(
5363 _isEqualTokens(node.continueKeyword, toNode.continueKeyword),
5364 _isEqualNodes(node.label, toNode.label),
5365 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5366 // TODO(paulberry): map node.target to toNode.target.
5367 return true;
5368 }
5369 return false;
5370 }
5371
5372 @override
5373 bool visitDeclaredIdentifier(DeclaredIdentifier node) {
5374 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier;
5375 return _and(
5376 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5377 _isEqualNodeLists(node.metadata, toNode.metadata),
5378 _isEqualTokens(node.keyword, toNode.keyword),
5379 _isEqualNodes(node.type, toNode.type),
5380 _isEqualNodes(node.identifier, toNode.identifier));
5381 }
5382
5383 @override
5384 bool visitDefaultFormalParameter(DefaultFormalParameter node) {
5385 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter;
5386 return _and(
5387 _isEqualNodes(node.parameter, toNode.parameter),
5388 node.kind == toNode.kind,
5389 _isEqualTokens(node.separator, toNode.separator),
5390 _isEqualNodes(node.defaultValue, toNode.defaultValue));
5391 }
5392
5393 @override
5394 bool visitDoStatement(DoStatement node) {
5395 DoStatement toNode = this._toNode as DoStatement;
5396 return _and(
5397 _isEqualTokens(node.doKeyword, toNode.doKeyword),
5398 _isEqualNodes(node.body, toNode.body),
5399 _isEqualTokens(node.whileKeyword, toNode.whileKeyword),
5400 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5401 _isEqualNodes(node.condition, toNode.condition),
5402 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5403 _isEqualTokens(node.semicolon, toNode.semicolon));
5404 }
5405
5406 @override
5407 bool visitDottedName(DottedName node) {
5408 DottedName toNode = this._toNode as DottedName;
5409 return _isEqualNodeLists(node.components, toNode.components);
5410 }
5411
5412 @override
5413 bool visitDoubleLiteral(DoubleLiteral node) {
5414 DoubleLiteral toNode = this._toNode as DoubleLiteral;
5415 if (_and(_isEqualTokens(node.literal, toNode.literal),
5416 node.value == toNode.value)) {
5417 toNode.propagatedType = node.propagatedType;
5418 toNode.staticType = node.staticType;
5419 return true;
5420 }
5421 return false;
5422 }
5423
5424 @override
5425 bool visitEmptyFunctionBody(EmptyFunctionBody node) {
5426 EmptyFunctionBody toNode = this._toNode as EmptyFunctionBody;
5427 return _isEqualTokens(node.semicolon, toNode.semicolon);
5428 }
5429
5430 @override
5431 bool visitEmptyStatement(EmptyStatement node) {
5432 EmptyStatement toNode = this._toNode as EmptyStatement;
5433 return _isEqualTokens(node.semicolon, toNode.semicolon);
5434 }
5435
5436 @override
5437 bool visitEnumConstantDeclaration(EnumConstantDeclaration node) {
5438 EnumConstantDeclaration toNode = this._toNode as EnumConstantDeclaration;
5439 return _and(
5440 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5441 _isEqualNodeLists(node.metadata, toNode.metadata),
5442 _isEqualNodes(node.name, toNode.name));
5443 }
5444
5445 @override
5446 bool visitEnumDeclaration(EnumDeclaration node) {
5447 EnumDeclaration toNode = this._toNode as EnumDeclaration;
5448 return _and(
5449 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5450 _isEqualNodeLists(node.metadata, toNode.metadata),
5451 _isEqualTokens(node.enumKeyword, toNode.enumKeyword),
5452 _isEqualNodes(node.name, toNode.name),
5453 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5454 _isEqualNodeLists(node.constants, toNode.constants),
5455 _isEqualTokens(node.rightBracket, toNode.rightBracket));
5456 }
5457
5458 @override
5459 bool visitExportDirective(ExportDirective node) {
5460 ExportDirective toNode = this._toNode as ExportDirective;
5461 if (_and(
5462 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5463 _isEqualNodeLists(node.metadata, toNode.metadata),
5464 _isEqualTokens(node.keyword, toNode.keyword),
5465 _isEqualNodes(node.uri, toNode.uri),
5466 _isEqualNodeLists(node.combinators, toNode.combinators),
5467 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5468 toNode.element = node.element;
5469 return true;
5470 }
5471 return false;
5472 }
5473
5474 @override
5475 bool visitExpressionFunctionBody(ExpressionFunctionBody node) {
5476 ExpressionFunctionBody toNode = this._toNode as ExpressionFunctionBody;
5477 return _and(
5478 _isEqualTokens(node.functionDefinition, toNode.functionDefinition),
5479 _isEqualNodes(node.expression, toNode.expression),
5480 _isEqualTokens(node.semicolon, toNode.semicolon));
5481 }
5482
5483 @override
5484 bool visitExpressionStatement(ExpressionStatement node) {
5485 ExpressionStatement toNode = this._toNode as ExpressionStatement;
5486 return _and(_isEqualNodes(node.expression, toNode.expression),
5487 _isEqualTokens(node.semicolon, toNode.semicolon));
5488 }
5489
5490 @override
5491 bool visitExtendsClause(ExtendsClause node) {
5492 ExtendsClause toNode = this._toNode as ExtendsClause;
5493 return _and(_isEqualTokens(node.extendsKeyword, toNode.extendsKeyword),
5494 _isEqualNodes(node.superclass, toNode.superclass));
5495 }
5496
5497 @override
5498 bool visitFieldDeclaration(FieldDeclaration node) {
5499 FieldDeclaration toNode = this._toNode as FieldDeclaration;
5500 return _and(
5501 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5502 _isEqualNodeLists(node.metadata, toNode.metadata),
5503 _isEqualTokens(node.staticKeyword, toNode.staticKeyword),
5504 _isEqualNodes(node.fields, toNode.fields),
5505 _isEqualTokens(node.semicolon, toNode.semicolon));
5506 }
5507
5508 @override
5509 bool visitFieldFormalParameter(FieldFormalParameter node) {
5510 FieldFormalParameter toNode = this._toNode as FieldFormalParameter;
5511 return _and(
5512 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5513 _isEqualNodeLists(node.metadata, toNode.metadata),
5514 _isEqualTokens(node.keyword, toNode.keyword),
5515 _isEqualNodes(node.type, toNode.type),
5516 _isEqualTokens(node.thisKeyword, toNode.thisKeyword),
5517 _isEqualTokens(node.period, toNode.period),
5518 _isEqualNodes(node.identifier, toNode.identifier));
5519 }
5520
5521 @override
5522 bool visitForEachStatement(ForEachStatement node) {
5523 ForEachStatement toNode = this._toNode as ForEachStatement;
5524 return _and(
5525 _isEqualTokens(node.forKeyword, toNode.forKeyword),
5526 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5527 _isEqualNodes(node.loopVariable, toNode.loopVariable),
5528 _isEqualTokens(node.inKeyword, toNode.inKeyword),
5529 _isEqualNodes(node.iterable, toNode.iterable),
5530 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5531 _isEqualNodes(node.body, toNode.body));
5532 }
5533
5534 @override
5535 bool visitFormalParameterList(FormalParameterList node) {
5536 FormalParameterList toNode = this._toNode as FormalParameterList;
5537 return _and(
5538 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5539 _isEqualNodeLists(node.parameters, toNode.parameters),
5540 _isEqualTokens(node.leftDelimiter, toNode.leftDelimiter),
5541 _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter),
5542 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis));
5543 }
5544
5545 @override
5546 bool visitForStatement(ForStatement node) {
5547 ForStatement toNode = this._toNode as ForStatement;
5548 return _and(
5549 _isEqualTokens(node.forKeyword, toNode.forKeyword),
5550 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5551 _isEqualNodes(node.variables, toNode.variables),
5552 _isEqualNodes(node.initialization, toNode.initialization),
5553 _isEqualTokens(node.leftSeparator, toNode.leftSeparator),
5554 _isEqualNodes(node.condition, toNode.condition),
5555 _isEqualTokens(node.rightSeparator, toNode.rightSeparator),
5556 _isEqualNodeLists(node.updaters, toNode.updaters),
5557 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5558 _isEqualNodes(node.body, toNode.body));
5559 }
5560
5561 @override
5562 bool visitFunctionDeclaration(FunctionDeclaration node) {
5563 FunctionDeclaration toNode = this._toNode as FunctionDeclaration;
5564 return _and(
5565 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5566 _isEqualNodeLists(node.metadata, toNode.metadata),
5567 _isEqualTokens(node.externalKeyword, toNode.externalKeyword),
5568 _isEqualNodes(node.returnType, toNode.returnType),
5569 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword),
5570 _isEqualNodes(node.name, toNode.name),
5571 _isEqualNodes(node.functionExpression, toNode.functionExpression));
5572 }
5573
5574 @override
5575 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) {
5576 FunctionDeclarationStatement toNode =
5577 this._toNode as FunctionDeclarationStatement;
5578 return _isEqualNodes(node.functionDeclaration, toNode.functionDeclaration);
5579 }
5580
5581 @override
5582 bool visitFunctionExpression(FunctionExpression node) {
5583 FunctionExpression toNode = this._toNode as FunctionExpression;
5584 if (_and(_isEqualNodes(node.parameters, toNode.parameters),
5585 _isEqualNodes(node.body, toNode.body))) {
5586 toNode.element = node.element;
5587 toNode.propagatedType = node.propagatedType;
5588 toNode.staticType = node.staticType;
5589 return true;
5590 }
5591 return false;
5592 }
5593
5594 @override
5595 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
5596 FunctionExpressionInvocation toNode =
5597 this._toNode as FunctionExpressionInvocation;
5598 if (_and(_isEqualNodes(node.function, toNode.function),
5599 _isEqualNodes(node.argumentList, toNode.argumentList))) {
5600 toNode.propagatedElement = node.propagatedElement;
5601 toNode.propagatedInvokeType = node.propagatedInvokeType;
5602 toNode.propagatedType = node.propagatedType;
5603 toNode.staticInvokeType = node.staticInvokeType;
5604 toNode.staticElement = node.staticElement;
5605 toNode.staticType = node.staticType;
5606 return true;
5607 }
5608 return false;
5609 }
5610
5611 @override
5612 bool visitFunctionTypeAlias(FunctionTypeAlias node) {
5613 FunctionTypeAlias toNode = this._toNode as FunctionTypeAlias;
5614 return _and(
5615 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5616 _isEqualNodeLists(node.metadata, toNode.metadata),
5617 _isEqualTokens(node.typedefKeyword, toNode.typedefKeyword),
5618 _isEqualNodes(node.returnType, toNode.returnType),
5619 _isEqualNodes(node.name, toNode.name),
5620 _isEqualNodes(node.typeParameters, toNode.typeParameters),
5621 _isEqualNodes(node.parameters, toNode.parameters),
5622 _isEqualTokens(node.semicolon, toNode.semicolon));
5623 }
5624
5625 @override
5626 bool visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
5627 FunctionTypedFormalParameter toNode =
5628 this._toNode as FunctionTypedFormalParameter;
5629 return _and(
5630 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5631 _isEqualNodeLists(node.metadata, toNode.metadata),
5632 _isEqualNodes(node.returnType, toNode.returnType),
5633 _isEqualNodes(node.identifier, toNode.identifier),
5634 _isEqualNodes(node.parameters, toNode.parameters));
5635 }
5636
5637 @override
5638 bool visitHideCombinator(HideCombinator node) {
5639 HideCombinator toNode = this._toNode as HideCombinator;
5640 return _and(_isEqualTokens(node.keyword, toNode.keyword),
5641 _isEqualNodeLists(node.hiddenNames, toNode.hiddenNames));
5642 }
5643
5644 @override
5645 bool visitIfStatement(IfStatement node) {
5646 IfStatement toNode = this._toNode as IfStatement;
5647 return _and(
5648 _isEqualTokens(node.ifKeyword, toNode.ifKeyword),
5649 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5650 _isEqualNodes(node.condition, toNode.condition),
5651 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
5652 _isEqualNodes(node.thenStatement, toNode.thenStatement),
5653 _isEqualTokens(node.elseKeyword, toNode.elseKeyword),
5654 _isEqualNodes(node.elseStatement, toNode.elseStatement));
5655 }
5656
5657 @override
5658 bool visitImplementsClause(ImplementsClause node) {
5659 ImplementsClause toNode = this._toNode as ImplementsClause;
5660 return _and(
5661 _isEqualTokens(node.implementsKeyword, toNode.implementsKeyword),
5662 _isEqualNodeLists(node.interfaces, toNode.interfaces));
5663 }
5664
5665 @override
5666 bool visitImportDirective(ImportDirective node) {
5667 ImportDirective toNode = this._toNode as ImportDirective;
5668 if (_and(
5669 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5670 _isEqualNodeLists(node.metadata, toNode.metadata),
5671 _isEqualTokens(node.keyword, toNode.keyword),
5672 _isEqualNodes(node.uri, toNode.uri),
5673 _isEqualTokens(node.asKeyword, toNode.asKeyword),
5674 _isEqualNodes(node.prefix, toNode.prefix),
5675 _isEqualNodeLists(node.combinators, toNode.combinators),
5676 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5677 toNode.element = node.element;
5678 return true;
5679 }
5680 return false;
5681 }
5682
5683 @override
5684 bool visitIndexExpression(IndexExpression node) {
5685 IndexExpression toNode = this._toNode as IndexExpression;
5686 if (_and(
5687 _isEqualNodes(node.target, toNode.target),
5688 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5689 _isEqualNodes(node.index, toNode.index),
5690 _isEqualTokens(node.rightBracket, toNode.rightBracket))) {
5691 toNode.auxiliaryElements = node.auxiliaryElements;
5692 toNode.propagatedElement = node.propagatedElement;
5693 toNode.propagatedType = node.propagatedType;
5694 toNode.staticElement = node.staticElement;
5695 toNode.staticType = node.staticType;
5696 return true;
5697 }
5698 return false;
5699 }
5700
5701 @override
5702 bool visitInstanceCreationExpression(InstanceCreationExpression node) {
5703 InstanceCreationExpression toNode =
5704 this._toNode as InstanceCreationExpression;
5705 if (_and(
5706 _isEqualTokens(node.keyword, toNode.keyword),
5707 _isEqualNodes(node.constructorName, toNode.constructorName),
5708 _isEqualNodes(node.argumentList, toNode.argumentList))) {
5709 toNode.propagatedType = node.propagatedType;
5710 toNode.staticElement = node.staticElement;
5711 toNode.staticType = node.staticType;
5712 return true;
5713 }
5714 return false;
5715 }
5716
5717 @override
5718 bool visitIntegerLiteral(IntegerLiteral node) {
5719 IntegerLiteral toNode = this._toNode as IntegerLiteral;
5720 if (_and(_isEqualTokens(node.literal, toNode.literal),
5721 node.value == toNode.value)) {
5722 toNode.propagatedType = node.propagatedType;
5723 toNode.staticType = node.staticType;
5724 return true;
5725 }
5726 return false;
5727 }
5728
5729 @override
5730 bool visitInterpolationExpression(InterpolationExpression node) {
5731 InterpolationExpression toNode = this._toNode as InterpolationExpression;
5732 return _and(
5733 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5734 _isEqualNodes(node.expression, toNode.expression),
5735 _isEqualTokens(node.rightBracket, toNode.rightBracket));
5736 }
5737
5738 @override
5739 bool visitInterpolationString(InterpolationString node) {
5740 InterpolationString toNode = this._toNode as InterpolationString;
5741 return _and(_isEqualTokens(node.contents, toNode.contents),
5742 node.value == toNode.value);
5743 }
5744
5745 @override
5746 bool visitIsExpression(IsExpression node) {
5747 IsExpression toNode = this._toNode as IsExpression;
5748 if (_and(
5749 _isEqualNodes(node.expression, toNode.expression),
5750 _isEqualTokens(node.isOperator, toNode.isOperator),
5751 _isEqualTokens(node.notOperator, toNode.notOperator),
5752 _isEqualNodes(node.type, toNode.type))) {
5753 toNode.propagatedType = node.propagatedType;
5754 toNode.staticType = node.staticType;
5755 return true;
5756 }
5757 return false;
5758 }
5759
5760 @override
5761 bool visitLabel(Label node) {
5762 Label toNode = this._toNode as Label;
5763 return _and(_isEqualNodes(node.label, toNode.label),
5764 _isEqualTokens(node.colon, toNode.colon));
5765 }
5766
5767 @override
5768 bool visitLabeledStatement(LabeledStatement node) {
5769 LabeledStatement toNode = this._toNode as LabeledStatement;
5770 return _and(_isEqualNodeLists(node.labels, toNode.labels),
5771 _isEqualNodes(node.statement, toNode.statement));
5772 }
5773
5774 @override
5775 bool visitLibraryDirective(LibraryDirective node) {
5776 LibraryDirective toNode = this._toNode as LibraryDirective;
5777 if (_and(
5778 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5779 _isEqualNodeLists(node.metadata, toNode.metadata),
5780 _isEqualTokens(node.libraryKeyword, toNode.libraryKeyword),
5781 _isEqualNodes(node.name, toNode.name),
5782 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5783 toNode.element = node.element;
5784 return true;
5785 }
5786 return false;
5787 }
5788
5789 @override
5790 bool visitLibraryIdentifier(LibraryIdentifier node) {
5791 LibraryIdentifier toNode = this._toNode as LibraryIdentifier;
5792 if (_isEqualNodeLists(node.components, toNode.components)) {
5793 toNode.propagatedType = node.propagatedType;
5794 toNode.staticType = node.staticType;
5795 return true;
5796 }
5797 return false;
5798 }
5799
5800 @override
5801 bool visitListLiteral(ListLiteral node) {
5802 ListLiteral toNode = this._toNode as ListLiteral;
5803 if (_and(
5804 _isEqualTokens(node.constKeyword, toNode.constKeyword),
5805 _isEqualNodes(node.typeArguments, toNode.typeArguments),
5806 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5807 _isEqualNodeLists(node.elements, toNode.elements),
5808 _isEqualTokens(node.rightBracket, toNode.rightBracket))) {
5809 toNode.propagatedType = node.propagatedType;
5810 toNode.staticType = node.staticType;
5811 return true;
5812 }
5813 return false;
5814 }
5815
5816 @override
5817 bool visitMapLiteral(MapLiteral node) {
5818 MapLiteral toNode = this._toNode as MapLiteral;
5819 if (_and(
5820 _isEqualTokens(node.constKeyword, toNode.constKeyword),
5821 _isEqualNodes(node.typeArguments, toNode.typeArguments),
5822 _isEqualTokens(node.leftBracket, toNode.leftBracket),
5823 _isEqualNodeLists(node.entries, toNode.entries),
5824 _isEqualTokens(node.rightBracket, toNode.rightBracket))) {
5825 toNode.propagatedType = node.propagatedType;
5826 toNode.staticType = node.staticType;
5827 return true;
5828 }
5829 return false;
5830 }
5831
5832 @override
5833 bool visitMapLiteralEntry(MapLiteralEntry node) {
5834 MapLiteralEntry toNode = this._toNode as MapLiteralEntry;
5835 return _and(
5836 _isEqualNodes(node.key, toNode.key),
5837 _isEqualTokens(node.separator, toNode.separator),
5838 _isEqualNodes(node.value, toNode.value));
5839 }
5840
5841 @override
5842 bool visitMethodDeclaration(MethodDeclaration node) {
5843 MethodDeclaration toNode = this._toNode as MethodDeclaration;
5844 return _and(
5845 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5846 _isEqualNodeLists(node.metadata, toNode.metadata),
5847 _isEqualTokens(node.externalKeyword, toNode.externalKeyword),
5848 _isEqualTokens(node.modifierKeyword, toNode.modifierKeyword),
5849 _isEqualNodes(node.returnType, toNode.returnType),
5850 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword),
5851 _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword),
5852 _isEqualNodes(node.name, toNode.name),
5853 _isEqualNodes(node.parameters, toNode.parameters),
5854 _isEqualNodes(node.body, toNode.body));
5855 }
5856
5857 @override
5858 bool visitMethodInvocation(MethodInvocation node) {
5859 MethodInvocation toNode = this._toNode as MethodInvocation;
5860 if (_and(
5861 _isEqualNodes(node.target, toNode.target),
5862 _isEqualTokens(node.operator, toNode.operator),
5863 _isEqualNodes(node.methodName, toNode.methodName),
5864 _isEqualNodes(node.argumentList, toNode.argumentList))) {
5865 toNode.propagatedInvokeType = node.propagatedInvokeType;
5866 toNode.propagatedType = node.propagatedType;
5867 toNode.staticInvokeType = node.staticInvokeType;
5868 toNode.staticType = node.staticType;
5869 return true;
5870 }
5871 return false;
5872 }
5873
5874 @override
5875 bool visitNamedExpression(NamedExpression node) {
5876 NamedExpression toNode = this._toNode as NamedExpression;
5877 if (_and(_isEqualNodes(node.name, toNode.name),
5878 _isEqualNodes(node.expression, toNode.expression))) {
5879 toNode.propagatedType = node.propagatedType;
5880 toNode.staticType = node.staticType;
5881 return true;
5882 }
5883 return false;
5884 }
5885
5886 @override
5887 bool visitNativeClause(NativeClause node) {
5888 NativeClause toNode = this._toNode as NativeClause;
5889 return _and(_isEqualTokens(node.nativeKeyword, toNode.nativeKeyword),
5890 _isEqualNodes(node.name, toNode.name));
5891 }
5892
5893 @override
5894 bool visitNativeFunctionBody(NativeFunctionBody node) {
5895 NativeFunctionBody toNode = this._toNode as NativeFunctionBody;
5896 return _and(
5897 _isEqualTokens(node.nativeKeyword, toNode.nativeKeyword),
5898 _isEqualNodes(node.stringLiteral, toNode.stringLiteral),
5899 _isEqualTokens(node.semicolon, toNode.semicolon));
5900 }
5901
5902 @override
5903 bool visitNullLiteral(NullLiteral node) {
5904 NullLiteral toNode = this._toNode as NullLiteral;
5905 if (_isEqualTokens(node.literal, toNode.literal)) {
5906 toNode.propagatedType = node.propagatedType;
5907 toNode.staticType = node.staticType;
5908 return true;
5909 }
5910 return false;
5911 }
5912
5913 @override
5914 bool visitParenthesizedExpression(ParenthesizedExpression node) {
5915 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression;
5916 if (_and(
5917 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
5918 _isEqualNodes(node.expression, toNode.expression),
5919 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis))) {
5920 toNode.propagatedType = node.propagatedType;
5921 toNode.staticType = node.staticType;
5922 return true;
5923 }
5924 return false;
5925 }
5926
5927 @override
5928 bool visitPartDirective(PartDirective node) {
5929 PartDirective toNode = this._toNode as PartDirective;
5930 if (_and(
5931 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5932 _isEqualNodeLists(node.metadata, toNode.metadata),
5933 _isEqualTokens(node.partKeyword, toNode.partKeyword),
5934 _isEqualNodes(node.uri, toNode.uri),
5935 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5936 toNode.element = node.element;
5937 return true;
5938 }
5939 return false;
5940 }
5941
5942 @override
5943 bool visitPartOfDirective(PartOfDirective node) {
5944 PartOfDirective toNode = this._toNode as PartOfDirective;
5945 if (_and(
5946 _isEqualNodes(node.documentationComment, toNode.documentationComment),
5947 _isEqualNodeLists(node.metadata, toNode.metadata),
5948 _isEqualTokens(node.partKeyword, toNode.partKeyword),
5949 _isEqualTokens(node.ofKeyword, toNode.ofKeyword),
5950 _isEqualNodes(node.libraryName, toNode.libraryName),
5951 _isEqualTokens(node.semicolon, toNode.semicolon))) {
5952 toNode.element = node.element;
5953 return true;
5954 }
5955 return false;
5956 }
5957
5958 @override
5959 bool visitPostfixExpression(PostfixExpression node) {
5960 PostfixExpression toNode = this._toNode as PostfixExpression;
5961 if (_and(_isEqualNodes(node.operand, toNode.operand),
5962 _isEqualTokens(node.operator, toNode.operator))) {
5963 toNode.propagatedElement = node.propagatedElement;
5964 toNode.propagatedType = node.propagatedType;
5965 toNode.staticElement = node.staticElement;
5966 toNode.staticType = node.staticType;
5967 return true;
5968 }
5969 return false;
5970 }
5971
5972 @override
5973 bool visitPrefixedIdentifier(PrefixedIdentifier node) {
5974 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier;
5975 if (_and(
5976 _isEqualNodes(node.prefix, toNode.prefix),
5977 _isEqualTokens(node.period, toNode.period),
5978 _isEqualNodes(node.identifier, toNode.identifier))) {
5979 toNode.propagatedType = node.propagatedType;
5980 toNode.staticType = node.staticType;
5981 return true;
5982 }
5983 return false;
5984 }
5985
5986 @override
5987 bool visitPrefixExpression(PrefixExpression node) {
5988 PrefixExpression toNode = this._toNode as PrefixExpression;
5989 if (_and(_isEqualTokens(node.operator, toNode.operator),
5990 _isEqualNodes(node.operand, toNode.operand))) {
5991 toNode.propagatedElement = node.propagatedElement;
5992 toNode.propagatedType = node.propagatedType;
5993 toNode.staticElement = node.staticElement;
5994 toNode.staticType = node.staticType;
5995 return true;
5996 }
5997 return false;
5998 }
5999
6000 @override
6001 bool visitPropertyAccess(PropertyAccess node) {
6002 PropertyAccess toNode = this._toNode as PropertyAccess;
6003 if (_and(
6004 _isEqualNodes(node.target, toNode.target),
6005 _isEqualTokens(node.operator, toNode.operator),
6006 _isEqualNodes(node.propertyName, toNode.propertyName))) {
6007 toNode.propagatedType = node.propagatedType;
6008 toNode.staticType = node.staticType;
6009 return true;
6010 }
6011 return false;
6012 }
6013
6014 @override
6015 bool visitRedirectingConstructorInvocation(
6016 RedirectingConstructorInvocation node) {
6017 RedirectingConstructorInvocation toNode =
6018 this._toNode as RedirectingConstructorInvocation;
6019 if (_and(
6020 _isEqualTokens(node.thisKeyword, toNode.thisKeyword),
6021 _isEqualTokens(node.period, toNode.period),
6022 _isEqualNodes(node.constructorName, toNode.constructorName),
6023 _isEqualNodes(node.argumentList, toNode.argumentList))) {
6024 toNode.staticElement = node.staticElement;
6025 return true;
6026 }
6027 return false;
6028 }
6029
6030 @override
6031 bool visitRethrowExpression(RethrowExpression node) {
6032 RethrowExpression toNode = this._toNode as RethrowExpression;
6033 if (_isEqualTokens(node.rethrowKeyword, toNode.rethrowKeyword)) {
6034 toNode.propagatedType = node.propagatedType;
6035 toNode.staticType = node.staticType;
6036 return true;
6037 }
6038 return false;
6039 }
6040
6041 @override
6042 bool visitReturnStatement(ReturnStatement node) {
6043 ReturnStatement toNode = this._toNode as ReturnStatement;
6044 return _and(
6045 _isEqualTokens(node.returnKeyword, toNode.returnKeyword),
6046 _isEqualNodes(node.expression, toNode.expression),
6047 _isEqualTokens(node.semicolon, toNode.semicolon));
6048 }
6049
6050 @override
6051 bool visitScriptTag(ScriptTag node) {
6052 ScriptTag toNode = this._toNode as ScriptTag;
6053 return _isEqualTokens(node.scriptTag, toNode.scriptTag);
6054 }
6055
6056 @override
6057 bool visitShowCombinator(ShowCombinator node) {
6058 ShowCombinator toNode = this._toNode as ShowCombinator;
6059 return _and(_isEqualTokens(node.keyword, toNode.keyword),
6060 _isEqualNodeLists(node.shownNames, toNode.shownNames));
6061 }
6062
6063 @override
6064 bool visitSimpleFormalParameter(SimpleFormalParameter node) {
6065 SimpleFormalParameter toNode = this._toNode as SimpleFormalParameter;
6066 return _and(
6067 _isEqualNodes(node.documentationComment, toNode.documentationComment),
6068 _isEqualNodeLists(node.metadata, toNode.metadata),
6069 _isEqualTokens(node.keyword, toNode.keyword),
6070 _isEqualNodes(node.type, toNode.type),
6071 _isEqualNodes(node.identifier, toNode.identifier));
6072 }
6073
6074 @override
6075 bool visitSimpleIdentifier(SimpleIdentifier node) {
6076 SimpleIdentifier toNode = this._toNode as SimpleIdentifier;
6077 if (_isEqualTokens(node.token, toNode.token)) {
6078 toNode.staticElement = node.staticElement;
6079 toNode.staticType = node.staticType;
6080 toNode.propagatedElement = node.propagatedElement;
6081 toNode.propagatedType = node.propagatedType;
6082 toNode.auxiliaryElements = node.auxiliaryElements;
6083 return true;
6084 }
6085 return false;
6086 }
6087
6088 @override
6089 bool visitSimpleStringLiteral(SimpleStringLiteral node) {
6090 SimpleStringLiteral toNode = this._toNode as SimpleStringLiteral;
6091 if (_and(_isEqualTokens(node.literal, toNode.literal),
6092 node.value == toNode.value)) {
6093 toNode.propagatedType = node.propagatedType;
6094 toNode.staticType = node.staticType;
6095 return true;
6096 }
6097 return false;
6098 }
6099
6100 @override
6101 bool visitStringInterpolation(StringInterpolation node) {
6102 StringInterpolation toNode = this._toNode as StringInterpolation;
6103 if (_isEqualNodeLists(node.elements, toNode.elements)) {
6104 toNode.propagatedType = node.propagatedType;
6105 toNode.staticType = node.staticType;
6106 return true;
6107 }
6108 return false;
6109 }
6110
6111 @override
6112 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) {
6113 SuperConstructorInvocation toNode =
6114 this._toNode as SuperConstructorInvocation;
6115 if (_and(
6116 _isEqualTokens(node.superKeyword, toNode.superKeyword),
6117 _isEqualTokens(node.period, toNode.period),
6118 _isEqualNodes(node.constructorName, toNode.constructorName),
6119 _isEqualNodes(node.argumentList, toNode.argumentList))) {
6120 toNode.staticElement = node.staticElement;
6121 return true;
6122 }
6123 return false;
6124 }
6125
6126 @override
6127 bool visitSuperExpression(SuperExpression node) {
6128 SuperExpression toNode = this._toNode as SuperExpression;
6129 if (_isEqualTokens(node.superKeyword, toNode.superKeyword)) {
6130 toNode.propagatedType = node.propagatedType;
6131 toNode.staticType = node.staticType;
6132 return true;
6133 }
6134 return false;
6135 }
6136
6137 @override
6138 bool visitSwitchCase(SwitchCase node) {
6139 SwitchCase toNode = this._toNode as SwitchCase;
6140 return _and(
6141 _isEqualNodeLists(node.labels, toNode.labels),
6142 _isEqualTokens(node.keyword, toNode.keyword),
6143 _isEqualNodes(node.expression, toNode.expression),
6144 _isEqualTokens(node.colon, toNode.colon),
6145 _isEqualNodeLists(node.statements, toNode.statements));
6146 }
6147
6148 @override
6149 bool visitSwitchDefault(SwitchDefault node) {
6150 SwitchDefault toNode = this._toNode as SwitchDefault;
6151 return _and(
6152 _isEqualNodeLists(node.labels, toNode.labels),
6153 _isEqualTokens(node.keyword, toNode.keyword),
6154 _isEqualTokens(node.colon, toNode.colon),
6155 _isEqualNodeLists(node.statements, toNode.statements));
6156 }
6157
6158 @override
6159 bool visitSwitchStatement(SwitchStatement node) {
6160 SwitchStatement toNode = this._toNode as SwitchStatement;
6161 return _and(
6162 _isEqualTokens(node.switchKeyword, toNode.switchKeyword),
6163 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
6164 _isEqualNodes(node.expression, toNode.expression),
6165 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
6166 _isEqualTokens(node.leftBracket, toNode.leftBracket),
6167 _isEqualNodeLists(node.members, toNode.members),
6168 _isEqualTokens(node.rightBracket, toNode.rightBracket));
6169 }
6170
6171 @override
6172 bool visitSymbolLiteral(SymbolLiteral node) {
6173 SymbolLiteral toNode = this._toNode as SymbolLiteral;
6174 if (_and(_isEqualTokens(node.poundSign, toNode.poundSign),
6175 _isEqualTokenLists(node.components, toNode.components))) {
6176 toNode.propagatedType = node.propagatedType;
6177 toNode.staticType = node.staticType;
6178 return true;
6179 }
6180 return false;
6181 }
6182
6183 @override
6184 bool visitThisExpression(ThisExpression node) {
6185 ThisExpression toNode = this._toNode as ThisExpression;
6186 if (_isEqualTokens(node.thisKeyword, toNode.thisKeyword)) {
6187 toNode.propagatedType = node.propagatedType;
6188 toNode.staticType = node.staticType;
6189 return true;
6190 }
6191 return false;
6192 }
6193
6194 @override
6195 bool visitThrowExpression(ThrowExpression node) {
6196 ThrowExpression toNode = this._toNode as ThrowExpression;
6197 if (_and(_isEqualTokens(node.throwKeyword, toNode.throwKeyword),
6198 _isEqualNodes(node.expression, toNode.expression))) {
6199 toNode.propagatedType = node.propagatedType;
6200 toNode.staticType = node.staticType;
6201 return true;
6202 }
6203 return false;
6204 }
6205
6206 @override
6207 bool visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
6208 TopLevelVariableDeclaration toNode =
6209 this._toNode as TopLevelVariableDeclaration;
6210 return _and(
6211 _isEqualNodes(node.documentationComment, toNode.documentationComment),
6212 _isEqualNodeLists(node.metadata, toNode.metadata),
6213 _isEqualNodes(node.variables, toNode.variables),
6214 _isEqualTokens(node.semicolon, toNode.semicolon));
6215 }
6216
6217 @override
6218 bool visitTryStatement(TryStatement node) {
6219 TryStatement toNode = this._toNode as TryStatement;
6220 return _and(
6221 _isEqualTokens(node.tryKeyword, toNode.tryKeyword),
6222 _isEqualNodes(node.body, toNode.body),
6223 _isEqualNodeLists(node.catchClauses, toNode.catchClauses),
6224 _isEqualTokens(node.finallyKeyword, toNode.finallyKeyword),
6225 _isEqualNodes(node.finallyBlock, toNode.finallyBlock));
6226 }
6227
6228 @override
6229 bool visitTypeArgumentList(TypeArgumentList node) {
6230 TypeArgumentList toNode = this._toNode as TypeArgumentList;
6231 return _and(
6232 _isEqualTokens(node.leftBracket, toNode.leftBracket),
6233 _isEqualNodeLists(node.arguments, toNode.arguments),
6234 _isEqualTokens(node.rightBracket, toNode.rightBracket));
6235 }
6236
6237 @override
6238 bool visitTypeName(TypeName node) {
6239 TypeName toNode = this._toNode as TypeName;
6240 if (_and(_isEqualNodes(node.name, toNode.name),
6241 _isEqualNodes(node.typeArguments, toNode.typeArguments))) {
6242 toNode.type = node.type;
6243 return true;
6244 }
6245 return false;
6246 }
6247
6248 @override
6249 bool visitTypeParameter(TypeParameter node) {
6250 TypeParameter toNode = this._toNode as TypeParameter;
6251 return _and(
6252 _isEqualNodes(node.documentationComment, toNode.documentationComment),
6253 _isEqualNodeLists(node.metadata, toNode.metadata),
6254 _isEqualNodes(node.name, toNode.name),
6255 _isEqualTokens(node.extendsKeyword, toNode.extendsKeyword),
6256 _isEqualNodes(node.bound, toNode.bound));
6257 }
6258
6259 @override
6260 bool visitTypeParameterList(TypeParameterList node) {
6261 TypeParameterList toNode = this._toNode as TypeParameterList;
6262 return _and(
6263 _isEqualTokens(node.leftBracket, toNode.leftBracket),
6264 _isEqualNodeLists(node.typeParameters, toNode.typeParameters),
6265 _isEqualTokens(node.rightBracket, toNode.rightBracket));
6266 }
6267
6268 @override
6269 bool visitVariableDeclaration(VariableDeclaration node) {
6270 VariableDeclaration toNode = this._toNode as VariableDeclaration;
6271 return _and(
6272 _isEqualNodes(node.documentationComment, toNode.documentationComment),
6273 _isEqualNodeLists(node.metadata, toNode.metadata),
6274 _isEqualNodes(node.name, toNode.name),
6275 _isEqualTokens(node.equals, toNode.equals),
6276 _isEqualNodes(node.initializer, toNode.initializer));
6277 }
6278
6279 @override
6280 bool visitVariableDeclarationList(VariableDeclarationList node) {
6281 VariableDeclarationList toNode = this._toNode as VariableDeclarationList;
6282 return _and(
6283 _isEqualNodes(node.documentationComment, toNode.documentationComment),
6284 _isEqualNodeLists(node.metadata, toNode.metadata),
6285 _isEqualTokens(node.keyword, toNode.keyword),
6286 _isEqualNodes(node.type, toNode.type),
6287 _isEqualNodeLists(node.variables, toNode.variables));
6288 }
6289
6290 @override
6291 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) {
6292 VariableDeclarationStatement toNode =
6293 this._toNode as VariableDeclarationStatement;
6294 return _and(_isEqualNodes(node.variables, toNode.variables),
6295 _isEqualTokens(node.semicolon, toNode.semicolon));
6296 }
6297
6298 @override
6299 bool visitWhileStatement(WhileStatement node) {
6300 WhileStatement toNode = this._toNode as WhileStatement;
6301 return _and(
6302 _isEqualTokens(node.whileKeyword, toNode.whileKeyword),
6303 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis),
6304 _isEqualNodes(node.condition, toNode.condition),
6305 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis),
6306 _isEqualNodes(node.body, toNode.body));
6307 }
6308
6309 @override
6310 bool visitWithClause(WithClause node) {
6311 WithClause toNode = this._toNode as WithClause;
6312 return _and(_isEqualTokens(node.withKeyword, toNode.withKeyword),
6313 _isEqualNodeLists(node.mixinTypes, toNode.mixinTypes));
6314 }
6315
6316 @override
6317 bool visitYieldStatement(YieldStatement node) {
6318 YieldStatement toNode = this._toNode as YieldStatement;
6319 return _and(
6320 _isEqualTokens(node.yieldKeyword, toNode.yieldKeyword),
6321 _isEqualNodes(node.expression, toNode.expression),
6322 _isEqualTokens(node.semicolon, toNode.semicolon));
6323 }
6324
6325 /**
6326 * Return `true` if all of the parameters are `true`.
6327 */
6328 bool _and(bool b1, bool b2,
6329 [bool b3 = true,
6330 bool b4 = true,
6331 bool b5 = true,
6332 bool b6 = true,
6333 bool b7 = true,
6334 bool b8 = true,
6335 bool b9 = true,
6336 bool b10 = true,
6337 bool b11 = true,
6338 bool b12 = true,
6339 bool b13 = true]) {
6340 // TODO(brianwilkerson) Inline this method.
6341 return b1 &&
6342 b2 &&
6343 b3 &&
6344 b4 &&
6345 b5 &&
6346 b6 &&
6347 b7 &&
6348 b8 &&
6349 b9 &&
6350 b10 &&
6351 b11 &&
6352 b12 &&
6353 b13;
6354 }
6355
6356 /**
6357 * Return `true` if the [first] and [second] lists of AST nodes have the same
6358 * size and corresponding elements are equal.
6359 */
6360 bool _isEqualNodeLists(NodeList first, NodeList second) {
6361 if (first == null) {
6362 return second == null;
6363 } else if (second == null) {
6364 return false;
6365 }
6366 int size = first.length;
6367 if (second.length != size) {
6368 return false;
6369 }
6370 bool equal = true;
6371 for (int i = 0; i < size; i++) {
6372 if (!_isEqualNodes(first[i], second[i])) {
6373 equal = false;
6374 }
6375 }
6376 return equal;
6377 }
6378
6379 /**
6380 * Return `true` if the [fromNode] and [toNode] have the same structure. As a
6381 * side-effect, if the nodes do have the same structure, any resolution data
6382 * from the first node will be copied to the second node.
6383 */
6384 bool _isEqualNodes(AstNode fromNode, AstNode toNode) {
6385 if (fromNode == null) {
6386 return toNode == null;
6387 } else if (toNode == null) {
6388 return false;
6389 } else if (fromNode.runtimeType == toNode.runtimeType) {
6390 this._toNode = toNode;
6391 return fromNode.accept(this);
6392 }
6393 //
6394 // Check for a simple transformation caused by entering a period.
6395 //
6396 if (toNode is PrefixedIdentifier) {
6397 SimpleIdentifier prefix = toNode.prefix;
6398 if (fromNode.runtimeType == prefix.runtimeType) {
6399 this._toNode = prefix;
6400 return fromNode.accept(this);
6401 }
6402 } else if (toNode is PropertyAccess) {
6403 Expression target = toNode.target;
6404 if (fromNode.runtimeType == target.runtimeType) {
6405 this._toNode = target;
6406 return fromNode.accept(this);
6407 }
6408 }
6409 return false;
6410 }
6411
6412 /**
6413 * Return `true` if the [first] and [second] arrays of tokens have the same
6414 * length and corresponding elements are equal.
6415 */
6416 bool _isEqualTokenLists(List<Token> first, List<Token> second) {
6417 int length = first.length;
6418 if (second.length != length) {
6419 return false;
6420 }
6421 for (int i = 0; i < length; i++) {
6422 if (!_isEqualTokens(first[i], second[i])) {
6423 return false;
6424 }
6425 }
6426 return true;
6427 }
6428
6429 /**
6430 * Return `true` if the [first] and [second] tokens have the same structure.
6431 */
6432 bool _isEqualTokens(Token first, Token second) {
6433 if (first == null) {
6434 return second == null;
6435 } else if (second == null) {
6436 return false;
6437 }
6438 return first.lexeme == second.lexeme;
6439 }
6440
6441 /**
6442 * Copy resolution data from the [fromNode] to the [toNode].
6443 */
6444 static void copyResolutionData(AstNode fromNode, AstNode toNode) {
6445 ResolutionCopier copier = new ResolutionCopier();
6446 copier._isEqualNodes(fromNode, toNode);
6447 }
6448 }
6449
6450 /**
5031 * Traverse the AST from initial child node to successive parents, building a 6451 * Traverse the AST from initial child node to successive parents, building a
5032 * collection of local variable and parameter names visible to the initial child 6452 * collection of local variable and parameter names visible to the initial child
5033 * node. In case of name shadowing, the first name seen is the most specific one 6453 * node. In case of name shadowing, the first name seen is the most specific one
5034 * so names are not redefined. 6454 * so names are not redefined.
5035 * 6455 *
5036 * Completion test code coverage is 95%. The two basic blocks that are not 6456 * Completion test code coverage is 95%. The two basic blocks that are not
5037 * executed cannot be executed. They are included for future reference. 6457 * executed cannot be executed. They are included for future reference.
5038 */ 6458 */
5039 class ScopedNameFinder extends GeneralizingAstVisitor<Object> { 6459 class ScopedNameFinder extends GeneralizingAstVisitor<Object> {
5040 Declaration _declarationNode; 6460 Declaration _declarationNode;
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
6347 * Safely visit the given [token], printing the [suffix] after the token if it 7767 * Safely visit the given [token], printing the [suffix] after the token if it
6348 * is non-`null`. 7768 * is non-`null`.
6349 */ 7769 */
6350 void _visitTokenWithSuffix(Token token, String suffix) { 7770 void _visitTokenWithSuffix(Token token, String suffix) {
6351 if (token != null) { 7771 if (token != null) {
6352 _writer.print(token.lexeme); 7772 _writer.print(token.lexeme);
6353 _writer.print(suffix); 7773 _writer.print(suffix);
6354 } 7774 }
6355 } 7775 }
6356 } 7776 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698