| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.parser; | 8 library engine.parser; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 */ | 101 */ |
| 102 Token staticKeyword; | 102 Token staticKeyword; |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * The token representing the keyword 'var', or `null` if the keyword was not
found. | 105 * The token representing the keyword 'var', or `null` if the keyword was not
found. |
| 106 */ | 106 */ |
| 107 Token varKeyword; | 107 Token varKeyword; |
| 108 | 108 |
| 109 String toString() { | 109 String toString() { |
| 110 JavaStringBuilder builder = new JavaStringBuilder(); | 110 JavaStringBuilder builder = new JavaStringBuilder(); |
| 111 bool needsSpace = appendKeyword(builder, false, abstractKeyword); | 111 bool needsSpace = _appendKeyword(builder, false, abstractKeyword); |
| 112 needsSpace = appendKeyword(builder, needsSpace, constKeyword); | 112 needsSpace = _appendKeyword(builder, needsSpace, constKeyword); |
| 113 needsSpace = appendKeyword(builder, needsSpace, externalKeyword); | 113 needsSpace = _appendKeyword(builder, needsSpace, externalKeyword); |
| 114 needsSpace = appendKeyword(builder, needsSpace, factoryKeyword); | 114 needsSpace = _appendKeyword(builder, needsSpace, factoryKeyword); |
| 115 needsSpace = appendKeyword(builder, needsSpace, finalKeyword); | 115 needsSpace = _appendKeyword(builder, needsSpace, finalKeyword); |
| 116 needsSpace = appendKeyword(builder, needsSpace, staticKeyword); | 116 needsSpace = _appendKeyword(builder, needsSpace, staticKeyword); |
| 117 appendKeyword(builder, needsSpace, varKeyword); | 117 _appendKeyword(builder, needsSpace, varKeyword); |
| 118 return builder.toString(); | 118 return builder.toString(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * If the given keyword is not `null`, append it to the given builder, prefixi
ng it with a | 122 * If the given keyword is not `null`, append it to the given builder, prefixi
ng it with a |
| 123 * space if needed. | 123 * space if needed. |
| 124 * | 124 * |
| 125 * @param builder the builder to which the keyword will be appended | 125 * @param builder the builder to which the keyword will be appended |
| 126 * @param needsSpace `true` if the keyword needs to be prefixed with a space | 126 * @param needsSpace `true` if the keyword needs to be prefixed with a space |
| 127 * @param keyword the keyword to be appended | 127 * @param keyword the keyword to be appended |
| 128 * @return `true` if subsequent keywords need to be prefixed with a space | 128 * @return `true` if subsequent keywords need to be prefixed with a space |
| 129 */ | 129 */ |
| 130 bool appendKeyword(JavaStringBuilder builder, bool needsSpace, Token keyword)
{ | 130 bool _appendKeyword(JavaStringBuilder builder, bool needsSpace, Token keyword)
{ |
| 131 if (keyword != null) { | 131 if (keyword != null) { |
| 132 if (needsSpace) { | 132 if (needsSpace) { |
| 133 builder.appendChar(0x20); | 133 builder.appendChar(0x20); |
| 134 } | 134 } |
| 135 builder.append(keyword.lexeme); | 135 builder.append(keyword.lexeme); |
| 136 return true; | 136 return true; |
| 137 } | 137 } |
| 138 return needsSpace; | 138 return needsSpace; |
| 139 } | 139 } |
| 140 } | 140 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 165 */ | 165 */ |
| 166 IncrementalParseDispatcher(Parser parser, AstNode oldNode) { | 166 IncrementalParseDispatcher(Parser parser, AstNode oldNode) { |
| 167 this._parser = parser; | 167 this._parser = parser; |
| 168 this._oldNode = oldNode; | 168 this._oldNode = oldNode; |
| 169 } | 169 } |
| 170 | 170 |
| 171 AstNode visitAdjacentStrings(AdjacentStrings node) { | 171 AstNode visitAdjacentStrings(AdjacentStrings node) { |
| 172 if (node.strings.contains(_oldNode)) { | 172 if (node.strings.contains(_oldNode)) { |
| 173 return _parser.parseStringLiteral(); | 173 return _parser.parseStringLiteral(); |
| 174 } | 174 } |
| 175 return notAChild(node); | 175 return _notAChild(node); |
| 176 } | 176 } |
| 177 | 177 |
| 178 AstNode visitAnnotation(Annotation node) { | 178 AstNode visitAnnotation(Annotation node) { |
| 179 if (identical(_oldNode, node.name)) { | 179 if (identical(_oldNode, node.name)) { |
| 180 throw new InsufficientContextException(); | 180 throw new InsufficientContextException(); |
| 181 } else if (identical(_oldNode, node.constructorName)) { | 181 } else if (identical(_oldNode, node.constructorName)) { |
| 182 throw new InsufficientContextException(); | 182 throw new InsufficientContextException(); |
| 183 } else if (identical(_oldNode, node.arguments)) { | 183 } else if (identical(_oldNode, node.arguments)) { |
| 184 return _parser.parseArgumentList(); | 184 return _parser.parseArgumentList(); |
| 185 } | 185 } |
| 186 return notAChild(node); | 186 return _notAChild(node); |
| 187 } | 187 } |
| 188 | 188 |
| 189 AstNode visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | 189 AstNode visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 190 if (identical(_oldNode, node.identifier)) { | 190 if (identical(_oldNode, node.identifier)) { |
| 191 return _parser.parseSimpleIdentifier(); | 191 return _parser.parseSimpleIdentifier(); |
| 192 } | 192 } |
| 193 return notAChild(node); | 193 return _notAChild(node); |
| 194 } | 194 } |
| 195 | 195 |
| 196 AstNode visitArgumentList(ArgumentList node) { | 196 AstNode visitArgumentList(ArgumentList node) { |
| 197 if (node.arguments.contains(_oldNode)) { | 197 if (node.arguments.contains(_oldNode)) { |
| 198 return _parser.parseArgument(); | 198 return _parser.parseArgument(); |
| 199 } | 199 } |
| 200 return notAChild(node); | 200 return _notAChild(node); |
| 201 } | 201 } |
| 202 | 202 |
| 203 AstNode visitAsExpression(AsExpression node) { | 203 AstNode visitAsExpression(AsExpression node) { |
| 204 if (identical(_oldNode, node.expression)) { | 204 if (identical(_oldNode, node.expression)) { |
| 205 return _parser.parseBitwiseOrExpression(); | 205 return _parser.parseBitwiseOrExpression(); |
| 206 } else if (identical(_oldNode, node.type)) { | 206 } else if (identical(_oldNode, node.type)) { |
| 207 return _parser.parseTypeName(); | 207 return _parser.parseTypeName(); |
| 208 } | 208 } |
| 209 return notAChild(node); | 209 return _notAChild(node); |
| 210 } | 210 } |
| 211 | 211 |
| 212 AstNode visitAssertStatement(AssertStatement node) { | 212 AstNode visitAssertStatement(AssertStatement node) { |
| 213 if (identical(_oldNode, node.condition)) { | 213 if (identical(_oldNode, node.condition)) { |
| 214 return _parser.parseExpression2(); | 214 return _parser.parseExpression2(); |
| 215 } | 215 } |
| 216 return notAChild(node); | 216 return _notAChild(node); |
| 217 } | 217 } |
| 218 | 218 |
| 219 AstNode visitAssignmentExpression(AssignmentExpression node) { | 219 AstNode visitAssignmentExpression(AssignmentExpression node) { |
| 220 if (identical(_oldNode, node.leftHandSide)) { | 220 if (identical(_oldNode, node.leftHandSide)) { |
| 221 // TODO(brianwilkerson) If the assignment is part of a cascade section, th
en we don't have a | 221 // TODO(brianwilkerson) If the assignment is part of a cascade section, th
en we don't have a |
| 222 // single parse method that will work. Otherwise, we can parse a condition
al expression, but | 222 // single parse method that will work. Otherwise, we can parse a condition
al expression, but |
| 223 // need to ensure that the resulting expression is assignable. | 223 // need to ensure that the resulting expression is assignable. |
| 224 // return parser.parseConditionalExpression(); | 224 // return parser.parseConditionalExpression(); |
| 225 throw new InsufficientContextException(); | 225 throw new InsufficientContextException(); |
| 226 } else if (identical(_oldNode, node.rightHandSide)) { | 226 } else if (identical(_oldNode, node.rightHandSide)) { |
| 227 if (isCascadeAllowedInAssignment(node)) { | 227 if (_isCascadeAllowedInAssignment(node)) { |
| 228 return _parser.parseExpression2(); | 228 return _parser.parseExpression2(); |
| 229 } | 229 } |
| 230 return _parser.parseExpressionWithoutCascade(); | 230 return _parser.parseExpressionWithoutCascade(); |
| 231 } | 231 } |
| 232 return notAChild(node); | 232 return _notAChild(node); |
| 233 } | 233 } |
| 234 | 234 |
| 235 AstNode visitBinaryExpression(BinaryExpression node) { | 235 AstNode visitBinaryExpression(BinaryExpression node) { |
| 236 if (identical(_oldNode, node.leftOperand)) { | 236 if (identical(_oldNode, node.leftOperand)) { |
| 237 throw new InsufficientContextException(); | 237 throw new InsufficientContextException(); |
| 238 } else if (identical(_oldNode, node.rightOperand)) { | 238 } else if (identical(_oldNode, node.rightOperand)) { |
| 239 throw new InsufficientContextException(); | 239 throw new InsufficientContextException(); |
| 240 } | 240 } |
| 241 return notAChild(node); | 241 return _notAChild(node); |
| 242 } | 242 } |
| 243 | 243 |
| 244 AstNode visitBlock(Block node) { | 244 AstNode visitBlock(Block node) { |
| 245 if (node.statements.contains(_oldNode)) { | 245 if (node.statements.contains(_oldNode)) { |
| 246 return _parser.parseStatement2(); | 246 return _parser.parseStatement2(); |
| 247 } | 247 } |
| 248 return notAChild(node); | 248 return _notAChild(node); |
| 249 } | 249 } |
| 250 | 250 |
| 251 AstNode visitBlockFunctionBody(BlockFunctionBody node) { | 251 AstNode visitBlockFunctionBody(BlockFunctionBody node) { |
| 252 if (identical(_oldNode, node.block)) { | 252 if (identical(_oldNode, node.block)) { |
| 253 return _parser.parseBlock(); | 253 return _parser.parseBlock(); |
| 254 } | 254 } |
| 255 return notAChild(node); | 255 return _notAChild(node); |
| 256 } | 256 } |
| 257 | 257 |
| 258 AstNode visitBooleanLiteral(BooleanLiteral node) => notAChild(node); | 258 AstNode visitBooleanLiteral(BooleanLiteral node) => _notAChild(node); |
| 259 | 259 |
| 260 AstNode visitBreakStatement(BreakStatement node) { | 260 AstNode visitBreakStatement(BreakStatement node) { |
| 261 if (identical(_oldNode, node.label)) { | 261 if (identical(_oldNode, node.label)) { |
| 262 return _parser.parseSimpleIdentifier(); | 262 return _parser.parseSimpleIdentifier(); |
| 263 } | 263 } |
| 264 return notAChild(node); | 264 return _notAChild(node); |
| 265 } | 265 } |
| 266 | 266 |
| 267 AstNode visitCascadeExpression(CascadeExpression node) { | 267 AstNode visitCascadeExpression(CascadeExpression node) { |
| 268 if (identical(_oldNode, node.target)) { | 268 if (identical(_oldNode, node.target)) { |
| 269 return _parser.parseConditionalExpression(); | 269 return _parser.parseConditionalExpression(); |
| 270 } else if (node.cascadeSections.contains(_oldNode)) { | 270 } else if (node.cascadeSections.contains(_oldNode)) { |
| 271 throw new InsufficientContextException(); | 271 throw new InsufficientContextException(); |
| 272 } | 272 } |
| 273 return notAChild(node); | 273 return _notAChild(node); |
| 274 } | 274 } |
| 275 | 275 |
| 276 AstNode visitCatchClause(CatchClause node) { | 276 AstNode visitCatchClause(CatchClause node) { |
| 277 if (identical(_oldNode, node.exceptionType)) { | 277 if (identical(_oldNode, node.exceptionType)) { |
| 278 return _parser.parseTypeName(); | 278 return _parser.parseTypeName(); |
| 279 } else if (identical(_oldNode, node.exceptionParameter)) { | 279 } else if (identical(_oldNode, node.exceptionParameter)) { |
| 280 return _parser.parseSimpleIdentifier(); | 280 return _parser.parseSimpleIdentifier(); |
| 281 } else if (identical(_oldNode, node.stackTraceParameter)) { | 281 } else if (identical(_oldNode, node.stackTraceParameter)) { |
| 282 return _parser.parseSimpleIdentifier(); | 282 return _parser.parseSimpleIdentifier(); |
| 283 } else if (identical(_oldNode, node.body)) { | 283 } else if (identical(_oldNode, node.body)) { |
| 284 return _parser.parseBlock(); | 284 return _parser.parseBlock(); |
| 285 } | 285 } |
| 286 return notAChild(node); | 286 return _notAChild(node); |
| 287 } | 287 } |
| 288 | 288 |
| 289 AstNode visitClassDeclaration(ClassDeclaration node) { | 289 AstNode visitClassDeclaration(ClassDeclaration node) { |
| 290 if (identical(_oldNode, node.documentationComment)) { | 290 if (identical(_oldNode, node.documentationComment)) { |
| 291 throw new InsufficientContextException(); | 291 throw new InsufficientContextException(); |
| 292 } else if (node.metadata.contains(_oldNode)) { | 292 } else if (node.metadata.contains(_oldNode)) { |
| 293 return _parser.parseAnnotation(); | 293 return _parser.parseAnnotation(); |
| 294 } else if (identical(_oldNode, node.name)) { | 294 } else if (identical(_oldNode, node.name)) { |
| 295 return _parser.parseSimpleIdentifier(); | 295 return _parser.parseSimpleIdentifier(); |
| 296 } else if (identical(_oldNode, node.typeParameters)) { | 296 } else if (identical(_oldNode, node.typeParameters)) { |
| 297 return _parser.parseTypeParameterList(); | 297 return _parser.parseTypeParameterList(); |
| 298 } else if (identical(_oldNode, node.extendsClause)) { | 298 } else if (identical(_oldNode, node.extendsClause)) { |
| 299 return _parser.parseExtendsClause(); | 299 return _parser.parseExtendsClause(); |
| 300 } else if (identical(_oldNode, node.withClause)) { | 300 } else if (identical(_oldNode, node.withClause)) { |
| 301 return _parser.parseWithClause(); | 301 return _parser.parseWithClause(); |
| 302 } else if (identical(_oldNode, node.implementsClause)) { | 302 } else if (identical(_oldNode, node.implementsClause)) { |
| 303 return _parser.parseImplementsClause(); | 303 return _parser.parseImplementsClause(); |
| 304 } else if (node.members.contains(_oldNode)) { | 304 } else if (node.members.contains(_oldNode)) { |
| 305 ClassMember member = _parser.parseClassMember(node.name.name); | 305 ClassMember member = _parser.parseClassMember(node.name.name); |
| 306 if (member == null) { | 306 if (member == null) { |
| 307 throw new InsufficientContextException(); | 307 throw new InsufficientContextException(); |
| 308 } | 308 } |
| 309 return member; | 309 return member; |
| 310 } | 310 } |
| 311 return notAChild(node); | 311 return _notAChild(node); |
| 312 } | 312 } |
| 313 | 313 |
| 314 AstNode visitClassTypeAlias(ClassTypeAlias node) { | 314 AstNode visitClassTypeAlias(ClassTypeAlias node) { |
| 315 if (identical(_oldNode, node.documentationComment)) { | 315 if (identical(_oldNode, node.documentationComment)) { |
| 316 throw new InsufficientContextException(); | 316 throw new InsufficientContextException(); |
| 317 } else if (node.metadata.contains(_oldNode)) { | 317 } else if (node.metadata.contains(_oldNode)) { |
| 318 return _parser.parseAnnotation(); | 318 return _parser.parseAnnotation(); |
| 319 } else if (identical(_oldNode, node.name)) { | 319 } else if (identical(_oldNode, node.name)) { |
| 320 return _parser.parseSimpleIdentifier(); | 320 return _parser.parseSimpleIdentifier(); |
| 321 } else if (identical(_oldNode, node.typeParameters)) { | 321 } else if (identical(_oldNode, node.typeParameters)) { |
| 322 return _parser.parseTypeParameterList(); | 322 return _parser.parseTypeParameterList(); |
| 323 } else if (identical(_oldNode, node.superclass)) { | 323 } else if (identical(_oldNode, node.superclass)) { |
| 324 return _parser.parseTypeName(); | 324 return _parser.parseTypeName(); |
| 325 } else if (identical(_oldNode, node.withClause)) { | 325 } else if (identical(_oldNode, node.withClause)) { |
| 326 return _parser.parseWithClause(); | 326 return _parser.parseWithClause(); |
| 327 } else if (identical(_oldNode, node.implementsClause)) { | 327 } else if (identical(_oldNode, node.implementsClause)) { |
| 328 return _parser.parseImplementsClause(); | 328 return _parser.parseImplementsClause(); |
| 329 } | 329 } |
| 330 return notAChild(node); | 330 return _notAChild(node); |
| 331 } | 331 } |
| 332 | 332 |
| 333 AstNode visitComment(Comment node) { | 333 AstNode visitComment(Comment node) { |
| 334 throw new InsufficientContextException(); | 334 throw new InsufficientContextException(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 AstNode visitCommentReference(CommentReference node) { | 337 AstNode visitCommentReference(CommentReference node) { |
| 338 if (identical(_oldNode, node.identifier)) { | 338 if (identical(_oldNode, node.identifier)) { |
| 339 return _parser.parsePrefixedIdentifier(); | 339 return _parser.parsePrefixedIdentifier(); |
| 340 } | 340 } |
| 341 return notAChild(node); | 341 return _notAChild(node); |
| 342 } | 342 } |
| 343 | 343 |
| 344 AstNode visitCompilationUnit(CompilationUnit node) { | 344 AstNode visitCompilationUnit(CompilationUnit node) { |
| 345 throw new InsufficientContextException(); | 345 throw new InsufficientContextException(); |
| 346 } | 346 } |
| 347 | 347 |
| 348 AstNode visitConditionalExpression(ConditionalExpression node) { | 348 AstNode visitConditionalExpression(ConditionalExpression node) { |
| 349 if (identical(_oldNode, node.condition)) { | 349 if (identical(_oldNode, node.condition)) { |
| 350 return _parser.parseLogicalOrExpression(); | 350 return _parser.parseLogicalOrExpression(); |
| 351 } else if (identical(_oldNode, node.thenExpression)) { | 351 } else if (identical(_oldNode, node.thenExpression)) { |
| 352 return _parser.parseExpressionWithoutCascade(); | 352 return _parser.parseExpressionWithoutCascade(); |
| 353 } else if (identical(_oldNode, node.elseExpression)) { | 353 } else if (identical(_oldNode, node.elseExpression)) { |
| 354 return _parser.parseExpressionWithoutCascade(); | 354 return _parser.parseExpressionWithoutCascade(); |
| 355 } | 355 } |
| 356 return notAChild(node); | 356 return _notAChild(node); |
| 357 } | 357 } |
| 358 | 358 |
| 359 AstNode visitConstructorDeclaration(ConstructorDeclaration node) { | 359 AstNode visitConstructorDeclaration(ConstructorDeclaration node) { |
| 360 if (identical(_oldNode, node.documentationComment)) { | 360 if (identical(_oldNode, node.documentationComment)) { |
| 361 throw new InsufficientContextException(); | 361 throw new InsufficientContextException(); |
| 362 } else if (node.metadata.contains(_oldNode)) { | 362 } else if (node.metadata.contains(_oldNode)) { |
| 363 return _parser.parseAnnotation(); | 363 return _parser.parseAnnotation(); |
| 364 } else if (identical(_oldNode, node.returnType)) { | 364 } else if (identical(_oldNode, node.returnType)) { |
| 365 throw new InsufficientContextException(); | 365 throw new InsufficientContextException(); |
| 366 } else if (identical(_oldNode, node.name)) { | 366 } else if (identical(_oldNode, node.name)) { |
| 367 throw new InsufficientContextException(); | 367 throw new InsufficientContextException(); |
| 368 } else if (identical(_oldNode, node.parameters)) { | 368 } else if (identical(_oldNode, node.parameters)) { |
| 369 return _parser.parseFormalParameterList(); | 369 return _parser.parseFormalParameterList(); |
| 370 } else if (identical(_oldNode, node.redirectedConstructor)) { | 370 } else if (identical(_oldNode, node.redirectedConstructor)) { |
| 371 throw new InsufficientContextException(); | 371 throw new InsufficientContextException(); |
| 372 } else if (node.initializers.contains(_oldNode)) { | 372 } else if (node.initializers.contains(_oldNode)) { |
| 373 throw new InsufficientContextException(); | 373 throw new InsufficientContextException(); |
| 374 } else if (identical(_oldNode, node.body)) { | 374 } else if (identical(_oldNode, node.body)) { |
| 375 throw new InsufficientContextException(); | 375 throw new InsufficientContextException(); |
| 376 } | 376 } |
| 377 return notAChild(node); | 377 return _notAChild(node); |
| 378 } | 378 } |
| 379 | 379 |
| 380 AstNode visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 380 AstNode visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 381 if (identical(_oldNode, node.fieldName)) { | 381 if (identical(_oldNode, node.fieldName)) { |
| 382 return _parser.parseSimpleIdentifier(); | 382 return _parser.parseSimpleIdentifier(); |
| 383 } else if (identical(_oldNode, node.expression)) { | 383 } else if (identical(_oldNode, node.expression)) { |
| 384 throw new InsufficientContextException(); | 384 throw new InsufficientContextException(); |
| 385 } | 385 } |
| 386 return notAChild(node); | 386 return _notAChild(node); |
| 387 } | 387 } |
| 388 | 388 |
| 389 AstNode visitConstructorName(ConstructorName node) { | 389 AstNode visitConstructorName(ConstructorName node) { |
| 390 if (identical(_oldNode, node.type)) { | 390 if (identical(_oldNode, node.type)) { |
| 391 return _parser.parseTypeName(); | 391 return _parser.parseTypeName(); |
| 392 } else if (identical(_oldNode, node.name)) { | 392 } else if (identical(_oldNode, node.name)) { |
| 393 return _parser.parseSimpleIdentifier(); | 393 return _parser.parseSimpleIdentifier(); |
| 394 } | 394 } |
| 395 return notAChild(node); | 395 return _notAChild(node); |
| 396 } | 396 } |
| 397 | 397 |
| 398 AstNode visitContinueStatement(ContinueStatement node) { | 398 AstNode visitContinueStatement(ContinueStatement node) { |
| 399 if (identical(_oldNode, node.label)) { | 399 if (identical(_oldNode, node.label)) { |
| 400 return _parser.parseSimpleIdentifier(); | 400 return _parser.parseSimpleIdentifier(); |
| 401 } | 401 } |
| 402 return notAChild(node); | 402 return _notAChild(node); |
| 403 } | 403 } |
| 404 | 404 |
| 405 AstNode visitDeclaredIdentifier(DeclaredIdentifier node) { | 405 AstNode visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 406 if (identical(_oldNode, node.documentationComment)) { | 406 if (identical(_oldNode, node.documentationComment)) { |
| 407 throw new InsufficientContextException(); | 407 throw new InsufficientContextException(); |
| 408 } else if (node.metadata.contains(_oldNode)) { | 408 } else if (node.metadata.contains(_oldNode)) { |
| 409 return _parser.parseAnnotation(); | 409 return _parser.parseAnnotation(); |
| 410 } else if (identical(_oldNode, node.type)) { | 410 } else if (identical(_oldNode, node.type)) { |
| 411 throw new InsufficientContextException(); | 411 throw new InsufficientContextException(); |
| 412 } else if (identical(_oldNode, node.identifier)) { | 412 } else if (identical(_oldNode, node.identifier)) { |
| 413 return _parser.parseSimpleIdentifier(); | 413 return _parser.parseSimpleIdentifier(); |
| 414 } | 414 } |
| 415 return notAChild(node); | 415 return _notAChild(node); |
| 416 } | 416 } |
| 417 | 417 |
| 418 AstNode visitDefaultFormalParameter(DefaultFormalParameter node) { | 418 AstNode visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 419 if (identical(_oldNode, node.parameter)) { | 419 if (identical(_oldNode, node.parameter)) { |
| 420 return _parser.parseNormalFormalParameter(); | 420 return _parser.parseNormalFormalParameter(); |
| 421 } else if (identical(_oldNode, node.defaultValue)) { | 421 } else if (identical(_oldNode, node.defaultValue)) { |
| 422 return _parser.parseExpression2(); | 422 return _parser.parseExpression2(); |
| 423 } | 423 } |
| 424 return notAChild(node); | 424 return _notAChild(node); |
| 425 } | 425 } |
| 426 | 426 |
| 427 AstNode visitDoStatement(DoStatement node) { | 427 AstNode visitDoStatement(DoStatement node) { |
| 428 if (identical(_oldNode, node.body)) { | 428 if (identical(_oldNode, node.body)) { |
| 429 return _parser.parseStatement2(); | 429 return _parser.parseStatement2(); |
| 430 } else if (identical(_oldNode, node.condition)) { | 430 } else if (identical(_oldNode, node.condition)) { |
| 431 return _parser.parseExpression2(); | 431 return _parser.parseExpression2(); |
| 432 } | 432 } |
| 433 return notAChild(node); | 433 return _notAChild(node); |
| 434 } | 434 } |
| 435 | 435 |
| 436 AstNode visitDoubleLiteral(DoubleLiteral node) => notAChild(node); | 436 AstNode visitDoubleLiteral(DoubleLiteral node) => _notAChild(node); |
| 437 | 437 |
| 438 AstNode visitEmptyFunctionBody(EmptyFunctionBody node) => notAChild(node); | 438 AstNode visitEmptyFunctionBody(EmptyFunctionBody node) => _notAChild(node); |
| 439 | 439 |
| 440 AstNode visitEmptyStatement(EmptyStatement node) => notAChild(node); | 440 AstNode visitEmptyStatement(EmptyStatement node) => _notAChild(node); |
| 441 | 441 |
| 442 AstNode visitExportDirective(ExportDirective node) { | 442 AstNode visitExportDirective(ExportDirective node) { |
| 443 if (identical(_oldNode, node.documentationComment)) { | 443 if (identical(_oldNode, node.documentationComment)) { |
| 444 throw new InsufficientContextException(); | 444 throw new InsufficientContextException(); |
| 445 } else if (node.metadata.contains(_oldNode)) { | 445 } else if (node.metadata.contains(_oldNode)) { |
| 446 return _parser.parseAnnotation(); | 446 return _parser.parseAnnotation(); |
| 447 } else if (identical(_oldNode, node.uri)) { | 447 } else if (identical(_oldNode, node.uri)) { |
| 448 return _parser.parseStringLiteral(); | 448 return _parser.parseStringLiteral(); |
| 449 } else if (node.combinators.contains(_oldNode)) { | 449 } else if (node.combinators.contains(_oldNode)) { |
| 450 throw new IncrementalParseException(); | 450 throw new IncrementalParseException(); |
| 451 } | 451 } |
| 452 return notAChild(node); | 452 return _notAChild(node); |
| 453 } | 453 } |
| 454 | 454 |
| 455 AstNode visitExpressionFunctionBody(ExpressionFunctionBody node) { | 455 AstNode visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 456 if (identical(_oldNode, node.expression)) { | 456 if (identical(_oldNode, node.expression)) { |
| 457 return _parser.parseExpression2(); | 457 return _parser.parseExpression2(); |
| 458 } | 458 } |
| 459 return notAChild(node); | 459 return _notAChild(node); |
| 460 } | 460 } |
| 461 | 461 |
| 462 AstNode visitExpressionStatement(ExpressionStatement node) { | 462 AstNode visitExpressionStatement(ExpressionStatement node) { |
| 463 if (identical(_oldNode, node.expression)) { | 463 if (identical(_oldNode, node.expression)) { |
| 464 return _parser.parseExpression2(); | 464 return _parser.parseExpression2(); |
| 465 } | 465 } |
| 466 return notAChild(node); | 466 return _notAChild(node); |
| 467 } | 467 } |
| 468 | 468 |
| 469 AstNode visitExtendsClause(ExtendsClause node) { | 469 AstNode visitExtendsClause(ExtendsClause node) { |
| 470 if (identical(_oldNode, node.superclass)) { | 470 if (identical(_oldNode, node.superclass)) { |
| 471 return _parser.parseTypeName(); | 471 return _parser.parseTypeName(); |
| 472 } | 472 } |
| 473 return notAChild(node); | 473 return _notAChild(node); |
| 474 } | 474 } |
| 475 | 475 |
| 476 AstNode visitFieldDeclaration(FieldDeclaration node) { | 476 AstNode visitFieldDeclaration(FieldDeclaration node) { |
| 477 if (identical(_oldNode, node.documentationComment)) { | 477 if (identical(_oldNode, node.documentationComment)) { |
| 478 throw new InsufficientContextException(); | 478 throw new InsufficientContextException(); |
| 479 } else if (node.metadata.contains(_oldNode)) { | 479 } else if (node.metadata.contains(_oldNode)) { |
| 480 return _parser.parseAnnotation(); | 480 return _parser.parseAnnotation(); |
| 481 } else if (identical(_oldNode, node.fields)) { | 481 } else if (identical(_oldNode, node.fields)) { |
| 482 throw new InsufficientContextException(); | 482 throw new InsufficientContextException(); |
| 483 } | 483 } |
| 484 return notAChild(node); | 484 return _notAChild(node); |
| 485 } | 485 } |
| 486 | 486 |
| 487 AstNode visitFieldFormalParameter(FieldFormalParameter node) { | 487 AstNode visitFieldFormalParameter(FieldFormalParameter node) { |
| 488 if (identical(_oldNode, node.documentationComment)) { | 488 if (identical(_oldNode, node.documentationComment)) { |
| 489 throw new InsufficientContextException(); | 489 throw new InsufficientContextException(); |
| 490 } else if (node.metadata.contains(_oldNode)) { | 490 } else if (node.metadata.contains(_oldNode)) { |
| 491 return _parser.parseAnnotation(); | 491 return _parser.parseAnnotation(); |
| 492 } else if (identical(_oldNode, node.type)) { | 492 } else if (identical(_oldNode, node.type)) { |
| 493 return _parser.parseTypeName(); | 493 return _parser.parseTypeName(); |
| 494 } else if (identical(_oldNode, node.identifier)) { | 494 } else if (identical(_oldNode, node.identifier)) { |
| 495 return _parser.parseSimpleIdentifier(); | 495 return _parser.parseSimpleIdentifier(); |
| 496 } else if (identical(_oldNode, node.parameters)) { | 496 } else if (identical(_oldNode, node.parameters)) { |
| 497 return _parser.parseFormalParameterList(); | 497 return _parser.parseFormalParameterList(); |
| 498 } | 498 } |
| 499 return notAChild(node); | 499 return _notAChild(node); |
| 500 } | 500 } |
| 501 | 501 |
| 502 AstNode visitForEachStatement(ForEachStatement node) { | 502 AstNode visitForEachStatement(ForEachStatement node) { |
| 503 if (identical(_oldNode, node.loopVariable)) { | 503 if (identical(_oldNode, node.loopVariable)) { |
| 504 throw new InsufficientContextException(); | 504 throw new InsufficientContextException(); |
| 505 } else if (identical(_oldNode, node.identifier)) { | 505 } else if (identical(_oldNode, node.identifier)) { |
| 506 return _parser.parseSimpleIdentifier(); | 506 return _parser.parseSimpleIdentifier(); |
| 507 } else if (identical(_oldNode, node.body)) { | 507 } else if (identical(_oldNode, node.body)) { |
| 508 return _parser.parseStatement2(); | 508 return _parser.parseStatement2(); |
| 509 } | 509 } |
| 510 return notAChild(node); | 510 return _notAChild(node); |
| 511 } | 511 } |
| 512 | 512 |
| 513 AstNode visitFormalParameterList(FormalParameterList node) { | 513 AstNode visitFormalParameterList(FormalParameterList node) { |
| 514 // We don't know which kind of parameter to parse. | 514 // We don't know which kind of parameter to parse. |
| 515 throw new InsufficientContextException(); | 515 throw new InsufficientContextException(); |
| 516 } | 516 } |
| 517 | 517 |
| 518 AstNode visitForStatement(ForStatement node) { | 518 AstNode visitForStatement(ForStatement node) { |
| 519 if (identical(_oldNode, node.variables)) { | 519 if (identical(_oldNode, node.variables)) { |
| 520 throw new InsufficientContextException(); | 520 throw new InsufficientContextException(); |
| 521 } else if (identical(_oldNode, node.initialization)) { | 521 } else if (identical(_oldNode, node.initialization)) { |
| 522 throw new InsufficientContextException(); | 522 throw new InsufficientContextException(); |
| 523 } else if (identical(_oldNode, node.condition)) { | 523 } else if (identical(_oldNode, node.condition)) { |
| 524 return _parser.parseExpression2(); | 524 return _parser.parseExpression2(); |
| 525 } else if (node.updaters.contains(_oldNode)) { | 525 } else if (node.updaters.contains(_oldNode)) { |
| 526 return _parser.parseExpression2(); | 526 return _parser.parseExpression2(); |
| 527 } else if (identical(_oldNode, node.body)) { | 527 } else if (identical(_oldNode, node.body)) { |
| 528 return _parser.parseStatement2(); | 528 return _parser.parseStatement2(); |
| 529 } | 529 } |
| 530 return notAChild(node); | 530 return _notAChild(node); |
| 531 } | 531 } |
| 532 | 532 |
| 533 AstNode visitFunctionDeclaration(FunctionDeclaration node) { | 533 AstNode visitFunctionDeclaration(FunctionDeclaration node) { |
| 534 if (identical(_oldNode, node.documentationComment)) { | 534 if (identical(_oldNode, node.documentationComment)) { |
| 535 throw new InsufficientContextException(); | 535 throw new InsufficientContextException(); |
| 536 } else if (node.metadata.contains(_oldNode)) { | 536 } else if (node.metadata.contains(_oldNode)) { |
| 537 return _parser.parseAnnotation(); | 537 return _parser.parseAnnotation(); |
| 538 } else if (identical(_oldNode, node.returnType)) { | 538 } else if (identical(_oldNode, node.returnType)) { |
| 539 return _parser.parseReturnType(); | 539 return _parser.parseReturnType(); |
| 540 } else if (identical(_oldNode, node.name)) { | 540 } else if (identical(_oldNode, node.name)) { |
| 541 return _parser.parseSimpleIdentifier(); | 541 return _parser.parseSimpleIdentifier(); |
| 542 } else if (identical(_oldNode, node.functionExpression)) { | 542 } else if (identical(_oldNode, node.functionExpression)) { |
| 543 throw new InsufficientContextException(); | 543 throw new InsufficientContextException(); |
| 544 } | 544 } |
| 545 return notAChild(node); | 545 return _notAChild(node); |
| 546 } | 546 } |
| 547 | 547 |
| 548 AstNode visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | 548 AstNode visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 549 if (identical(_oldNode, node.functionDeclaration)) { | 549 if (identical(_oldNode, node.functionDeclaration)) { |
| 550 throw new InsufficientContextException(); | 550 throw new InsufficientContextException(); |
| 551 } | 551 } |
| 552 return notAChild(node); | 552 return _notAChild(node); |
| 553 } | 553 } |
| 554 | 554 |
| 555 AstNode visitFunctionExpression(FunctionExpression node) { | 555 AstNode visitFunctionExpression(FunctionExpression node) { |
| 556 if (identical(_oldNode, node.parameters)) { | 556 if (identical(_oldNode, node.parameters)) { |
| 557 return _parser.parseFormalParameterList(); | 557 return _parser.parseFormalParameterList(); |
| 558 } else if (identical(_oldNode, node.body)) { | 558 } else if (identical(_oldNode, node.body)) { |
| 559 throw new InsufficientContextException(); | 559 throw new InsufficientContextException(); |
| 560 } | 560 } |
| 561 return notAChild(node); | 561 return _notAChild(node); |
| 562 } | 562 } |
| 563 | 563 |
| 564 AstNode visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 564 AstNode visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 565 if (identical(_oldNode, node.function)) { | 565 if (identical(_oldNode, node.function)) { |
| 566 throw new InsufficientContextException(); | 566 throw new InsufficientContextException(); |
| 567 } else if (identical(_oldNode, node.argumentList)) { | 567 } else if (identical(_oldNode, node.argumentList)) { |
| 568 return _parser.parseArgumentList(); | 568 return _parser.parseArgumentList(); |
| 569 } | 569 } |
| 570 return notAChild(node); | 570 return _notAChild(node); |
| 571 } | 571 } |
| 572 | 572 |
| 573 AstNode visitFunctionTypeAlias(FunctionTypeAlias node) { | 573 AstNode visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 574 if (identical(_oldNode, node.documentationComment)) { | 574 if (identical(_oldNode, node.documentationComment)) { |
| 575 throw new InsufficientContextException(); | 575 throw new InsufficientContextException(); |
| 576 } else if (node.metadata.contains(_oldNode)) { | 576 } else if (node.metadata.contains(_oldNode)) { |
| 577 return _parser.parseAnnotation(); | 577 return _parser.parseAnnotation(); |
| 578 } else if (identical(_oldNode, node.returnType)) { | 578 } else if (identical(_oldNode, node.returnType)) { |
| 579 return _parser.parseReturnType(); | 579 return _parser.parseReturnType(); |
| 580 } else if (identical(_oldNode, node.name)) { | 580 } else if (identical(_oldNode, node.name)) { |
| 581 return _parser.parseSimpleIdentifier(); | 581 return _parser.parseSimpleIdentifier(); |
| 582 } else if (identical(_oldNode, node.typeParameters)) { | 582 } else if (identical(_oldNode, node.typeParameters)) { |
| 583 return _parser.parseTypeParameterList(); | 583 return _parser.parseTypeParameterList(); |
| 584 } else if (identical(_oldNode, node.parameters)) { | 584 } else if (identical(_oldNode, node.parameters)) { |
| 585 return _parser.parseFormalParameterList(); | 585 return _parser.parseFormalParameterList(); |
| 586 } | 586 } |
| 587 return notAChild(node); | 587 return _notAChild(node); |
| 588 } | 588 } |
| 589 | 589 |
| 590 AstNode visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 590 AstNode visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 591 if (identical(_oldNode, node.documentationComment)) { | 591 if (identical(_oldNode, node.documentationComment)) { |
| 592 throw new InsufficientContextException(); | 592 throw new InsufficientContextException(); |
| 593 } else if (node.metadata.contains(_oldNode)) { | 593 } else if (node.metadata.contains(_oldNode)) { |
| 594 return _parser.parseAnnotation(); | 594 return _parser.parseAnnotation(); |
| 595 } else if (identical(_oldNode, node.returnType)) { | 595 } else if (identical(_oldNode, node.returnType)) { |
| 596 return _parser.parseReturnType(); | 596 return _parser.parseReturnType(); |
| 597 } else if (identical(_oldNode, node.identifier)) { | 597 } else if (identical(_oldNode, node.identifier)) { |
| 598 return _parser.parseSimpleIdentifier(); | 598 return _parser.parseSimpleIdentifier(); |
| 599 } else if (identical(_oldNode, node.parameters)) { | 599 } else if (identical(_oldNode, node.parameters)) { |
| 600 return _parser.parseFormalParameterList(); | 600 return _parser.parseFormalParameterList(); |
| 601 } | 601 } |
| 602 return notAChild(node); | 602 return _notAChild(node); |
| 603 } | 603 } |
| 604 | 604 |
| 605 AstNode visitHideCombinator(HideCombinator node) { | 605 AstNode visitHideCombinator(HideCombinator node) { |
| 606 if (node.hiddenNames.contains(_oldNode)) { | 606 if (node.hiddenNames.contains(_oldNode)) { |
| 607 return _parser.parseSimpleIdentifier(); | 607 return _parser.parseSimpleIdentifier(); |
| 608 } | 608 } |
| 609 return notAChild(node); | 609 return _notAChild(node); |
| 610 } | 610 } |
| 611 | 611 |
| 612 AstNode visitIfStatement(IfStatement node) { | 612 AstNode visitIfStatement(IfStatement node) { |
| 613 if (identical(_oldNode, node.condition)) { | 613 if (identical(_oldNode, node.condition)) { |
| 614 return _parser.parseExpression2(); | 614 return _parser.parseExpression2(); |
| 615 } else if (identical(_oldNode, node.thenStatement)) { | 615 } else if (identical(_oldNode, node.thenStatement)) { |
| 616 return _parser.parseStatement2(); | 616 return _parser.parseStatement2(); |
| 617 } else if (identical(_oldNode, node.elseStatement)) { | 617 } else if (identical(_oldNode, node.elseStatement)) { |
| 618 return _parser.parseStatement2(); | 618 return _parser.parseStatement2(); |
| 619 } | 619 } |
| 620 return notAChild(node); | 620 return _notAChild(node); |
| 621 } | 621 } |
| 622 | 622 |
| 623 AstNode visitImplementsClause(ImplementsClause node) { | 623 AstNode visitImplementsClause(ImplementsClause node) { |
| 624 if (node.interfaces.contains(node)) { | 624 if (node.interfaces.contains(node)) { |
| 625 return _parser.parseTypeName(); | 625 return _parser.parseTypeName(); |
| 626 } | 626 } |
| 627 return notAChild(node); | 627 return _notAChild(node); |
| 628 } | 628 } |
| 629 | 629 |
| 630 AstNode visitImportDirective(ImportDirective node) { | 630 AstNode visitImportDirective(ImportDirective node) { |
| 631 if (identical(_oldNode, node.documentationComment)) { | 631 if (identical(_oldNode, node.documentationComment)) { |
| 632 throw new InsufficientContextException(); | 632 throw new InsufficientContextException(); |
| 633 } else if (node.metadata.contains(_oldNode)) { | 633 } else if (node.metadata.contains(_oldNode)) { |
| 634 return _parser.parseAnnotation(); | 634 return _parser.parseAnnotation(); |
| 635 } else if (identical(_oldNode, node.uri)) { | 635 } else if (identical(_oldNode, node.uri)) { |
| 636 return _parser.parseStringLiteral(); | 636 return _parser.parseStringLiteral(); |
| 637 } else if (identical(_oldNode, node.prefix)) { | 637 } else if (identical(_oldNode, node.prefix)) { |
| 638 return _parser.parseSimpleIdentifier(); | 638 return _parser.parseSimpleIdentifier(); |
| 639 } else if (node.combinators.contains(_oldNode)) { | 639 } else if (node.combinators.contains(_oldNode)) { |
| 640 throw new IncrementalParseException(); | 640 throw new IncrementalParseException(); |
| 641 } | 641 } |
| 642 return notAChild(node); | 642 return _notAChild(node); |
| 643 } | 643 } |
| 644 | 644 |
| 645 AstNode visitIndexExpression(IndexExpression node) { | 645 AstNode visitIndexExpression(IndexExpression node) { |
| 646 if (identical(_oldNode, node.target)) { | 646 if (identical(_oldNode, node.target)) { |
| 647 throw new InsufficientContextException(); | 647 throw new InsufficientContextException(); |
| 648 } else if (identical(_oldNode, node.index)) { | 648 } else if (identical(_oldNode, node.index)) { |
| 649 return _parser.parseExpression2(); | 649 return _parser.parseExpression2(); |
| 650 } | 650 } |
| 651 return notAChild(node); | 651 return _notAChild(node); |
| 652 } | 652 } |
| 653 | 653 |
| 654 AstNode visitInstanceCreationExpression(InstanceCreationExpression node) { | 654 AstNode visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 655 if (identical(_oldNode, node.constructorName)) { | 655 if (identical(_oldNode, node.constructorName)) { |
| 656 return _parser.parseConstructorName(); | 656 return _parser.parseConstructorName(); |
| 657 } else if (identical(_oldNode, node.argumentList)) { | 657 } else if (identical(_oldNode, node.argumentList)) { |
| 658 return _parser.parseArgumentList(); | 658 return _parser.parseArgumentList(); |
| 659 } | 659 } |
| 660 return notAChild(node); | 660 return _notAChild(node); |
| 661 } | 661 } |
| 662 | 662 |
| 663 AstNode visitIntegerLiteral(IntegerLiteral node) => notAChild(node); | 663 AstNode visitIntegerLiteral(IntegerLiteral node) => _notAChild(node); |
| 664 | 664 |
| 665 AstNode visitInterpolationExpression(InterpolationExpression node) { | 665 AstNode visitInterpolationExpression(InterpolationExpression node) { |
| 666 if (identical(_oldNode, node.expression)) { | 666 if (identical(_oldNode, node.expression)) { |
| 667 if (node.leftBracket == null) { | 667 if (node.leftBracket == null) { |
| 668 throw new InsufficientContextException(); | 668 throw new InsufficientContextException(); |
| 669 } | 669 } |
| 670 return _parser.parseExpression2(); | 670 return _parser.parseExpression2(); |
| 671 } | 671 } |
| 672 return notAChild(node); | 672 return _notAChild(node); |
| 673 } | 673 } |
| 674 | 674 |
| 675 AstNode visitInterpolationString(InterpolationString node) { | 675 AstNode visitInterpolationString(InterpolationString node) { |
| 676 throw new InsufficientContextException(); | 676 throw new InsufficientContextException(); |
| 677 } | 677 } |
| 678 | 678 |
| 679 AstNode visitIsExpression(IsExpression node) { | 679 AstNode visitIsExpression(IsExpression node) { |
| 680 if (identical(_oldNode, node.expression)) { | 680 if (identical(_oldNode, node.expression)) { |
| 681 return _parser.parseBitwiseOrExpression(); | 681 return _parser.parseBitwiseOrExpression(); |
| 682 } else if (identical(_oldNode, node.type)) { | 682 } else if (identical(_oldNode, node.type)) { |
| 683 return _parser.parseTypeName(); | 683 return _parser.parseTypeName(); |
| 684 } | 684 } |
| 685 return notAChild(node); | 685 return _notAChild(node); |
| 686 } | 686 } |
| 687 | 687 |
| 688 AstNode visitLabel(Label node) { | 688 AstNode visitLabel(Label node) { |
| 689 if (identical(_oldNode, node.label)) { | 689 if (identical(_oldNode, node.label)) { |
| 690 return _parser.parseSimpleIdentifier(); | 690 return _parser.parseSimpleIdentifier(); |
| 691 } | 691 } |
| 692 return notAChild(node); | 692 return _notAChild(node); |
| 693 } | 693 } |
| 694 | 694 |
| 695 AstNode visitLabeledStatement(LabeledStatement node) { | 695 AstNode visitLabeledStatement(LabeledStatement node) { |
| 696 if (node.labels.contains(_oldNode)) { | 696 if (node.labels.contains(_oldNode)) { |
| 697 return _parser.parseLabel(); | 697 return _parser.parseLabel(); |
| 698 } else if (identical(_oldNode, node.statement)) { | 698 } else if (identical(_oldNode, node.statement)) { |
| 699 return _parser.parseStatement2(); | 699 return _parser.parseStatement2(); |
| 700 } | 700 } |
| 701 return notAChild(node); | 701 return _notAChild(node); |
| 702 } | 702 } |
| 703 | 703 |
| 704 AstNode visitLibraryDirective(LibraryDirective node) { | 704 AstNode visitLibraryDirective(LibraryDirective node) { |
| 705 if (identical(_oldNode, node.documentationComment)) { | 705 if (identical(_oldNode, node.documentationComment)) { |
| 706 throw new InsufficientContextException(); | 706 throw new InsufficientContextException(); |
| 707 } else if (node.metadata.contains(_oldNode)) { | 707 } else if (node.metadata.contains(_oldNode)) { |
| 708 return _parser.parseAnnotation(); | 708 return _parser.parseAnnotation(); |
| 709 } else if (identical(_oldNode, node.name)) { | 709 } else if (identical(_oldNode, node.name)) { |
| 710 return _parser.parseLibraryIdentifier(); | 710 return _parser.parseLibraryIdentifier(); |
| 711 } | 711 } |
| 712 return notAChild(node); | 712 return _notAChild(node); |
| 713 } | 713 } |
| 714 | 714 |
| 715 AstNode visitLibraryIdentifier(LibraryIdentifier node) { | 715 AstNode visitLibraryIdentifier(LibraryIdentifier node) { |
| 716 if (node.components.contains(_oldNode)) { | 716 if (node.components.contains(_oldNode)) { |
| 717 return _parser.parseSimpleIdentifier(); | 717 return _parser.parseSimpleIdentifier(); |
| 718 } | 718 } |
| 719 return notAChild(node); | 719 return _notAChild(node); |
| 720 } | 720 } |
| 721 | 721 |
| 722 AstNode visitListLiteral(ListLiteral node) { | 722 AstNode visitListLiteral(ListLiteral node) { |
| 723 if (identical(_oldNode, node.typeArguments)) { | 723 if (identical(_oldNode, node.typeArguments)) { |
| 724 return _parser.parseTypeArgumentList(); | 724 return _parser.parseTypeArgumentList(); |
| 725 } else if (node.elements.contains(_oldNode)) { | 725 } else if (node.elements.contains(_oldNode)) { |
| 726 return _parser.parseExpression2(); | 726 return _parser.parseExpression2(); |
| 727 } | 727 } |
| 728 return notAChild(node); | 728 return _notAChild(node); |
| 729 } | 729 } |
| 730 | 730 |
| 731 AstNode visitMapLiteral(MapLiteral node) { | 731 AstNode visitMapLiteral(MapLiteral node) { |
| 732 if (identical(_oldNode, node.typeArguments)) { | 732 if (identical(_oldNode, node.typeArguments)) { |
| 733 return _parser.parseTypeArgumentList(); | 733 return _parser.parseTypeArgumentList(); |
| 734 } else if (node.entries.contains(_oldNode)) { | 734 } else if (node.entries.contains(_oldNode)) { |
| 735 return _parser.parseMapLiteralEntry(); | 735 return _parser.parseMapLiteralEntry(); |
| 736 } | 736 } |
| 737 return notAChild(node); | 737 return _notAChild(node); |
| 738 } | 738 } |
| 739 | 739 |
| 740 AstNode visitMapLiteralEntry(MapLiteralEntry node) { | 740 AstNode visitMapLiteralEntry(MapLiteralEntry node) { |
| 741 if (identical(_oldNode, node.key)) { | 741 if (identical(_oldNode, node.key)) { |
| 742 return _parser.parseExpression2(); | 742 return _parser.parseExpression2(); |
| 743 } else if (identical(_oldNode, node.value)) { | 743 } else if (identical(_oldNode, node.value)) { |
| 744 return _parser.parseExpression2(); | 744 return _parser.parseExpression2(); |
| 745 } | 745 } |
| 746 return notAChild(node); | 746 return _notAChild(node); |
| 747 } | 747 } |
| 748 | 748 |
| 749 AstNode visitMethodDeclaration(MethodDeclaration node) { | 749 AstNode visitMethodDeclaration(MethodDeclaration node) { |
| 750 if (identical(_oldNode, node.documentationComment)) { | 750 if (identical(_oldNode, node.documentationComment)) { |
| 751 throw new InsufficientContextException(); | 751 throw new InsufficientContextException(); |
| 752 } else if (node.metadata.contains(_oldNode)) { | 752 } else if (node.metadata.contains(_oldNode)) { |
| 753 return _parser.parseAnnotation(); | 753 return _parser.parseAnnotation(); |
| 754 } else if (identical(_oldNode, node.returnType)) { | 754 } else if (identical(_oldNode, node.returnType)) { |
| 755 throw new InsufficientContextException(); | 755 throw new InsufficientContextException(); |
| 756 } else if (identical(_oldNode, node.name)) { | 756 } else if (identical(_oldNode, node.name)) { |
| 757 if (node.operatorKeyword != null) { | 757 if (node.operatorKeyword != null) { |
| 758 throw new InsufficientContextException(); | 758 throw new InsufficientContextException(); |
| 759 } | 759 } |
| 760 return _parser.parseSimpleIdentifier(); | 760 return _parser.parseSimpleIdentifier(); |
| 761 } else if (identical(_oldNode, node.body)) { | 761 } else if (identical(_oldNode, node.body)) { |
| 762 //return parser.parseFunctionBody(); | 762 //return parser.parseFunctionBody(); |
| 763 throw new InsufficientContextException(); | 763 throw new InsufficientContextException(); |
| 764 } | 764 } |
| 765 return notAChild(node); | 765 return _notAChild(node); |
| 766 } | 766 } |
| 767 | 767 |
| 768 AstNode visitMethodInvocation(MethodInvocation node) { | 768 AstNode visitMethodInvocation(MethodInvocation node) { |
| 769 if (identical(_oldNode, node.target)) { | 769 if (identical(_oldNode, node.target)) { |
| 770 throw new IncrementalParseException(); | 770 throw new IncrementalParseException(); |
| 771 } else if (identical(_oldNode, node.methodName)) { | 771 } else if (identical(_oldNode, node.methodName)) { |
| 772 return _parser.parseSimpleIdentifier(); | 772 return _parser.parseSimpleIdentifier(); |
| 773 } else if (identical(_oldNode, node.argumentList)) { | 773 } else if (identical(_oldNode, node.argumentList)) { |
| 774 return _parser.parseArgumentList(); | 774 return _parser.parseArgumentList(); |
| 775 } | 775 } |
| 776 return notAChild(node); | 776 return _notAChild(node); |
| 777 } | 777 } |
| 778 | 778 |
| 779 AstNode visitNamedExpression(NamedExpression node) { | 779 AstNode visitNamedExpression(NamedExpression node) { |
| 780 if (identical(_oldNode, node.name)) { | 780 if (identical(_oldNode, node.name)) { |
| 781 return _parser.parseLabel(); | 781 return _parser.parseLabel(); |
| 782 } else if (identical(_oldNode, node.expression)) { | 782 } else if (identical(_oldNode, node.expression)) { |
| 783 return _parser.parseExpression2(); | 783 return _parser.parseExpression2(); |
| 784 } | 784 } |
| 785 return notAChild(node); | 785 return _notAChild(node); |
| 786 } | 786 } |
| 787 | 787 |
| 788 AstNode visitNativeClause(NativeClause node) { | 788 AstNode visitNativeClause(NativeClause node) { |
| 789 if (identical(_oldNode, node.name)) { | 789 if (identical(_oldNode, node.name)) { |
| 790 return _parser.parseStringLiteral(); | 790 return _parser.parseStringLiteral(); |
| 791 } | 791 } |
| 792 return notAChild(node); | 792 return _notAChild(node); |
| 793 } | 793 } |
| 794 | 794 |
| 795 AstNode visitNativeFunctionBody(NativeFunctionBody node) { | 795 AstNode visitNativeFunctionBody(NativeFunctionBody node) { |
| 796 if (identical(_oldNode, node.stringLiteral)) { | 796 if (identical(_oldNode, node.stringLiteral)) { |
| 797 return _parser.parseStringLiteral(); | 797 return _parser.parseStringLiteral(); |
| 798 } | 798 } |
| 799 return notAChild(node); | 799 return _notAChild(node); |
| 800 } | 800 } |
| 801 | 801 |
| 802 AstNode visitNullLiteral(NullLiteral node) => notAChild(node); | 802 AstNode visitNullLiteral(NullLiteral node) => _notAChild(node); |
| 803 | 803 |
| 804 AstNode visitParenthesizedExpression(ParenthesizedExpression node) { | 804 AstNode visitParenthesizedExpression(ParenthesizedExpression node) { |
| 805 if (identical(_oldNode, node.expression)) { | 805 if (identical(_oldNode, node.expression)) { |
| 806 return _parser.parseExpression2(); | 806 return _parser.parseExpression2(); |
| 807 } | 807 } |
| 808 return notAChild(node); | 808 return _notAChild(node); |
| 809 } | 809 } |
| 810 | 810 |
| 811 AstNode visitPartDirective(PartDirective node) { | 811 AstNode visitPartDirective(PartDirective node) { |
| 812 if (identical(_oldNode, node.documentationComment)) { | 812 if (identical(_oldNode, node.documentationComment)) { |
| 813 throw new InsufficientContextException(); | 813 throw new InsufficientContextException(); |
| 814 } else if (node.metadata.contains(_oldNode)) { | 814 } else if (node.metadata.contains(_oldNode)) { |
| 815 return _parser.parseAnnotation(); | 815 return _parser.parseAnnotation(); |
| 816 } else if (identical(_oldNode, node.uri)) { | 816 } else if (identical(_oldNode, node.uri)) { |
| 817 return _parser.parseStringLiteral(); | 817 return _parser.parseStringLiteral(); |
| 818 } | 818 } |
| 819 return notAChild(node); | 819 return _notAChild(node); |
| 820 } | 820 } |
| 821 | 821 |
| 822 AstNode visitPartOfDirective(PartOfDirective node) { | 822 AstNode visitPartOfDirective(PartOfDirective node) { |
| 823 if (identical(_oldNode, node.documentationComment)) { | 823 if (identical(_oldNode, node.documentationComment)) { |
| 824 throw new InsufficientContextException(); | 824 throw new InsufficientContextException(); |
| 825 } else if (node.metadata.contains(_oldNode)) { | 825 } else if (node.metadata.contains(_oldNode)) { |
| 826 return _parser.parseAnnotation(); | 826 return _parser.parseAnnotation(); |
| 827 } else if (identical(_oldNode, node.libraryName)) { | 827 } else if (identical(_oldNode, node.libraryName)) { |
| 828 return _parser.parseLibraryIdentifier(); | 828 return _parser.parseLibraryIdentifier(); |
| 829 } | 829 } |
| 830 return notAChild(node); | 830 return _notAChild(node); |
| 831 } | 831 } |
| 832 | 832 |
| 833 AstNode visitPostfixExpression(PostfixExpression node) { | 833 AstNode visitPostfixExpression(PostfixExpression node) { |
| 834 if (identical(_oldNode, node.operand)) { | 834 if (identical(_oldNode, node.operand)) { |
| 835 throw new InsufficientContextException(); | 835 throw new InsufficientContextException(); |
| 836 } | 836 } |
| 837 return notAChild(node); | 837 return _notAChild(node); |
| 838 } | 838 } |
| 839 | 839 |
| 840 AstNode visitPrefixedIdentifier(PrefixedIdentifier node) { | 840 AstNode visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 841 if (identical(_oldNode, node.prefix)) { | 841 if (identical(_oldNode, node.prefix)) { |
| 842 return _parser.parseSimpleIdentifier(); | 842 return _parser.parseSimpleIdentifier(); |
| 843 } else if (identical(_oldNode, node.identifier)) { | 843 } else if (identical(_oldNode, node.identifier)) { |
| 844 return _parser.parseSimpleIdentifier(); | 844 return _parser.parseSimpleIdentifier(); |
| 845 } | 845 } |
| 846 return notAChild(node); | 846 return _notAChild(node); |
| 847 } | 847 } |
| 848 | 848 |
| 849 AstNode visitPrefixExpression(PrefixExpression node) { | 849 AstNode visitPrefixExpression(PrefixExpression node) { |
| 850 if (identical(_oldNode, node.operand)) { | 850 if (identical(_oldNode, node.operand)) { |
| 851 throw new InsufficientContextException(); | 851 throw new InsufficientContextException(); |
| 852 } | 852 } |
| 853 return notAChild(node); | 853 return _notAChild(node); |
| 854 } | 854 } |
| 855 | 855 |
| 856 AstNode visitPropertyAccess(PropertyAccess node) { | 856 AstNode visitPropertyAccess(PropertyAccess node) { |
| 857 if (identical(_oldNode, node.target)) { | 857 if (identical(_oldNode, node.target)) { |
| 858 throw new InsufficientContextException(); | 858 throw new InsufficientContextException(); |
| 859 } else if (identical(_oldNode, node.propertyName)) { | 859 } else if (identical(_oldNode, node.propertyName)) { |
| 860 return _parser.parseSimpleIdentifier(); | 860 return _parser.parseSimpleIdentifier(); |
| 861 } | 861 } |
| 862 return notAChild(node); | 862 return _notAChild(node); |
| 863 } | 863 } |
| 864 | 864 |
| 865 AstNode visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 865 AstNode visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 866 if (identical(_oldNode, node.constructorName)) { | 866 if (identical(_oldNode, node.constructorName)) { |
| 867 return _parser.parseSimpleIdentifier(); | 867 return _parser.parseSimpleIdentifier(); |
| 868 } else if (identical(_oldNode, node.argumentList)) { | 868 } else if (identical(_oldNode, node.argumentList)) { |
| 869 return _parser.parseArgumentList(); | 869 return _parser.parseArgumentList(); |
| 870 } | 870 } |
| 871 return notAChild(node); | 871 return _notAChild(node); |
| 872 } | 872 } |
| 873 | 873 |
| 874 AstNode visitRethrowExpression(RethrowExpression node) => notAChild(node); | 874 AstNode visitRethrowExpression(RethrowExpression node) => _notAChild(node); |
| 875 | 875 |
| 876 AstNode visitReturnStatement(ReturnStatement node) { | 876 AstNode visitReturnStatement(ReturnStatement node) { |
| 877 if (identical(_oldNode, node.expression)) { | 877 if (identical(_oldNode, node.expression)) { |
| 878 return _parser.parseExpression2(); | 878 return _parser.parseExpression2(); |
| 879 } | 879 } |
| 880 return notAChild(node); | 880 return _notAChild(node); |
| 881 } | 881 } |
| 882 | 882 |
| 883 AstNode visitScriptTag(ScriptTag node) => notAChild(node); | 883 AstNode visitScriptTag(ScriptTag node) => _notAChild(node); |
| 884 | 884 |
| 885 AstNode visitShowCombinator(ShowCombinator node) { | 885 AstNode visitShowCombinator(ShowCombinator node) { |
| 886 if (node.shownNames.contains(_oldNode)) { | 886 if (node.shownNames.contains(_oldNode)) { |
| 887 return _parser.parseSimpleIdentifier(); | 887 return _parser.parseSimpleIdentifier(); |
| 888 } | 888 } |
| 889 return notAChild(node); | 889 return _notAChild(node); |
| 890 } | 890 } |
| 891 | 891 |
| 892 AstNode visitSimpleFormalParameter(SimpleFormalParameter node) { | 892 AstNode visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 893 if (identical(_oldNode, node.documentationComment)) { | 893 if (identical(_oldNode, node.documentationComment)) { |
| 894 throw new InsufficientContextException(); | 894 throw new InsufficientContextException(); |
| 895 } else if (node.metadata.contains(_oldNode)) { | 895 } else if (node.metadata.contains(_oldNode)) { |
| 896 return _parser.parseAnnotation(); | 896 return _parser.parseAnnotation(); |
| 897 } else if (identical(_oldNode, node.type)) { | 897 } else if (identical(_oldNode, node.type)) { |
| 898 throw new InsufficientContextException(); | 898 throw new InsufficientContextException(); |
| 899 } else if (identical(_oldNode, node.identifier)) { | 899 } else if (identical(_oldNode, node.identifier)) { |
| 900 throw new InsufficientContextException(); | 900 throw new InsufficientContextException(); |
| 901 } | 901 } |
| 902 return notAChild(node); | 902 return _notAChild(node); |
| 903 } | 903 } |
| 904 | 904 |
| 905 AstNode visitSimpleIdentifier(SimpleIdentifier node) => notAChild(node); | 905 AstNode visitSimpleIdentifier(SimpleIdentifier node) => _notAChild(node); |
| 906 | 906 |
| 907 AstNode visitSimpleStringLiteral(SimpleStringLiteral node) => notAChild(node); | 907 AstNode visitSimpleStringLiteral(SimpleStringLiteral node) => _notAChild(node)
; |
| 908 | 908 |
| 909 AstNode visitStringInterpolation(StringInterpolation node) { | 909 AstNode visitStringInterpolation(StringInterpolation node) { |
| 910 if (node.elements.contains(_oldNode)) { | 910 if (node.elements.contains(_oldNode)) { |
| 911 throw new InsufficientContextException(); | 911 throw new InsufficientContextException(); |
| 912 } | 912 } |
| 913 return notAChild(node); | 913 return _notAChild(node); |
| 914 } | 914 } |
| 915 | 915 |
| 916 AstNode visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 916 AstNode visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 917 if (identical(_oldNode, node.constructorName)) { | 917 if (identical(_oldNode, node.constructorName)) { |
| 918 return _parser.parseSimpleIdentifier(); | 918 return _parser.parseSimpleIdentifier(); |
| 919 } else if (identical(_oldNode, node.argumentList)) { | 919 } else if (identical(_oldNode, node.argumentList)) { |
| 920 return _parser.parseArgumentList(); | 920 return _parser.parseArgumentList(); |
| 921 } | 921 } |
| 922 return notAChild(node); | 922 return _notAChild(node); |
| 923 } | 923 } |
| 924 | 924 |
| 925 AstNode visitSuperExpression(SuperExpression node) => notAChild(node); | 925 AstNode visitSuperExpression(SuperExpression node) => _notAChild(node); |
| 926 | 926 |
| 927 AstNode visitSwitchCase(SwitchCase node) { | 927 AstNode visitSwitchCase(SwitchCase node) { |
| 928 if (node.labels.contains(_oldNode)) { | 928 if (node.labels.contains(_oldNode)) { |
| 929 return _parser.parseLabel(); | 929 return _parser.parseLabel(); |
| 930 } else if (identical(_oldNode, node.expression)) { | 930 } else if (identical(_oldNode, node.expression)) { |
| 931 return _parser.parseExpression2(); | 931 return _parser.parseExpression2(); |
| 932 } else if (node.statements.contains(_oldNode)) { | 932 } else if (node.statements.contains(_oldNode)) { |
| 933 return _parser.parseStatement2(); | 933 return _parser.parseStatement2(); |
| 934 } | 934 } |
| 935 return notAChild(node); | 935 return _notAChild(node); |
| 936 } | 936 } |
| 937 | 937 |
| 938 AstNode visitSwitchDefault(SwitchDefault node) { | 938 AstNode visitSwitchDefault(SwitchDefault node) { |
| 939 if (node.labels.contains(_oldNode)) { | 939 if (node.labels.contains(_oldNode)) { |
| 940 return _parser.parseLabel(); | 940 return _parser.parseLabel(); |
| 941 } else if (node.statements.contains(_oldNode)) { | 941 } else if (node.statements.contains(_oldNode)) { |
| 942 return _parser.parseStatement2(); | 942 return _parser.parseStatement2(); |
| 943 } | 943 } |
| 944 return notAChild(node); | 944 return _notAChild(node); |
| 945 } | 945 } |
| 946 | 946 |
| 947 AstNode visitSwitchStatement(SwitchStatement node) { | 947 AstNode visitSwitchStatement(SwitchStatement node) { |
| 948 if (identical(_oldNode, node.expression)) { | 948 if (identical(_oldNode, node.expression)) { |
| 949 return _parser.parseExpression2(); | 949 return _parser.parseExpression2(); |
| 950 } else if (node.members.contains(_oldNode)) { | 950 } else if (node.members.contains(_oldNode)) { |
| 951 throw new InsufficientContextException(); | 951 throw new InsufficientContextException(); |
| 952 } | 952 } |
| 953 return notAChild(node); | 953 return _notAChild(node); |
| 954 } | 954 } |
| 955 | 955 |
| 956 AstNode visitSymbolLiteral(SymbolLiteral node) => notAChild(node); | 956 AstNode visitSymbolLiteral(SymbolLiteral node) => _notAChild(node); |
| 957 | 957 |
| 958 AstNode visitThisExpression(ThisExpression node) => notAChild(node); | 958 AstNode visitThisExpression(ThisExpression node) => _notAChild(node); |
| 959 | 959 |
| 960 AstNode visitThrowExpression(ThrowExpression node) { | 960 AstNode visitThrowExpression(ThrowExpression node) { |
| 961 if (identical(_oldNode, node.expression)) { | 961 if (identical(_oldNode, node.expression)) { |
| 962 if (isCascadeAllowedInThrow(node)) { | 962 if (_isCascadeAllowedInThrow(node)) { |
| 963 return _parser.parseExpression2(); | 963 return _parser.parseExpression2(); |
| 964 } | 964 } |
| 965 return _parser.parseExpressionWithoutCascade(); | 965 return _parser.parseExpressionWithoutCascade(); |
| 966 } | 966 } |
| 967 return notAChild(node); | 967 return _notAChild(node); |
| 968 } | 968 } |
| 969 | 969 |
| 970 AstNode visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 970 AstNode visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 971 if (identical(_oldNode, node.documentationComment)) { | 971 if (identical(_oldNode, node.documentationComment)) { |
| 972 throw new InsufficientContextException(); | 972 throw new InsufficientContextException(); |
| 973 } else if (node.metadata.contains(_oldNode)) { | 973 } else if (node.metadata.contains(_oldNode)) { |
| 974 return _parser.parseAnnotation(); | 974 return _parser.parseAnnotation(); |
| 975 } else if (identical(_oldNode, node.variables)) { | 975 } else if (identical(_oldNode, node.variables)) { |
| 976 throw new InsufficientContextException(); | 976 throw new InsufficientContextException(); |
| 977 } | 977 } |
| 978 return notAChild(node); | 978 return _notAChild(node); |
| 979 } | 979 } |
| 980 | 980 |
| 981 AstNode visitTryStatement(TryStatement node) { | 981 AstNode visitTryStatement(TryStatement node) { |
| 982 if (identical(_oldNode, node.body)) { | 982 if (identical(_oldNode, node.body)) { |
| 983 return _parser.parseBlock(); | 983 return _parser.parseBlock(); |
| 984 } else if (node.catchClauses.contains(_oldNode)) { | 984 } else if (node.catchClauses.contains(_oldNode)) { |
| 985 throw new InsufficientContextException(); | 985 throw new InsufficientContextException(); |
| 986 } else if (identical(_oldNode, node.finallyBlock)) { | 986 } else if (identical(_oldNode, node.finallyBlock)) { |
| 987 throw new InsufficientContextException(); | 987 throw new InsufficientContextException(); |
| 988 } | 988 } |
| 989 return notAChild(node); | 989 return _notAChild(node); |
| 990 } | 990 } |
| 991 | 991 |
| 992 AstNode visitTypeArgumentList(TypeArgumentList node) { | 992 AstNode visitTypeArgumentList(TypeArgumentList node) { |
| 993 if (node.arguments.contains(_oldNode)) { | 993 if (node.arguments.contains(_oldNode)) { |
| 994 return _parser.parseTypeName(); | 994 return _parser.parseTypeName(); |
| 995 } | 995 } |
| 996 return notAChild(node); | 996 return _notAChild(node); |
| 997 } | 997 } |
| 998 | 998 |
| 999 AstNode visitTypeName(TypeName node) { | 999 AstNode visitTypeName(TypeName node) { |
| 1000 if (identical(_oldNode, node.name)) { | 1000 if (identical(_oldNode, node.name)) { |
| 1001 return _parser.parsePrefixedIdentifier(); | 1001 return _parser.parsePrefixedIdentifier(); |
| 1002 } else if (identical(_oldNode, node.typeArguments)) { | 1002 } else if (identical(_oldNode, node.typeArguments)) { |
| 1003 return _parser.parseTypeArgumentList(); | 1003 return _parser.parseTypeArgumentList(); |
| 1004 } | 1004 } |
| 1005 return notAChild(node); | 1005 return _notAChild(node); |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 AstNode visitTypeParameter(TypeParameter node) { | 1008 AstNode visitTypeParameter(TypeParameter node) { |
| 1009 if (identical(_oldNode, node.documentationComment)) { | 1009 if (identical(_oldNode, node.documentationComment)) { |
| 1010 throw new InsufficientContextException(); | 1010 throw new InsufficientContextException(); |
| 1011 } else if (node.metadata.contains(_oldNode)) { | 1011 } else if (node.metadata.contains(_oldNode)) { |
| 1012 return _parser.parseAnnotation(); | 1012 return _parser.parseAnnotation(); |
| 1013 } else if (identical(_oldNode, node.name)) { | 1013 } else if (identical(_oldNode, node.name)) { |
| 1014 return _parser.parseSimpleIdentifier(); | 1014 return _parser.parseSimpleIdentifier(); |
| 1015 } else if (identical(_oldNode, node.bound)) { | 1015 } else if (identical(_oldNode, node.bound)) { |
| 1016 return _parser.parseTypeName(); | 1016 return _parser.parseTypeName(); |
| 1017 } | 1017 } |
| 1018 return notAChild(node); | 1018 return _notAChild(node); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 AstNode visitTypeParameterList(TypeParameterList node) { | 1021 AstNode visitTypeParameterList(TypeParameterList node) { |
| 1022 if (node.typeParameters.contains(node)) { | 1022 if (node.typeParameters.contains(node)) { |
| 1023 return _parser.parseTypeParameter(); | 1023 return _parser.parseTypeParameter(); |
| 1024 } | 1024 } |
| 1025 return notAChild(node); | 1025 return _notAChild(node); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 AstNode visitVariableDeclaration(VariableDeclaration node) { | 1028 AstNode visitVariableDeclaration(VariableDeclaration node) { |
| 1029 if (identical(_oldNode, node.documentationComment)) { | 1029 if (identical(_oldNode, node.documentationComment)) { |
| 1030 throw new InsufficientContextException(); | 1030 throw new InsufficientContextException(); |
| 1031 } else if (node.metadata.contains(_oldNode)) { | 1031 } else if (node.metadata.contains(_oldNode)) { |
| 1032 return _parser.parseAnnotation(); | 1032 return _parser.parseAnnotation(); |
| 1033 } else if (identical(_oldNode, node.name)) { | 1033 } else if (identical(_oldNode, node.name)) { |
| 1034 throw new InsufficientContextException(); | 1034 throw new InsufficientContextException(); |
| 1035 } else if (identical(_oldNode, node.initializer)) { | 1035 } else if (identical(_oldNode, node.initializer)) { |
| 1036 throw new InsufficientContextException(); | 1036 throw new InsufficientContextException(); |
| 1037 } | 1037 } |
| 1038 return notAChild(node); | 1038 return _notAChild(node); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 AstNode visitVariableDeclarationList(VariableDeclarationList node) { | 1041 AstNode visitVariableDeclarationList(VariableDeclarationList node) { |
| 1042 if (identical(_oldNode, node.documentationComment)) { | 1042 if (identical(_oldNode, node.documentationComment)) { |
| 1043 throw new InsufficientContextException(); | 1043 throw new InsufficientContextException(); |
| 1044 } else if (node.metadata.contains(_oldNode)) { | 1044 } else if (node.metadata.contains(_oldNode)) { |
| 1045 return _parser.parseAnnotation(); | 1045 return _parser.parseAnnotation(); |
| 1046 } else if (node.variables.contains(_oldNode)) { | 1046 } else if (node.variables.contains(_oldNode)) { |
| 1047 throw new InsufficientContextException(); | 1047 throw new InsufficientContextException(); |
| 1048 } | 1048 } |
| 1049 return notAChild(node); | 1049 return _notAChild(node); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 AstNode visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 1052 AstNode visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 1053 if (identical(_oldNode, node.variables)) { | 1053 if (identical(_oldNode, node.variables)) { |
| 1054 throw new InsufficientContextException(); | 1054 throw new InsufficientContextException(); |
| 1055 } | 1055 } |
| 1056 return notAChild(node); | 1056 return _notAChild(node); |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 AstNode visitWhileStatement(WhileStatement node) { | 1059 AstNode visitWhileStatement(WhileStatement node) { |
| 1060 if (identical(_oldNode, node.condition)) { | 1060 if (identical(_oldNode, node.condition)) { |
| 1061 return _parser.parseExpression2(); | 1061 return _parser.parseExpression2(); |
| 1062 } else if (identical(_oldNode, node.body)) { | 1062 } else if (identical(_oldNode, node.body)) { |
| 1063 return _parser.parseStatement2(); | 1063 return _parser.parseStatement2(); |
| 1064 } | 1064 } |
| 1065 return notAChild(node); | 1065 return _notAChild(node); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 AstNode visitWithClause(WithClause node) { | 1068 AstNode visitWithClause(WithClause node) { |
| 1069 if (node.mixinTypes.contains(node)) { | 1069 if (node.mixinTypes.contains(node)) { |
| 1070 return _parser.parseTypeName(); | 1070 return _parser.parseTypeName(); |
| 1071 } | 1071 } |
| 1072 return notAChild(node); | 1072 return _notAChild(node); |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 /** | 1075 /** |
| 1076 * Return `true` if the given assignment expression can have a cascade express
ion on the | 1076 * Return `true` if the given assignment expression can have a cascade express
ion on the |
| 1077 * right-hand side. | 1077 * right-hand side. |
| 1078 * | 1078 * |
| 1079 * @param node the assignment expression being tested | 1079 * @param node the assignment expression being tested |
| 1080 * @return `true` if the right-hand side can be a cascade expression | 1080 * @return `true` if the right-hand side can be a cascade expression |
| 1081 */ | 1081 */ |
| 1082 bool isCascadeAllowedInAssignment(AssignmentExpression node) { | 1082 bool _isCascadeAllowedInAssignment(AssignmentExpression node) { |
| 1083 // TODO(brianwilkerson) Implement this method. | 1083 // TODO(brianwilkerson) Implement this method. |
| 1084 throw new InsufficientContextException(); | 1084 throw new InsufficientContextException(); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 /** | 1087 /** |
| 1088 * Return `true` if the given throw expression can have a cascade expression. | 1088 * Return `true` if the given throw expression can have a cascade expression. |
| 1089 * | 1089 * |
| 1090 * @param node the throw expression being tested | 1090 * @param node the throw expression being tested |
| 1091 * @return `true` if the expression can be a cascade expression | 1091 * @return `true` if the expression can be a cascade expression |
| 1092 */ | 1092 */ |
| 1093 bool isCascadeAllowedInThrow(ThrowExpression node) { | 1093 bool _isCascadeAllowedInThrow(ThrowExpression node) { |
| 1094 // TODO(brianwilkerson) Implement this method. | 1094 // TODO(brianwilkerson) Implement this method. |
| 1095 throw new InsufficientContextException(); | 1095 throw new InsufficientContextException(); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 /** | 1098 /** |
| 1099 * Throw an exception indicating that the visited node was not the parent of t
he node to be | 1099 * Throw an exception indicating that the visited node was not the parent of t
he node to be |
| 1100 * replaced. | 1100 * replaced. |
| 1101 * | 1101 * |
| 1102 * @param visitedNode the visited node that should have been the parent of the
node to be replaced | 1102 * @param visitedNode the visited node that should have been the parent of the
node to be replaced |
| 1103 */ | 1103 */ |
| 1104 AstNode notAChild(AstNode visitedNode) { | 1104 AstNode _notAChild(AstNode visitedNode) { |
| 1105 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()})"); | 1105 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()})"); |
| 1106 } | 1106 } |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 /** | 1109 /** |
| 1110 * Instances of the class `IncrementalParseException` represent an exception tha
t occurred | 1110 * Instances of the class `IncrementalParseException` represent an exception tha
t occurred |
| 1111 * while attempting to parse a replacement for a specified node in an existing A
ST structure. | 1111 * while attempting to parse a replacement for a specified node in an existing A
ST structure. |
| 1112 */ | 1112 */ |
| 1113 class IncrementalParseException extends RuntimeException { | 1113 class IncrementalParseException extends RuntimeException { |
| 1114 /** | 1114 /** |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 // | 1206 // |
| 1207 if (originalEnd < originalStart) { | 1207 if (originalEnd < originalStart) { |
| 1208 oldNode = new NodeLocator.con1(originalStart).searchWithin(originalStructu
re); | 1208 oldNode = new NodeLocator.con1(originalStart).searchWithin(originalStructu
re); |
| 1209 } else { | 1209 } else { |
| 1210 oldNode = new NodeLocator.con2(originalStart, originalEnd).searchWithin(or
iginalStructure); | 1210 oldNode = new NodeLocator.con2(originalStart, originalEnd).searchWithin(or
iginalStructure); |
| 1211 } | 1211 } |
| 1212 // | 1212 // |
| 1213 // Find the token at which parsing is to begin. | 1213 // Find the token at which parsing is to begin. |
| 1214 // | 1214 // |
| 1215 int originalOffset = oldNode.offset; | 1215 int originalOffset = oldNode.offset; |
| 1216 Token parseToken = findTokenAt(firstToken, originalOffset); | 1216 Token parseToken = _findTokenAt(firstToken, originalOffset); |
| 1217 if (parseToken == null) { | 1217 if (parseToken == null) { |
| 1218 return null; | 1218 return null; |
| 1219 } | 1219 } |
| 1220 // | 1220 // |
| 1221 // Parse the appropriate AST structure starting at the appropriate place. | 1221 // Parse the appropriate AST structure starting at the appropriate place. |
| 1222 // | 1222 // |
| 1223 Parser parser = new Parser(_source, _errorListener); | 1223 Parser parser = new Parser(_source, _errorListener); |
| 1224 parser.currentToken = parseToken; | 1224 parser.currentToken = parseToken; |
| 1225 while (newNode == null) { | 1225 while (newNode == null) { |
| 1226 AstNode parent = oldNode.parent; | 1226 AstNode parent = oldNode.parent; |
| 1227 if (parent == null) { | 1227 if (parent == null) { |
| 1228 parseToken = findFirstToken(parseToken); | 1228 parseToken = _findFirstToken(parseToken); |
| 1229 parser.currentToken = parseToken; | 1229 parser.currentToken = parseToken; |
| 1230 return parser.parseCompilationUnit2(); | 1230 return parser.parseCompilationUnit2(); |
| 1231 } | 1231 } |
| 1232 bool advanceToParent = false; | 1232 bool advanceToParent = false; |
| 1233 try { | 1233 try { |
| 1234 IncrementalParseDispatcher dispatcher = new IncrementalParseDispatcher(p
arser, oldNode); | 1234 IncrementalParseDispatcher dispatcher = new IncrementalParseDispatcher(p
arser, oldNode); |
| 1235 newNode = parent.accept(dispatcher); | 1235 newNode = parent.accept(dispatcher); |
| 1236 // | 1236 // |
| 1237 // Validate that the new node can replace the old node. | 1237 // Validate that the new node can replace the old node. |
| 1238 // | 1238 // |
| 1239 Token mappedToken = _tokenMap.get(oldNode.endToken.next); | 1239 Token mappedToken = _tokenMap.get(oldNode.endToken.next); |
| 1240 if (mappedToken == null || mappedToken.offset != newNode.endToken.next.o
ffset || newNode.offset != oldNode.offset) { | 1240 if (mappedToken == null || mappedToken.offset != newNode.endToken.next.o
ffset || newNode.offset != oldNode.offset) { |
| 1241 advanceToParent = true; | 1241 advanceToParent = true; |
| 1242 } | 1242 } |
| 1243 } on InsufficientContextException catch (exception) { | 1243 } on InsufficientContextException catch (exception) { |
| 1244 advanceToParent = true; | 1244 advanceToParent = true; |
| 1245 } on JavaException catch (exception) { | 1245 } on JavaException catch (exception) { |
| 1246 return null; | 1246 return null; |
| 1247 } | 1247 } |
| 1248 if (advanceToParent) { | 1248 if (advanceToParent) { |
| 1249 newNode = null; | 1249 newNode = null; |
| 1250 oldNode = parent; | 1250 oldNode = parent; |
| 1251 originalOffset = oldNode.offset; | 1251 originalOffset = oldNode.offset; |
| 1252 parseToken = findTokenAt(parseToken, originalOffset); | 1252 parseToken = _findTokenAt(parseToken, originalOffset); |
| 1253 parser.currentToken = parseToken; | 1253 parser.currentToken = parseToken; |
| 1254 } | 1254 } |
| 1255 } | 1255 } |
| 1256 _updatedNode = newNode; | 1256 _updatedNode = newNode; |
| 1257 // | 1257 // |
| 1258 // Replace the old node with the new node in a copy of the original AST stru
cture. | 1258 // Replace the old node with the new node in a copy of the original AST stru
cture. |
| 1259 // | 1259 // |
| 1260 if (identical(oldNode, originalStructure)) { | 1260 if (identical(oldNode, originalStructure)) { |
| 1261 // We ended up re-parsing the whole structure, so there's no need for a co
py. | 1261 // We ended up re-parsing the whole structure, so there's no need for a co
py. |
| 1262 ResolutionCopier.copyResolutionData(oldNode, newNode); | 1262 ResolutionCopier.copyResolutionData(oldNode, newNode); |
| 1263 return newNode; | 1263 return newNode; |
| 1264 } | 1264 } |
| 1265 ResolutionCopier.copyResolutionData(oldNode, newNode); | 1265 ResolutionCopier.copyResolutionData(oldNode, newNode); |
| 1266 IncrementalAstCloner cloner = new IncrementalAstCloner(oldNode, newNode, _to
kenMap); | 1266 IncrementalAstCloner cloner = new IncrementalAstCloner(oldNode, newNode, _to
kenMap); |
| 1267 return originalStructure.accept(cloner) as AstNode; | 1267 return originalStructure.accept(cloner) as AstNode; |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 /** | 1270 /** |
| 1271 * Return the first (non-EOF) token in the token stream containing the given t
oken. | 1271 * Return the first (non-EOF) token in the token stream containing the given t
oken. |
| 1272 * | 1272 * |
| 1273 * @param firstToken the token from which the search is to begin | 1273 * @param firstToken the token from which the search is to begin |
| 1274 * @return the first token in the token stream containing the given token | 1274 * @return the first token in the token stream containing the given token |
| 1275 */ | 1275 */ |
| 1276 Token findFirstToken(Token firstToken) { | 1276 Token _findFirstToken(Token firstToken) { |
| 1277 while (firstToken.type != TokenType.EOF) { | 1277 while (firstToken.type != TokenType.EOF) { |
| 1278 firstToken = firstToken.previous; | 1278 firstToken = firstToken.previous; |
| 1279 } | 1279 } |
| 1280 return firstToken.next; | 1280 return firstToken.next; |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 /** | 1283 /** |
| 1284 * Find the token at or before the given token with the given offset, or `null
` if there is | 1284 * Find the token at or before the given token with the given offset, or `null
` if there is |
| 1285 * no such token. | 1285 * no such token. |
| 1286 * | 1286 * |
| 1287 * @param firstToken the token from which the search is to begin | 1287 * @param firstToken the token from which the search is to begin |
| 1288 * @param offset the offset of the token to be returned | 1288 * @param offset the offset of the token to be returned |
| 1289 * @return the token with the given offset | 1289 * @return the token with the given offset |
| 1290 */ | 1290 */ |
| 1291 Token findTokenAt(Token firstToken, int offset) { | 1291 Token _findTokenAt(Token firstToken, int offset) { |
| 1292 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) { | 1292 while (firstToken.offset > offset && firstToken.type != TokenType.EOF) { |
| 1293 firstToken = firstToken.previous; | 1293 firstToken = firstToken.previous; |
| 1294 } | 1294 } |
| 1295 return firstToken; | 1295 return firstToken; |
| 1296 } | 1296 } |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 /** | 1299 /** |
| 1300 * Instances of the class `InsufficientContextException` represent a situation i
n which an AST | 1300 * Instances of the class `InsufficientContextException` represent a situation i
n which an AST |
| 1301 * node cannot be re-parsed because there is not enough context to know how to r
e-parse the node. | 1301 * node cannot be re-parsed because there is not enough context to know how to r
e-parse the node. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 * Parse a sequence of statements, starting with the given token. | 1437 * Parse a sequence of statements, starting with the given token. |
| 1438 * | 1438 * |
| 1439 * @param token the first token of the sequence of statement | 1439 * @param token the first token of the sequence of statement |
| 1440 * @return the statements that were parsed, or `null` if the tokens do not rep
resent a | 1440 * @return the statements that were parsed, or `null` if the tokens do not rep
resent a |
| 1441 * recognizable sequence of statements | 1441 * recognizable sequence of statements |
| 1442 */ | 1442 */ |
| 1443 List<Statement> parseStatements(Token token) { | 1443 List<Statement> parseStatements(Token token) { |
| 1444 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.Parser.parseStatements"); | 1444 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi
ne.Parser.parseStatements"); |
| 1445 try { | 1445 try { |
| 1446 _currentToken = token; | 1446 _currentToken = token; |
| 1447 return parseStatementList(); | 1447 return _parseStatementList(); |
| 1448 } finally { | 1448 } finally { |
| 1449 instrumentation.log(); | 1449 instrumentation.log(); |
| 1450 } | 1450 } |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 /** | 1453 /** |
| 1454 * Set whether parser is to parse function bodies. | 1454 * Set whether parser is to parse function bodies. |
| 1455 * | 1455 * |
| 1456 * @param parseFunctionBodies `true` if parser is to parse function bodies | 1456 * @param parseFunctionBodies `true` if parser is to parse function bodies |
| 1457 */ | 1457 */ |
| 1458 void set parseFunctionBodies(bool parseFunctionBodies) { | 1458 void set parseFunctionBodies(bool parseFunctionBodies) { |
| 1459 this._parseFunctionBodies = parseFunctionBodies; | 1459 this._parseFunctionBodies = parseFunctionBodies; |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 /** | 1462 /** |
| 1463 * Parse an annotation. | 1463 * Parse an annotation. |
| 1464 * | 1464 * |
| 1465 * <pre> | 1465 * <pre> |
| 1466 * annotation ::= | 1466 * annotation ::= |
| 1467 * '@' qualified ('.' identifier)? arguments? | 1467 * '@' qualified ('.' identifier)? arguments? |
| 1468 * </pre> | 1468 * </pre> |
| 1469 * | 1469 * |
| 1470 * @return the annotation that was parsed | 1470 * @return the annotation that was parsed |
| 1471 */ | 1471 */ |
| 1472 Annotation parseAnnotation() { | 1472 Annotation parseAnnotation() { |
| 1473 Token atSign = expect(TokenType.AT); | 1473 Token atSign = _expect(TokenType.AT); |
| 1474 Identifier name = parsePrefixedIdentifier(); | 1474 Identifier name = parsePrefixedIdentifier(); |
| 1475 Token period = null; | 1475 Token period = null; |
| 1476 SimpleIdentifier constructorName = null; | 1476 SimpleIdentifier constructorName = null; |
| 1477 if (matches(TokenType.PERIOD)) { | 1477 if (_matches(TokenType.PERIOD)) { |
| 1478 period = andAdvance; | 1478 period = andAdvance; |
| 1479 constructorName = parseSimpleIdentifier(); | 1479 constructorName = parseSimpleIdentifier(); |
| 1480 } | 1480 } |
| 1481 ArgumentList arguments = null; | 1481 ArgumentList arguments = null; |
| 1482 if (matches(TokenType.OPEN_PAREN)) { | 1482 if (_matches(TokenType.OPEN_PAREN)) { |
| 1483 arguments = parseArgumentList(); | 1483 arguments = parseArgumentList(); |
| 1484 } | 1484 } |
| 1485 return new Annotation(atSign, name, period, constructorName, arguments); | 1485 return new Annotation(atSign, name, period, constructorName, arguments); |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 /** | 1488 /** |
| 1489 * Parse an argument. | 1489 * Parse an argument. |
| 1490 * | 1490 * |
| 1491 * <pre> | 1491 * <pre> |
| 1492 * argument ::= | 1492 * argument ::= |
| 1493 * namedArgument | 1493 * namedArgument |
| 1494 * | expression | 1494 * | expression |
| 1495 * | 1495 * |
| 1496 * namedArgument ::= | 1496 * namedArgument ::= |
| 1497 * label expression | 1497 * label expression |
| 1498 * </pre> | 1498 * </pre> |
| 1499 * | 1499 * |
| 1500 * @return the argument that was parsed | 1500 * @return the argument that was parsed |
| 1501 */ | 1501 */ |
| 1502 Expression parseArgument() { | 1502 Expression parseArgument() { |
| 1503 // | 1503 // |
| 1504 // Both namedArgument and expression can start with an identifier, but only
namedArgument can | 1504 // Both namedArgument and expression can start with an identifier, but only
namedArgument can |
| 1505 // have an identifier followed by a colon. | 1505 // have an identifier followed by a colon. |
| 1506 // | 1506 // |
| 1507 if (matchesIdentifier() && tokenMatches(peek(), TokenType.COLON)) { | 1507 if (_matchesIdentifier() && _tokenMatches(_peek(), TokenType.COLON)) { |
| 1508 return new NamedExpression(parseLabel(), parseExpression2()); | 1508 return new NamedExpression(parseLabel(), parseExpression2()); |
| 1509 } else { | 1509 } else { |
| 1510 return parseExpression2(); | 1510 return parseExpression2(); |
| 1511 } | 1511 } |
| 1512 } | 1512 } |
| 1513 | 1513 |
| 1514 /** | 1514 /** |
| 1515 * Parse a list of arguments. | 1515 * Parse a list of arguments. |
| 1516 * | 1516 * |
| 1517 * <pre> | 1517 * <pre> |
| 1518 * arguments ::= | 1518 * arguments ::= |
| 1519 * '(' argumentList? ')' | 1519 * '(' argumentList? ')' |
| 1520 * | 1520 * |
| 1521 * argumentList ::= | 1521 * argumentList ::= |
| 1522 * namedArgument (',' namedArgument)* | 1522 * namedArgument (',' namedArgument)* |
| 1523 * | expressionList (',' namedArgument)* | 1523 * | expressionList (',' namedArgument)* |
| 1524 * </pre> | 1524 * </pre> |
| 1525 * | 1525 * |
| 1526 * @return the argument list that was parsed | 1526 * @return the argument list that was parsed |
| 1527 */ | 1527 */ |
| 1528 ArgumentList parseArgumentList() { | 1528 ArgumentList parseArgumentList() { |
| 1529 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 1529 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 1530 List<Expression> arguments = new List<Expression>(); | 1530 List<Expression> arguments = new List<Expression>(); |
| 1531 if (matches(TokenType.CLOSE_PAREN)) { | 1531 if (_matches(TokenType.CLOSE_PAREN)) { |
| 1532 return new ArgumentList(leftParenthesis, arguments, andAdvance); | 1532 return new ArgumentList(leftParenthesis, arguments, andAdvance); |
| 1533 } | 1533 } |
| 1534 // | 1534 // |
| 1535 // Even though unnamed arguments must all appear before any named arguments,
we allow them to | 1535 // Even though unnamed arguments must all appear before any named arguments,
we allow them to |
| 1536 // appear in any order so that we can recover faster. | 1536 // appear in any order so that we can recover faster. |
| 1537 // | 1537 // |
| 1538 Expression argument = parseArgument(); | 1538 Expression argument = parseArgument(); |
| 1539 arguments.add(argument); | 1539 arguments.add(argument); |
| 1540 bool foundNamedArgument = argument is NamedExpression; | 1540 bool foundNamedArgument = argument is NamedExpression; |
| 1541 bool generatedError = false; | 1541 bool generatedError = false; |
| 1542 while (optional(TokenType.COMMA)) { | 1542 while (_optional(TokenType.COMMA)) { |
| 1543 argument = parseArgument(); | 1543 argument = parseArgument(); |
| 1544 arguments.add(argument); | 1544 arguments.add(argument); |
| 1545 if (foundNamedArgument) { | 1545 if (foundNamedArgument) { |
| 1546 if (!generatedError && argument is! NamedExpression) { | 1546 if (!generatedError && argument is! NamedExpression) { |
| 1547 // Report the error, once, but allow the arguments to be in any order
in the AST. | 1547 // Report the error, once, but allow the arguments to be in any order
in the AST. |
| 1548 reportErrorForCurrentToken(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGU
MENT, []); | 1548 _reportErrorForCurrentToken(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARG
UMENT, []); |
| 1549 generatedError = true; | 1549 generatedError = true; |
| 1550 } | 1550 } |
| 1551 } else if (argument is NamedExpression) { | 1551 } else if (argument is NamedExpression) { |
| 1552 foundNamedArgument = true; | 1552 foundNamedArgument = true; |
| 1553 } | 1553 } |
| 1554 } | 1554 } |
| 1555 // TODO(brianwilkerson) Recovery: Look at the left parenthesis to see whethe
r there is a | 1555 // TODO(brianwilkerson) Recovery: Look at the left parenthesis to see whethe
r there is a |
| 1556 // matching right parenthesis. If there is, then we're more likely missing a
comma and should | 1556 // matching right parenthesis. If there is, then we're more likely missing a
comma and should |
| 1557 // go back to parsing arguments. | 1557 // go back to parsing arguments. |
| 1558 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 1558 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 1559 return new ArgumentList(leftParenthesis, arguments, rightParenthesis); | 1559 return new ArgumentList(leftParenthesis, arguments, rightParenthesis); |
| 1560 } | 1560 } |
| 1561 | 1561 |
| 1562 /** | 1562 /** |
| 1563 * Parse a bitwise or expression. | 1563 * Parse a bitwise or expression. |
| 1564 * | 1564 * |
| 1565 * <pre> | 1565 * <pre> |
| 1566 * bitwiseOrExpression ::= | 1566 * bitwiseOrExpression ::= |
| 1567 * bitwiseXorExpression ('|' bitwiseXorExpression)* | 1567 * bitwiseXorExpression ('|' bitwiseXorExpression)* |
| 1568 * | 'super' ('|' bitwiseXorExpression)+ | 1568 * | 'super' ('|' bitwiseXorExpression)+ |
| 1569 * </pre> | 1569 * </pre> |
| 1570 * | 1570 * |
| 1571 * @return the bitwise or expression that was parsed | 1571 * @return the bitwise or expression that was parsed |
| 1572 */ | 1572 */ |
| 1573 Expression parseBitwiseOrExpression() { | 1573 Expression parseBitwiseOrExpression() { |
| 1574 Expression expression; | 1574 Expression expression; |
| 1575 if (matchesKeyword(Keyword.SUPER) && tokenMatches(peek(), TokenType.BAR)) { | 1575 if (_matchesKeyword(Keyword.SUPER) && _tokenMatches(_peek(), TokenType.BAR))
{ |
| 1576 expression = new SuperExpression(andAdvance); | 1576 expression = new SuperExpression(andAdvance); |
| 1577 } else { | 1577 } else { |
| 1578 expression = parseBitwiseXorExpression(); | 1578 expression = _parseBitwiseXorExpression(); |
| 1579 } | 1579 } |
| 1580 while (matches(TokenType.BAR)) { | 1580 while (_matches(TokenType.BAR)) { |
| 1581 Token operator = andAdvance; | 1581 Token operator = andAdvance; |
| 1582 expression = new BinaryExpression(expression, operator, parseBitwiseXorExp
ression()); | 1582 expression = new BinaryExpression(expression, operator, _parseBitwiseXorEx
pression()); |
| 1583 } | 1583 } |
| 1584 return expression; | 1584 return expression; |
| 1585 } | 1585 } |
| 1586 | 1586 |
| 1587 /** | 1587 /** |
| 1588 * Parse a block. | 1588 * Parse a block. |
| 1589 * | 1589 * |
| 1590 * <pre> | 1590 * <pre> |
| 1591 * block ::= | 1591 * block ::= |
| 1592 * '{' statements '}' | 1592 * '{' statements '}' |
| 1593 * </pre> | 1593 * </pre> |
| 1594 * | 1594 * |
| 1595 * @return the block that was parsed | 1595 * @return the block that was parsed |
| 1596 */ | 1596 */ |
| 1597 Block parseBlock() { | 1597 Block parseBlock() { |
| 1598 Token leftBracket = expect(TokenType.OPEN_CURLY_BRACKET); | 1598 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); |
| 1599 List<Statement> statements = new List<Statement>(); | 1599 List<Statement> statements = new List<Statement>(); |
| 1600 Token statementStart = _currentToken; | 1600 Token statementStart = _currentToken; |
| 1601 while (!matches(TokenType.EOF) && !matches(TokenType.CLOSE_CURLY_BRACKET)) { | 1601 while (!_matches(TokenType.EOF) && !_matches(TokenType.CLOSE_CURLY_BRACKET))
{ |
| 1602 Statement statement = parseStatement2(); | 1602 Statement statement = parseStatement2(); |
| 1603 if (statement != null) { | 1603 if (statement != null) { |
| 1604 statements.add(statement); | 1604 statements.add(statement); |
| 1605 } | 1605 } |
| 1606 if (identical(_currentToken, statementStart)) { | 1606 if (identical(_currentToken, statementStart)) { |
| 1607 // Ensure that we are making progress and report an error if we're not. | 1607 // Ensure that we are making progress and report an error if we're not. |
| 1608 reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_c
urrentToken.lexeme]); | 1608 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_
currentToken.lexeme]); |
| 1609 advance(); | 1609 _advance(); |
| 1610 } | 1610 } |
| 1611 statementStart = _currentToken; | 1611 statementStart = _currentToken; |
| 1612 } | 1612 } |
| 1613 Token rightBracket = expect(TokenType.CLOSE_CURLY_BRACKET); | 1613 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
| 1614 return new Block(leftBracket, statements, rightBracket); | 1614 return new Block(leftBracket, statements, rightBracket); |
| 1615 } | 1615 } |
| 1616 | 1616 |
| 1617 /** | 1617 /** |
| 1618 * Parse a class member. | 1618 * Parse a class member. |
| 1619 * | 1619 * |
| 1620 * <pre> | 1620 * <pre> |
| 1621 * classMemberDefinition ::= | 1621 * classMemberDefinition ::= |
| 1622 * declaration ';' | 1622 * declaration ';' |
| 1623 * | methodSignature functionBody | 1623 * | methodSignature functionBody |
| 1624 * </pre> | 1624 * </pre> |
| 1625 * | 1625 * |
| 1626 * @param className the name of the class containing the member being parsed | 1626 * @param className the name of the class containing the member being parsed |
| 1627 * @return the class member that was parsed, or `null` if what was found was n
ot a valid | 1627 * @return the class member that was parsed, or `null` if what was found was n
ot a valid |
| 1628 * class member | 1628 * class member |
| 1629 */ | 1629 */ |
| 1630 ClassMember parseClassMember(String className) { | 1630 ClassMember parseClassMember(String className) { |
| 1631 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 1631 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 1632 Modifiers modifiers = parseModifiers(); | 1632 Modifiers modifiers = _parseModifiers(); |
| 1633 if (matchesKeyword(Keyword.VOID)) { | 1633 if (_matchesKeyword(Keyword.VOID)) { |
| 1634 TypeName returnType = parseReturnType(); | 1634 TypeName returnType = parseReturnType(); |
| 1635 if (matchesKeyword(Keyword.GET) && tokenMatchesIdentifier(peek())) { | 1635 if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek())) { |
| 1636 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1636 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1637 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifi
ers.staticKeyword, returnType); | 1637 return _parseGetter(commentAndMetadata, modifiers.externalKeyword, modif
iers.staticKeyword, returnType); |
| 1638 } else if (matchesKeyword(Keyword.SET) && tokenMatchesIdentifier(peek()))
{ | 1638 } else if (_matchesKeyword(Keyword.SET) && _tokenMatchesIdentifier(_peek()
)) { |
| 1639 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1639 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1640 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifi
ers.staticKeyword, returnType); | 1640 return _parseSetter(commentAndMetadata, modifiers.externalKeyword, modif
iers.staticKeyword, returnType); |
| 1641 } else if (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) { | 1641 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
| 1642 validateModifiersForOperator(modifiers); | 1642 _validateModifiersForOperator(modifiers); |
| 1643 return parseOperator(commentAndMetadata, modifiers.externalKeyword, retu
rnType); | 1643 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, ret
urnType); |
| 1644 } else if (matchesIdentifier() && matchesAny(peek(), [ | 1644 } else if (_matchesIdentifier() && _peek().matchesAny([ |
| 1645 TokenType.OPEN_PAREN, | 1645 TokenType.OPEN_PAREN, |
| 1646 TokenType.OPEN_CURLY_BRACKET, | 1646 TokenType.OPEN_CURLY_BRACKET, |
| 1647 TokenType.FUNCTION])) { | 1647 TokenType.FUNCTION])) { |
| 1648 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1648 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1649 return parseMethodDeclarationAfterReturnType(commentAndMetadata, modifie
rs.externalKeyword, modifiers.staticKeyword, returnType); | 1649 return _parseMethodDeclarationAfterReturnType(commentAndMetadata, modifi
ers.externalKeyword, modifiers.staticKeyword, returnType); |
| 1650 } else { | 1650 } else { |
| 1651 // | 1651 // |
| 1652 // We have found an error of some kind. Try to recover. | 1652 // We have found an error of some kind. Try to recover. |
| 1653 // | 1653 // |
| 1654 if (matchesIdentifier()) { | 1654 if (_matchesIdentifier()) { |
| 1655 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { | 1655 if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { |
| 1656 // | 1656 // |
| 1657 // We appear to have a variable declaration with a type of "void". | 1657 // We appear to have a variable declaration with a type of "void". |
| 1658 // | 1658 // |
| 1659 reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType, []); | 1659 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType, []); |
| 1660 return parseInitializedIdentifierList(commentAndMetadata, modifiers.
staticKeyword, validateModifiersForField(modifiers), returnType); | 1660 return _parseInitializedIdentifierList(commentAndMetadata, modifiers
.staticKeyword, _validateModifiersForField(modifiers), returnType); |
| 1661 } | 1661 } |
| 1662 } | 1662 } |
| 1663 if (isOperator(_currentToken)) { | 1663 if (_isOperator(_currentToken)) { |
| 1664 // | 1664 // |
| 1665 // We appear to have found an operator declaration without the 'operat
or' keyword. | 1665 // We appear to have found an operator declaration without the 'operat
or' keyword. |
| 1666 // | 1666 // |
| 1667 validateModifiersForOperator(modifiers); | 1667 _validateModifiersForOperator(modifiers); |
| 1668 return parseOperator(commentAndMetadata, modifiers.externalKeyword, re
turnType); | 1668 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, r
eturnType); |
| 1669 } | 1669 } |
| 1670 reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken,
[]); | 1670 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken,
[]); |
| 1671 return null; | 1671 return null; |
| 1672 } | 1672 } |
| 1673 } else if (matchesKeyword(Keyword.GET) && tokenMatchesIdentifier(peek())) { | 1673 } else if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek()))
{ |
| 1674 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1674 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1675 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); | 1675 return _parseGetter(commentAndMetadata, modifiers.externalKeyword, modifie
rs.staticKeyword, null); |
| 1676 } else if (matchesKeyword(Keyword.SET) && tokenMatchesIdentifier(peek())) { | 1676 } else if (_matchesKeyword(Keyword.SET) && _tokenMatchesIdentifier(_peek()))
{ |
| 1677 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1677 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1678 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); | 1678 return _parseSetter(commentAndMetadata, modifiers.externalKeyword, modifie
rs.staticKeyword, null); |
| 1679 } else if (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) { | 1679 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
| 1680 validateModifiersForOperator(modifiers); | 1680 _validateModifiersForOperator(modifiers); |
| 1681 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null); | 1681 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, null)
; |
| 1682 } else if (!matchesIdentifier()) { | 1682 } else if (!_matchesIdentifier()) { |
| 1683 if (isOperator(_currentToken)) { | 1683 if (_isOperator(_currentToken)) { |
| 1684 // | 1684 // |
| 1685 // We appear to have found an operator declaration without the 'operator
' keyword. | 1685 // We appear to have found an operator declaration without the 'operator
' keyword. |
| 1686 // | 1686 // |
| 1687 validateModifiersForOperator(modifiers); | 1687 _validateModifiersForOperator(modifiers); |
| 1688 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null
); | 1688 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, nul
l); |
| 1689 } | 1689 } |
| 1690 reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken,
[]); | 1690 _reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken,
[]); |
| 1691 if (commentAndMetadata.comment != null || !commentAndMetadata.metadata.isE
mpty) { | 1691 if (commentAndMetadata.comment != null || !commentAndMetadata.metadata.isE
mpty) { |
| 1692 // | 1692 // |
| 1693 // We appear to have found an incomplete declaration at the end of the c
lass. At this point | 1693 // We appear to have found an incomplete declaration at the end of the c
lass. At this point |
| 1694 // it consists of a metadata, which we don't want to loose, so we'll tre
at it as a method | 1694 // it consists of a metadata, which we don't want to loose, so we'll tre
at it as a method |
| 1695 // declaration with a missing name, parameters and empty body. | 1695 // declaration with a missing name, parameters and empty body. |
| 1696 // | 1696 // |
| 1697 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetad
ata.metadata, null, null, null, null, null, createSyntheticIdentifier(), new For
malParameterList(null, new List<FormalParameter>(), null, null, null), new Empty
FunctionBody(createSyntheticToken(TokenType.SEMICOLON))); | 1697 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetad
ata.metadata, null, null, null, null, null, _createSyntheticIdentifier(), new Fo
rmalParameterList(null, new List<FormalParameter>(), null, null, null), new Empt
yFunctionBody(_createSyntheticToken(TokenType.SEMICOLON))); |
| 1698 } | 1698 } |
| 1699 return null; | 1699 return null; |
| 1700 } else if (tokenMatches(peek(), TokenType.PERIOD) && tokenMatchesIdentifier(
peekAt(2)) && tokenMatches(peekAt(3), TokenType.OPEN_PAREN)) { | 1700 } else if (_tokenMatches(_peek(), TokenType.PERIOD) && _tokenMatchesIdentifi
er(_peekAt(2)) && _tokenMatches(_peekAt(3), TokenType.OPEN_PAREN)) { |
| 1701 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); | 1701 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword, _v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimple
Identifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); |
| 1702 } else if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 1702 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 1703 SimpleIdentifier methodName = parseSimpleIdentifier(); | 1703 SimpleIdentifier methodName = parseSimpleIdentifier(); |
| 1704 FormalParameterList parameters = parseFormalParameterList(); | 1704 FormalParameterList parameters = parseFormalParameterList(); |
| 1705 if (matches(TokenType.COLON) || modifiers.factoryKeyword != null || method
Name.name == className) { | 1705 if (_matches(TokenType.COLON) || modifiers.factoryKeyword != null || metho
dName.name == className) { |
| 1706 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); | 1706 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword,
_validateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodNam
e, null, null, parameters); |
| 1707 } | 1707 } |
| 1708 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1708 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1709 validateFormalParameterList(parameters); | 1709 _validateFormalParameterList(parameters); |
| 1710 return parseMethodDeclarationAfterParameters(commentAndMetadata, modifiers
.externalKeyword, modifiers.staticKeyword, null, methodName, parameters); | 1710 return _parseMethodDeclarationAfterParameters(commentAndMetadata, modifier
s.externalKeyword, modifiers.staticKeyword, null, methodName, parameters); |
| 1711 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { | 1711 } else if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { |
| 1712 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo
difiers.varKeyword == null) { | 1712 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo
difiers.varKeyword == null) { |
| 1713 reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TY
PE, []); | 1713 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_T
YPE, []); |
| 1714 } | 1714 } |
| 1715 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static
Keyword, validateModifiersForField(modifiers), null); | 1715 return _parseInitializedIdentifierList(commentAndMetadata, modifiers.stati
cKeyword, _validateModifiersForField(modifiers), null); |
| 1716 } | 1716 } |
| 1717 TypeName type = parseTypeName(); | 1717 TypeName type = parseTypeName(); |
| 1718 if (matchesKeyword(Keyword.GET) && tokenMatchesIdentifier(peek())) { | 1718 if (_matchesKeyword(Keyword.GET) && _tokenMatchesIdentifier(_peek())) { |
| 1719 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1719 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1720 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); | 1720 return _parseGetter(commentAndMetadata, modifiers.externalKeyword, modifie
rs.staticKeyword, type); |
| 1721 } else if (matchesKeyword(Keyword.SET) && tokenMatchesIdentifier(peek())) { | 1721 } else if (_matchesKeyword(Keyword.SET) && _tokenMatchesIdentifier(_peek()))
{ |
| 1722 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1722 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1723 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); | 1723 return _parseSetter(commentAndMetadata, modifiers.externalKeyword, modifie
rs.staticKeyword, type); |
| 1724 } else if (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) { | 1724 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
| 1725 validateModifiersForOperator(modifiers); | 1725 _validateModifiersForOperator(modifiers); |
| 1726 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type); | 1726 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, type)
; |
| 1727 } else if (!matchesIdentifier()) { | 1727 } else if (!_matchesIdentifier()) { |
| 1728 if (matches(TokenType.CLOSE_CURLY_BRACKET)) { | 1728 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
| 1729 // | 1729 // |
| 1730 // We appear to have found an incomplete declaration at the end of the c
lass. At this point | 1730 // We appear to have found an incomplete declaration at the end of the c
lass. At this point |
| 1731 // it consists of a type name, so we'll treat it as a field declaration
with a missing | 1731 // it consists of a type name, so we'll treat it as a field declaration
with a missing |
| 1732 // field name and semicolon. | 1732 // field name and semicolon. |
| 1733 // | 1733 // |
| 1734 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat
icKeyword, validateModifiersForField(modifiers), type); | 1734 return _parseInitializedIdentifierList(commentAndMetadata, modifiers.sta
ticKeyword, _validateModifiersForField(modifiers), type); |
| 1735 } | 1735 } |
| 1736 if (isOperator(_currentToken)) { | 1736 if (_isOperator(_currentToken)) { |
| 1737 // | 1737 // |
| 1738 // We appear to have found an operator declaration without the 'operator
' keyword. | 1738 // We appear to have found an operator declaration without the 'operator
' keyword. |
| 1739 // | 1739 // |
| 1740 validateModifiersForOperator(modifiers); | 1740 _validateModifiersForOperator(modifiers); |
| 1741 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type
); | 1741 return _parseOperator(commentAndMetadata, modifiers.externalKeyword, typ
e); |
| 1742 } | 1742 } |
| 1743 // | 1743 // |
| 1744 // We appear to have found an incomplete declaration before another declar
ation. | 1744 // We appear to have found an incomplete declaration before another declar
ation. |
| 1745 // At this point it consists of a type name, so we'll treat it as a field
declaration | 1745 // At this point it consists of a type name, so we'll treat it as a field
declaration |
| 1746 // with a missing field name and semicolon. | 1746 // with a missing field name and semicolon. |
| 1747 // | 1747 // |
| 1748 reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken,
[]); | 1748 _reportErrorForToken(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken,
[]); |
| 1749 try { | 1749 try { |
| 1750 lockErrorListener(); | 1750 _lockErrorListener(); |
| 1751 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat
icKeyword, validateModifiersForField(modifiers), type); | 1751 return _parseInitializedIdentifierList(commentAndMetadata, modifiers.sta
ticKeyword, _validateModifiersForField(modifiers), type); |
| 1752 } finally { | 1752 } finally { |
| 1753 unlockErrorListener(); | 1753 _unlockErrorListener(); |
| 1754 } | 1754 } |
| 1755 } else if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 1755 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 1756 SimpleIdentifier methodName = parseSimpleIdentifier(); | 1756 SimpleIdentifier methodName = parseSimpleIdentifier(); |
| 1757 FormalParameterList parameters = parseFormalParameterList(); | 1757 FormalParameterList parameters = parseFormalParameterList(); |
| 1758 if (methodName.name == className) { | 1758 if (methodName.name == className) { |
| 1759 reportErrorForNode(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type, [
]); | 1759 _reportErrorForNode(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type,
[]); |
| 1760 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); | 1760 return _parseConstructor(commentAndMetadata, modifiers.externalKeyword,
_validateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodNam
e, null, null, parameters); |
| 1761 } | 1761 } |
| 1762 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1762 _validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1763 validateFormalParameterList(parameters); | 1763 _validateFormalParameterList(parameters); |
| 1764 return parseMethodDeclarationAfterParameters(commentAndMetadata, modifiers
.externalKeyword, modifiers.staticKeyword, type, methodName, parameters); | 1764 return _parseMethodDeclarationAfterParameters(commentAndMetadata, modifier
s.externalKeyword, modifiers.staticKeyword, type, methodName, parameters); |
| 1765 } | 1765 } |
| 1766 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe
yword, validateModifiersForField(modifiers), type); | 1766 return _parseInitializedIdentifierList(commentAndMetadata, modifiers.staticK
eyword, _validateModifiersForField(modifiers), type); |
| 1767 } | 1767 } |
| 1768 | 1768 |
| 1769 /** | 1769 /** |
| 1770 * Parse a compilation unit. | 1770 * Parse a compilation unit. |
| 1771 * | 1771 * |
| 1772 * Specified: | 1772 * Specified: |
| 1773 * | 1773 * |
| 1774 * <pre> | 1774 * <pre> |
| 1775 * compilationUnit ::= | 1775 * compilationUnit ::= |
| 1776 * scriptTag? directive* topLevelDeclaration* | 1776 * scriptTag? directive* topLevelDeclaration* |
| 1777 * </pre> | 1777 * </pre> |
| 1778 * Actual: | 1778 * Actual: |
| 1779 * | 1779 * |
| 1780 * <pre> | 1780 * <pre> |
| 1781 * compilationUnit ::= | 1781 * compilationUnit ::= |
| 1782 * scriptTag? topLevelElement* | 1782 * scriptTag? topLevelElement* |
| 1783 * | 1783 * |
| 1784 * topLevelElement ::= | 1784 * topLevelElement ::= |
| 1785 * directive | 1785 * directive |
| 1786 * | topLevelDeclaration | 1786 * | topLevelDeclaration |
| 1787 * </pre> | 1787 * </pre> |
| 1788 * | 1788 * |
| 1789 * @return the compilation unit that was parsed | 1789 * @return the compilation unit that was parsed |
| 1790 */ | 1790 */ |
| 1791 CompilationUnit parseCompilationUnit2() { | 1791 CompilationUnit parseCompilationUnit2() { |
| 1792 Token firstToken = _currentToken; | 1792 Token firstToken = _currentToken; |
| 1793 ScriptTag scriptTag = null; | 1793 ScriptTag scriptTag = null; |
| 1794 if (matches(TokenType.SCRIPT_TAG)) { | 1794 if (_matches(TokenType.SCRIPT_TAG)) { |
| 1795 scriptTag = new ScriptTag(andAdvance); | 1795 scriptTag = new ScriptTag(andAdvance); |
| 1796 } | 1796 } |
| 1797 // | 1797 // |
| 1798 // Even though all directives must appear before declarations and must occur
in a given order, | 1798 // Even though all directives must appear before declarations and must occur
in a given order, |
| 1799 // we allow directives and declarations to occur in any order so that we can
recover better. | 1799 // we allow directives and declarations to occur in any order so that we can
recover better. |
| 1800 // | 1800 // |
| 1801 bool libraryDirectiveFound = false; | 1801 bool libraryDirectiveFound = false; |
| 1802 bool partOfDirectiveFound = false; | 1802 bool partOfDirectiveFound = false; |
| 1803 bool partDirectiveFound = false; | 1803 bool partDirectiveFound = false; |
| 1804 bool directiveFoundAfterDeclaration = false; | 1804 bool directiveFoundAfterDeclaration = false; |
| 1805 List<Directive> directives = new List<Directive>(); | 1805 List<Directive> directives = new List<Directive>(); |
| 1806 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; | 1806 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; |
| 1807 Token memberStart = _currentToken; | 1807 Token memberStart = _currentToken; |
| 1808 while (!matches(TokenType.EOF)) { | 1808 while (!_matches(TokenType.EOF)) { |
| 1809 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 1809 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 1810 if ((matchesKeyword(Keyword.IMPORT) || matchesKeyword(Keyword.EXPORT) || m
atchesKeyword(Keyword.LIBRARY) || matchesKeyword(Keyword.PART)) && !tokenMatches
(peek(), TokenType.PERIOD) && !tokenMatches(peek(), TokenType.LT) && !tokenMatch
es(peek(), TokenType.OPEN_PAREN)) { | 1810 if ((_matchesKeyword(Keyword.IMPORT) || _matchesKeyword(Keyword.EXPORT) ||
_matchesKeyword(Keyword.LIBRARY) || _matchesKeyword(Keyword.PART)) && !_tokenMa
tches(_peek(), TokenType.PERIOD) && !_tokenMatches(_peek(), TokenType.LT) && !_t
okenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 1811 Directive directive = parseDirective(commentAndMetadata); | 1811 Directive directive = _parseDirective(commentAndMetadata); |
| 1812 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { | 1812 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { |
| 1813 reportErrorForCurrentToken(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION
, []); | 1813 _reportErrorForCurrentToken(ParserErrorCode.DIRECTIVE_AFTER_DECLARATIO
N, []); |
| 1814 directiveFoundAfterDeclaration = true; | 1814 directiveFoundAfterDeclaration = true; |
| 1815 } | 1815 } |
| 1816 if (directive is LibraryDirective) { | 1816 if (directive is LibraryDirective) { |
| 1817 if (libraryDirectiveFound) { | 1817 if (libraryDirectiveFound) { |
| 1818 reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIV
ES, []); | 1818 _reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTI
VES, []); |
| 1819 } else { | 1819 } else { |
| 1820 if (directives.length > 0) { | 1820 if (directives.length > 0) { |
| 1821 reportErrorForToken(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, d
irective.libraryToken, []); | 1821 _reportErrorForToken(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST,
directive.libraryToken, []); |
| 1822 } | 1822 } |
| 1823 libraryDirectiveFound = true; | 1823 libraryDirectiveFound = true; |
| 1824 } | 1824 } |
| 1825 } else if (directive is PartDirective) { | 1825 } else if (directive is PartDirective) { |
| 1826 partDirectiveFound = true; | 1826 partDirectiveFound = true; |
| 1827 } else if (partDirectiveFound) { | 1827 } else if (partDirectiveFound) { |
| 1828 if (directive is ExportDirective) { | 1828 if (directive is ExportDirective) { |
| 1829 reportErrorForToken(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRE
CTIVE, directive.keyword, []); | 1829 _reportErrorForToken(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIR
ECTIVE, directive.keyword, []); |
| 1830 } else if (directive is ImportDirective) { | 1830 } else if (directive is ImportDirective) { |
| 1831 reportErrorForToken(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRE
CTIVE, directive.keyword, []); | 1831 _reportErrorForToken(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIR
ECTIVE, directive.keyword, []); |
| 1832 } | 1832 } |
| 1833 } | 1833 } |
| 1834 if (directive is PartOfDirective) { | 1834 if (directive is PartOfDirective) { |
| 1835 if (partOfDirectiveFound) { | 1835 if (partOfDirectiveFound) { |
| 1836 reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIV
ES, []); | 1836 _reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_PART_OF_DIRECTI
VES, []); |
| 1837 } else { | 1837 } else { |
| 1838 int directiveCount = directives.length; | 1838 int directiveCount = directives.length; |
| 1839 for (int i = 0; i < directiveCount; i++) { | 1839 for (int i = 0; i < directiveCount; i++) { |
| 1840 reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART,
directives[i].keyword, []); | 1840 _reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART
, directives[i].keyword, []); |
| 1841 } | 1841 } |
| 1842 partOfDirectiveFound = true; | 1842 partOfDirectiveFound = true; |
| 1843 } | 1843 } |
| 1844 } else { | 1844 } else { |
| 1845 if (partOfDirectiveFound) { | 1845 if (partOfDirectiveFound) { |
| 1846 reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, d
irective.keyword, []); | 1846 _reportErrorForToken(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART,
directive.keyword, []); |
| 1847 } | 1847 } |
| 1848 } | 1848 } |
| 1849 directives.add(directive); | 1849 directives.add(directive); |
| 1850 } else if (matches(TokenType.SEMICOLON)) { | 1850 } else if (_matches(TokenType.SEMICOLON)) { |
| 1851 reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_c
urrentToken.lexeme]); | 1851 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_
currentToken.lexeme]); |
| 1852 advance(); | 1852 _advance(); |
| 1853 } else { | 1853 } else { |
| 1854 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta
data); | 1854 CompilationUnitMember member = _parseCompilationUnitMember(commentAndMet
adata); |
| 1855 if (member != null) { | 1855 if (member != null) { |
| 1856 declarations.add(member); | 1856 declarations.add(member); |
| 1857 } | 1857 } |
| 1858 } | 1858 } |
| 1859 if (identical(_currentToken, memberStart)) { | 1859 if (identical(_currentToken, memberStart)) { |
| 1860 reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_c
urrentToken.lexeme]); | 1860 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_
currentToken.lexeme]); |
| 1861 advance(); | 1861 _advance(); |
| 1862 while (!matches(TokenType.EOF) && !couldBeStartOfCompilationUnitMember()
) { | 1862 while (!_matches(TokenType.EOF) && !_couldBeStartOfCompilationUnitMember
()) { |
| 1863 advance(); | 1863 _advance(); |
| 1864 } | 1864 } |
| 1865 } | 1865 } |
| 1866 memberStart = _currentToken; | 1866 memberStart = _currentToken; |
| 1867 } | 1867 } |
| 1868 return new CompilationUnit(firstToken, scriptTag, directives, declarations,
_currentToken); | 1868 return new CompilationUnit(firstToken, scriptTag, directives, declarations,
_currentToken); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 /** | 1871 /** |
| 1872 * Parse a conditional expression. | 1872 * Parse a conditional expression. |
| 1873 * | 1873 * |
| 1874 * <pre> | 1874 * <pre> |
| 1875 * conditionalExpression ::= | 1875 * conditionalExpression ::= |
| 1876 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithout
Cascade)? | 1876 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithout
Cascade)? |
| 1877 * </pre> | 1877 * </pre> |
| 1878 * | 1878 * |
| 1879 * @return the conditional expression that was parsed | 1879 * @return the conditional expression that was parsed |
| 1880 */ | 1880 */ |
| 1881 Expression parseConditionalExpression() { | 1881 Expression parseConditionalExpression() { |
| 1882 Expression condition = parseLogicalOrExpression(); | 1882 Expression condition = parseLogicalOrExpression(); |
| 1883 if (!matches(TokenType.QUESTION)) { | 1883 if (!_matches(TokenType.QUESTION)) { |
| 1884 return condition; | 1884 return condition; |
| 1885 } | 1885 } |
| 1886 Token question = andAdvance; | 1886 Token question = andAdvance; |
| 1887 Expression thenExpression = parseExpressionWithoutCascade(); | 1887 Expression thenExpression = parseExpressionWithoutCascade(); |
| 1888 Token colon = expect(TokenType.COLON); | 1888 Token colon = _expect(TokenType.COLON); |
| 1889 Expression elseExpression = parseExpressionWithoutCascade(); | 1889 Expression elseExpression = parseExpressionWithoutCascade(); |
| 1890 return new ConditionalExpression(condition, question, thenExpression, colon,
elseExpression); | 1890 return new ConditionalExpression(condition, question, thenExpression, colon,
elseExpression); |
| 1891 } | 1891 } |
| 1892 | 1892 |
| 1893 /** | 1893 /** |
| 1894 * Parse the name of a constructor. | 1894 * Parse the name of a constructor. |
| 1895 * | 1895 * |
| 1896 * <pre> | 1896 * <pre> |
| 1897 * constructorName: | 1897 * constructorName: |
| 1898 * type ('.' identifier)? | 1898 * type ('.' identifier)? |
| 1899 * </pre> | 1899 * </pre> |
| 1900 * | 1900 * |
| 1901 * @return the constructor name that was parsed | 1901 * @return the constructor name that was parsed |
| 1902 */ | 1902 */ |
| 1903 ConstructorName parseConstructorName() { | 1903 ConstructorName parseConstructorName() { |
| 1904 TypeName type = parseTypeName(); | 1904 TypeName type = parseTypeName(); |
| 1905 Token period = null; | 1905 Token period = null; |
| 1906 SimpleIdentifier name = null; | 1906 SimpleIdentifier name = null; |
| 1907 if (matches(TokenType.PERIOD)) { | 1907 if (_matches(TokenType.PERIOD)) { |
| 1908 period = andAdvance; | 1908 period = andAdvance; |
| 1909 name = parseSimpleIdentifier(); | 1909 name = parseSimpleIdentifier(); |
| 1910 } | 1910 } |
| 1911 return new ConstructorName(type, period, name); | 1911 return new ConstructorName(type, period, name); |
| 1912 } | 1912 } |
| 1913 | 1913 |
| 1914 /** | 1914 /** |
| 1915 * Parse an expression that does not contain any cascades. | 1915 * Parse an expression that does not contain any cascades. |
| 1916 * | 1916 * |
| 1917 * <pre> | 1917 * <pre> |
| 1918 * expression ::= | 1918 * expression ::= |
| 1919 * assignableExpression assignmentOperator expression | 1919 * assignableExpression assignmentOperator expression |
| 1920 * | conditionalExpression cascadeSection* | 1920 * | conditionalExpression cascadeSection* |
| 1921 * | throwExpression | 1921 * | throwExpression |
| 1922 * </pre> | 1922 * </pre> |
| 1923 * | 1923 * |
| 1924 * @return the expression that was parsed | 1924 * @return the expression that was parsed |
| 1925 */ | 1925 */ |
| 1926 Expression parseExpression2() { | 1926 Expression parseExpression2() { |
| 1927 if (matchesKeyword(Keyword.THROW)) { | 1927 if (_matchesKeyword(Keyword.THROW)) { |
| 1928 return parseThrowExpression(); | 1928 return _parseThrowExpression(); |
| 1929 } else if (matchesKeyword(Keyword.RETHROW)) { | 1929 } else if (_matchesKeyword(Keyword.RETHROW)) { |
| 1930 return parseRethrowExpression(); | 1930 return _parseRethrowExpression(); |
| 1931 } | 1931 } |
| 1932 // | 1932 // |
| 1933 // assignableExpression is a subset of conditionalExpression, so we can pars
e a conditional | 1933 // assignableExpression is a subset of conditionalExpression, so we can pars
e a conditional |
| 1934 // expression and then determine whether it is followed by an assignmentOper
ator, checking for | 1934 // expression and then determine whether it is followed by an assignmentOper
ator, checking for |
| 1935 // conformance to the restricted grammar after making that determination. | 1935 // conformance to the restricted grammar after making that determination. |
| 1936 // | 1936 // |
| 1937 Expression expression = parseConditionalExpression(); | 1937 Expression expression = parseConditionalExpression(); |
| 1938 TokenType tokenType = _currentToken.type; | 1938 TokenType tokenType = _currentToken.type; |
| 1939 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { | 1939 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { |
| 1940 List<Expression> cascadeSections = new List<Expression>(); | 1940 List<Expression> cascadeSections = new List<Expression>(); |
| 1941 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { | 1941 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { |
| 1942 Expression section = parseCascadeSection(); | 1942 Expression section = _parseCascadeSection(); |
| 1943 if (section != null) { | 1943 if (section != null) { |
| 1944 cascadeSections.add(section); | 1944 cascadeSections.add(section); |
| 1945 } | 1945 } |
| 1946 tokenType = _currentToken.type; | 1946 tokenType = _currentToken.type; |
| 1947 } | 1947 } |
| 1948 return new CascadeExpression(expression, cascadeSections); | 1948 return new CascadeExpression(expression, cascadeSections); |
| 1949 } else if (tokenType.isAssignmentOperator) { | 1949 } else if (tokenType.isAssignmentOperator) { |
| 1950 Token operator = andAdvance; | 1950 Token operator = andAdvance; |
| 1951 ensureAssignable(expression); | 1951 _ensureAssignable(expression); |
| 1952 return new AssignmentExpression(expression, operator, parseExpression2()); | 1952 return new AssignmentExpression(expression, operator, parseExpression2()); |
| 1953 } | 1953 } |
| 1954 return expression; | 1954 return expression; |
| 1955 } | 1955 } |
| 1956 | 1956 |
| 1957 /** | 1957 /** |
| 1958 * Parse an expression that does not contain any cascades. | 1958 * Parse an expression that does not contain any cascades. |
| 1959 * | 1959 * |
| 1960 * <pre> | 1960 * <pre> |
| 1961 * expressionWithoutCascade ::= | 1961 * expressionWithoutCascade ::= |
| 1962 * assignableExpression assignmentOperator expressionWithoutCascade | 1962 * assignableExpression assignmentOperator expressionWithoutCascade |
| 1963 * | conditionalExpression | 1963 * | conditionalExpression |
| 1964 * | throwExpressionWithoutCascade | 1964 * | throwExpressionWithoutCascade |
| 1965 * </pre> | 1965 * </pre> |
| 1966 * | 1966 * |
| 1967 * @return the expression that was parsed | 1967 * @return the expression that was parsed |
| 1968 */ | 1968 */ |
| 1969 Expression parseExpressionWithoutCascade() { | 1969 Expression parseExpressionWithoutCascade() { |
| 1970 if (matchesKeyword(Keyword.THROW)) { | 1970 if (_matchesKeyword(Keyword.THROW)) { |
| 1971 return parseThrowExpressionWithoutCascade(); | 1971 return _parseThrowExpressionWithoutCascade(); |
| 1972 } else if (matchesKeyword(Keyword.RETHROW)) { | 1972 } else if (_matchesKeyword(Keyword.RETHROW)) { |
| 1973 return parseRethrowExpression(); | 1973 return _parseRethrowExpression(); |
| 1974 } | 1974 } |
| 1975 // | 1975 // |
| 1976 // assignableExpression is a subset of conditionalExpression, so we can pars
e a conditional | 1976 // assignableExpression is a subset of conditionalExpression, so we can pars
e a conditional |
| 1977 // expression and then determine whether it is followed by an assignmentOper
ator, checking for | 1977 // expression and then determine whether it is followed by an assignmentOper
ator, checking for |
| 1978 // conformance to the restricted grammar after making that determination. | 1978 // conformance to the restricted grammar after making that determination. |
| 1979 // | 1979 // |
| 1980 Expression expression = parseConditionalExpression(); | 1980 Expression expression = parseConditionalExpression(); |
| 1981 if (_currentToken.type.isAssignmentOperator) { | 1981 if (_currentToken.type.isAssignmentOperator) { |
| 1982 Token operator = andAdvance; | 1982 Token operator = andAdvance; |
| 1983 ensureAssignable(expression); | 1983 _ensureAssignable(expression); |
| 1984 expression = new AssignmentExpression(expression, operator, parseExpressio
nWithoutCascade()); | 1984 expression = new AssignmentExpression(expression, operator, parseExpressio
nWithoutCascade()); |
| 1985 } | 1985 } |
| 1986 return expression; | 1986 return expression; |
| 1987 } | 1987 } |
| 1988 | 1988 |
| 1989 /** | 1989 /** |
| 1990 * Parse a class extends clause. | 1990 * Parse a class extends clause. |
| 1991 * | 1991 * |
| 1992 * <pre> | 1992 * <pre> |
| 1993 * classExtendsClause ::= | 1993 * classExtendsClause ::= |
| 1994 * 'extends' type | 1994 * 'extends' type |
| 1995 * </pre> | 1995 * </pre> |
| 1996 * | 1996 * |
| 1997 * @return the class extends clause that was parsed | 1997 * @return the class extends clause that was parsed |
| 1998 */ | 1998 */ |
| 1999 ExtendsClause parseExtendsClause() { | 1999 ExtendsClause parseExtendsClause() { |
| 2000 Token keyword = expectKeyword(Keyword.EXTENDS); | 2000 Token keyword = _expectKeyword(Keyword.EXTENDS); |
| 2001 TypeName superclass = parseTypeName(); | 2001 TypeName superclass = parseTypeName(); |
| 2002 return new ExtendsClause(keyword, superclass); | 2002 return new ExtendsClause(keyword, superclass); |
| 2003 } | 2003 } |
| 2004 | 2004 |
| 2005 /** | 2005 /** |
| 2006 * Parse a list of formal parameters. | 2006 * Parse a list of formal parameters. |
| 2007 * | 2007 * |
| 2008 * <pre> | 2008 * <pre> |
| 2009 * formalParameterList ::= | 2009 * formalParameterList ::= |
| 2010 * '(' ')' | 2010 * '(' ')' |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2021 * optionalPositionalFormalParameters ::= | 2021 * optionalPositionalFormalParameters ::= |
| 2022 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' | 2022 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' |
| 2023 * | 2023 * |
| 2024 * namedFormalParameters ::= | 2024 * namedFormalParameters ::= |
| 2025 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' | 2025 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' |
| 2026 * </pre> | 2026 * </pre> |
| 2027 * | 2027 * |
| 2028 * @return the formal parameters that were parsed | 2028 * @return the formal parameters that were parsed |
| 2029 */ | 2029 */ |
| 2030 FormalParameterList parseFormalParameterList() { | 2030 FormalParameterList parseFormalParameterList() { |
| 2031 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 2031 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 2032 if (matches(TokenType.CLOSE_PAREN)) { | 2032 if (_matches(TokenType.CLOSE_PAREN)) { |
| 2033 return new FormalParameterList(leftParenthesis, null, null, null, andAdvan
ce); | 2033 return new FormalParameterList(leftParenthesis, null, null, null, andAdvan
ce); |
| 2034 } | 2034 } |
| 2035 // | 2035 // |
| 2036 // Even though it is invalid to have default parameters outside of brackets,
required parameters | 2036 // Even though it is invalid to have default parameters outside of brackets,
required parameters |
| 2037 // inside of brackets, or multiple groups of default and named parameters, w
e allow all of these | 2037 // inside of brackets, or multiple groups of default and named parameters, w
e allow all of these |
| 2038 // cases so that we can recover better. | 2038 // cases so that we can recover better. |
| 2039 // | 2039 // |
| 2040 List<FormalParameter> parameters = new List<FormalParameter>(); | 2040 List<FormalParameter> parameters = new List<FormalParameter>(); |
| 2041 List<FormalParameter> normalParameters = new List<FormalParameter>(); | 2041 List<FormalParameter> normalParameters = new List<FormalParameter>(); |
| 2042 List<FormalParameter> positionalParameters = new List<FormalParameter>(); | 2042 List<FormalParameter> positionalParameters = new List<FormalParameter>(); |
| 2043 List<FormalParameter> namedParameters = new List<FormalParameter>(); | 2043 List<FormalParameter> namedParameters = new List<FormalParameter>(); |
| 2044 List<FormalParameter> currentParameters = normalParameters; | 2044 List<FormalParameter> currentParameters = normalParameters; |
| 2045 Token leftSquareBracket = null; | 2045 Token leftSquareBracket = null; |
| 2046 Token rightSquareBracket = null; | 2046 Token rightSquareBracket = null; |
| 2047 Token leftCurlyBracket = null; | 2047 Token leftCurlyBracket = null; |
| 2048 Token rightCurlyBracket = null; | 2048 Token rightCurlyBracket = null; |
| 2049 ParameterKind kind = ParameterKind.REQUIRED; | 2049 ParameterKind kind = ParameterKind.REQUIRED; |
| 2050 bool firstParameter = true; | 2050 bool firstParameter = true; |
| 2051 bool reportedMuliplePositionalGroups = false; | 2051 bool reportedMuliplePositionalGroups = false; |
| 2052 bool reportedMulipleNamedGroups = false; | 2052 bool reportedMulipleNamedGroups = false; |
| 2053 bool reportedMixedGroups = false; | 2053 bool reportedMixedGroups = false; |
| 2054 bool wasOptionalParameter = false; | 2054 bool wasOptionalParameter = false; |
| 2055 Token initialToken = null; | 2055 Token initialToken = null; |
| 2056 do { | 2056 do { |
| 2057 if (firstParameter) { | 2057 if (firstParameter) { |
| 2058 firstParameter = false; | 2058 firstParameter = false; |
| 2059 } else if (!optional(TokenType.COMMA)) { | 2059 } else if (!_optional(TokenType.COMMA)) { |
| 2060 // TODO(brianwilkerson) The token is wrong, we need to recover from this
case. | 2060 // TODO(brianwilkerson) The token is wrong, we need to recover from this
case. |
| 2061 if (getEndToken(leftParenthesis) != null) { | 2061 if (_getEndToken(leftParenthesis) != null) { |
| 2062 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [TokenType.
COMMA.lexeme]); | 2062 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [TokenType
.COMMA.lexeme]); |
| 2063 } else { | 2063 } else { |
| 2064 reportErrorForToken(ParserErrorCode.MISSING_CLOSING_PARENTHESIS, _curr
entToken.previous, []); | 2064 _reportErrorForToken(ParserErrorCode.MISSING_CLOSING_PARENTHESIS, _cur
rentToken.previous, []); |
| 2065 break; | 2065 break; |
| 2066 } | 2066 } |
| 2067 } | 2067 } |
| 2068 initialToken = _currentToken; | 2068 initialToken = _currentToken; |
| 2069 // | 2069 // |
| 2070 // Handle the beginning of parameter groups. | 2070 // Handle the beginning of parameter groups. |
| 2071 // | 2071 // |
| 2072 if (matches(TokenType.OPEN_SQUARE_BRACKET)) { | 2072 if (_matches(TokenType.OPEN_SQUARE_BRACKET)) { |
| 2073 wasOptionalParameter = true; | 2073 wasOptionalParameter = true; |
| 2074 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { | 2074 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { |
| 2075 reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMET
ER_GROUPS, []); | 2075 _reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_POSITIONAL_PARAME
TER_GROUPS, []); |
| 2076 reportedMuliplePositionalGroups = true; | 2076 reportedMuliplePositionalGroups = true; |
| 2077 } | 2077 } |
| 2078 if (leftCurlyBracket != null && !reportedMixedGroups) { | 2078 if (leftCurlyBracket != null && !reportedMixedGroups) { |
| 2079 reportErrorForCurrentToken(ParserErrorCode.MIXED_PARAMETER_GROUPS, [])
; | 2079 _reportErrorForCurrentToken(ParserErrorCode.MIXED_PARAMETER_GROUPS, []
); |
| 2080 reportedMixedGroups = true; | 2080 reportedMixedGroups = true; |
| 2081 } | 2081 } |
| 2082 leftSquareBracket = andAdvance; | 2082 leftSquareBracket = andAdvance; |
| 2083 currentParameters = positionalParameters; | 2083 currentParameters = positionalParameters; |
| 2084 kind = ParameterKind.POSITIONAL; | 2084 kind = ParameterKind.POSITIONAL; |
| 2085 } else if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 2085 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 2086 wasOptionalParameter = true; | 2086 wasOptionalParameter = true; |
| 2087 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { | 2087 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { |
| 2088 reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GR
OUPS, []); | 2088 _reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_G
ROUPS, []); |
| 2089 reportedMulipleNamedGroups = true; | 2089 reportedMulipleNamedGroups = true; |
| 2090 } | 2090 } |
| 2091 if (leftSquareBracket != null && !reportedMixedGroups) { | 2091 if (leftSquareBracket != null && !reportedMixedGroups) { |
| 2092 reportErrorForCurrentToken(ParserErrorCode.MIXED_PARAMETER_GROUPS, [])
; | 2092 _reportErrorForCurrentToken(ParserErrorCode.MIXED_PARAMETER_GROUPS, []
); |
| 2093 reportedMixedGroups = true; | 2093 reportedMixedGroups = true; |
| 2094 } | 2094 } |
| 2095 leftCurlyBracket = andAdvance; | 2095 leftCurlyBracket = andAdvance; |
| 2096 currentParameters = namedParameters; | 2096 currentParameters = namedParameters; |
| 2097 kind = ParameterKind.NAMED; | 2097 kind = ParameterKind.NAMED; |
| 2098 } | 2098 } |
| 2099 // | 2099 // |
| 2100 // Parse and record the parameter. | 2100 // Parse and record the parameter. |
| 2101 // | 2101 // |
| 2102 FormalParameter parameter = parseFormalParameter(kind); | 2102 FormalParameter parameter = _parseFormalParameter(kind); |
| 2103 parameters.add(parameter); | 2103 parameters.add(parameter); |
| 2104 currentParameters.add(parameter); | 2104 currentParameters.add(parameter); |
| 2105 if (identical(kind, ParameterKind.REQUIRED) && wasOptionalParameter) { | 2105 if (identical(kind, ParameterKind.REQUIRED) && wasOptionalParameter) { |
| 2106 reportErrorForNode(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, pa
rameter, []); | 2106 _reportErrorForNode(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, p
arameter, []); |
| 2107 } | 2107 } |
| 2108 // | 2108 // |
| 2109 // Handle the end of parameter groups. | 2109 // Handle the end of parameter groups. |
| 2110 // | 2110 // |
| 2111 // TODO(brianwilkerson) Improve the detection and reporting of missing and
mismatched delimiters. | 2111 // TODO(brianwilkerson) Improve the detection and reporting of missing and
mismatched delimiters. |
| 2112 if (matches(TokenType.CLOSE_SQUARE_BRACKET)) { | 2112 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) { |
| 2113 rightSquareBracket = andAdvance; | 2113 rightSquareBracket = andAdvance; |
| 2114 currentParameters = normalParameters; | 2114 currentParameters = normalParameters; |
| 2115 if (leftSquareBracket == null) { | 2115 if (leftSquareBracket == null) { |
| 2116 if (leftCurlyBracket != null) { | 2116 if (leftCurlyBracket != null) { |
| 2117 reportErrorForCurrentToken(ParserErrorCode.WRONG_TERMINATOR_FOR_PARA
METER_GROUP, ["}"]); | 2117 _reportErrorForCurrentToken(ParserErrorCode.WRONG_TERMINATOR_FOR_PAR
AMETER_GROUP, ["}"]); |
| 2118 rightCurlyBracket = rightSquareBracket; | 2118 rightCurlyBracket = rightSquareBracket; |
| 2119 rightSquareBracket = null; | 2119 rightSquareBracket = null; |
| 2120 } else { | 2120 } else { |
| 2121 reportErrorForCurrentToken(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR
_PARAMETER_GROUP, ["["]); | 2121 _reportErrorForCurrentToken(ParserErrorCode.UNEXPECTED_TERMINATOR_FO
R_PARAMETER_GROUP, ["["]); |
| 2122 } | 2122 } |
| 2123 } | 2123 } |
| 2124 kind = ParameterKind.REQUIRED; | 2124 kind = ParameterKind.REQUIRED; |
| 2125 } else if (matches(TokenType.CLOSE_CURLY_BRACKET)) { | 2125 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
| 2126 rightCurlyBracket = andAdvance; | 2126 rightCurlyBracket = andAdvance; |
| 2127 currentParameters = normalParameters; | 2127 currentParameters = normalParameters; |
| 2128 if (leftCurlyBracket == null) { | 2128 if (leftCurlyBracket == null) { |
| 2129 if (leftSquareBracket != null) { | 2129 if (leftSquareBracket != null) { |
| 2130 reportErrorForCurrentToken(ParserErrorCode.WRONG_TERMINATOR_FOR_PARA
METER_GROUP, ["]"]); | 2130 _reportErrorForCurrentToken(ParserErrorCode.WRONG_TERMINATOR_FOR_PAR
AMETER_GROUP, ["]"]); |
| 2131 rightSquareBracket = rightCurlyBracket; | 2131 rightSquareBracket = rightCurlyBracket; |
| 2132 rightCurlyBracket = null; | 2132 rightCurlyBracket = null; |
| 2133 } else { | 2133 } else { |
| 2134 reportErrorForCurrentToken(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR
_PARAMETER_GROUP, ["{"]); | 2134 _reportErrorForCurrentToken(ParserErrorCode.UNEXPECTED_TERMINATOR_FO
R_PARAMETER_GROUP, ["{"]); |
| 2135 } | 2135 } |
| 2136 } | 2136 } |
| 2137 kind = ParameterKind.REQUIRED; | 2137 kind = ParameterKind.REQUIRED; |
| 2138 } | 2138 } |
| 2139 } while (!matches(TokenType.CLOSE_PAREN) && initialToken != _currentToken); | 2139 } while (!_matches(TokenType.CLOSE_PAREN) && initialToken != _currentToken); |
| 2140 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 2140 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 2141 // | 2141 // |
| 2142 // Check that the groups were closed correctly. | 2142 // Check that the groups were closed correctly. |
| 2143 // | 2143 // |
| 2144 if (leftSquareBracket != null && rightSquareBracket == null) { | 2144 if (leftSquareBracket != null && rightSquareBracket == null) { |
| 2145 reportErrorForCurrentToken(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETE
R_GROUP, ["]"]); | 2145 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMET
ER_GROUP, ["]"]); |
| 2146 } | 2146 } |
| 2147 if (leftCurlyBracket != null && rightCurlyBracket == null) { | 2147 if (leftCurlyBracket != null && rightCurlyBracket == null) { |
| 2148 reportErrorForCurrentToken(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETE
R_GROUP, ["}"]); | 2148 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMET
ER_GROUP, ["}"]); |
| 2149 } | 2149 } |
| 2150 // | 2150 // |
| 2151 // Build the parameter list. | 2151 // Build the parameter list. |
| 2152 // | 2152 // |
| 2153 if (leftSquareBracket == null) { | 2153 if (leftSquareBracket == null) { |
| 2154 leftSquareBracket = leftCurlyBracket; | 2154 leftSquareBracket = leftCurlyBracket; |
| 2155 } | 2155 } |
| 2156 if (rightSquareBracket == null) { | 2156 if (rightSquareBracket == null) { |
| 2157 rightSquareBracket = rightCurlyBracket; | 2157 rightSquareBracket = rightCurlyBracket; |
| 2158 } | 2158 } |
| 2159 return new FormalParameterList(leftParenthesis, parameters, leftSquareBracke
t, rightSquareBracket, rightParenthesis); | 2159 return new FormalParameterList(leftParenthesis, parameters, leftSquareBracke
t, rightSquareBracket, rightParenthesis); |
| 2160 } | 2160 } |
| 2161 | 2161 |
| 2162 /** | 2162 /** |
| 2163 * Parse a function expression. | 2163 * Parse a function expression. |
| 2164 * | 2164 * |
| 2165 * <pre> | 2165 * <pre> |
| 2166 * functionExpression ::= | 2166 * functionExpression ::= |
| 2167 * formalParameterList functionExpressionBody | 2167 * formalParameterList functionExpressionBody |
| 2168 * </pre> | 2168 * </pre> |
| 2169 * | 2169 * |
| 2170 * @return the function expression that was parsed | 2170 * @return the function expression that was parsed |
| 2171 */ | 2171 */ |
| 2172 FunctionExpression parseFunctionExpression() { | 2172 FunctionExpression parseFunctionExpression() { |
| 2173 FormalParameterList parameters = parseFormalParameterList(); | 2173 FormalParameterList parameters = parseFormalParameterList(); |
| 2174 validateFormalParameterList(parameters); | 2174 _validateFormalParameterList(parameters); |
| 2175 FunctionBody body = parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTIO
N_BODY, true); | 2175 FunctionBody body = _parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTI
ON_BODY, true); |
| 2176 return new FunctionExpression(parameters, body); | 2176 return new FunctionExpression(parameters, body); |
| 2177 } | 2177 } |
| 2178 | 2178 |
| 2179 /** | 2179 /** |
| 2180 * Parse an implements clause. | 2180 * Parse an implements clause. |
| 2181 * | 2181 * |
| 2182 * <pre> | 2182 * <pre> |
| 2183 * implementsClause ::= | 2183 * implementsClause ::= |
| 2184 * 'implements' type (',' type)* | 2184 * 'implements' type (',' type)* |
| 2185 * </pre> | 2185 * </pre> |
| 2186 * | 2186 * |
| 2187 * @return the implements clause that was parsed | 2187 * @return the implements clause that was parsed |
| 2188 */ | 2188 */ |
| 2189 ImplementsClause parseImplementsClause() { | 2189 ImplementsClause parseImplementsClause() { |
| 2190 Token keyword = expectKeyword(Keyword.IMPLEMENTS); | 2190 Token keyword = _expectKeyword(Keyword.IMPLEMENTS); |
| 2191 List<TypeName> interfaces = new List<TypeName>(); | 2191 List<TypeName> interfaces = new List<TypeName>(); |
| 2192 interfaces.add(parseTypeName()); | 2192 interfaces.add(parseTypeName()); |
| 2193 while (optional(TokenType.COMMA)) { | 2193 while (_optional(TokenType.COMMA)) { |
| 2194 interfaces.add(parseTypeName()); | 2194 interfaces.add(parseTypeName()); |
| 2195 } | 2195 } |
| 2196 return new ImplementsClause(keyword, interfaces); | 2196 return new ImplementsClause(keyword, interfaces); |
| 2197 } | 2197 } |
| 2198 | 2198 |
| 2199 /** | 2199 /** |
| 2200 * Parse a label. | 2200 * Parse a label. |
| 2201 * | 2201 * |
| 2202 * <pre> | 2202 * <pre> |
| 2203 * label ::= | 2203 * label ::= |
| 2204 * identifier ':' | 2204 * identifier ':' |
| 2205 * </pre> | 2205 * </pre> |
| 2206 * | 2206 * |
| 2207 * @return the label that was parsed | 2207 * @return the label that was parsed |
| 2208 */ | 2208 */ |
| 2209 Label parseLabel() { | 2209 Label parseLabel() { |
| 2210 SimpleIdentifier label = parseSimpleIdentifier(); | 2210 SimpleIdentifier label = parseSimpleIdentifier(); |
| 2211 Token colon = expect(TokenType.COLON); | 2211 Token colon = _expect(TokenType.COLON); |
| 2212 return new Label(label, colon); | 2212 return new Label(label, colon); |
| 2213 } | 2213 } |
| 2214 | 2214 |
| 2215 /** | 2215 /** |
| 2216 * Parse a library identifier. | 2216 * Parse a library identifier. |
| 2217 * | 2217 * |
| 2218 * <pre> | 2218 * <pre> |
| 2219 * libraryIdentifier ::= | 2219 * libraryIdentifier ::= |
| 2220 * identifier ('.' identifier)* | 2220 * identifier ('.' identifier)* |
| 2221 * </pre> | 2221 * </pre> |
| 2222 * | 2222 * |
| 2223 * @return the library identifier that was parsed | 2223 * @return the library identifier that was parsed |
| 2224 */ | 2224 */ |
| 2225 LibraryIdentifier parseLibraryIdentifier() { | 2225 LibraryIdentifier parseLibraryIdentifier() { |
| 2226 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); | 2226 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); |
| 2227 components.add(parseSimpleIdentifier()); | 2227 components.add(parseSimpleIdentifier()); |
| 2228 while (matches(TokenType.PERIOD)) { | 2228 while (_matches(TokenType.PERIOD)) { |
| 2229 advance(); | 2229 _advance(); |
| 2230 components.add(parseSimpleIdentifier()); | 2230 components.add(parseSimpleIdentifier()); |
| 2231 } | 2231 } |
| 2232 return new LibraryIdentifier(components); | 2232 return new LibraryIdentifier(components); |
| 2233 } | 2233 } |
| 2234 | 2234 |
| 2235 /** | 2235 /** |
| 2236 * Parse a logical or expression. | 2236 * Parse a logical or expression. |
| 2237 * | 2237 * |
| 2238 * <pre> | 2238 * <pre> |
| 2239 * logicalOrExpression ::= | 2239 * logicalOrExpression ::= |
| 2240 * logicalAndExpression ('||' logicalAndExpression)* | 2240 * logicalAndExpression ('||' logicalAndExpression)* |
| 2241 * </pre> | 2241 * </pre> |
| 2242 * | 2242 * |
| 2243 * @return the logical or expression that was parsed | 2243 * @return the logical or expression that was parsed |
| 2244 */ | 2244 */ |
| 2245 Expression parseLogicalOrExpression() { | 2245 Expression parseLogicalOrExpression() { |
| 2246 Expression expression = parseLogicalAndExpression(); | 2246 Expression expression = _parseLogicalAndExpression(); |
| 2247 while (matches(TokenType.BAR_BAR)) { | 2247 while (_matches(TokenType.BAR_BAR)) { |
| 2248 Token operator = andAdvance; | 2248 Token operator = andAdvance; |
| 2249 expression = new BinaryExpression(expression, operator, parseLogicalAndExp
ression()); | 2249 expression = new BinaryExpression(expression, operator, _parseLogicalAndEx
pression()); |
| 2250 } | 2250 } |
| 2251 return expression; | 2251 return expression; |
| 2252 } | 2252 } |
| 2253 | 2253 |
| 2254 /** | 2254 /** |
| 2255 * Parse a map literal entry. | 2255 * Parse a map literal entry. |
| 2256 * | 2256 * |
| 2257 * <pre> | 2257 * <pre> |
| 2258 * mapLiteralEntry ::= | 2258 * mapLiteralEntry ::= |
| 2259 * expression ':' expression | 2259 * expression ':' expression |
| 2260 * </pre> | 2260 * </pre> |
| 2261 * | 2261 * |
| 2262 * @return the map literal entry that was parsed | 2262 * @return the map literal entry that was parsed |
| 2263 */ | 2263 */ |
| 2264 MapLiteralEntry parseMapLiteralEntry() { | 2264 MapLiteralEntry parseMapLiteralEntry() { |
| 2265 Expression key = parseExpression2(); | 2265 Expression key = parseExpression2(); |
| 2266 Token separator = expect(TokenType.COLON); | 2266 Token separator = _expect(TokenType.COLON); |
| 2267 Expression value = parseExpression2(); | 2267 Expression value = parseExpression2(); |
| 2268 return new MapLiteralEntry(key, separator, value); | 2268 return new MapLiteralEntry(key, separator, value); |
| 2269 } | 2269 } |
| 2270 | 2270 |
| 2271 /** | 2271 /** |
| 2272 * Parse a normal formal parameter. | 2272 * Parse a normal formal parameter. |
| 2273 * | 2273 * |
| 2274 * <pre> | 2274 * <pre> |
| 2275 * normalFormalParameter ::= | 2275 * normalFormalParameter ::= |
| 2276 * functionSignature | 2276 * functionSignature |
| 2277 * | fieldFormalParameter | 2277 * | fieldFormalParameter |
| 2278 * | simpleFormalParameter | 2278 * | simpleFormalParameter |
| 2279 * | 2279 * |
| 2280 * functionSignature: | 2280 * functionSignature: |
| 2281 * metadata returnType? identifier formalParameterList | 2281 * metadata returnType? identifier formalParameterList |
| 2282 * | 2282 * |
| 2283 * fieldFormalParameter ::= | 2283 * fieldFormalParameter ::= |
| 2284 * metadata finalConstVarOrType? 'this' '.' identifier | 2284 * metadata finalConstVarOrType? 'this' '.' identifier |
| 2285 * | 2285 * |
| 2286 * simpleFormalParameter ::= | 2286 * simpleFormalParameter ::= |
| 2287 * declaredIdentifier | 2287 * declaredIdentifier |
| 2288 * | metadata identifier | 2288 * | metadata identifier |
| 2289 * </pre> | 2289 * </pre> |
| 2290 * | 2290 * |
| 2291 * @return the normal formal parameter that was parsed | 2291 * @return the normal formal parameter that was parsed |
| 2292 */ | 2292 */ |
| 2293 NormalFormalParameter parseNormalFormalParameter() { | 2293 NormalFormalParameter parseNormalFormalParameter() { |
| 2294 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 2294 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 2295 FinalConstVarOrType holder = parseFinalConstVarOrType(true); | 2295 FinalConstVarOrType holder = _parseFinalConstVarOrType(true); |
| 2296 Token thisKeyword = null; | 2296 Token thisKeyword = null; |
| 2297 Token period = null; | 2297 Token period = null; |
| 2298 if (matchesKeyword(Keyword.THIS)) { | 2298 if (_matchesKeyword(Keyword.THIS)) { |
| 2299 thisKeyword = andAdvance; | 2299 thisKeyword = andAdvance; |
| 2300 period = expect(TokenType.PERIOD); | 2300 period = _expect(TokenType.PERIOD); |
| 2301 } | 2301 } |
| 2302 SimpleIdentifier identifier = parseSimpleIdentifier(); | 2302 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 2303 if (matches(TokenType.OPEN_PAREN)) { | 2303 if (_matches(TokenType.OPEN_PAREN)) { |
| 2304 FormalParameterList parameters = parseFormalParameterList(); | 2304 FormalParameterList parameters = parseFormalParameterList(); |
| 2305 if (thisKeyword == null) { | 2305 if (thisKeyword == null) { |
| 2306 if (holder.keyword != null) { | 2306 if (holder.keyword != null) { |
| 2307 reportErrorForToken(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, hold
er.keyword, []); | 2307 _reportErrorForToken(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, hol
der.keyword, []); |
| 2308 } | 2308 } |
| 2309 return new FunctionTypedFormalParameter(commentAndMetadata.comment, comm
entAndMetadata.metadata, holder.type, identifier, parameters); | 2309 return new FunctionTypedFormalParameter(commentAndMetadata.comment, comm
entAndMetadata.metadata, holder.type, identifier, parameters); |
| 2310 } else { | 2310 } else { |
| 2311 return new FieldFormalParameter(commentAndMetadata.comment, commentAndMe
tadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier, p
arameters); | 2311 return new FieldFormalParameter(commentAndMetadata.comment, commentAndMe
tadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier, p
arameters); |
| 2312 } | 2312 } |
| 2313 } | 2313 } |
| 2314 TypeName type = holder.type; | 2314 TypeName type = holder.type; |
| 2315 if (type != null) { | 2315 if (type != null) { |
| 2316 if (tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) { | 2316 if (_tokenMatchesKeyword(type.name.beginToken, Keyword.VOID)) { |
| 2317 reportErrorForToken(ParserErrorCode.VOID_PARAMETER, type.name.beginToken
, []); | 2317 _reportErrorForToken(ParserErrorCode.VOID_PARAMETER, type.name.beginToke
n, []); |
| 2318 } else if (holder.keyword != null && tokenMatchesKeyword(holder.keyword, K
eyword.VAR)) { | 2318 } else if (holder.keyword != null && _tokenMatchesKeyword(holder.keyword,
Keyword.VAR)) { |
| 2319 reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword, []); | 2319 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, holder.keyword, []); |
| 2320 } | 2320 } |
| 2321 } | 2321 } |
| 2322 if (thisKeyword != null) { | 2322 if (thisKeyword != null) { |
| 2323 return new FieldFormalParameter(commentAndMetadata.comment, commentAndMeta
data.metadata, holder.keyword, holder.type, thisKeyword, period, identifier, nul
l); | 2323 return new FieldFormalParameter(commentAndMetadata.comment, commentAndMeta
data.metadata, holder.keyword, holder.type, thisKeyword, period, identifier, nul
l); |
| 2324 } | 2324 } |
| 2325 return new SimpleFormalParameter(commentAndMetadata.comment, commentAndMetad
ata.metadata, holder.keyword, holder.type, identifier); | 2325 return new SimpleFormalParameter(commentAndMetadata.comment, commentAndMetad
ata.metadata, holder.keyword, holder.type, identifier); |
| 2326 } | 2326 } |
| 2327 | 2327 |
| 2328 /** | 2328 /** |
| 2329 * Parse a prefixed identifier. | 2329 * Parse a prefixed identifier. |
| 2330 * | 2330 * |
| 2331 * <pre> | 2331 * <pre> |
| 2332 * prefixedIdentifier ::= | 2332 * prefixedIdentifier ::= |
| 2333 * identifier ('.' identifier)? | 2333 * identifier ('.' identifier)? |
| 2334 * </pre> | 2334 * </pre> |
| 2335 * | 2335 * |
| 2336 * @return the prefixed identifier that was parsed | 2336 * @return the prefixed identifier that was parsed |
| 2337 */ | 2337 */ |
| 2338 Identifier parsePrefixedIdentifier() { | 2338 Identifier parsePrefixedIdentifier() { |
| 2339 SimpleIdentifier qualifier = parseSimpleIdentifier(); | 2339 SimpleIdentifier qualifier = parseSimpleIdentifier(); |
| 2340 if (!matches(TokenType.PERIOD)) { | 2340 if (!_matches(TokenType.PERIOD)) { |
| 2341 return qualifier; | 2341 return qualifier; |
| 2342 } | 2342 } |
| 2343 Token period = andAdvance; | 2343 Token period = andAdvance; |
| 2344 SimpleIdentifier qualified = parseSimpleIdentifier(); | 2344 SimpleIdentifier qualified = parseSimpleIdentifier(); |
| 2345 return new PrefixedIdentifier(qualifier, period, qualified); | 2345 return new PrefixedIdentifier(qualifier, period, qualified); |
| 2346 } | 2346 } |
| 2347 | 2347 |
| 2348 /** | 2348 /** |
| 2349 * Parse a return type. | 2349 * Parse a return type. |
| 2350 * | 2350 * |
| 2351 * <pre> | 2351 * <pre> |
| 2352 * returnType ::= | 2352 * returnType ::= |
| 2353 * 'void' | 2353 * 'void' |
| 2354 * | type | 2354 * | type |
| 2355 * </pre> | 2355 * </pre> |
| 2356 * | 2356 * |
| 2357 * @return the return type that was parsed | 2357 * @return the return type that was parsed |
| 2358 */ | 2358 */ |
| 2359 TypeName parseReturnType() { | 2359 TypeName parseReturnType() { |
| 2360 if (matchesKeyword(Keyword.VOID)) { | 2360 if (_matchesKeyword(Keyword.VOID)) { |
| 2361 return new TypeName(new SimpleIdentifier(andAdvance), null); | 2361 return new TypeName(new SimpleIdentifier(andAdvance), null); |
| 2362 } else { | 2362 } else { |
| 2363 return parseTypeName(); | 2363 return parseTypeName(); |
| 2364 } | 2364 } |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 /** | 2367 /** |
| 2368 * Parse a simple identifier. | 2368 * Parse a simple identifier. |
| 2369 * | 2369 * |
| 2370 * <pre> | 2370 * <pre> |
| 2371 * identifier ::= | 2371 * identifier ::= |
| 2372 * IDENTIFIER | 2372 * IDENTIFIER |
| 2373 * </pre> | 2373 * </pre> |
| 2374 * | 2374 * |
| 2375 * @return the simple identifier that was parsed | 2375 * @return the simple identifier that was parsed |
| 2376 */ | 2376 */ |
| 2377 SimpleIdentifier parseSimpleIdentifier() { | 2377 SimpleIdentifier parseSimpleIdentifier() { |
| 2378 if (matchesIdentifier()) { | 2378 if (_matchesIdentifier()) { |
| 2379 return new SimpleIdentifier(andAdvance); | 2379 return new SimpleIdentifier(andAdvance); |
| 2380 } | 2380 } |
| 2381 reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); | 2381 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 2382 return createSyntheticIdentifier(); | 2382 return _createSyntheticIdentifier(); |
| 2383 } | 2383 } |
| 2384 | 2384 |
| 2385 /** | 2385 /** |
| 2386 * Parse a statement. | 2386 * Parse a statement. |
| 2387 * | 2387 * |
| 2388 * <pre> | 2388 * <pre> |
| 2389 * statement ::= | 2389 * statement ::= |
| 2390 * label* nonLabeledStatement | 2390 * label* nonLabeledStatement |
| 2391 * </pre> | 2391 * </pre> |
| 2392 * | 2392 * |
| 2393 * @return the statement that was parsed | 2393 * @return the statement that was parsed |
| 2394 */ | 2394 */ |
| 2395 Statement parseStatement2() { | 2395 Statement parseStatement2() { |
| 2396 List<Label> labels = new List<Label>(); | 2396 List<Label> labels = new List<Label>(); |
| 2397 while (matchesIdentifier() && tokenMatches(peek(), TokenType.COLON)) { | 2397 while (_matchesIdentifier() && _tokenMatches(_peek(), TokenType.COLON)) { |
| 2398 labels.add(parseLabel()); | 2398 labels.add(parseLabel()); |
| 2399 } | 2399 } |
| 2400 Statement statement = parseNonLabeledStatement(); | 2400 Statement statement = _parseNonLabeledStatement(); |
| 2401 if (labels.isEmpty) { | 2401 if (labels.isEmpty) { |
| 2402 return statement; | 2402 return statement; |
| 2403 } | 2403 } |
| 2404 return new LabeledStatement(labels, statement); | 2404 return new LabeledStatement(labels, statement); |
| 2405 } | 2405 } |
| 2406 | 2406 |
| 2407 /** | 2407 /** |
| 2408 * Parse a string literal. | 2408 * Parse a string literal. |
| 2409 * | 2409 * |
| 2410 * <pre> | 2410 * <pre> |
| 2411 * stringLiteral ::= | 2411 * stringLiteral ::= |
| 2412 * MULTI_LINE_STRING+ | 2412 * MULTI_LINE_STRING+ |
| 2413 * | SINGLE_LINE_STRING+ | 2413 * | SINGLE_LINE_STRING+ |
| 2414 * </pre> | 2414 * </pre> |
| 2415 * | 2415 * |
| 2416 * @return the string literal that was parsed | 2416 * @return the string literal that was parsed |
| 2417 */ | 2417 */ |
| 2418 StringLiteral parseStringLiteral() { | 2418 StringLiteral parseStringLiteral() { |
| 2419 List<StringLiteral> strings = new List<StringLiteral>(); | 2419 List<StringLiteral> strings = new List<StringLiteral>(); |
| 2420 while (matches(TokenType.STRING)) { | 2420 while (_matches(TokenType.STRING)) { |
| 2421 Token string = andAdvance; | 2421 Token string = andAdvance; |
| 2422 if (matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches(TokenTyp
e.STRING_INTERPOLATION_IDENTIFIER)) { | 2422 if (_matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || _matches(TokenT
ype.STRING_INTERPOLATION_IDENTIFIER)) { |
| 2423 strings.add(parseStringInterpolation(string)); | 2423 strings.add(_parseStringInterpolation(string)); |
| 2424 } else { | 2424 } else { |
| 2425 strings.add(new SimpleStringLiteral(string, computeStringValue(string.le
xeme, true, true))); | 2425 strings.add(new SimpleStringLiteral(string, _computeStringValue(string.l
exeme, true, true))); |
| 2426 } | 2426 } |
| 2427 } | 2427 } |
| 2428 if (strings.length < 1) { | 2428 if (strings.length < 1) { |
| 2429 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_STRING_LITERAL, []); | 2429 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_STRING_LITERAL, []); |
| 2430 return createSyntheticStringLiteral(); | 2430 return _createSyntheticStringLiteral(); |
| 2431 } else if (strings.length == 1) { | 2431 } else if (strings.length == 1) { |
| 2432 return strings[0]; | 2432 return strings[0]; |
| 2433 } else { | 2433 } else { |
| 2434 return new AdjacentStrings(strings); | 2434 return new AdjacentStrings(strings); |
| 2435 } | 2435 } |
| 2436 } | 2436 } |
| 2437 | 2437 |
| 2438 /** | 2438 /** |
| 2439 * Parse a list of type arguments. | 2439 * Parse a list of type arguments. |
| 2440 * | 2440 * |
| 2441 * <pre> | 2441 * <pre> |
| 2442 * typeArguments ::= | 2442 * typeArguments ::= |
| 2443 * '<' typeList '>' | 2443 * '<' typeList '>' |
| 2444 * | 2444 * |
| 2445 * typeList ::= | 2445 * typeList ::= |
| 2446 * type (',' type)* | 2446 * type (',' type)* |
| 2447 * </pre> | 2447 * </pre> |
| 2448 * | 2448 * |
| 2449 * @return the type argument list that was parsed | 2449 * @return the type argument list that was parsed |
| 2450 */ | 2450 */ |
| 2451 TypeArgumentList parseTypeArgumentList() { | 2451 TypeArgumentList parseTypeArgumentList() { |
| 2452 Token leftBracket = expect(TokenType.LT); | 2452 Token leftBracket = _expect(TokenType.LT); |
| 2453 List<TypeName> arguments = new List<TypeName>(); | 2453 List<TypeName> arguments = new List<TypeName>(); |
| 2454 arguments.add(parseTypeName()); | 2454 arguments.add(parseTypeName()); |
| 2455 while (optional(TokenType.COMMA)) { | 2455 while (_optional(TokenType.COMMA)) { |
| 2456 arguments.add(parseTypeName()); | 2456 arguments.add(parseTypeName()); |
| 2457 } | 2457 } |
| 2458 Token rightBracket = expect(TokenType.GT); | 2458 Token rightBracket = _expect(TokenType.GT); |
| 2459 return new TypeArgumentList(leftBracket, arguments, rightBracket); | 2459 return new TypeArgumentList(leftBracket, arguments, rightBracket); |
| 2460 } | 2460 } |
| 2461 | 2461 |
| 2462 /** | 2462 /** |
| 2463 * Parse a type name. | 2463 * Parse a type name. |
| 2464 * | 2464 * |
| 2465 * <pre> | 2465 * <pre> |
| 2466 * type ::= | 2466 * type ::= |
| 2467 * qualified typeArguments? | 2467 * qualified typeArguments? |
| 2468 * </pre> | 2468 * </pre> |
| 2469 * | 2469 * |
| 2470 * @return the type name that was parsed | 2470 * @return the type name that was parsed |
| 2471 */ | 2471 */ |
| 2472 TypeName parseTypeName() { | 2472 TypeName parseTypeName() { |
| 2473 Identifier typeName; | 2473 Identifier typeName; |
| 2474 if (matchesKeyword(Keyword.VAR)) { | 2474 if (_matchesKeyword(Keyword.VAR)) { |
| 2475 reportErrorForCurrentToken(ParserErrorCode.VAR_AS_TYPE_NAME, []); | 2475 _reportErrorForCurrentToken(ParserErrorCode.VAR_AS_TYPE_NAME, []); |
| 2476 typeName = new SimpleIdentifier(andAdvance); | 2476 typeName = new SimpleIdentifier(andAdvance); |
| 2477 } else if (matchesIdentifier()) { | 2477 } else if (_matchesIdentifier()) { |
| 2478 typeName = parsePrefixedIdentifier(); | 2478 typeName = parsePrefixedIdentifier(); |
| 2479 } else { | 2479 } else { |
| 2480 typeName = createSyntheticIdentifier(); | 2480 typeName = _createSyntheticIdentifier(); |
| 2481 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TYPE_NAME, []); | 2481 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TYPE_NAME, []); |
| 2482 } | 2482 } |
| 2483 TypeArgumentList typeArguments = null; | 2483 TypeArgumentList typeArguments = null; |
| 2484 if (matches(TokenType.LT)) { | 2484 if (_matches(TokenType.LT)) { |
| 2485 typeArguments = parseTypeArgumentList(); | 2485 typeArguments = parseTypeArgumentList(); |
| 2486 } | 2486 } |
| 2487 return new TypeName(typeName, typeArguments); | 2487 return new TypeName(typeName, typeArguments); |
| 2488 } | 2488 } |
| 2489 | 2489 |
| 2490 /** | 2490 /** |
| 2491 * Parse a type parameter. | 2491 * Parse a type parameter. |
| 2492 * | 2492 * |
| 2493 * <pre> | 2493 * <pre> |
| 2494 * typeParameter ::= | 2494 * typeParameter ::= |
| 2495 * metadata name ('extends' bound)? | 2495 * metadata name ('extends' bound)? |
| 2496 * </pre> | 2496 * </pre> |
| 2497 * | 2497 * |
| 2498 * @return the type parameter that was parsed | 2498 * @return the type parameter that was parsed |
| 2499 */ | 2499 */ |
| 2500 TypeParameter parseTypeParameter() { | 2500 TypeParameter parseTypeParameter() { |
| 2501 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 2501 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 2502 SimpleIdentifier name = parseSimpleIdentifier(); | 2502 SimpleIdentifier name = parseSimpleIdentifier(); |
| 2503 if (matchesKeyword(Keyword.EXTENDS)) { | 2503 if (_matchesKeyword(Keyword.EXTENDS)) { |
| 2504 Token keyword = andAdvance; | 2504 Token keyword = andAdvance; |
| 2505 TypeName bound = parseTypeName(); | 2505 TypeName bound = parseTypeName(); |
| 2506 return new TypeParameter(commentAndMetadata.comment, commentAndMetadata.me
tadata, name, keyword, bound); | 2506 return new TypeParameter(commentAndMetadata.comment, commentAndMetadata.me
tadata, name, keyword, bound); |
| 2507 } | 2507 } |
| 2508 return new TypeParameter(commentAndMetadata.comment, commentAndMetadata.meta
data, name, null, null); | 2508 return new TypeParameter(commentAndMetadata.comment, commentAndMetadata.meta
data, name, null, null); |
| 2509 } | 2509 } |
| 2510 | 2510 |
| 2511 /** | 2511 /** |
| 2512 * Parse a list of type parameters. | 2512 * Parse a list of type parameters. |
| 2513 * | 2513 * |
| 2514 * <pre> | 2514 * <pre> |
| 2515 * typeParameterList ::= | 2515 * typeParameterList ::= |
| 2516 * '<' typeParameter (',' typeParameter)* '>' | 2516 * '<' typeParameter (',' typeParameter)* '>' |
| 2517 * </pre> | 2517 * </pre> |
| 2518 * | 2518 * |
| 2519 * @return the list of type parameters that were parsed | 2519 * @return the list of type parameters that were parsed |
| 2520 */ | 2520 */ |
| 2521 TypeParameterList parseTypeParameterList() { | 2521 TypeParameterList parseTypeParameterList() { |
| 2522 Token leftBracket = expect(TokenType.LT); | 2522 Token leftBracket = _expect(TokenType.LT); |
| 2523 List<TypeParameter> typeParameters = new List<TypeParameter>(); | 2523 List<TypeParameter> typeParameters = new List<TypeParameter>(); |
| 2524 typeParameters.add(parseTypeParameter()); | 2524 typeParameters.add(parseTypeParameter()); |
| 2525 while (optional(TokenType.COMMA)) { | 2525 while (_optional(TokenType.COMMA)) { |
| 2526 typeParameters.add(parseTypeParameter()); | 2526 typeParameters.add(parseTypeParameter()); |
| 2527 } | 2527 } |
| 2528 Token rightBracket = expect(TokenType.GT); | 2528 Token rightBracket = _expect(TokenType.GT); |
| 2529 return new TypeParameterList(leftBracket, typeParameters, rightBracket); | 2529 return new TypeParameterList(leftBracket, typeParameters, rightBracket); |
| 2530 } | 2530 } |
| 2531 | 2531 |
| 2532 /** | 2532 /** |
| 2533 * Parse a with clause. | 2533 * Parse a with clause. |
| 2534 * | 2534 * |
| 2535 * <pre> | 2535 * <pre> |
| 2536 * withClause ::= | 2536 * withClause ::= |
| 2537 * 'with' typeName (',' typeName)* | 2537 * 'with' typeName (',' typeName)* |
| 2538 * </pre> | 2538 * </pre> |
| 2539 * | 2539 * |
| 2540 * @return the with clause that was parsed | 2540 * @return the with clause that was parsed |
| 2541 */ | 2541 */ |
| 2542 WithClause parseWithClause() { | 2542 WithClause parseWithClause() { |
| 2543 Token with2 = expectKeyword(Keyword.WITH); | 2543 Token with2 = _expectKeyword(Keyword.WITH); |
| 2544 List<TypeName> types = new List<TypeName>(); | 2544 List<TypeName> types = new List<TypeName>(); |
| 2545 types.add(parseTypeName()); | 2545 types.add(parseTypeName()); |
| 2546 while (optional(TokenType.COMMA)) { | 2546 while (_optional(TokenType.COMMA)) { |
| 2547 types.add(parseTypeName()); | 2547 types.add(parseTypeName()); |
| 2548 } | 2548 } |
| 2549 return new WithClause(with2, types); | 2549 return new WithClause(with2, types); |
| 2550 } | 2550 } |
| 2551 | 2551 |
| 2552 void set currentToken(Token currentToken) { | 2552 void set currentToken(Token currentToken) { |
| 2553 this._currentToken = currentToken; | 2553 this._currentToken = currentToken; |
| 2554 } | 2554 } |
| 2555 | 2555 |
| 2556 /** | 2556 /** |
| 2557 * Advance to the next token in the token stream. | 2557 * Advance to the next token in the token stream. |
| 2558 */ | 2558 */ |
| 2559 void advance() { | 2559 void _advance() { |
| 2560 _currentToken = _currentToken.next; | 2560 _currentToken = _currentToken.next; |
| 2561 } | 2561 } |
| 2562 | 2562 |
| 2563 /** | 2563 /** |
| 2564 * Append the character equivalent of the given scalar value to the given buil
der. Use the start | 2564 * Append the character equivalent of the given scalar value to the given buil
der. Use the start |
| 2565 * and end indices to report an error, and don't append anything to the builde
r, if the scalar | 2565 * and end indices to report an error, and don't append anything to the builde
r, if the scalar |
| 2566 * value is invalid. | 2566 * value is invalid. |
| 2567 * | 2567 * |
| 2568 * @param builder the builder to which the scalar value is to be appended | 2568 * @param builder the builder to which the scalar value is to be appended |
| 2569 * @param escapeSequence the escape sequence that was parsed to produce the sc
alar value | 2569 * @param escapeSequence the escape sequence that was parsed to produce the sc
alar value |
| 2570 * @param scalarValue the value to be appended | 2570 * @param scalarValue the value to be appended |
| 2571 * @param startIndex the index of the first character representing the scalar
value | 2571 * @param startIndex the index of the first character representing the scalar
value |
| 2572 * @param endIndex the index of the last character representing the scalar val
ue | 2572 * @param endIndex the index of the last character representing the scalar val
ue |
| 2573 */ | 2573 */ |
| 2574 void appendScalarValue(JavaStringBuilder builder, String escapeSequence, int s
calarValue, int startIndex, int endIndex) { | 2574 void _appendScalarValue(JavaStringBuilder builder, String escapeSequence, int
scalarValue, int startIndex, int endIndex) { |
| 2575 if (scalarValue < 0 || scalarValue > Character.MAX_CODE_POINT || (scalarValu
e >= 0xD800 && scalarValue <= 0xDFFF)) { | 2575 if (scalarValue < 0 || scalarValue > Character.MAX_CODE_POINT || (scalarValu
e >= 0xD800 && scalarValue <= 0xDFFF)) { |
| 2576 reportErrorForCurrentToken(ParserErrorCode.INVALID_CODE_POINT, [escapeSequ
ence]); | 2576 _reportErrorForCurrentToken(ParserErrorCode.INVALID_CODE_POINT, [escapeSeq
uence]); |
| 2577 return; | 2577 return; |
| 2578 } | 2578 } |
| 2579 if (scalarValue < Character.MAX_VALUE) { | 2579 if (scalarValue < Character.MAX_VALUE) { |
| 2580 builder.appendChar(scalarValue); | 2580 builder.appendChar(scalarValue); |
| 2581 } else { | 2581 } else { |
| 2582 builder.append(Character.toChars(scalarValue)); | 2582 builder.append(Character.toChars(scalarValue)); |
| 2583 } | 2583 } |
| 2584 } | 2584 } |
| 2585 | 2585 |
| 2586 /** | 2586 /** |
| 2587 * Compute the content of a string with the given literal representation. | 2587 * Compute the content of a string with the given literal representation. |
| 2588 * | 2588 * |
| 2589 * @param lexeme the literal representation of the string | 2589 * @param lexeme the literal representation of the string |
| 2590 * @param first `true` if this is the first token in a string literal | 2590 * @param first `true` if this is the first token in a string literal |
| 2591 * @param last `true` if this is the last token in a string literal | 2591 * @param last `true` if this is the last token in a string literal |
| 2592 * @return the actual value of the string | 2592 * @return the actual value of the string |
| 2593 */ | 2593 */ |
| 2594 String computeStringValue(String lexeme, bool first, bool last) { | 2594 String _computeStringValue(String lexeme, bool first, bool last) { |
| 2595 bool isRaw = false; | 2595 bool isRaw = false; |
| 2596 int start = 0; | 2596 int start = 0; |
| 2597 if (first) { | 2597 if (first) { |
| 2598 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || Stri
ngUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { | 2598 if (StringUtilities.startsWith4(lexeme, 0, 0x72, 0x22, 0x22, 0x22) || Stri
ngUtilities.startsWith4(lexeme, 0, 0x72, 0x27, 0x27, 0x27)) { |
| 2599 isRaw = true; | 2599 isRaw = true; |
| 2600 start += 4; | 2600 start += 4; |
| 2601 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || StringUti
lities.startsWith2(lexeme, 0, 0x72, 0x27)) { | 2601 } else if (StringUtilities.startsWith2(lexeme, 0, 0x72, 0x22) || StringUti
lities.startsWith2(lexeme, 0, 0x72, 0x27)) { |
| 2602 isRaw = true; | 2602 isRaw = true; |
| 2603 start += 2; | 2603 start += 2; |
| 2604 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || Str
ingUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { | 2604 } else if (StringUtilities.startsWith3(lexeme, 0, 0x22, 0x22, 0x22) || Str
ingUtilities.startsWith3(lexeme, 0, 0x27, 0x27, 0x27)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2618 if (end - start + 1 < 0) { | 2618 if (end - start + 1 < 0) { |
| 2619 AnalysisEngine.instance.logger.logError("Internal error: computeStringValu
e(${lexeme}, ${first}, ${last})"); | 2619 AnalysisEngine.instance.logger.logError("Internal error: computeStringValu
e(${lexeme}, ${first}, ${last})"); |
| 2620 return ""; | 2620 return ""; |
| 2621 } | 2621 } |
| 2622 if (isRaw) { | 2622 if (isRaw) { |
| 2623 return lexeme.substring(start, end); | 2623 return lexeme.substring(start, end); |
| 2624 } | 2624 } |
| 2625 JavaStringBuilder builder = new JavaStringBuilder(); | 2625 JavaStringBuilder builder = new JavaStringBuilder(); |
| 2626 int index = start; | 2626 int index = start; |
| 2627 while (index < end) { | 2627 while (index < end) { |
| 2628 index = translateCharacter(builder, lexeme, index); | 2628 index = _translateCharacter(builder, lexeme, index); |
| 2629 } | 2629 } |
| 2630 return builder.toString(); | 2630 return builder.toString(); |
| 2631 } | 2631 } |
| 2632 | 2632 |
| 2633 /** | 2633 /** |
| 2634 * Convert the given method declaration into the nearest valid top-level funct
ion declaration. | 2634 * Convert the given method declaration into the nearest valid top-level funct
ion declaration. |
| 2635 * | 2635 * |
| 2636 * @param method the method to be converted | 2636 * @param method the method to be converted |
| 2637 * @return the function declaration that most closely captures the components
of the given method | 2637 * @return the function declaration that most closely captures the components
of the given method |
| 2638 * declaration | 2638 * declaration |
| 2639 */ | 2639 */ |
| 2640 FunctionDeclaration convertToFunctionDeclaration(MethodDeclaration method) =>
new FunctionDeclaration(method.documentationComment, method.metadata, method.ext
ernalKeyword, method.returnType, method.propertyKeyword, method.name, new Functi
onExpression(method.parameters, method.body)); | 2640 FunctionDeclaration _convertToFunctionDeclaration(MethodDeclaration method) =>
new FunctionDeclaration(method.documentationComment, method.metadata, method.ex
ternalKeyword, method.returnType, method.propertyKeyword, method.name, new Funct
ionExpression(method.parameters, method.body)); |
| 2641 | 2641 |
| 2642 /** | 2642 /** |
| 2643 * Return `true` if the current token could be the start of a compilation unit
member. This | 2643 * Return `true` if the current token could be the start of a compilation unit
member. This |
| 2644 * method is used for recovery purposes to decide when to stop skipping tokens
after finding an | 2644 * method is used for recovery purposes to decide when to stop skipping tokens
after finding an |
| 2645 * error while parsing a compilation unit member. | 2645 * error while parsing a compilation unit member. |
| 2646 * | 2646 * |
| 2647 * @return `true` if the current token could be the start of a compilation uni
t member | 2647 * @return `true` if the current token could be the start of a compilation uni
t member |
| 2648 */ | 2648 */ |
| 2649 bool couldBeStartOfCompilationUnitMember() { | 2649 bool _couldBeStartOfCompilationUnitMember() { |
| 2650 if ((matchesKeyword(Keyword.IMPORT) || matchesKeyword(Keyword.EXPORT) || mat
chesKeyword(Keyword.LIBRARY) || matchesKeyword(Keyword.PART)) && !tokenMatches(p
eek(), TokenType.PERIOD) && !tokenMatches(peek(), TokenType.LT)) { | 2650 if ((_matchesKeyword(Keyword.IMPORT) || _matchesKeyword(Keyword.EXPORT) || _
matchesKeyword(Keyword.LIBRARY) || _matchesKeyword(Keyword.PART)) && !_tokenMatc
hes(_peek(), TokenType.PERIOD) && !_tokenMatches(_peek(), TokenType.LT)) { |
| 2651 // This looks like the start of a directive | 2651 // This looks like the start of a directive |
| 2652 return true; | 2652 return true; |
| 2653 } else if (matchesKeyword(Keyword.CLASS)) { | 2653 } else if (_matchesKeyword(Keyword.CLASS)) { |
| 2654 // This looks like the start of a class definition | 2654 // This looks like the start of a class definition |
| 2655 return true; | 2655 return true; |
| 2656 } else if (matchesKeyword(Keyword.TYPEDEF) && !tokenMatches(peek(), TokenTyp
e.PERIOD) && !tokenMatches(peek(), TokenType.LT)) { | 2656 } else if (_matchesKeyword(Keyword.TYPEDEF) && !_tokenMatches(_peek(), Token
Type.PERIOD) && !_tokenMatches(_peek(), TokenType.LT)) { |
| 2657 // This looks like the start of a typedef | 2657 // This looks like the start of a typedef |
| 2658 return true; | 2658 return true; |
| 2659 } else if (matchesKeyword(Keyword.VOID) || ((matchesKeyword(Keyword.GET) ||
matchesKeyword(Keyword.SET)) && tokenMatchesIdentifier(peek())) || (matchesKeywo
rd(Keyword.OPERATOR) && isOperator(peek()))) { | 2659 } else if (_matchesKeyword(Keyword.VOID) || ((_matchesKeyword(Keyword.GET) |
| _matchesKeyword(Keyword.SET)) && _tokenMatchesIdentifier(_peek())) || (_matche
sKeyword(Keyword.OPERATOR) && _isOperator(_peek()))) { |
| 2660 // This looks like the start of a function | 2660 // This looks like the start of a function |
| 2661 return true; | 2661 return true; |
| 2662 } else if (matchesIdentifier()) { | 2662 } else if (_matchesIdentifier()) { |
| 2663 if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 2663 if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 2664 // This looks like the start of a function | 2664 // This looks like the start of a function |
| 2665 return true; | 2665 return true; |
| 2666 } | 2666 } |
| 2667 Token token = skipReturnType(_currentToken); | 2667 Token token = _skipReturnType(_currentToken); |
| 2668 if (token == null) { | 2668 if (token == null) { |
| 2669 return false; | 2669 return false; |
| 2670 } | 2670 } |
| 2671 if (matchesKeyword(Keyword.GET) || matchesKeyword(Keyword.SET) || (matches
Keyword(Keyword.OPERATOR) && isOperator(peek())) || matchesIdentifier()) { | 2671 if (_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET) || (_matc
hesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) || _matchesIdentifier()) { |
| 2672 return true; | 2672 return true; |
| 2673 } | 2673 } |
| 2674 } | 2674 } |
| 2675 return false; | 2675 return false; |
| 2676 } | 2676 } |
| 2677 | 2677 |
| 2678 /** | 2678 /** |
| 2679 * Create a synthetic identifier. | 2679 * Create a synthetic identifier. |
| 2680 * | 2680 * |
| 2681 * @return the synthetic identifier that was created | 2681 * @return the synthetic identifier that was created |
| 2682 */ | 2682 */ |
| 2683 SimpleIdentifier createSyntheticIdentifier() { | 2683 SimpleIdentifier _createSyntheticIdentifier() { |
| 2684 Token syntheticToken; | 2684 Token syntheticToken; |
| 2685 if (identical(_currentToken.type, TokenType.KEYWORD)) { | 2685 if (identical(_currentToken.type, TokenType.KEYWORD)) { |
| 2686 // Consider current keyword token as an identifier. | 2686 // Consider current keyword token as an identifier. |
| 2687 // It is not always true, e.g. "^is T" where "^" is place the place for sy
nthetic identifier. | 2687 // It is not always true, e.g. "^is T" where "^" is place the place for sy
nthetic identifier. |
| 2688 // By creating SyntheticStringToken we can distinguish a real identifier f
rom synthetic. | 2688 // By creating SyntheticStringToken we can distinguish a real identifier f
rom synthetic. |
| 2689 // In the code completion behavior will depend on a cursor position - befo
re or on "is". | 2689 // In the code completion behavior will depend on a cursor position - befo
re or on "is". |
| 2690 syntheticToken = injectToken(new SyntheticStringToken(TokenType.IDENTIFIER
, _currentToken.lexeme, _currentToken.offset)); | 2690 syntheticToken = _injectToken(new SyntheticStringToken(TokenType.IDENTIFIE
R, _currentToken.lexeme, _currentToken.offset)); |
| 2691 } else { | 2691 } else { |
| 2692 syntheticToken = createSyntheticToken(TokenType.IDENTIFIER); | 2692 syntheticToken = _createSyntheticToken(TokenType.IDENTIFIER); |
| 2693 } | 2693 } |
| 2694 return new SimpleIdentifier(syntheticToken); | 2694 return new SimpleIdentifier(syntheticToken); |
| 2695 } | 2695 } |
| 2696 | 2696 |
| 2697 /** | 2697 /** |
| 2698 * Create a synthetic token representing the given keyword. | 2698 * Create a synthetic token representing the given keyword. |
| 2699 * | 2699 * |
| 2700 * @return the synthetic token that was created | 2700 * @return the synthetic token that was created |
| 2701 */ | 2701 */ |
| 2702 Token createSyntheticKeyword(Keyword keyword) => injectToken(new Parser_Synthe
ticKeywordToken(keyword, _currentToken.offset)); | 2702 Token _createSyntheticKeyword(Keyword keyword) => _injectToken(new Parser_Synt
heticKeywordToken(keyword, _currentToken.offset)); |
| 2703 | 2703 |
| 2704 /** | 2704 /** |
| 2705 * Create a synthetic string literal. | 2705 * Create a synthetic string literal. |
| 2706 * | 2706 * |
| 2707 * @return the synthetic string literal that was created | 2707 * @return the synthetic string literal that was created |
| 2708 */ | 2708 */ |
| 2709 SimpleStringLiteral createSyntheticStringLiteral() => new SimpleStringLiteral(
createSyntheticToken(TokenType.STRING), ""); | 2709 SimpleStringLiteral _createSyntheticStringLiteral() => new SimpleStringLiteral
(_createSyntheticToken(TokenType.STRING), ""); |
| 2710 | 2710 |
| 2711 /** | 2711 /** |
| 2712 * Create a synthetic token with the given type. | 2712 * Create a synthetic token with the given type. |
| 2713 * | 2713 * |
| 2714 * @return the synthetic token that was created | 2714 * @return the synthetic token that was created |
| 2715 */ | 2715 */ |
| 2716 Token createSyntheticToken(TokenType type) => injectToken(new StringToken(type
, "", _currentToken.offset)); | 2716 Token _createSyntheticToken(TokenType type) => _injectToken(new StringToken(ty
pe, "", _currentToken.offset)); |
| 2717 | 2717 |
| 2718 /** | 2718 /** |
| 2719 * Check that the given expression is assignable and report an error if it isn
't. | 2719 * Check that the given expression is assignable and report an error if it isn
't. |
| 2720 * | 2720 * |
| 2721 * <pre> | 2721 * <pre> |
| 2722 * assignableExpression ::= | 2722 * assignableExpression ::= |
| 2723 * primary (arguments* assignableSelector)+ | 2723 * primary (arguments* assignableSelector)+ |
| 2724 * | 'super' assignableSelector | 2724 * | 'super' assignableSelector |
| 2725 * | identifier | 2725 * | identifier |
| 2726 * | 2726 * |
| 2727 * assignableSelector ::= | 2727 * assignableSelector ::= |
| 2728 * '[' expression ']' | 2728 * '[' expression ']' |
| 2729 * | '.' identifier | 2729 * | '.' identifier |
| 2730 * </pre> | 2730 * </pre> |
| 2731 * | 2731 * |
| 2732 * @param expression the expression being checked | 2732 * @param expression the expression being checked |
| 2733 */ | 2733 */ |
| 2734 void ensureAssignable(Expression expression) { | 2734 void _ensureAssignable(Expression expression) { |
| 2735 if (expression != null && !expression.isAssignable) { | 2735 if (expression != null && !expression.isAssignable) { |
| 2736 reportErrorForCurrentToken(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIG
NABLE, []); | 2736 _reportErrorForCurrentToken(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSI
GNABLE, []); |
| 2737 } | 2737 } |
| 2738 } | 2738 } |
| 2739 | 2739 |
| 2740 /** | 2740 /** |
| 2741 * If the current token has the expected type, return it after advancing to th
e next token. | 2741 * If the current token has the expected type, return it after advancing to th
e next token. |
| 2742 * Otherwise report an error and return the current token without advancing. | 2742 * Otherwise report an error and return the current token without advancing. |
| 2743 * | 2743 * |
| 2744 * @param type the type of token that is expected | 2744 * @param type the type of token that is expected |
| 2745 * @return the token that matched the given type | 2745 * @return the token that matched the given type |
| 2746 */ | 2746 */ |
| 2747 Token expect(TokenType type) { | 2747 Token _expect(TokenType type) { |
| 2748 if (matches(type)) { | 2748 if (_matches(type)) { |
| 2749 return andAdvance; | 2749 return andAdvance; |
| 2750 } | 2750 } |
| 2751 // Remove uses of this method in favor of matches? | 2751 // Remove uses of this method in favor of matches? |
| 2752 // Pass in the error code to use to report the error? | 2752 // Pass in the error code to use to report the error? |
| 2753 if (identical(type, TokenType.SEMICOLON)) { | 2753 if (identical(type, TokenType.SEMICOLON)) { |
| 2754 reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous
, [type.lexeme]); | 2754 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previou
s, [type.lexeme]); |
| 2755 } else { | 2755 } else { |
| 2756 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme]); | 2756 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme])
; |
| 2757 } | 2757 } |
| 2758 return _currentToken; | 2758 return _currentToken; |
| 2759 } | 2759 } |
| 2760 | 2760 |
| 2761 /** | 2761 /** |
| 2762 * If the current token is a keyword matching the given string, return it afte
r advancing to the | 2762 * If the current token is a keyword matching the given string, return it afte
r advancing to the |
| 2763 * next token. Otherwise report an error and return the current token without
advancing. | 2763 * next token. Otherwise report an error and return the current token without
advancing. |
| 2764 * | 2764 * |
| 2765 * @param keyword the keyword that is expected | 2765 * @param keyword the keyword that is expected |
| 2766 * @return the token that matched the given type | 2766 * @return the token that matched the given type |
| 2767 */ | 2767 */ |
| 2768 Token expectKeyword(Keyword keyword) { | 2768 Token _expectKeyword(Keyword keyword) { |
| 2769 if (matchesKeyword(keyword)) { | 2769 if (_matchesKeyword(keyword)) { |
| 2770 return andAdvance; | 2770 return andAdvance; |
| 2771 } | 2771 } |
| 2772 // Remove uses of this method in favor of matches? | 2772 // Remove uses of this method in favor of matches? |
| 2773 // Pass in the error code to use to report the error? | 2773 // Pass in the error code to use to report the error? |
| 2774 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax])
; | 2774 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]
); |
| 2775 return _currentToken; | 2775 return _currentToken; |
| 2776 } | 2776 } |
| 2777 | 2777 |
| 2778 /** | 2778 /** |
| 2779 * If [currentToken] is a semicolon, returns it; otherwise reports error and c
reates a | 2779 * If [currentToken] is a semicolon, returns it; otherwise reports error and c
reates a |
| 2780 * synthetic one. | 2780 * synthetic one. |
| 2781 * | 2781 * |
| 2782 * TODO(scheglov) consider pushing this into [expect] | 2782 * TODO(scheglov) consider pushing this into [expect] |
| 2783 */ | 2783 */ |
| 2784 Token expectSemicolon() { | 2784 Token _expectSemicolon() { |
| 2785 if (matches(TokenType.SEMICOLON)) { | 2785 if (_matches(TokenType.SEMICOLON)) { |
| 2786 return andAdvance; | 2786 return andAdvance; |
| 2787 } else { | 2787 } else { |
| 2788 reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous
, [";"]); | 2788 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previou
s, [";"]); |
| 2789 return createSyntheticToken(TokenType.SEMICOLON); | 2789 return _createSyntheticToken(TokenType.SEMICOLON); |
| 2790 } | 2790 } |
| 2791 } | 2791 } |
| 2792 | 2792 |
| 2793 /** | 2793 /** |
| 2794 * Search the given list of ranges for a range that contains the given index.
Return the range | 2794 * Search the given list of ranges for a range that contains the given index.
Return the range |
| 2795 * that was found, or `null` if none of the ranges contain the index. | 2795 * that was found, or `null` if none of the ranges contain the index. |
| 2796 * | 2796 * |
| 2797 * @param ranges the ranges to be searched | 2797 * @param ranges the ranges to be searched |
| 2798 * @param index the index contained in the returned range | 2798 * @param index the index contained in the returned range |
| 2799 * @return the range that was found | 2799 * @return the range that was found |
| 2800 */ | 2800 */ |
| 2801 List<int> findRange(List<List<int>> ranges, int index) { | 2801 List<int> _findRange(List<List<int>> ranges, int index) { |
| 2802 int rangeCount = ranges.length; | 2802 int rangeCount = ranges.length; |
| 2803 for (int i = 0; i < rangeCount; i++) { | 2803 for (int i = 0; i < rangeCount; i++) { |
| 2804 List<int> range = ranges[i]; | 2804 List<int> range = ranges[i]; |
| 2805 if (range[0] <= index && index <= range[1]) { | 2805 if (range[0] <= index && index <= range[1]) { |
| 2806 return range; | 2806 return range; |
| 2807 } else if (index < range[0]) { | 2807 } else if (index < range[0]) { |
| 2808 return null; | 2808 return null; |
| 2809 } | 2809 } |
| 2810 } | 2810 } |
| 2811 return null; | 2811 return null; |
| 2812 } | 2812 } |
| 2813 | 2813 |
| 2814 /** | 2814 /** |
| 2815 * Advance to the next token in the token stream, making it the new current to
ken. | 2815 * Advance to the next token in the token stream, making it the new current to
ken. |
| 2816 * | 2816 * |
| 2817 * @return the token that was current before this method was invoked | 2817 * @return the token that was current before this method was invoked |
| 2818 */ | 2818 */ |
| 2819 Token get andAdvance { | 2819 Token get andAdvance { |
| 2820 Token token = _currentToken; | 2820 Token token = _currentToken; |
| 2821 advance(); | 2821 _advance(); |
| 2822 return token; | 2822 return token; |
| 2823 } | 2823 } |
| 2824 | 2824 |
| 2825 /** | 2825 /** |
| 2826 * Return a list of the ranges of characters in the given comment string that
should be treated as | 2826 * Return a list of the ranges of characters in the given comment string that
should be treated as |
| 2827 * code blocks. | 2827 * code blocks. |
| 2828 * | 2828 * |
| 2829 * @param comment the comment being processed | 2829 * @param comment the comment being processed |
| 2830 * @return the ranges of characters that should be treated as code blocks | 2830 * @return the ranges of characters that should be treated as code blocks |
| 2831 */ | 2831 */ |
| 2832 List<List<int>> getCodeBlockRanges(String comment) { | 2832 List<List<int>> _getCodeBlockRanges(String comment) { |
| 2833 List<List<int>> ranges = new List<List<int>>(); | 2833 List<List<int>> ranges = new List<List<int>>(); |
| 2834 int length = comment.length; | 2834 int length = comment.length; |
| 2835 if (length < 3) { | 2835 if (length < 3) { |
| 2836 return ranges; | 2836 return ranges; |
| 2837 } | 2837 } |
| 2838 int index = 0; | 2838 int index = 0; |
| 2839 int firstChar = comment.codeUnitAt(0); | 2839 int firstChar = comment.codeUnitAt(0); |
| 2840 if (firstChar == 0x2F) { | 2840 if (firstChar == 0x2F) { |
| 2841 int secondChar = comment.codeUnitAt(1); | 2841 int secondChar = comment.codeUnitAt(1); |
| 2842 int thirdChar = comment.codeUnitAt(2); | 2842 int thirdChar = comment.codeUnitAt(2); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2873 return ranges; | 2873 return ranges; |
| 2874 } | 2874 } |
| 2875 | 2875 |
| 2876 /** | 2876 /** |
| 2877 * Return the end token associated with the given begin token, or `null` if ei
ther the given | 2877 * Return the end token associated with the given begin token, or `null` if ei
ther the given |
| 2878 * token is not a begin token or it does not have an end token associated with
it. | 2878 * token is not a begin token or it does not have an end token associated with
it. |
| 2879 * | 2879 * |
| 2880 * @param beginToken the token that is expected to have an end token associate
d with it | 2880 * @param beginToken the token that is expected to have an end token associate
d with it |
| 2881 * @return the end token associated with the begin token | 2881 * @return the end token associated with the begin token |
| 2882 */ | 2882 */ |
| 2883 Token getEndToken(Token beginToken) { | 2883 Token _getEndToken(Token beginToken) { |
| 2884 if (beginToken is BeginToken) { | 2884 if (beginToken is BeginToken) { |
| 2885 return beginToken.endToken; | 2885 return beginToken.endToken; |
| 2886 } | 2886 } |
| 2887 return null; | 2887 return null; |
| 2888 } | 2888 } |
| 2889 | 2889 |
| 2890 /** | 2890 /** |
| 2891 * Return `true` if the current token is the first token of a return type that
is followed | 2891 * Return `true` if the current token is the first token of a return type that
is followed |
| 2892 * by an identifier, possibly followed by a list of type parameters, followed
by a | 2892 * by an identifier, possibly followed by a list of type parameters, followed
by a |
| 2893 * left-parenthesis. This is used by parseTypeAlias to determine whether or no
t to parse a return | 2893 * left-parenthesis. This is used by parseTypeAlias to determine whether or no
t to parse a return |
| 2894 * type. | 2894 * type. |
| 2895 * | 2895 * |
| 2896 * @return `true` if we can successfully parse the rest of a type alias if we
first parse a | 2896 * @return `true` if we can successfully parse the rest of a type alias if we
first parse a |
| 2897 * return type. | 2897 * return type. |
| 2898 */ | 2898 */ |
| 2899 bool get hasReturnTypeInTypeAlias { | 2899 bool get hasReturnTypeInTypeAlias { |
| 2900 Token next = skipReturnType(_currentToken); | 2900 Token next = _skipReturnType(_currentToken); |
| 2901 if (next == null) { | 2901 if (next == null) { |
| 2902 return false; | 2902 return false; |
| 2903 } | 2903 } |
| 2904 return tokenMatchesIdentifier(next); | 2904 return _tokenMatchesIdentifier(next); |
| 2905 } | 2905 } |
| 2906 | 2906 |
| 2907 /** | 2907 /** |
| 2908 * Inject the given token into the token stream immediately before the current
token. | 2908 * Inject the given token into the token stream immediately before the current
token. |
| 2909 * | 2909 * |
| 2910 * @param token the token to be added to the token stream | 2910 * @param token the token to be added to the token stream |
| 2911 * @return the token that was just added to the token stream | 2911 * @return the token that was just added to the token stream |
| 2912 */ | 2912 */ |
| 2913 Token injectToken(Token token) { | 2913 Token _injectToken(Token token) { |
| 2914 Token previous = _currentToken.previous; | 2914 Token previous = _currentToken.previous; |
| 2915 token.setNext(_currentToken); | 2915 token.setNext(_currentToken); |
| 2916 previous.setNext(token); | 2916 previous.setNext(token); |
| 2917 return token; | 2917 return token; |
| 2918 } | 2918 } |
| 2919 | 2919 |
| 2920 /** | 2920 /** |
| 2921 * Return `true` if the current token appears to be the beginning of a functio
n declaration. | 2921 * Return `true` if the current token appears to be the beginning of a functio
n declaration. |
| 2922 * | 2922 * |
| 2923 * @return `true` if the current token appears to be the beginning of a functi
on declaration | 2923 * @return `true` if the current token appears to be the beginning of a functi
on declaration |
| 2924 */ | 2924 */ |
| 2925 bool isFunctionDeclaration() { | 2925 bool _isFunctionDeclaration() { |
| 2926 if (matchesKeyword(Keyword.VOID)) { | 2926 if (_matchesKeyword(Keyword.VOID)) { |
| 2927 return true; | 2927 return true; |
| 2928 } | 2928 } |
| 2929 Token afterReturnType = skipTypeName(_currentToken); | 2929 Token afterReturnType = _skipTypeName(_currentToken); |
| 2930 if (afterReturnType == null) { | 2930 if (afterReturnType == null) { |
| 2931 // There was no return type, but it is optional, so go back to where we st
arted. | 2931 // There was no return type, but it is optional, so go back to where we st
arted. |
| 2932 afterReturnType = _currentToken; | 2932 afterReturnType = _currentToken; |
| 2933 } | 2933 } |
| 2934 Token afterIdentifier = skipSimpleIdentifier(afterReturnType); | 2934 Token afterIdentifier = _skipSimpleIdentifier(afterReturnType); |
| 2935 if (afterIdentifier == null) { | 2935 if (afterIdentifier == null) { |
| 2936 // It's possible that we parsed the function name as if it were a type nam
e, so see whether | 2936 // It's possible that we parsed the function name as if it were a type nam
e, so see whether |
| 2937 // it makes sense if we assume that there is no type. | 2937 // it makes sense if we assume that there is no type. |
| 2938 afterIdentifier = skipSimpleIdentifier(_currentToken); | 2938 afterIdentifier = _skipSimpleIdentifier(_currentToken); |
| 2939 } | 2939 } |
| 2940 if (afterIdentifier == null) { | 2940 if (afterIdentifier == null) { |
| 2941 return false; | 2941 return false; |
| 2942 } | 2942 } |
| 2943 if (isFunctionExpression(afterIdentifier)) { | 2943 if (_isFunctionExpression(afterIdentifier)) { |
| 2944 return true; | 2944 return true; |
| 2945 } | 2945 } |
| 2946 // It's possible that we have found a getter. While this isn't valid at this
point we test for | 2946 // It's possible that we have found a getter. While this isn't valid at this
point we test for |
| 2947 // it in order to recover better. | 2947 // it in order to recover better. |
| 2948 if (matchesKeyword(Keyword.GET)) { | 2948 if (_matchesKeyword(Keyword.GET)) { |
| 2949 Token afterName = skipSimpleIdentifier(_currentToken.next); | 2949 Token afterName = _skipSimpleIdentifier(_currentToken.next); |
| 2950 if (afterName == null) { | 2950 if (afterName == null) { |
| 2951 return false; | 2951 return false; |
| 2952 } | 2952 } |
| 2953 return tokenMatches(afterName, TokenType.FUNCTION) || tokenMatches(afterNa
me, TokenType.OPEN_CURLY_BRACKET); | 2953 return _tokenMatches(afterName, TokenType.FUNCTION) || _tokenMatches(after
Name, TokenType.OPEN_CURLY_BRACKET); |
| 2954 } | 2954 } |
| 2955 return false; | 2955 return false; |
| 2956 } | 2956 } |
| 2957 | 2957 |
| 2958 /** | 2958 /** |
| 2959 * Return `true` if the given token appears to be the beginning of a function
expression. | 2959 * Return `true` if the given token appears to be the beginning of a function
expression. |
| 2960 * | 2960 * |
| 2961 * @param startToken the token that might be the start of a function expressio
n | 2961 * @param startToken the token that might be the start of a function expressio
n |
| 2962 * @return `true` if the given token appears to be the beginning of a function
expression | 2962 * @return `true` if the given token appears to be the beginning of a function
expression |
| 2963 */ | 2963 */ |
| 2964 bool isFunctionExpression(Token startToken) { | 2964 bool _isFunctionExpression(Token startToken) { |
| 2965 Token afterParameters = skipFormalParameterList(startToken); | 2965 Token afterParameters = _skipFormalParameterList(startToken); |
| 2966 if (afterParameters == null) { | 2966 if (afterParameters == null) { |
| 2967 return false; | 2967 return false; |
| 2968 } | 2968 } |
| 2969 return matchesAny(afterParameters, [TokenType.OPEN_CURLY_BRACKET, TokenType.
FUNCTION]); | 2969 return afterParameters.matchesAny([TokenType.OPEN_CURLY_BRACKET, TokenType.F
UNCTION]); |
| 2970 } | 2970 } |
| 2971 | 2971 |
| 2972 /** | 2972 /** |
| 2973 * Return `true` if the given character is a valid hexadecimal digit. | 2973 * Return `true` if the given character is a valid hexadecimal digit. |
| 2974 * | 2974 * |
| 2975 * @param character the character being tested | 2975 * @param character the character being tested |
| 2976 * @return `true` if the character is a valid hexadecimal digit | 2976 * @return `true` if the character is a valid hexadecimal digit |
| 2977 */ | 2977 */ |
| 2978 bool isHexDigit(int character) => (0x30 <= character && character <= 0x39) ||
(0x41 <= character && character <= 0x46) || (0x61 <= character && character <= 0
x66); | 2978 bool _isHexDigit(int character) => (0x30 <= character && character <= 0x39) ||
(0x41 <= character && character <= 0x46) || (0x61 <= character && character <=
0x66); |
| 2979 | 2979 |
| 2980 /** | 2980 /** |
| 2981 * Return `true` if the current token is the first token in an initialized var
iable | 2981 * Return `true` if the current token is the first token in an initialized var
iable |
| 2982 * declaration rather than an expression. This method assumes that we have alr
eady skipped past | 2982 * declaration rather than an expression. This method assumes that we have alr
eady skipped past |
| 2983 * any metadata that might be associated with the declaration. | 2983 * any metadata that might be associated with the declaration. |
| 2984 * | 2984 * |
| 2985 * <pre> | 2985 * <pre> |
| 2986 * initializedVariableDeclaration ::= | 2986 * initializedVariableDeclaration ::= |
| 2987 * declaredIdentifier ('=' expression)? (',' initializedIdentifier)* | 2987 * declaredIdentifier ('=' expression)? (',' initializedIdentifier)* |
| 2988 * | 2988 * |
| 2989 * declaredIdentifier ::= | 2989 * declaredIdentifier ::= |
| 2990 * metadata finalConstVarOrType identifier | 2990 * metadata finalConstVarOrType identifier |
| 2991 * | 2991 * |
| 2992 * finalConstVarOrType ::= | 2992 * finalConstVarOrType ::= |
| 2993 * 'final' type? | 2993 * 'final' type? |
| 2994 * | 'const' type? | 2994 * | 'const' type? |
| 2995 * | 'var' | 2995 * | 'var' |
| 2996 * | type | 2996 * | type |
| 2997 * | 2997 * |
| 2998 * type ::= | 2998 * type ::= |
| 2999 * qualified typeArguments? | 2999 * qualified typeArguments? |
| 3000 * | 3000 * |
| 3001 * initializedIdentifier ::= | 3001 * initializedIdentifier ::= |
| 3002 * identifier ('=' expression)? | 3002 * identifier ('=' expression)? |
| 3003 * </pre> | 3003 * </pre> |
| 3004 * | 3004 * |
| 3005 * @return `true` if the current token is the first token in an initialized va
riable | 3005 * @return `true` if the current token is the first token in an initialized va
riable |
| 3006 * declaration | 3006 * declaration |
| 3007 */ | 3007 */ |
| 3008 bool isInitializedVariableDeclaration() { | 3008 bool _isInitializedVariableDeclaration() { |
| 3009 if (matchesKeyword(Keyword.FINAL) || matchesKeyword(Keyword.VAR)) { | 3009 if (_matchesKeyword(Keyword.FINAL) || _matchesKeyword(Keyword.VAR)) { |
| 3010 // An expression cannot start with a keyword other than 'const', 'rethrow'
, or 'throw'. | 3010 // An expression cannot start with a keyword other than 'const', 'rethrow'
, or 'throw'. |
| 3011 return true; | 3011 return true; |
| 3012 } | 3012 } |
| 3013 if (matchesKeyword(Keyword.CONST)) { | 3013 if (_matchesKeyword(Keyword.CONST)) { |
| 3014 // Look to see whether we might be at the start of a list or map literal,
otherwise this | 3014 // Look to see whether we might be at the start of a list or map literal,
otherwise this |
| 3015 // should be the start of a variable declaration. | 3015 // should be the start of a variable declaration. |
| 3016 return !matchesAny(peek(), [ | 3016 return !_peek().matchesAny([ |
| 3017 TokenType.LT, | 3017 TokenType.LT, |
| 3018 TokenType.OPEN_CURLY_BRACKET, | 3018 TokenType.OPEN_CURLY_BRACKET, |
| 3019 TokenType.OPEN_SQUARE_BRACKET, | 3019 TokenType.OPEN_SQUARE_BRACKET, |
| 3020 TokenType.INDEX]); | 3020 TokenType.INDEX]); |
| 3021 } | 3021 } |
| 3022 // We know that we have an identifier, and need to see whether it might be a
type name. | 3022 // We know that we have an identifier, and need to see whether it might be a
type name. |
| 3023 Token token = skipTypeName(_currentToken); | 3023 Token token = _skipTypeName(_currentToken); |
| 3024 if (token == null) { | 3024 if (token == null) { |
| 3025 // There was no type name, so this can't be a declaration. | 3025 // There was no type name, so this can't be a declaration. |
| 3026 return false; | 3026 return false; |
| 3027 } | 3027 } |
| 3028 token = skipSimpleIdentifier(token); | 3028 token = _skipSimpleIdentifier(token); |
| 3029 if (token == null) { | 3029 if (token == null) { |
| 3030 return false; | 3030 return false; |
| 3031 } | 3031 } |
| 3032 TokenType type = token.type; | 3032 TokenType type = token.type; |
| 3033 return identical(type, TokenType.EQ) || identical(type, TokenType.COMMA) ||
identical(type, TokenType.SEMICOLON) || tokenMatchesKeyword(token, Keyword.IN); | 3033 return identical(type, TokenType.EQ) || identical(type, TokenType.COMMA) ||
identical(type, TokenType.SEMICOLON) || _tokenMatchesKeyword(token, Keyword.IN); |
| 3034 } | 3034 } |
| 3035 | 3035 |
| 3036 /** | 3036 /** |
| 3037 * Given that we have just found bracketed text within a comment, look to see
whether that text is | 3037 * Given that we have just found bracketed text within a comment, look to see
whether that text is |
| 3038 * (a) followed by a parenthesized link address, (b) followed by a colon, or (
c) followed by | 3038 * (a) followed by a parenthesized link address, (b) followed by a colon, or (
c) followed by |
| 3039 * optional whitespace and another square bracket. | 3039 * optional whitespace and another square bracket. |
| 3040 * | 3040 * |
| 3041 * This method uses the syntax described by the <a | 3041 * This method uses the syntax described by the <a |
| 3042 * href="http://daringfireball.net/projects/markdown/syntax">markdown</a> proj
ect. | 3042 * href="http://daringfireball.net/projects/markdown/syntax">markdown</a> proj
ect. |
| 3043 * | 3043 * |
| 3044 * @param comment the comment text in which the bracketed text was found | 3044 * @param comment the comment text in which the bracketed text was found |
| 3045 * @param rightIndex the index of the right bracket | 3045 * @param rightIndex the index of the right bracket |
| 3046 * @return `true` if the bracketed text is followed by a link address | 3046 * @return `true` if the bracketed text is followed by a link address |
| 3047 */ | 3047 */ |
| 3048 bool isLinkText(String comment, int rightIndex) { | 3048 bool _isLinkText(String comment, int rightIndex) { |
| 3049 int length = comment.length; | 3049 int length = comment.length; |
| 3050 int index = rightIndex + 1; | 3050 int index = rightIndex + 1; |
| 3051 if (index >= length) { | 3051 if (index >= length) { |
| 3052 return false; | 3052 return false; |
| 3053 } | 3053 } |
| 3054 int nextChar = comment.codeUnitAt(index); | 3054 int nextChar = comment.codeUnitAt(index); |
| 3055 if (nextChar == 0x28 || nextChar == 0x3A) { | 3055 if (nextChar == 0x28 || nextChar == 0x3A) { |
| 3056 return true; | 3056 return true; |
| 3057 } | 3057 } |
| 3058 while (Character.isWhitespace(nextChar)) { | 3058 while (Character.isWhitespace(nextChar)) { |
| 3059 index = index + 1; | 3059 index = index + 1; |
| 3060 if (index >= length) { | 3060 if (index >= length) { |
| 3061 return false; | 3061 return false; |
| 3062 } | 3062 } |
| 3063 nextChar = comment.codeUnitAt(index); | 3063 nextChar = comment.codeUnitAt(index); |
| 3064 } | 3064 } |
| 3065 return nextChar == 0x5B; | 3065 return nextChar == 0x5B; |
| 3066 } | 3066 } |
| 3067 | 3067 |
| 3068 /** | 3068 /** |
| 3069 * Return `true` if the given token appears to be the beginning of an operator
declaration. | 3069 * Return `true` if the given token appears to be the beginning of an operator
declaration. |
| 3070 * | 3070 * |
| 3071 * @param startToken the token that might be the start of an operator declarat
ion | 3071 * @param startToken the token that might be the start of an operator declarat
ion |
| 3072 * @return `true` if the given token appears to be the beginning of an operato
r declaration | 3072 * @return `true` if the given token appears to be the beginning of an operato
r declaration |
| 3073 */ | 3073 */ |
| 3074 bool isOperator(Token startToken) { | 3074 bool _isOperator(Token startToken) { |
| 3075 // Accept any operator here, even if it is not user definable. | 3075 // Accept any operator here, even if it is not user definable. |
| 3076 if (!startToken.isOperator) { | 3076 if (!startToken.isOperator) { |
| 3077 return false; | 3077 return false; |
| 3078 } | 3078 } |
| 3079 // Token "=" means that it is actually field initializer. | 3079 // Token "=" means that it is actually field initializer. |
| 3080 if (identical(startToken.type, TokenType.EQ)) { | 3080 if (identical(startToken.type, TokenType.EQ)) { |
| 3081 return false; | 3081 return false; |
| 3082 } | 3082 } |
| 3083 // Consume all operator tokens. | 3083 // Consume all operator tokens. |
| 3084 Token token = startToken.next; | 3084 Token token = startToken.next; |
| 3085 while (token.isOperator) { | 3085 while (token.isOperator) { |
| 3086 token = token.next; | 3086 token = token.next; |
| 3087 } | 3087 } |
| 3088 // Formal parameter list is expect now. | 3088 // Formal parameter list is expect now. |
| 3089 return tokenMatches(token, TokenType.OPEN_PAREN); | 3089 return _tokenMatches(token, TokenType.OPEN_PAREN); |
| 3090 } | 3090 } |
| 3091 | 3091 |
| 3092 /** | 3092 /** |
| 3093 * Return `true` if the current token appears to be the beginning of a switch
member. | 3093 * Return `true` if the current token appears to be the beginning of a switch
member. |
| 3094 * | 3094 * |
| 3095 * @return `true` if the current token appears to be the beginning of a switch
member | 3095 * @return `true` if the current token appears to be the beginning of a switch
member |
| 3096 */ | 3096 */ |
| 3097 bool isSwitchMember() { | 3097 bool _isSwitchMember() { |
| 3098 Token token = _currentToken; | 3098 Token token = _currentToken; |
| 3099 while (tokenMatches(token, TokenType.IDENTIFIER) && tokenMatches(token.next,
TokenType.COLON)) { | 3099 while (_tokenMatches(token, TokenType.IDENTIFIER) && _tokenMatches(token.nex
t, TokenType.COLON)) { |
| 3100 token = token.next.next; | 3100 token = token.next.next; |
| 3101 } | 3101 } |
| 3102 if (identical(token.type, TokenType.KEYWORD)) { | 3102 if (identical(token.type, TokenType.KEYWORD)) { |
| 3103 Keyword keyword = (token as KeywordToken).keyword; | 3103 Keyword keyword = (token as KeywordToken).keyword; |
| 3104 return identical(keyword, Keyword.CASE) || identical(keyword, Keyword.DEFA
ULT); | 3104 return identical(keyword, Keyword.CASE) || identical(keyword, Keyword.DEFA
ULT); |
| 3105 } | 3105 } |
| 3106 return false; | 3106 return false; |
| 3107 } | 3107 } |
| 3108 | 3108 |
| 3109 /** | 3109 /** |
| 3110 * Return `true` if the given token appears to be the first token of a type na
me that is | 3110 * Return `true` if the given token appears to be the first token of a type na
me that is |
| 3111 * followed by a variable or field formal parameter. | 3111 * followed by a variable or field formal parameter. |
| 3112 * | 3112 * |
| 3113 * @param startToken the first token of the sequence being checked | 3113 * @param startToken the first token of the sequence being checked |
| 3114 * @return `true` if there is a type name and variable starting at the given t
oken | 3114 * @return `true` if there is a type name and variable starting at the given t
oken |
| 3115 */ | 3115 */ |
| 3116 bool isTypedIdentifier(Token startToken) { | 3116 bool _isTypedIdentifier(Token startToken) { |
| 3117 Token token = skipReturnType(startToken); | 3117 Token token = _skipReturnType(startToken); |
| 3118 if (token == null) { | 3118 if (token == null) { |
| 3119 return false; | 3119 return false; |
| 3120 } else if (tokenMatchesIdentifier(token)) { | 3120 } else if (_tokenMatchesIdentifier(token)) { |
| 3121 return true; | 3121 return true; |
| 3122 } else if (tokenMatchesKeyword(token, Keyword.THIS) && tokenMatches(token.ne
xt, TokenType.PERIOD) && tokenMatchesIdentifier(token.next.next)) { | 3122 } else if (_tokenMatchesKeyword(token, Keyword.THIS) && _tokenMatches(token.
next, TokenType.PERIOD) && _tokenMatchesIdentifier(token.next.next)) { |
| 3123 return true; | 3123 return true; |
| 3124 } | 3124 } |
| 3125 return false; | 3125 return false; |
| 3126 } | 3126 } |
| 3127 | 3127 |
| 3128 /** | 3128 /** |
| 3129 * Compare the given tokens to find the token that appears first in the source
being parsed. That | 3129 * Compare the given tokens to find the token that appears first in the source
being parsed. That |
| 3130 * is, return the left-most of all of the tokens. The arguments are allowed to
be `null`. | 3130 * is, return the left-most of all of the tokens. The arguments are allowed to
be `null`. |
| 3131 * Return the token with the smallest offset, or `null` if there are no argume
nts or if all | 3131 * Return the token with the smallest offset, or `null` if there are no argume
nts or if all |
| 3132 * of the arguments are `null`. | 3132 * of the arguments are `null`. |
| 3133 * | 3133 * |
| 3134 * @param tokens the tokens being compared | 3134 * @param tokens the tokens being compared |
| 3135 * @return the token with the smallest offset | 3135 * @return the token with the smallest offset |
| 3136 */ | 3136 */ |
| 3137 Token lexicallyFirst(List<Token> tokens) { | 3137 Token _lexicallyFirst(List<Token> tokens) { |
| 3138 Token first = null; | 3138 Token first = null; |
| 3139 int firstOffset = 2147483647; | 3139 int firstOffset = 2147483647; |
| 3140 for (Token token in tokens) { | 3140 for (Token token in tokens) { |
| 3141 if (token != null) { | 3141 if (token != null) { |
| 3142 int offset = token.offset; | 3142 int offset = token.offset; |
| 3143 if (offset < firstOffset) { | 3143 if (offset < firstOffset) { |
| 3144 first = token; | 3144 first = token; |
| 3145 firstOffset = offset; | 3145 firstOffset = offset; |
| 3146 } | 3146 } |
| 3147 } | 3147 } |
| 3148 } | 3148 } |
| 3149 return first; | 3149 return first; |
| 3150 } | 3150 } |
| 3151 | 3151 |
| 3152 /** | 3152 /** |
| 3153 * Increments the error reporting lock level. If level is more than `0`, then | 3153 * Increments the error reporting lock level. If level is more than `0`, then |
| 3154 * [reportError] wont report any error. | 3154 * [reportError] wont report any error. |
| 3155 */ | 3155 */ |
| 3156 void lockErrorListener() { | 3156 void _lockErrorListener() { |
| 3157 _errorListenerLock++; | 3157 _errorListenerLock++; |
| 3158 } | 3158 } |
| 3159 | 3159 |
| 3160 /** | 3160 /** |
| 3161 * Return `true` if the current token has the given type. Note that this metho
d, unlike | 3161 * Return `true` if the current token has the given type. Note that this metho
d, unlike |
| 3162 * other variants, will modify the token stream if possible to match a wider r
ange of tokens. In | 3162 * other variants, will modify the token stream if possible to match a wider r
ange of tokens. In |
| 3163 * particular, if we are attempting to match a '>' and the next token is eithe
r a '>>' or '>>>', | 3163 * particular, if we are attempting to match a '>' and the next token is eithe
r a '>>' or '>>>', |
| 3164 * the token stream will be re-written and `true` will be returned. | 3164 * the token stream will be re-written and `true` will be returned. |
| 3165 * | 3165 * |
| 3166 * @param type the type of token that can optionally appear in the current loc
ation | 3166 * @param type the type of token that can optionally appear in the current loc
ation |
| 3167 * @return `true` if the current token has the given type | 3167 * @return `true` if the current token has the given type |
| 3168 */ | 3168 */ |
| 3169 bool matches(TokenType type) { | 3169 bool _matches(TokenType type) { |
| 3170 TokenType currentType = _currentToken.type; | 3170 TokenType currentType = _currentToken.type; |
| 3171 if (currentType != type) { | 3171 if (currentType != type) { |
| 3172 if (identical(type, TokenType.GT)) { | 3172 if (identical(type, TokenType.GT)) { |
| 3173 if (identical(currentType, TokenType.GT_GT)) { | 3173 if (identical(currentType, TokenType.GT_GT)) { |
| 3174 int offset = _currentToken.offset; | 3174 int offset = _currentToken.offset; |
| 3175 Token first = new Token(TokenType.GT, offset); | 3175 Token first = new Token(TokenType.GT, offset); |
| 3176 Token second = new Token(TokenType.GT, offset + 1); | 3176 Token second = new Token(TokenType.GT, offset + 1); |
| 3177 second.setNext(_currentToken.next); | 3177 second.setNext(_currentToken.next); |
| 3178 first.setNext(second); | 3178 first.setNext(second); |
| 3179 _currentToken.previous.setNext(first); | 3179 _currentToken.previous.setNext(first); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3200 _currentToken = first; | 3200 _currentToken = first; |
| 3201 return true; | 3201 return true; |
| 3202 } | 3202 } |
| 3203 } | 3203 } |
| 3204 return false; | 3204 return false; |
| 3205 } | 3205 } |
| 3206 return true; | 3206 return true; |
| 3207 } | 3207 } |
| 3208 | 3208 |
| 3209 /** | 3209 /** |
| 3210 * Return `true` if the given token has any one of the given types. | |
| 3211 * | |
| 3212 * @param token the token being tested | |
| 3213 * @param types the types of token that are being tested for | |
| 3214 * @return `true` if the given token has any of the given types | |
| 3215 */ | |
| 3216 bool matchesAny(Token token, List<TokenType> types) { | |
| 3217 TokenType actualType = token.type; | |
| 3218 for (TokenType type in types) { | |
| 3219 if (identical(actualType, type)) { | |
| 3220 return true; | |
| 3221 } | |
| 3222 } | |
| 3223 return false; | |
| 3224 } | |
| 3225 | |
| 3226 /** | |
| 3227 * Return `true` if the current token is a valid identifier. Valid identifiers
include | 3210 * Return `true` if the current token is a valid identifier. Valid identifiers
include |
| 3228 * built-in identifiers (pseudo-keywords). | 3211 * built-in identifiers (pseudo-keywords). |
| 3229 * | 3212 * |
| 3230 * @return `true` if the current token is a valid identifier | 3213 * @return `true` if the current token is a valid identifier |
| 3231 */ | 3214 */ |
| 3232 bool matchesIdentifier() => tokenMatchesIdentifier(_currentToken); | 3215 bool _matchesIdentifier() => _tokenMatchesIdentifier(_currentToken); |
| 3233 | 3216 |
| 3234 /** | 3217 /** |
| 3235 * Return `true` if the current token matches the given keyword. | 3218 * Return `true` if the current token matches the given keyword. |
| 3236 * | 3219 * |
| 3237 * @param keyword the keyword that can optionally appear in the current locati
on | 3220 * @param keyword the keyword that can optionally appear in the current locati
on |
| 3238 * @return `true` if the current token matches the given keyword | 3221 * @return `true` if the current token matches the given keyword |
| 3239 */ | 3222 */ |
| 3240 bool matchesKeyword(Keyword keyword) => tokenMatchesKeyword(_currentToken, key
word); | 3223 bool _matchesKeyword(Keyword keyword) => _tokenMatchesKeyword(_currentToken, k
eyword); |
| 3241 | 3224 |
| 3242 /** | 3225 /** |
| 3243 * Return `true` if the current token matches the given identifier. | 3226 * Return `true` if the current token matches the given identifier. |
| 3244 * | 3227 * |
| 3245 * @param identifier the identifier that can optionally appear in the current
location | 3228 * @param identifier the identifier that can optionally appear in the current
location |
| 3246 * @return `true` if the current token matches the given identifier | 3229 * @return `true` if the current token matches the given identifier |
| 3247 */ | 3230 */ |
| 3248 bool matchesString(String identifier) => identical(_currentToken.type, TokenTy
pe.IDENTIFIER) && _currentToken.lexeme == identifier; | 3231 bool _matchesString(String identifier) => identical(_currentToken.type, TokenT
ype.IDENTIFIER) && _currentToken.lexeme == identifier; |
| 3249 | 3232 |
| 3250 /** | 3233 /** |
| 3251 * If the current token has the given type, then advance to the next token and
return `true` | 3234 * If the current token has the given type, then advance to the next token and
return `true` |
| 3252 * . Otherwise, return `false` without advancing. | 3235 * . Otherwise, return `false` without advancing. |
| 3253 * | 3236 * |
| 3254 * @param type the type of token that can optionally appear in the current loc
ation | 3237 * @param type the type of token that can optionally appear in the current loc
ation |
| 3255 * @return `true` if the current token has the given type | 3238 * @return `true` if the current token has the given type |
| 3256 */ | 3239 */ |
| 3257 bool optional(TokenType type) { | 3240 bool _optional(TokenType type) { |
| 3258 if (matches(type)) { | 3241 if (_matches(type)) { |
| 3259 advance(); | 3242 _advance(); |
| 3260 return true; | 3243 return true; |
| 3261 } | 3244 } |
| 3262 return false; | 3245 return false; |
| 3263 } | 3246 } |
| 3264 | 3247 |
| 3265 /** | 3248 /** |
| 3266 * Parse an additive expression. | 3249 * Parse an additive expression. |
| 3267 * | 3250 * |
| 3268 * <pre> | 3251 * <pre> |
| 3269 * additiveExpression ::= | 3252 * additiveExpression ::= |
| 3270 * multiplicativeExpression (additiveOperator multiplicativeExpression)* | 3253 * multiplicativeExpression (additiveOperator multiplicativeExpression)* |
| 3271 * | 'super' (additiveOperator multiplicativeExpression)+ | 3254 * | 'super' (additiveOperator multiplicativeExpression)+ |
| 3272 * </pre> | 3255 * </pre> |
| 3273 * | 3256 * |
| 3274 * @return the additive expression that was parsed | 3257 * @return the additive expression that was parsed |
| 3275 */ | 3258 */ |
| 3276 Expression parseAdditiveExpression() { | 3259 Expression _parseAdditiveExpression() { |
| 3277 Expression expression; | 3260 Expression expression; |
| 3278 if (matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isAdditiveOpera
tor) { | 3261 if (_matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isAdditiveOper
ator) { |
| 3279 expression = new SuperExpression(andAdvance); | 3262 expression = new SuperExpression(andAdvance); |
| 3280 } else { | 3263 } else { |
| 3281 expression = parseMultiplicativeExpression(); | 3264 expression = _parseMultiplicativeExpression(); |
| 3282 } | 3265 } |
| 3283 while (_currentToken.type.isAdditiveOperator) { | 3266 while (_currentToken.type.isAdditiveOperator) { |
| 3284 Token operator = andAdvance; | 3267 Token operator = andAdvance; |
| 3285 expression = new BinaryExpression(expression, operator, parseMultiplicativ
eExpression()); | 3268 expression = new BinaryExpression(expression, operator, _parseMultiplicati
veExpression()); |
| 3286 } | 3269 } |
| 3287 return expression; | 3270 return expression; |
| 3288 } | 3271 } |
| 3289 | 3272 |
| 3290 /** | 3273 /** |
| 3291 * Parse an argument definition test. | 3274 * Parse an argument definition test. |
| 3292 * | 3275 * |
| 3293 * <pre> | 3276 * <pre> |
| 3294 * argumentDefinitionTest ::= | 3277 * argumentDefinitionTest ::= |
| 3295 * '?' identifier | 3278 * '?' identifier |
| 3296 * </pre> | 3279 * </pre> |
| 3297 * | 3280 * |
| 3298 * @return the argument definition test that was parsed | 3281 * @return the argument definition test that was parsed |
| 3299 */ | 3282 */ |
| 3300 ArgumentDefinitionTest parseArgumentDefinitionTest() { | 3283 ArgumentDefinitionTest _parseArgumentDefinitionTest() { |
| 3301 Token question = expect(TokenType.QUESTION); | 3284 Token question = _expect(TokenType.QUESTION); |
| 3302 SimpleIdentifier identifier = parseSimpleIdentifier(); | 3285 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 3303 reportErrorForToken(ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, que
stion, []); | 3286 _reportErrorForToken(ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, qu
estion, []); |
| 3304 return new ArgumentDefinitionTest(question, identifier); | 3287 return new ArgumentDefinitionTest(question, identifier); |
| 3305 } | 3288 } |
| 3306 | 3289 |
| 3307 /** | 3290 /** |
| 3308 * Parse an assert statement. | 3291 * Parse an assert statement. |
| 3309 * | 3292 * |
| 3310 * <pre> | 3293 * <pre> |
| 3311 * assertStatement ::= | 3294 * assertStatement ::= |
| 3312 * 'assert' '(' conditionalExpression ')' ';' | 3295 * 'assert' '(' conditionalExpression ')' ';' |
| 3313 * </pre> | 3296 * </pre> |
| 3314 * | 3297 * |
| 3315 * @return the assert statement | 3298 * @return the assert statement |
| 3316 */ | 3299 */ |
| 3317 AssertStatement parseAssertStatement() { | 3300 AssertStatement _parseAssertStatement() { |
| 3318 Token keyword = expectKeyword(Keyword.ASSERT); | 3301 Token keyword = _expectKeyword(Keyword.ASSERT); |
| 3319 Token leftParen = expect(TokenType.OPEN_PAREN); | 3302 Token leftParen = _expect(TokenType.OPEN_PAREN); |
| 3320 Expression expression = parseExpression2(); | 3303 Expression expression = parseExpression2(); |
| 3321 if (expression is AssignmentExpression) { | 3304 if (expression is AssignmentExpression) { |
| 3322 reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expres
sion, []); | 3305 _reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expre
ssion, []); |
| 3323 } else if (expression is CascadeExpression) { | 3306 } else if (expression is CascadeExpression) { |
| 3324 reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expressio
n, []); | 3307 _reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expressi
on, []); |
| 3325 } else if (expression is ThrowExpression) { | 3308 } else if (expression is ThrowExpression) { |
| 3326 reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression,
[]); | 3309 _reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression
, []); |
| 3327 } else if (expression is RethrowExpression) { | 3310 } else if (expression is RethrowExpression) { |
| 3328 reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expressio
n, []); | 3311 _reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expressi
on, []); |
| 3329 } | 3312 } |
| 3330 Token rightParen = expect(TokenType.CLOSE_PAREN); | 3313 Token rightParen = _expect(TokenType.CLOSE_PAREN); |
| 3331 Token semicolon = expect(TokenType.SEMICOLON); | 3314 Token semicolon = _expect(TokenType.SEMICOLON); |
| 3332 return new AssertStatement(keyword, leftParen, expression, rightParen, semic
olon); | 3315 return new AssertStatement(keyword, leftParen, expression, rightParen, semic
olon); |
| 3333 } | 3316 } |
| 3334 | 3317 |
| 3335 /** | 3318 /** |
| 3336 * Parse an assignable expression. | 3319 * Parse an assignable expression. |
| 3337 * | 3320 * |
| 3338 * <pre> | 3321 * <pre> |
| 3339 * assignableExpression ::= | 3322 * assignableExpression ::= |
| 3340 * primary (arguments* assignableSelector)+ | 3323 * primary (arguments* assignableSelector)+ |
| 3341 * | 'super' assignableSelector | 3324 * | 'super' assignableSelector |
| 3342 * | identifier | 3325 * | identifier |
| 3343 * </pre> | 3326 * </pre> |
| 3344 * | 3327 * |
| 3345 * @param primaryAllowed `true` if the expression is allowed to be a primary w
ithout any | 3328 * @param primaryAllowed `true` if the expression is allowed to be a primary w
ithout any |
| 3346 * assignable selector | 3329 * assignable selector |
| 3347 * @return the assignable expression that was parsed | 3330 * @return the assignable expression that was parsed |
| 3348 */ | 3331 */ |
| 3349 Expression parseAssignableExpression(bool primaryAllowed) { | 3332 Expression _parseAssignableExpression(bool primaryAllowed) { |
| 3350 if (matchesKeyword(Keyword.SUPER)) { | 3333 if (_matchesKeyword(Keyword.SUPER)) { |
| 3351 return parseAssignableSelector(new SuperExpression(andAdvance), false); | 3334 return _parseAssignableSelector(new SuperExpression(andAdvance), false); |
| 3352 } | 3335 } |
| 3353 // | 3336 // |
| 3354 // A primary expression can start with an identifier. We resolve the ambigui
ty by determining | 3337 // A primary expression can start with an identifier. We resolve the ambigui
ty by determining |
| 3355 // whether the primary consists of anything other than an identifier and/or
is followed by an | 3338 // whether the primary consists of anything other than an identifier and/or
is followed by an |
| 3356 // assignableSelector. | 3339 // assignableSelector. |
| 3357 // | 3340 // |
| 3358 Expression expression = parsePrimaryExpression(); | 3341 Expression expression = _parsePrimaryExpression(); |
| 3359 bool isOptional = primaryAllowed || expression is SimpleIdentifier; | 3342 bool isOptional = primaryAllowed || expression is SimpleIdentifier; |
| 3360 while (true) { | 3343 while (true) { |
| 3361 while (matches(TokenType.OPEN_PAREN)) { | 3344 while (_matches(TokenType.OPEN_PAREN)) { |
| 3362 ArgumentList argumentList = parseArgumentList(); | 3345 ArgumentList argumentList = parseArgumentList(); |
| 3363 if (expression is SimpleIdentifier) { | 3346 if (expression is SimpleIdentifier) { |
| 3364 expression = new MethodInvocation(null, null, expression as SimpleIden
tifier, argumentList); | 3347 expression = new MethodInvocation(null, null, expression as SimpleIden
tifier, argumentList); |
| 3365 } else if (expression is PrefixedIdentifier) { | 3348 } else if (expression is PrefixedIdentifier) { |
| 3366 PrefixedIdentifier identifier = expression as PrefixedIdentifier; | 3349 PrefixedIdentifier identifier = expression as PrefixedIdentifier; |
| 3367 expression = new MethodInvocation(identifier.prefix, identifier.period
, identifier.identifier, argumentList); | 3350 expression = new MethodInvocation(identifier.prefix, identifier.period
, identifier.identifier, argumentList); |
| 3368 } else if (expression is PropertyAccess) { | 3351 } else if (expression is PropertyAccess) { |
| 3369 PropertyAccess access = expression as PropertyAccess; | 3352 PropertyAccess access = expression as PropertyAccess; |
| 3370 expression = new MethodInvocation(access.target, access.operator, acce
ss.propertyName, argumentList); | 3353 expression = new MethodInvocation(access.target, access.operator, acce
ss.propertyName, argumentList); |
| 3371 } else { | 3354 } else { |
| 3372 expression = new FunctionExpressionInvocation(expression, argumentList
); | 3355 expression = new FunctionExpressionInvocation(expression, argumentList
); |
| 3373 } | 3356 } |
| 3374 if (!primaryAllowed) { | 3357 if (!primaryAllowed) { |
| 3375 isOptional = false; | 3358 isOptional = false; |
| 3376 } | 3359 } |
| 3377 } | 3360 } |
| 3378 Expression selectorExpression = parseAssignableSelector(expression, isOpti
onal || (expression is PrefixedIdentifier)); | 3361 Expression selectorExpression = _parseAssignableSelector(expression, isOpt
ional || (expression is PrefixedIdentifier)); |
| 3379 if (identical(selectorExpression, expression)) { | 3362 if (identical(selectorExpression, expression)) { |
| 3380 if (!isOptional && (expression is PrefixedIdentifier)) { | 3363 if (!isOptional && (expression is PrefixedIdentifier)) { |
| 3381 PrefixedIdentifier identifier = expression as PrefixedIdentifier; | 3364 PrefixedIdentifier identifier = expression as PrefixedIdentifier; |
| 3382 expression = new PropertyAccess(identifier.prefix, identifier.period,
identifier.identifier); | 3365 expression = new PropertyAccess(identifier.prefix, identifier.period,
identifier.identifier); |
| 3383 } | 3366 } |
| 3384 return expression; | 3367 return expression; |
| 3385 } | 3368 } |
| 3386 expression = selectorExpression; | 3369 expression = selectorExpression; |
| 3387 isOptional = true; | 3370 isOptional = true; |
| 3388 } | 3371 } |
| 3389 } | 3372 } |
| 3390 | 3373 |
| 3391 /** | 3374 /** |
| 3392 * Parse an assignable selector. | 3375 * Parse an assignable selector. |
| 3393 * | 3376 * |
| 3394 * <pre> | 3377 * <pre> |
| 3395 * assignableSelector ::= | 3378 * assignableSelector ::= |
| 3396 * '[' expression ']' | 3379 * '[' expression ']' |
| 3397 * | '.' identifier | 3380 * | '.' identifier |
| 3398 * </pre> | 3381 * </pre> |
| 3399 * | 3382 * |
| 3400 * @param prefix the expression preceding the selector | 3383 * @param prefix the expression preceding the selector |
| 3401 * @param optional `true` if the selector is optional | 3384 * @param optional `true` if the selector is optional |
| 3402 * @return the assignable selector that was parsed | 3385 * @return the assignable selector that was parsed |
| 3403 */ | 3386 */ |
| 3404 Expression parseAssignableSelector(Expression prefix, bool optional) { | 3387 Expression _parseAssignableSelector(Expression prefix, bool optional) { |
| 3405 if (matches(TokenType.OPEN_SQUARE_BRACKET)) { | 3388 if (_matches(TokenType.OPEN_SQUARE_BRACKET)) { |
| 3406 Token leftBracket = andAdvance; | 3389 Token leftBracket = andAdvance; |
| 3407 Expression index = parseExpression2(); | 3390 Expression index = parseExpression2(); |
| 3408 Token rightBracket = expect(TokenType.CLOSE_SQUARE_BRACKET); | 3391 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); |
| 3409 return new IndexExpression.forTarget(prefix, leftBracket, index, rightBrac
ket); | 3392 return new IndexExpression.forTarget(prefix, leftBracket, index, rightBrac
ket); |
| 3410 } else if (matches(TokenType.PERIOD)) { | 3393 } else if (_matches(TokenType.PERIOD)) { |
| 3411 Token period = andAdvance; | 3394 Token period = andAdvance; |
| 3412 return new PropertyAccess(prefix, period, parseSimpleIdentifier()); | 3395 return new PropertyAccess(prefix, period, parseSimpleIdentifier()); |
| 3413 } else { | 3396 } else { |
| 3414 if (!optional) { | 3397 if (!optional) { |
| 3415 // Report the missing selector. | 3398 // Report the missing selector. |
| 3416 reportErrorForCurrentToken(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
[]); | 3399 _reportErrorForCurrentToken(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR,
[]); |
| 3417 } | 3400 } |
| 3418 return prefix; | 3401 return prefix; |
| 3419 } | 3402 } |
| 3420 } | 3403 } |
| 3421 | 3404 |
| 3422 /** | 3405 /** |
| 3423 * Parse a bitwise and expression. | 3406 * Parse a bitwise and expression. |
| 3424 * | 3407 * |
| 3425 * <pre> | 3408 * <pre> |
| 3426 * bitwiseAndExpression ::= | 3409 * bitwiseAndExpression ::= |
| 3427 * shiftExpression ('&' shiftExpression)* | 3410 * shiftExpression ('&' shiftExpression)* |
| 3428 * | 'super' ('&' shiftExpression)+ | 3411 * | 'super' ('&' shiftExpression)+ |
| 3429 * </pre> | 3412 * </pre> |
| 3430 * | 3413 * |
| 3431 * @return the bitwise and expression that was parsed | 3414 * @return the bitwise and expression that was parsed |
| 3432 */ | 3415 */ |
| 3433 Expression parseBitwiseAndExpression() { | 3416 Expression _parseBitwiseAndExpression() { |
| 3434 Expression expression; | 3417 Expression expression; |
| 3435 if (matchesKeyword(Keyword.SUPER) && tokenMatches(peek(), TokenType.AMPERSAN
D)) { | 3418 if (_matchesKeyword(Keyword.SUPER) && _tokenMatches(_peek(), TokenType.AMPER
SAND)) { |
| 3436 expression = new SuperExpression(andAdvance); | 3419 expression = new SuperExpression(andAdvance); |
| 3437 } else { | 3420 } else { |
| 3438 expression = parseShiftExpression(); | 3421 expression = _parseShiftExpression(); |
| 3439 } | 3422 } |
| 3440 while (matches(TokenType.AMPERSAND)) { | 3423 while (_matches(TokenType.AMPERSAND)) { |
| 3441 Token operator = andAdvance; | 3424 Token operator = andAdvance; |
| 3442 expression = new BinaryExpression(expression, operator, parseShiftExpressi
on()); | 3425 expression = new BinaryExpression(expression, operator, _parseShiftExpress
ion()); |
| 3443 } | 3426 } |
| 3444 return expression; | 3427 return expression; |
| 3445 } | 3428 } |
| 3446 | 3429 |
| 3447 /** | 3430 /** |
| 3448 * Parse a bitwise exclusive-or expression. | 3431 * Parse a bitwise exclusive-or expression. |
| 3449 * | 3432 * |
| 3450 * <pre> | 3433 * <pre> |
| 3451 * bitwiseXorExpression ::= | 3434 * bitwiseXorExpression ::= |
| 3452 * bitwiseAndExpression ('^' bitwiseAndExpression)* | 3435 * bitwiseAndExpression ('^' bitwiseAndExpression)* |
| 3453 * | 'super' ('^' bitwiseAndExpression)+ | 3436 * | 'super' ('^' bitwiseAndExpression)+ |
| 3454 * </pre> | 3437 * </pre> |
| 3455 * | 3438 * |
| 3456 * @return the bitwise exclusive-or expression that was parsed | 3439 * @return the bitwise exclusive-or expression that was parsed |
| 3457 */ | 3440 */ |
| 3458 Expression parseBitwiseXorExpression() { | 3441 Expression _parseBitwiseXorExpression() { |
| 3459 Expression expression; | 3442 Expression expression; |
| 3460 if (matchesKeyword(Keyword.SUPER) && tokenMatches(peek(), TokenType.CARET))
{ | 3443 if (_matchesKeyword(Keyword.SUPER) && _tokenMatches(_peek(), TokenType.CARET
)) { |
| 3461 expression = new SuperExpression(andAdvance); | 3444 expression = new SuperExpression(andAdvance); |
| 3462 } else { | 3445 } else { |
| 3463 expression = parseBitwiseAndExpression(); | 3446 expression = _parseBitwiseAndExpression(); |
| 3464 } | 3447 } |
| 3465 while (matches(TokenType.CARET)) { | 3448 while (_matches(TokenType.CARET)) { |
| 3466 Token operator = andAdvance; | 3449 Token operator = andAdvance; |
| 3467 expression = new BinaryExpression(expression, operator, parseBitwiseAndExp
ression()); | 3450 expression = new BinaryExpression(expression, operator, _parseBitwiseAndEx
pression()); |
| 3468 } | 3451 } |
| 3469 return expression; | 3452 return expression; |
| 3470 } | 3453 } |
| 3471 | 3454 |
| 3472 /** | 3455 /** |
| 3473 * Parse a break statement. | 3456 * Parse a break statement. |
| 3474 * | 3457 * |
| 3475 * <pre> | 3458 * <pre> |
| 3476 * breakStatement ::= | 3459 * breakStatement ::= |
| 3477 * 'break' identifier? ';' | 3460 * 'break' identifier? ';' |
| 3478 * </pre> | 3461 * </pre> |
| 3479 * | 3462 * |
| 3480 * @return the break statement that was parsed | 3463 * @return the break statement that was parsed |
| 3481 */ | 3464 */ |
| 3482 Statement parseBreakStatement() { | 3465 Statement _parseBreakStatement() { |
| 3483 Token breakKeyword = expectKeyword(Keyword.BREAK); | 3466 Token breakKeyword = _expectKeyword(Keyword.BREAK); |
| 3484 SimpleIdentifier label = null; | 3467 SimpleIdentifier label = null; |
| 3485 if (matchesIdentifier()) { | 3468 if (_matchesIdentifier()) { |
| 3486 label = parseSimpleIdentifier(); | 3469 label = parseSimpleIdentifier(); |
| 3487 } | 3470 } |
| 3488 if (!_inLoop && !_inSwitch && label == null) { | 3471 if (!_inLoop && !_inSwitch && label == null) { |
| 3489 reportErrorForToken(ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, breakKeyword, [
]); | 3472 _reportErrorForToken(ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, breakKeyword,
[]); |
| 3490 } | 3473 } |
| 3491 Token semicolon = expect(TokenType.SEMICOLON); | 3474 Token semicolon = _expect(TokenType.SEMICOLON); |
| 3492 return new BreakStatement(breakKeyword, label, semicolon); | 3475 return new BreakStatement(breakKeyword, label, semicolon); |
| 3493 } | 3476 } |
| 3494 | 3477 |
| 3495 /** | 3478 /** |
| 3496 * Parse a cascade section. | 3479 * Parse a cascade section. |
| 3497 * | 3480 * |
| 3498 * <pre> | 3481 * <pre> |
| 3499 * cascadeSection ::= | 3482 * cascadeSection ::= |
| 3500 * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* casc
adeAssignment? | 3483 * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* casc
adeAssignment? |
| 3501 * | 3484 * |
| 3502 * cascadeSelector ::= | 3485 * cascadeSelector ::= |
| 3503 * '[' expression ']' | 3486 * '[' expression ']' |
| 3504 * | identifier | 3487 * | identifier |
| 3505 * | 3488 * |
| 3506 * cascadeAssignment ::= | 3489 * cascadeAssignment ::= |
| 3507 * assignmentOperator expressionWithoutCascade | 3490 * assignmentOperator expressionWithoutCascade |
| 3508 * </pre> | 3491 * </pre> |
| 3509 * | 3492 * |
| 3510 * @return the expression representing the cascaded method invocation | 3493 * @return the expression representing the cascaded method invocation |
| 3511 */ | 3494 */ |
| 3512 Expression parseCascadeSection() { | 3495 Expression _parseCascadeSection() { |
| 3513 Token period = expect(TokenType.PERIOD_PERIOD); | 3496 Token period = _expect(TokenType.PERIOD_PERIOD); |
| 3514 Expression expression = null; | 3497 Expression expression = null; |
| 3515 SimpleIdentifier functionName = null; | 3498 SimpleIdentifier functionName = null; |
| 3516 if (matchesIdentifier()) { | 3499 if (_matchesIdentifier()) { |
| 3517 functionName = parseSimpleIdentifier(); | 3500 functionName = parseSimpleIdentifier(); |
| 3518 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) { | 3501 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) { |
| 3519 Token leftBracket = andAdvance; | 3502 Token leftBracket = andAdvance; |
| 3520 Expression index = parseExpression2(); | 3503 Expression index = parseExpression2(); |
| 3521 Token rightBracket = expect(TokenType.CLOSE_SQUARE_BRACKET); | 3504 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); |
| 3522 expression = new IndexExpression.forCascade(period, leftBracket, index, ri
ghtBracket); | 3505 expression = new IndexExpression.forCascade(period, leftBracket, index, ri
ghtBracket); |
| 3523 period = null; | 3506 period = null; |
| 3524 } else { | 3507 } else { |
| 3525 reportErrorForToken(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [_c
urrentToken.lexeme]); | 3508 _reportErrorForToken(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [_
currentToken.lexeme]); |
| 3526 functionName = createSyntheticIdentifier(); | 3509 functionName = _createSyntheticIdentifier(); |
| 3527 } | 3510 } |
| 3528 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 3511 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
| 3529 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 3512 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
| 3530 if (functionName != null) { | 3513 if (functionName != null) { |
| 3531 expression = new MethodInvocation(expression, period, functionName, pa
rseArgumentList()); | 3514 expression = new MethodInvocation(expression, period, functionName, pa
rseArgumentList()); |
| 3532 period = null; | 3515 period = null; |
| 3533 functionName = null; | 3516 functionName = null; |
| 3534 } else if (expression == null) { | 3517 } else if (expression == null) { |
| 3535 // It should not be possible to get here. | 3518 // It should not be possible to get here. |
| 3536 expression = new MethodInvocation(expression, period, createSyntheticI
dentifier(), parseArgumentList()); | 3519 expression = new MethodInvocation(expression, period, _createSynthetic
Identifier(), parseArgumentList()); |
| 3537 } else { | 3520 } else { |
| 3538 expression = new FunctionExpressionInvocation(expression, parseArgumen
tList()); | 3521 expression = new FunctionExpressionInvocation(expression, parseArgumen
tList()); |
| 3539 } | 3522 } |
| 3540 } | 3523 } |
| 3541 } else if (functionName != null) { | 3524 } else if (functionName != null) { |
| 3542 expression = new PropertyAccess(expression, period, functionName); | 3525 expression = new PropertyAccess(expression, period, functionName); |
| 3543 period = null; | 3526 period = null; |
| 3544 } | 3527 } |
| 3545 bool progress = true; | 3528 bool progress = true; |
| 3546 while (progress) { | 3529 while (progress) { |
| 3547 progress = false; | 3530 progress = false; |
| 3548 Expression selector = parseAssignableSelector(expression, true); | 3531 Expression selector = _parseAssignableSelector(expression, true); |
| 3549 if (selector != expression) { | 3532 if (selector != expression) { |
| 3550 expression = selector; | 3533 expression = selector; |
| 3551 progress = true; | 3534 progress = true; |
| 3552 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 3535 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
| 3553 if (expression is PropertyAccess) { | 3536 if (expression is PropertyAccess) { |
| 3554 PropertyAccess propertyAccess = expression as PropertyAccess; | 3537 PropertyAccess propertyAccess = expression as PropertyAccess; |
| 3555 expression = new MethodInvocation(propertyAccess.target, propertyAcc
ess.operator, propertyAccess.propertyName, parseArgumentList()); | 3538 expression = new MethodInvocation(propertyAccess.target, propertyAcc
ess.operator, propertyAccess.propertyName, parseArgumentList()); |
| 3556 } else { | 3539 } else { |
| 3557 expression = new FunctionExpressionInvocation(expression, parseArgum
entList()); | 3540 expression = new FunctionExpressionInvocation(expression, parseArgum
entList()); |
| 3558 } | 3541 } |
| 3559 } | 3542 } |
| 3560 } | 3543 } |
| 3561 } | 3544 } |
| 3562 if (_currentToken.type.isAssignmentOperator) { | 3545 if (_currentToken.type.isAssignmentOperator) { |
| 3563 Token operator = andAdvance; | 3546 Token operator = andAdvance; |
| 3564 ensureAssignable(expression); | 3547 _ensureAssignable(expression); |
| 3565 expression = new AssignmentExpression(expression, operator, parseExpressio
nWithoutCascade()); | 3548 expression = new AssignmentExpression(expression, operator, parseExpressio
nWithoutCascade()); |
| 3566 } | 3549 } |
| 3567 return expression; | 3550 return expression; |
| 3568 } | 3551 } |
| 3569 | 3552 |
| 3570 /** | 3553 /** |
| 3571 * Parse a class declaration. | 3554 * Parse a class declaration. |
| 3572 * | 3555 * |
| 3573 * <pre> | 3556 * <pre> |
| 3574 * classDeclaration ::= | 3557 * classDeclaration ::= |
| 3575 * metadata 'abstract'? 'class' name typeParameterList? (extendsClause wit
hClause?)? implementsClause? '{' classMembers '}' | | 3558 * metadata 'abstract'? 'class' name typeParameterList? (extendsClause wit
hClause?)? implementsClause? '{' classMembers '}' | |
| 3576 * metadata 'abstract'? 'class' mixinApplicationClass | 3559 * metadata 'abstract'? 'class' mixinApplicationClass |
| 3577 * </pre> | 3560 * </pre> |
| 3578 * | 3561 * |
| 3579 * @param commentAndMetadata the metadata to be associated with the member | 3562 * @param commentAndMetadata the metadata to be associated with the member |
| 3580 * @param abstractKeyword the token for the keyword 'abstract', or `null` if t
he keyword was | 3563 * @param abstractKeyword the token for the keyword 'abstract', or `null` if t
he keyword was |
| 3581 * not given | 3564 * not given |
| 3582 * @return the class declaration that was parsed | 3565 * @return the class declaration that was parsed |
| 3583 */ | 3566 */ |
| 3584 CompilationUnitMember parseClassDeclaration(CommentAndMetadata commentAndMetad
ata, Token abstractKeyword) { | 3567 CompilationUnitMember _parseClassDeclaration(CommentAndMetadata commentAndMeta
data, Token abstractKeyword) { |
| 3585 Token keyword = expectKeyword(Keyword.CLASS); | 3568 Token keyword = _expectKeyword(Keyword.CLASS); |
| 3586 if (matchesIdentifier()) { | 3569 if (_matchesIdentifier()) { |
| 3587 Token next = peek(); | 3570 Token next = _peek(); |
| 3588 if (tokenMatches(next, TokenType.LT)) { | 3571 if (_tokenMatches(next, TokenType.LT)) { |
| 3589 next = skipTypeParameterList(next); | 3572 next = _skipTypeParameterList(next); |
| 3590 if (next != null && tokenMatches(next, TokenType.EQ)) { | 3573 if (next != null && _tokenMatches(next, TokenType.EQ)) { |
| 3591 return parseClassTypeAlias(commentAndMetadata, abstractKeyword, keywor
d); | 3574 return _parseClassTypeAlias(commentAndMetadata, abstractKeyword, keywo
rd); |
| 3592 } | 3575 } |
| 3593 } else if (tokenMatches(next, TokenType.EQ)) { | 3576 } else if (_tokenMatches(next, TokenType.EQ)) { |
| 3594 return parseClassTypeAlias(commentAndMetadata, abstractKeyword, keyword)
; | 3577 return _parseClassTypeAlias(commentAndMetadata, abstractKeyword, keyword
); |
| 3595 } | 3578 } |
| 3596 } | 3579 } |
| 3597 SimpleIdentifier name = parseSimpleIdentifier(); | 3580 SimpleIdentifier name = parseSimpleIdentifier(); |
| 3598 String className = name.name; | 3581 String className = name.name; |
| 3599 TypeParameterList typeParameters = null; | 3582 TypeParameterList typeParameters = null; |
| 3600 if (matches(TokenType.LT)) { | 3583 if (_matches(TokenType.LT)) { |
| 3601 typeParameters = parseTypeParameterList(); | 3584 typeParameters = parseTypeParameterList(); |
| 3602 } | 3585 } |
| 3603 // | 3586 // |
| 3604 // Parse the clauses. The parser accepts clauses in any order, but will gene
rate errors if they | 3587 // Parse the clauses. The parser accepts clauses in any order, but will gene
rate errors if they |
| 3605 // are not in the order required by the specification. | 3588 // are not in the order required by the specification. |
| 3606 // | 3589 // |
| 3607 ExtendsClause extendsClause = null; | 3590 ExtendsClause extendsClause = null; |
| 3608 WithClause withClause = null; | 3591 WithClause withClause = null; |
| 3609 ImplementsClause implementsClause = null; | 3592 ImplementsClause implementsClause = null; |
| 3610 bool foundClause = true; | 3593 bool foundClause = true; |
| 3611 while (foundClause) { | 3594 while (foundClause) { |
| 3612 if (matchesKeyword(Keyword.EXTENDS)) { | 3595 if (_matchesKeyword(Keyword.EXTENDS)) { |
| 3613 if (extendsClause == null) { | 3596 if (extendsClause == null) { |
| 3614 extendsClause = parseExtendsClause(); | 3597 extendsClause = parseExtendsClause(); |
| 3615 if (withClause != null) { | 3598 if (withClause != null) { |
| 3616 reportErrorForToken(ParserErrorCode.WITH_BEFORE_EXTENDS, withClause.
withKeyword, []); | 3599 _reportErrorForToken(ParserErrorCode.WITH_BEFORE_EXTENDS, withClause
.withKeyword, []); |
| 3617 } else if (implementsClause != null) { | 3600 } else if (implementsClause != null) { |
| 3618 reportErrorForToken(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, imple
mentsClause.keyword, []); | 3601 _reportErrorForToken(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, impl
ementsClause.keyword, []); |
| 3619 } | 3602 } |
| 3620 } else { | 3603 } else { |
| 3621 reportErrorForToken(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, extendsC
lause.keyword, []); | 3604 _reportErrorForToken(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, extends
Clause.keyword, []); |
| 3622 parseExtendsClause(); | 3605 parseExtendsClause(); |
| 3623 } | 3606 } |
| 3624 } else if (matchesKeyword(Keyword.WITH)) { | 3607 } else if (_matchesKeyword(Keyword.WITH)) { |
| 3625 if (withClause == null) { | 3608 if (withClause == null) { |
| 3626 withClause = parseWithClause(); | 3609 withClause = parseWithClause(); |
| 3627 if (implementsClause != null) { | 3610 if (implementsClause != null) { |
| 3628 reportErrorForToken(ParserErrorCode.IMPLEMENTS_BEFORE_WITH, implemen
tsClause.keyword, []); | 3611 _reportErrorForToken(ParserErrorCode.IMPLEMENTS_BEFORE_WITH, impleme
ntsClause.keyword, []); |
| 3629 } | 3612 } |
| 3630 } else { | 3613 } else { |
| 3631 reportErrorForToken(ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause.
withKeyword, []); | 3614 _reportErrorForToken(ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause
.withKeyword, []); |
| 3632 parseWithClause(); | 3615 parseWithClause(); |
| 3633 } | 3616 } |
| 3634 } else if (matchesKeyword(Keyword.IMPLEMENTS)) { | 3617 } else if (_matchesKeyword(Keyword.IMPLEMENTS)) { |
| 3635 if (implementsClause == null) { | 3618 if (implementsClause == null) { |
| 3636 implementsClause = parseImplementsClause(); | 3619 implementsClause = parseImplementsClause(); |
| 3637 } else { | 3620 } else { |
| 3638 reportErrorForToken(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, imple
mentsClause.keyword, []); | 3621 _reportErrorForToken(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, impl
ementsClause.keyword, []); |
| 3639 parseImplementsClause(); | 3622 parseImplementsClause(); |
| 3640 } | 3623 } |
| 3641 } else { | 3624 } else { |
| 3642 foundClause = false; | 3625 foundClause = false; |
| 3643 } | 3626 } |
| 3644 } | 3627 } |
| 3645 if (withClause != null && extendsClause == null) { | 3628 if (withClause != null && extendsClause == null) { |
| 3646 reportErrorForToken(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withK
eyword, []); | 3629 _reportErrorForToken(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.with
Keyword, []); |
| 3647 } | 3630 } |
| 3648 // | 3631 // |
| 3649 // Look for and skip over the extra-lingual 'native' specification. | 3632 // Look for and skip over the extra-lingual 'native' specification. |
| 3650 // | 3633 // |
| 3651 NativeClause nativeClause = null; | 3634 NativeClause nativeClause = null; |
| 3652 if (matchesString(_NATIVE) && tokenMatches(peek(), TokenType.STRING)) { | 3635 if (_matchesString(_NATIVE) && _tokenMatches(_peek(), TokenType.STRING)) { |
| 3653 nativeClause = parseNativeClause(); | 3636 nativeClause = _parseNativeClause(); |
| 3654 } | 3637 } |
| 3655 // | 3638 // |
| 3656 // Parse the body of the class. | 3639 // Parse the body of the class. |
| 3657 // | 3640 // |
| 3658 Token leftBracket = null; | 3641 Token leftBracket = null; |
| 3659 List<ClassMember> members = null; | 3642 List<ClassMember> members = null; |
| 3660 Token rightBracket = null; | 3643 Token rightBracket = null; |
| 3661 if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 3644 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 3662 leftBracket = expect(TokenType.OPEN_CURLY_BRACKET); | 3645 leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); |
| 3663 members = parseClassMembers(className, getEndToken(leftBracket)); | 3646 members = _parseClassMembers(className, _getEndToken(leftBracket)); |
| 3664 rightBracket = expect(TokenType.CLOSE_CURLY_BRACKET); | 3647 rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
| 3665 } else { | 3648 } else { |
| 3666 leftBracket = createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); | 3649 leftBracket = _createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); |
| 3667 rightBracket = createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); | 3650 rightBracket = _createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); |
| 3668 reportErrorForCurrentToken(ParserErrorCode.MISSING_CLASS_BODY, []); | 3651 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CLASS_BODY, []); |
| 3669 } | 3652 } |
| 3670 ClassDeclaration classDeclaration = new ClassDeclaration(commentAndMetadata.
comment, commentAndMetadata.metadata, abstractKeyword, keyword, name, typeParame
ters, extendsClause, withClause, implementsClause, leftBracket, members, rightBr
acket); | 3653 ClassDeclaration classDeclaration = new ClassDeclaration(commentAndMetadata.
comment, commentAndMetadata.metadata, abstractKeyword, keyword, name, typeParame
ters, extendsClause, withClause, implementsClause, leftBracket, members, rightBr
acket); |
| 3671 classDeclaration.nativeClause = nativeClause; | 3654 classDeclaration.nativeClause = nativeClause; |
| 3672 return classDeclaration; | 3655 return classDeclaration; |
| 3673 } | 3656 } |
| 3674 | 3657 |
| 3675 /** | 3658 /** |
| 3676 * Parse a list of class members. | 3659 * Parse a list of class members. |
| 3677 * | 3660 * |
| 3678 * <pre> | 3661 * <pre> |
| 3679 * classMembers ::= | 3662 * classMembers ::= |
| 3680 * (metadata memberDefinition)* | 3663 * (metadata memberDefinition)* |
| 3681 * </pre> | 3664 * </pre> |
| 3682 * | 3665 * |
| 3683 * @param className the name of the class whose members are being parsed | 3666 * @param className the name of the class whose members are being parsed |
| 3684 * @param closingBracket the closing bracket for the class, or `null` if the c
losing bracket | 3667 * @param closingBracket the closing bracket for the class, or `null` if the c
losing bracket |
| 3685 * is missing | 3668 * is missing |
| 3686 * @return the list of class members that were parsed | 3669 * @return the list of class members that were parsed |
| 3687 */ | 3670 */ |
| 3688 List<ClassMember> parseClassMembers(String className, Token closingBracket) { | 3671 List<ClassMember> _parseClassMembers(String className, Token closingBracket) { |
| 3689 List<ClassMember> members = new List<ClassMember>(); | 3672 List<ClassMember> members = new List<ClassMember>(); |
| 3690 Token memberStart = _currentToken; | 3673 Token memberStart = _currentToken; |
| 3691 while (!matches(TokenType.EOF) && !matches(TokenType.CLOSE_CURLY_BRACKET) &&
(closingBracket != null || (!matchesKeyword(Keyword.CLASS) && !matchesKeyword(K
eyword.TYPEDEF)))) { | 3674 while (!_matches(TokenType.EOF) && !_matches(TokenType.CLOSE_CURLY_BRACKET)
&& (closingBracket != null || (!_matchesKeyword(Keyword.CLASS) && !_matchesKeywo
rd(Keyword.TYPEDEF)))) { |
| 3692 if (matches(TokenType.SEMICOLON)) { | 3675 if (_matches(TokenType.SEMICOLON)) { |
| 3693 reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_c
urrentToken.lexeme]); | 3676 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_
currentToken.lexeme]); |
| 3694 advance(); | 3677 _advance(); |
| 3695 } else { | 3678 } else { |
| 3696 ClassMember member = parseClassMember(className); | 3679 ClassMember member = parseClassMember(className); |
| 3697 if (member != null) { | 3680 if (member != null) { |
| 3698 members.add(member); | 3681 members.add(member); |
| 3699 } | 3682 } |
| 3700 } | 3683 } |
| 3701 if (identical(_currentToken, memberStart)) { | 3684 if (identical(_currentToken, memberStart)) { |
| 3702 reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_c
urrentToken.lexeme]); | 3685 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_
currentToken.lexeme]); |
| 3703 advance(); | 3686 _advance(); |
| 3704 } | 3687 } |
| 3705 memberStart = _currentToken; | 3688 memberStart = _currentToken; |
| 3706 } | 3689 } |
| 3707 return members; | 3690 return members; |
| 3708 } | 3691 } |
| 3709 | 3692 |
| 3710 /** | 3693 /** |
| 3711 * Parse a class type alias. | 3694 * Parse a class type alias. |
| 3712 * | 3695 * |
| 3713 * <pre> | 3696 * <pre> |
| 3714 * classTypeAlias ::= | 3697 * classTypeAlias ::= |
| 3715 * identifier typeParameters? '=' 'abstract'? mixinApplication | 3698 * identifier typeParameters? '=' 'abstract'? mixinApplication |
| 3716 * | 3699 * |
| 3717 * mixinApplication ::= | 3700 * mixinApplication ::= |
| 3718 * type withClause implementsClause? ';' | 3701 * type withClause implementsClause? ';' |
| 3719 * </pre> | 3702 * </pre> |
| 3720 * | 3703 * |
| 3721 * @param commentAndMetadata the metadata to be associated with the member | 3704 * @param commentAndMetadata the metadata to be associated with the member |
| 3722 * @param abstractKeyword the token representing the 'abstract' keyword | 3705 * @param abstractKeyword the token representing the 'abstract' keyword |
| 3723 * @param classKeyword the token representing the 'class' keyword | 3706 * @param classKeyword the token representing the 'class' keyword |
| 3724 * @return the class type alias that was parsed | 3707 * @return the class type alias that was parsed |
| 3725 */ | 3708 */ |
| 3726 ClassTypeAlias parseClassTypeAlias(CommentAndMetadata commentAndMetadata, Toke
n abstractKeyword, Token classKeyword) { | 3709 ClassTypeAlias _parseClassTypeAlias(CommentAndMetadata commentAndMetadata, Tok
en abstractKeyword, Token classKeyword) { |
| 3727 SimpleIdentifier className = parseSimpleIdentifier(); | 3710 SimpleIdentifier className = parseSimpleIdentifier(); |
| 3728 TypeParameterList typeParameters = null; | 3711 TypeParameterList typeParameters = null; |
| 3729 if (matches(TokenType.LT)) { | 3712 if (_matches(TokenType.LT)) { |
| 3730 typeParameters = parseTypeParameterList(); | 3713 typeParameters = parseTypeParameterList(); |
| 3731 } | 3714 } |
| 3732 Token equals = expect(TokenType.EQ); | 3715 Token equals = _expect(TokenType.EQ); |
| 3733 if (matchesKeyword(Keyword.ABSTRACT)) { | 3716 if (_matchesKeyword(Keyword.ABSTRACT)) { |
| 3734 abstractKeyword = andAdvance; | 3717 abstractKeyword = andAdvance; |
| 3735 } | 3718 } |
| 3736 TypeName superclass = parseTypeName(); | 3719 TypeName superclass = parseTypeName(); |
| 3737 WithClause withClause = null; | 3720 WithClause withClause = null; |
| 3738 if (matchesKeyword(Keyword.WITH)) { | 3721 if (_matchesKeyword(Keyword.WITH)) { |
| 3739 withClause = parseWithClause(); | 3722 withClause = parseWithClause(); |
| 3740 } | 3723 } |
| 3741 ImplementsClause implementsClause = null; | 3724 ImplementsClause implementsClause = null; |
| 3742 if (matchesKeyword(Keyword.IMPLEMENTS)) { | 3725 if (_matchesKeyword(Keyword.IMPLEMENTS)) { |
| 3743 implementsClause = parseImplementsClause(); | 3726 implementsClause = parseImplementsClause(); |
| 3744 } | 3727 } |
| 3745 Token semicolon; | 3728 Token semicolon; |
| 3746 if (matches(TokenType.SEMICOLON)) { | 3729 if (_matches(TokenType.SEMICOLON)) { |
| 3747 semicolon = andAdvance; | 3730 semicolon = andAdvance; |
| 3748 } else { | 3731 } else { |
| 3749 if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 3732 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 3750 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [TokenType.SE
MICOLON.lexeme]); | 3733 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_TOKEN, [TokenType.S
EMICOLON.lexeme]); |
| 3751 Token leftBracket = andAdvance; | 3734 Token leftBracket = andAdvance; |
| 3752 parseClassMembers(className.name, getEndToken(leftBracket)); | 3735 _parseClassMembers(className.name, _getEndToken(leftBracket)); |
| 3753 expect(TokenType.CLOSE_CURLY_BRACKET); | 3736 _expect(TokenType.CLOSE_CURLY_BRACKET); |
| 3754 } else { | 3737 } else { |
| 3755 reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previo
us, [TokenType.SEMICOLON.lexeme]); | 3738 _reportErrorForToken(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previ
ous, [TokenType.SEMICOLON.lexeme]); |
| 3756 } | 3739 } |
| 3757 semicolon = createSyntheticToken(TokenType.SEMICOLON); | 3740 semicolon = _createSyntheticToken(TokenType.SEMICOLON); |
| 3758 } | 3741 } |
| 3759 return new ClassTypeAlias(commentAndMetadata.comment, commentAndMetadata.met
adata, classKeyword, className, typeParameters, equals, abstractKeyword, supercl
ass, withClause, implementsClause, semicolon); | 3742 return new ClassTypeAlias(commentAndMetadata.comment, commentAndMetadata.met
adata, classKeyword, className, typeParameters, equals, abstractKeyword, supercl
ass, withClause, implementsClause, semicolon); |
| 3760 } | 3743 } |
| 3761 | 3744 |
| 3762 /** | 3745 /** |
| 3763 * Parse a list of combinators in a directive. | 3746 * Parse a list of combinators in a directive. |
| 3764 * | 3747 * |
| 3765 * <pre> | 3748 * <pre> |
| 3766 * combinator ::= | 3749 * combinator ::= |
| 3767 * 'show' identifier (',' identifier)* | 3750 * 'show' identifier (',' identifier)* |
| 3768 * | 'hide' identifier (',' identifier)* | 3751 * | 'hide' identifier (',' identifier)* |
| 3769 * </pre> | 3752 * </pre> |
| 3770 * | 3753 * |
| 3771 * @return the combinators that were parsed | 3754 * @return the combinators that were parsed |
| 3772 */ | 3755 */ |
| 3773 List<Combinator> parseCombinators() { | 3756 List<Combinator> _parseCombinators() { |
| 3774 List<Combinator> combinators = new List<Combinator>(); | 3757 List<Combinator> combinators = new List<Combinator>(); |
| 3775 while (matchesString(_SHOW) || matchesString(_HIDE)) { | 3758 while (_matchesString(_SHOW) || _matchesString(_HIDE)) { |
| 3776 Token keyword = expect(TokenType.IDENTIFIER); | 3759 Token keyword = _expect(TokenType.IDENTIFIER); |
| 3777 if (keyword.lexeme == _SHOW) { | 3760 if (keyword.lexeme == _SHOW) { |
| 3778 List<SimpleIdentifier> shownNames = parseIdentifierList(); | 3761 List<SimpleIdentifier> shownNames = _parseIdentifierList(); |
| 3779 combinators.add(new ShowCombinator(keyword, shownNames)); | 3762 combinators.add(new ShowCombinator(keyword, shownNames)); |
| 3780 } else { | 3763 } else { |
| 3781 List<SimpleIdentifier> hiddenNames = parseIdentifierList(); | 3764 List<SimpleIdentifier> hiddenNames = _parseIdentifierList(); |
| 3782 combinators.add(new HideCombinator(keyword, hiddenNames)); | 3765 combinators.add(new HideCombinator(keyword, hiddenNames)); |
| 3783 } | 3766 } |
| 3784 } | 3767 } |
| 3785 return combinators; | 3768 return combinators; |
| 3786 } | 3769 } |
| 3787 | 3770 |
| 3788 /** | 3771 /** |
| 3789 * Parse the documentation comment and metadata preceding a declaration. This
method allows any | 3772 * Parse the documentation comment and metadata preceding a declaration. This
method allows any |
| 3790 * number of documentation comments to occur before, after or between the meta
data, but only | 3773 * number of documentation comments to occur before, after or between the meta
data, but only |
| 3791 * returns the last (right-most) documentation comment that is found. | 3774 * returns the last (right-most) documentation comment that is found. |
| 3792 * | 3775 * |
| 3793 * <pre> | 3776 * <pre> |
| 3794 * metadata ::= | 3777 * metadata ::= |
| 3795 * annotation* | 3778 * annotation* |
| 3796 * </pre> | 3779 * </pre> |
| 3797 * | 3780 * |
| 3798 * @return the documentation comment and metadata that were parsed | 3781 * @return the documentation comment and metadata that were parsed |
| 3799 */ | 3782 */ |
| 3800 CommentAndMetadata parseCommentAndMetadata() { | 3783 CommentAndMetadata _parseCommentAndMetadata() { |
| 3801 Comment comment = parseDocumentationComment(); | 3784 Comment comment = _parseDocumentationComment(); |
| 3802 List<Annotation> metadata = new List<Annotation>(); | 3785 List<Annotation> metadata = new List<Annotation>(); |
| 3803 while (matches(TokenType.AT)) { | 3786 while (_matches(TokenType.AT)) { |
| 3804 metadata.add(parseAnnotation()); | 3787 metadata.add(parseAnnotation()); |
| 3805 Comment optionalComment = parseDocumentationComment(); | 3788 Comment optionalComment = _parseDocumentationComment(); |
| 3806 if (optionalComment != null) { | 3789 if (optionalComment != null) { |
| 3807 comment = optionalComment; | 3790 comment = optionalComment; |
| 3808 } | 3791 } |
| 3809 } | 3792 } |
| 3810 return new CommentAndMetadata(comment, metadata); | 3793 return new CommentAndMetadata(comment, metadata); |
| 3811 } | 3794 } |
| 3812 | 3795 |
| 3813 /** | 3796 /** |
| 3814 * Parse a comment reference from the source between square brackets. | 3797 * Parse a comment reference from the source between square brackets. |
| 3815 * | 3798 * |
| 3816 * <pre> | 3799 * <pre> |
| 3817 * commentReference ::= | 3800 * commentReference ::= |
| 3818 * 'new'? prefixedIdentifier | 3801 * 'new'? prefixedIdentifier |
| 3819 * </pre> | 3802 * </pre> |
| 3820 * | 3803 * |
| 3821 * @param referenceSource the source occurring between the square brackets wit
hin a documentation | 3804 * @param referenceSource the source occurring between the square brackets wit
hin a documentation |
| 3822 * comment | 3805 * comment |
| 3823 * @param sourceOffset the offset of the first character of the reference sour
ce | 3806 * @param sourceOffset the offset of the first character of the reference sour
ce |
| 3824 * @return the comment reference that was parsed, or `null` if no reference co
uld be found | 3807 * @return the comment reference that was parsed, or `null` if no reference co
uld be found |
| 3825 */ | 3808 */ |
| 3826 CommentReference parseCommentReference(String referenceSource, int sourceOffse
t) { | 3809 CommentReference _parseCommentReference(String referenceSource, int sourceOffs
et) { |
| 3827 // TODO(brianwilkerson) The errors are not getting the right offset/length a
nd are being duplicated. | 3810 // TODO(brianwilkerson) The errors are not getting the right offset/length a
nd are being duplicated. |
| 3828 if (referenceSource.length == 0) { | 3811 if (referenceSource.length == 0) { |
| 3829 Token syntheticToken = new SyntheticStringToken(TokenType.IDENTIFIER, "",
sourceOffset); | 3812 Token syntheticToken = new SyntheticStringToken(TokenType.IDENTIFIER, "",
sourceOffset); |
| 3830 return new CommentReference(null, new SimpleIdentifier(syntheticToken)); | 3813 return new CommentReference(null, new SimpleIdentifier(syntheticToken)); |
| 3831 } | 3814 } |
| 3832 try { | 3815 try { |
| 3833 BooleanErrorListener listener = new BooleanErrorListener(); | 3816 BooleanErrorListener listener = new BooleanErrorListener(); |
| 3834 Scanner scanner = new Scanner(null, new SubSequenceReader(referenceSource,
sourceOffset), listener); | 3817 Scanner scanner = new Scanner(null, new SubSequenceReader(referenceSource,
sourceOffset), listener); |
| 3835 scanner.setSourceStart(1, 1); | 3818 scanner.setSourceStart(1, 1); |
| 3836 Token firstToken = scanner.tokenize(); | 3819 Token firstToken = scanner.tokenize(); |
| 3837 if (listener.errorReported) { | 3820 if (listener.errorReported) { |
| 3838 return null; | 3821 return null; |
| 3839 } | 3822 } |
| 3840 Token newKeyword = null; | 3823 Token newKeyword = null; |
| 3841 if (tokenMatchesKeyword(firstToken, Keyword.NEW)) { | 3824 if (_tokenMatchesKeyword(firstToken, Keyword.NEW)) { |
| 3842 newKeyword = firstToken; | 3825 newKeyword = firstToken; |
| 3843 firstToken = firstToken.next; | 3826 firstToken = firstToken.next; |
| 3844 } | 3827 } |
| 3845 if (tokenMatchesIdentifier(firstToken)) { | 3828 if (_tokenMatchesIdentifier(firstToken)) { |
| 3846 Token secondToken = firstToken.next; | 3829 Token secondToken = firstToken.next; |
| 3847 Token thirdToken = secondToken.next; | 3830 Token thirdToken = secondToken.next; |
| 3848 Token nextToken; | 3831 Token nextToken; |
| 3849 Identifier identifier; | 3832 Identifier identifier; |
| 3850 if (tokenMatches(secondToken, TokenType.PERIOD) && tokenMatchesIdentifie
r(thirdToken)) { | 3833 if (_tokenMatches(secondToken, TokenType.PERIOD) && _tokenMatchesIdentif
ier(thirdToken)) { |
| 3851 identifier = new PrefixedIdentifier(new SimpleIdentifier(firstToken),
secondToken, new SimpleIdentifier(thirdToken)); | 3834 identifier = new PrefixedIdentifier(new SimpleIdentifier(firstToken),
secondToken, new SimpleIdentifier(thirdToken)); |
| 3852 nextToken = thirdToken.next; | 3835 nextToken = thirdToken.next; |
| 3853 } else { | 3836 } else { |
| 3854 identifier = new SimpleIdentifier(firstToken); | 3837 identifier = new SimpleIdentifier(firstToken); |
| 3855 nextToken = firstToken.next; | 3838 nextToken = firstToken.next; |
| 3856 } | 3839 } |
| 3857 if (nextToken.type != TokenType.EOF) { | 3840 if (nextToken.type != TokenType.EOF) { |
| 3858 return null; | 3841 return null; |
| 3859 } | 3842 } |
| 3860 return new CommentReference(newKeyword, identifier); | 3843 return new CommentReference(newKeyword, identifier); |
| 3861 } else if (tokenMatchesKeyword(firstToken, Keyword.THIS) || tokenMatchesKe
yword(firstToken, Keyword.NULL) || tokenMatchesKeyword(firstToken, Keyword.TRUE)
|| tokenMatchesKeyword(firstToken, Keyword.FALSE)) { | 3844 } else if (_tokenMatchesKeyword(firstToken, Keyword.THIS) || _tokenMatches
Keyword(firstToken, Keyword.NULL) || _tokenMatchesKeyword(firstToken, Keyword.TR
UE) || _tokenMatchesKeyword(firstToken, Keyword.FALSE)) { |
| 3862 // TODO(brianwilkerson) If we want to support this we will need to exten
d the definition | 3845 // TODO(brianwilkerson) If we want to support this we will need to exten
d the definition |
| 3863 // of CommentReference to take an expression rather than an identifier.
For now we just | 3846 // of CommentReference to take an expression rather than an identifier.
For now we just |
| 3864 // ignore it to reduce the number of errors produced, but that's probabl
y not a valid | 3847 // ignore it to reduce the number of errors produced, but that's probabl
y not a valid |
| 3865 // long term approach. | 3848 // long term approach. |
| 3866 return null; | 3849 return null; |
| 3867 } | 3850 } |
| 3868 } on JavaException catch (exception) { | 3851 } on JavaException catch (exception) { |
| 3869 } | 3852 } |
| 3870 return null; | 3853 return null; |
| 3871 } | 3854 } |
| 3872 | 3855 |
| 3873 /** | 3856 /** |
| 3874 * Parse all of the comment references occurring in the given array of documen
tation comments. | 3857 * Parse all of the comment references occurring in the given array of documen
tation comments. |
| 3875 * | 3858 * |
| 3876 * <pre> | 3859 * <pre> |
| 3877 * commentReference ::= | 3860 * commentReference ::= |
| 3878 * '[' 'new'? qualified ']' libraryReference? | 3861 * '[' 'new'? qualified ']' libraryReference? |
| 3879 * | 3862 * |
| 3880 * libraryReference ::= | 3863 * libraryReference ::= |
| 3881 * '(' stringLiteral ')' | 3864 * '(' stringLiteral ')' |
| 3882 * </pre> | 3865 * </pre> |
| 3883 * | 3866 * |
| 3884 * @param tokens the comment tokens representing the documentation comments to
be parsed | 3867 * @param tokens the comment tokens representing the documentation comments to
be parsed |
| 3885 * @return the comment references that were parsed | 3868 * @return the comment references that were parsed |
| 3886 */ | 3869 */ |
| 3887 List<CommentReference> parseCommentReferences(List<Token> tokens) { | 3870 List<CommentReference> _parseCommentReferences(List<Token> tokens) { |
| 3888 List<CommentReference> references = new List<CommentReference>(); | 3871 List<CommentReference> references = new List<CommentReference>(); |
| 3889 for (Token token in tokens) { | 3872 for (Token token in tokens) { |
| 3890 String comment = token.lexeme; | 3873 String comment = token.lexeme; |
| 3891 int length = comment.length; | 3874 int length = comment.length; |
| 3892 List<List<int>> codeBlockRanges = getCodeBlockRanges(comment); | 3875 List<List<int>> codeBlockRanges = _getCodeBlockRanges(comment); |
| 3893 int leftIndex = comment.indexOf('['); | 3876 int leftIndex = comment.indexOf('['); |
| 3894 while (leftIndex >= 0 && leftIndex + 1 < length) { | 3877 while (leftIndex >= 0 && leftIndex + 1 < length) { |
| 3895 List<int> range = findRange(codeBlockRanges, leftIndex); | 3878 List<int> range = _findRange(codeBlockRanges, leftIndex); |
| 3896 if (range == null) { | 3879 if (range == null) { |
| 3897 int nameOffset = token.offset + leftIndex + 1; | 3880 int nameOffset = token.offset + leftIndex + 1; |
| 3898 int rightIndex = JavaString.indexOf(comment, ']', leftIndex); | 3881 int rightIndex = JavaString.indexOf(comment, ']', leftIndex); |
| 3899 if (rightIndex >= 0) { | 3882 if (rightIndex >= 0) { |
| 3900 int firstChar = comment.codeUnitAt(leftIndex + 1); | 3883 int firstChar = comment.codeUnitAt(leftIndex + 1); |
| 3901 if (firstChar != 0x27 && firstChar != 0x22) { | 3884 if (firstChar != 0x27 && firstChar != 0x22) { |
| 3902 if (isLinkText(comment, rightIndex)) { | 3885 if (_isLinkText(comment, rightIndex)) { |
| 3903 } else { | 3886 } else { |
| 3904 CommentReference reference = parseCommentReference(comment.subst
ring(leftIndex + 1, rightIndex), nameOffset); | 3887 CommentReference reference = _parseCommentReference(comment.subs
tring(leftIndex + 1, rightIndex), nameOffset); |
| 3905 if (reference != null) { | 3888 if (reference != null) { |
| 3906 references.add(reference); | 3889 references.add(reference); |
| 3907 } | 3890 } |
| 3908 } | 3891 } |
| 3909 } | 3892 } |
| 3910 } else { | 3893 } else { |
| 3911 // terminating ']' is not typed yet | 3894 // terminating ']' is not typed yet |
| 3912 int charAfterLeft = comment.codeUnitAt(leftIndex + 1); | 3895 int charAfterLeft = comment.codeUnitAt(leftIndex + 1); |
| 3913 if (Character.isLetterOrDigit(charAfterLeft)) { | 3896 if (Character.isLetterOrDigit(charAfterLeft)) { |
| 3914 int nameEnd = StringUtilities.indexOfFirstNotLetterDigit(comment,
leftIndex + 1); | 3897 int nameEnd = StringUtilities.indexOfFirstNotLetterDigit(comment,
leftIndex + 1); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3944 * | functionSignature functionBody | 3927 * | functionSignature functionBody |
| 3945 * | returnType? getOrSet identifier formalParameterList functionBody | 3928 * | returnType? getOrSet identifier formalParameterList functionBody |
| 3946 * | (final | const) type? staticFinalDeclarationList ';' | 3929 * | (final | const) type? staticFinalDeclarationList ';' |
| 3947 * | variableDeclaration ';' | 3930 * | variableDeclaration ';' |
| 3948 * </pre> | 3931 * </pre> |
| 3949 * | 3932 * |
| 3950 * @param commentAndMetadata the metadata to be associated with the member | 3933 * @param commentAndMetadata the metadata to be associated with the member |
| 3951 * @return the compilation unit member that was parsed, or `null` if what was
parsed could | 3934 * @return the compilation unit member that was parsed, or `null` if what was
parsed could |
| 3952 * not be represented as a compilation unit member | 3935 * not be represented as a compilation unit member |
| 3953 */ | 3936 */ |
| 3954 CompilationUnitMember parseCompilationUnitMember(CommentAndMetadata commentAnd
Metadata) { | 3937 CompilationUnitMember _parseCompilationUnitMember(CommentAndMetadata commentAn
dMetadata) { |
| 3955 Modifiers modifiers = parseModifiers(); | 3938 Modifiers modifiers = _parseModifiers(); |
| 3956 if (matchesKeyword(Keyword.CLASS)) { | 3939 if (_matchesKeyword(Keyword.CLASS)) { |
| 3957 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); | 3940 return _parseClassDeclaration(commentAndMetadata, _validateModifiersForCla
ss(modifiers)); |
| 3958 } else if (matchesKeyword(Keyword.TYPEDEF) && !tokenMatches(peek(), TokenTyp
e.PERIOD) && !tokenMatches(peek(), TokenType.LT) && !tokenMatches(peek(), TokenT
ype.OPEN_PAREN)) { | 3941 } else if (_matchesKeyword(Keyword.TYPEDEF) && !_tokenMatches(_peek(), Token
Type.PERIOD) && !_tokenMatches(_peek(), TokenType.LT) && !_tokenMatches(_peek(),
TokenType.OPEN_PAREN)) { |
| 3959 validateModifiersForTypedef(modifiers); | 3942 _validateModifiersForTypedef(modifiers); |
| 3960 return parseTypeAlias(commentAndMetadata); | 3943 return _parseTypeAlias(commentAndMetadata); |
| 3961 } | 3944 } |
| 3962 if (matchesKeyword(Keyword.VOID)) { | 3945 if (_matchesKeyword(Keyword.VOID)) { |
| 3963 TypeName returnType = parseReturnType(); | 3946 TypeName returnType = parseReturnType(); |
| 3964 if ((matchesKeyword(Keyword.GET) || matchesKeyword(Keyword.SET)) && tokenM
atchesIdentifier(peek())) { | 3947 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && _tok
enMatchesIdentifier(_peek())) { |
| 3965 validateModifiersForTopLevelFunction(modifiers); | 3948 _validateModifiersForTopLevelFunction(modifiers); |
| 3966 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, returnType); | 3949 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalK
eyword, returnType); |
| 3967 } else if (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) { | 3950 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
| 3968 reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, [
]); | 3951 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken,
[]); |
| 3969 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, mo
difiers.externalKeyword, returnType)); | 3952 return _convertToFunctionDeclaration(_parseOperator(commentAndMetadata,
modifiers.externalKeyword, returnType)); |
| 3970 } else if (matchesIdentifier() && matchesAny(peek(), [ | 3953 } else if (_matchesIdentifier() && _peek().matchesAny([ |
| 3971 TokenType.OPEN_PAREN, | 3954 TokenType.OPEN_PAREN, |
| 3972 TokenType.OPEN_CURLY_BRACKET, | 3955 TokenType.OPEN_CURLY_BRACKET, |
| 3973 TokenType.FUNCTION])) { | 3956 TokenType.FUNCTION])) { |
| 3974 validateModifiersForTopLevelFunction(modifiers); | 3957 _validateModifiersForTopLevelFunction(modifiers); |
| 3975 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, returnType); | 3958 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalK
eyword, returnType); |
| 3976 } else { | 3959 } else { |
| 3977 // | 3960 // |
| 3978 // We have found an error of some kind. Try to recover. | 3961 // We have found an error of some kind. Try to recover. |
| 3979 // | 3962 // |
| 3980 if (matchesIdentifier()) { | 3963 if (_matchesIdentifier()) { |
| 3981 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { | 3964 if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { |
| 3982 // | 3965 // |
| 3983 // We appear to have a variable declaration with a type of "void". | 3966 // We appear to have a variable declaration with a type of "void". |
| 3984 // | 3967 // |
| 3985 reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType, []); | 3968 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType, []); |
| 3986 return new TopLevelVariableDeclaration(commentAndMetadata.comment, c
ommentAndMetadata.metadata, parseVariableDeclarationListAfterType(null, validate
ModifiersForTopLevelVariable(modifiers), null), expect(TokenType.SEMICOLON)); | 3969 return new TopLevelVariableDeclaration(commentAndMetadata.comment, c
ommentAndMetadata.metadata, _parseVariableDeclarationListAfterType(null, _valida
teModifiersForTopLevelVariable(modifiers), null), _expect(TokenType.SEMICOLON)); |
| 3987 } | 3970 } |
| 3988 } | 3971 } |
| 3989 reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken,
[]); | 3972 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken,
[]); |
| 3990 return null; | 3973 return null; |
| 3991 } | 3974 } |
| 3992 } else if ((matchesKeyword(Keyword.GET) || matchesKeyword(Keyword.SET)) && t
okenMatchesIdentifier(peek())) { | 3975 } else if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) &&
_tokenMatchesIdentifier(_peek())) { |
| 3993 validateModifiersForTopLevelFunction(modifiers); | 3976 _validateModifiersForTopLevelFunction(modifiers); |
| 3994 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null); | 3977 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey
word, null); |
| 3995 } else if (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) { | 3978 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
| 3996 reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, [])
; | 3979 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []
); |
| 3997 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, modi
fiers.externalKeyword, null)); | 3980 return _convertToFunctionDeclaration(_parseOperator(commentAndMetadata, mo
difiers.externalKeyword, null)); |
| 3998 } else if (!matchesIdentifier()) { | 3981 } else if (!_matchesIdentifier()) { |
| 3999 reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []
); | 3982 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, [
]); |
| 4000 return null; | 3983 return null; |
| 4001 } else if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 3984 } else if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 4002 validateModifiersForTopLevelFunction(modifiers); | 3985 _validateModifiersForTopLevelFunction(modifiers); |
| 4003 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null); | 3986 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey
word, null); |
| 4004 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { | 3987 } else if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { |
| 4005 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo
difiers.varKeyword == null) { | 3988 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo
difiers.varKeyword == null) { |
| 4006 reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TY
PE, []); | 3989 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_T
YPE, []); |
| 4007 } | 3990 } |
| 4008 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment
AndMetadata.metadata, parseVariableDeclarationListAfterType(null, validateModifi
ersForTopLevelVariable(modifiers), null), expect(TokenType.SEMICOLON)); | 3991 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment
AndMetadata.metadata, _parseVariableDeclarationListAfterType(null, _validateModi
fiersForTopLevelVariable(modifiers), null), _expect(TokenType.SEMICOLON)); |
| 4009 } | 3992 } |
| 4010 TypeName returnType = parseReturnType(); | 3993 TypeName returnType = parseReturnType(); |
| 4011 if ((matchesKeyword(Keyword.GET) || matchesKeyword(Keyword.SET)) && tokenMat
chesIdentifier(peek())) { | 3994 if ((_matchesKeyword(Keyword.GET) || _matchesKeyword(Keyword.SET)) && _token
MatchesIdentifier(_peek())) { |
| 4012 validateModifiersForTopLevelFunction(modifiers); | 3995 _validateModifiersForTopLevelFunction(modifiers); |
| 4013 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType); | 3996 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey
word, returnType); |
| 4014 } else if (matchesKeyword(Keyword.OPERATOR) && isOperator(peek())) { | 3997 } else if (_matchesKeyword(Keyword.OPERATOR) && _isOperator(_peek())) { |
| 4015 reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, [])
; | 3998 _reportErrorForToken(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []
); |
| 4016 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, modi
fiers.externalKeyword, returnType)); | 3999 return _convertToFunctionDeclaration(_parseOperator(commentAndMetadata, mo
difiers.externalKeyword, returnType)); |
| 4017 } else if (matches(TokenType.AT)) { | 4000 } else if (_matches(TokenType.AT)) { |
| 4018 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment
AndMetadata.metadata, parseVariableDeclarationListAfterType(null, validateModifi
ersForTopLevelVariable(modifiers), returnType), expect(TokenType.SEMICOLON)); | 4001 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment
AndMetadata.metadata, _parseVariableDeclarationListAfterType(null, _validateModi
fiersForTopLevelVariable(modifiers), returnType), _expect(TokenType.SEMICOLON)); |
| 4019 } else if (!matchesIdentifier()) { | 4002 } else if (!_matchesIdentifier()) { |
| 4020 // TODO(brianwilkerson) Generalize this error. We could also be parsing a
top-level variable at this point. | 4003 // TODO(brianwilkerson) Generalize this error. We could also be parsing a
top-level variable at this point. |
| 4021 reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []
); | 4004 _reportErrorForToken(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, [
]); |
| 4022 Token semicolon; | 4005 Token semicolon; |
| 4023 if (matches(TokenType.SEMICOLON)) { | 4006 if (_matches(TokenType.SEMICOLON)) { |
| 4024 semicolon = andAdvance; | 4007 semicolon = andAdvance; |
| 4025 } else { | 4008 } else { |
| 4026 semicolon = createSyntheticToken(TokenType.SEMICOLON); | 4009 semicolon = _createSyntheticToken(TokenType.SEMICOLON); |
| 4027 } | 4010 } |
| 4028 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 4011 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
| 4029 variables.add(new VariableDeclaration(null, null, createSyntheticIdentifie
r(), null, null)); | 4012 variables.add(new VariableDeclaration(null, null, _createSyntheticIdentifi
er(), null, null)); |
| 4030 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment
AndMetadata.metadata, new VariableDeclarationList(null, null, null, returnType,
variables), semicolon); | 4013 return new TopLevelVariableDeclaration(commentAndMetadata.comment, comment
AndMetadata.metadata, new VariableDeclarationList(null, null, null, returnType,
variables), semicolon); |
| 4031 } | 4014 } |
| 4032 if (matchesAny(peek(), [ | 4015 if (_peek().matchesAny([ |
| 4033 TokenType.OPEN_PAREN, | 4016 TokenType.OPEN_PAREN, |
| 4034 TokenType.FUNCTION, | 4017 TokenType.FUNCTION, |
| 4035 TokenType.OPEN_CURLY_BRACKET])) { | 4018 TokenType.OPEN_CURLY_BRACKET])) { |
| 4036 validateModifiersForTopLevelFunction(modifiers); | 4019 _validateModifiersForTopLevelFunction(modifiers); |
| 4037 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType); | 4020 return _parseFunctionDeclaration(commentAndMetadata, modifiers.externalKey
word, returnType); |
| 4038 } | 4021 } |
| 4039 return new TopLevelVariableDeclaration(commentAndMetadata.comment, commentAn
dMetadata.metadata, parseVariableDeclarationListAfterType(null, validateModifier
sForTopLevelVariable(modifiers), returnType), expect(TokenType.SEMICOLON)); | 4022 return new TopLevelVariableDeclaration(commentAndMetadata.comment, commentAn
dMetadata.metadata, _parseVariableDeclarationListAfterType(null, _validateModifi
ersForTopLevelVariable(modifiers), returnType), _expect(TokenType.SEMICOLON)); |
| 4040 } | 4023 } |
| 4041 | 4024 |
| 4042 /** | 4025 /** |
| 4043 * Parse a const expression. | 4026 * Parse a const expression. |
| 4044 * | 4027 * |
| 4045 * <pre> | 4028 * <pre> |
| 4046 * constExpression ::= | 4029 * constExpression ::= |
| 4047 * instanceCreationExpression | 4030 * instanceCreationExpression |
| 4048 * | listLiteral | 4031 * | listLiteral |
| 4049 * | mapLiteral | 4032 * | mapLiteral |
| 4050 * </pre> | 4033 * </pre> |
| 4051 * | 4034 * |
| 4052 * @return the const expression that was parsed | 4035 * @return the const expression that was parsed |
| 4053 */ | 4036 */ |
| 4054 Expression parseConstExpression() { | 4037 Expression _parseConstExpression() { |
| 4055 Token keyword = expectKeyword(Keyword.CONST); | 4038 Token keyword = _expectKeyword(Keyword.CONST); |
| 4056 if (matches(TokenType.OPEN_SQUARE_BRACKET) || matches(TokenType.INDEX)) { | 4039 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.INDEX)) { |
| 4057 return parseListLiteral(keyword, null); | 4040 return _parseListLiteral(keyword, null); |
| 4058 } else if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 4041 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 4059 return parseMapLiteral(keyword, null); | 4042 return _parseMapLiteral(keyword, null); |
| 4060 } else if (matches(TokenType.LT)) { | 4043 } else if (_matches(TokenType.LT)) { |
| 4061 return parseListOrMapLiteral(keyword); | 4044 return _parseListOrMapLiteral(keyword); |
| 4062 } | 4045 } |
| 4063 return parseInstanceCreationExpression(keyword); | 4046 return _parseInstanceCreationExpression(keyword); |
| 4064 } | 4047 } |
| 4065 | 4048 |
| 4066 ConstructorDeclaration parseConstructor(CommentAndMetadata commentAndMetadata,
Token externalKeyword, Token constKeyword, Token factoryKeyword, SimpleIdentifi
er returnType, Token period, SimpleIdentifier name, FormalParameterList paramete
rs) { | 4049 ConstructorDeclaration _parseConstructor(CommentAndMetadata commentAndMetadata
, Token externalKeyword, Token constKeyword, Token factoryKeyword, SimpleIdentif
ier returnType, Token period, SimpleIdentifier name, FormalParameterList paramet
ers) { |
| 4067 bool bodyAllowed = externalKeyword == null; | 4050 bool bodyAllowed = externalKeyword == null; |
| 4068 Token separator = null; | 4051 Token separator = null; |
| 4069 List<ConstructorInitializer> initializers = null; | 4052 List<ConstructorInitializer> initializers = null; |
| 4070 if (matches(TokenType.COLON)) { | 4053 if (_matches(TokenType.COLON)) { |
| 4071 separator = andAdvance; | 4054 separator = andAdvance; |
| 4072 initializers = new List<ConstructorInitializer>(); | 4055 initializers = new List<ConstructorInitializer>(); |
| 4073 do { | 4056 do { |
| 4074 if (matchesKeyword(Keyword.THIS)) { | 4057 if (_matchesKeyword(Keyword.THIS)) { |
| 4075 if (tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 4058 if (_tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 4076 bodyAllowed = false; | 4059 bodyAllowed = false; |
| 4077 initializers.add(parseRedirectingConstructorInvocation()); | 4060 initializers.add(_parseRedirectingConstructorInvocation()); |
| 4078 } else if (tokenMatches(peek(), TokenType.PERIOD) && tokenMatches(peek
At(3), TokenType.OPEN_PAREN)) { | 4061 } else if (_tokenMatches(_peek(), TokenType.PERIOD) && _tokenMatches(_
peekAt(3), TokenType.OPEN_PAREN)) { |
| 4079 bodyAllowed = false; | 4062 bodyAllowed = false; |
| 4080 initializers.add(parseRedirectingConstructorInvocation()); | 4063 initializers.add(_parseRedirectingConstructorInvocation()); |
| 4081 } else { | 4064 } else { |
| 4082 initializers.add(parseConstructorFieldInitializer()); | 4065 initializers.add(_parseConstructorFieldInitializer()); |
| 4083 } | 4066 } |
| 4084 } else if (matchesKeyword(Keyword.SUPER)) { | 4067 } else if (_matchesKeyword(Keyword.SUPER)) { |
| 4085 initializers.add(parseSuperConstructorInvocation()); | 4068 initializers.add(_parseSuperConstructorInvocation()); |
| 4086 } else { | 4069 } else { |
| 4087 initializers.add(parseConstructorFieldInitializer()); | 4070 initializers.add(_parseConstructorFieldInitializer()); |
| 4088 } | 4071 } |
| 4089 } while (optional(TokenType.COMMA)); | 4072 } while (_optional(TokenType.COMMA)); |
| 4090 } | 4073 } |
| 4091 ConstructorName redirectedConstructor = null; | 4074 ConstructorName redirectedConstructor = null; |
| 4092 FunctionBody body; | 4075 FunctionBody body; |
| 4093 if (matches(TokenType.EQ)) { | 4076 if (_matches(TokenType.EQ)) { |
| 4094 separator = andAdvance; | 4077 separator = andAdvance; |
| 4095 redirectedConstructor = parseConstructorName(); | 4078 redirectedConstructor = parseConstructorName(); |
| 4096 body = new EmptyFunctionBody(expect(TokenType.SEMICOLON)); | 4079 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON)); |
| 4097 if (factoryKeyword == null) { | 4080 if (factoryKeyword == null) { |
| 4098 reportErrorForNode(ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTO
R, redirectedConstructor, []); | 4081 _reportErrorForNode(ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCT
OR, redirectedConstructor, []); |
| 4099 } | 4082 } |
| 4100 } else { | 4083 } else { |
| 4101 body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, fals
e); | 4084 body = _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, fal
se); |
| 4102 if (constKeyword != null && factoryKeyword != null && externalKeyword == n
ull) { | 4085 if (constKeyword != null && factoryKeyword != null && externalKeyword == n
ull) { |
| 4103 reportErrorForToken(ParserErrorCode.CONST_FACTORY, factoryKeyword, []); | 4086 _reportErrorForToken(ParserErrorCode.CONST_FACTORY, factoryKeyword, []); |
| 4104 } else if (body is EmptyFunctionBody) { | 4087 } else if (body is EmptyFunctionBody) { |
| 4105 if (factoryKeyword != null && externalKeyword == null) { | 4088 if (factoryKeyword != null && externalKeyword == null) { |
| 4106 reportErrorForToken(ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeywo
rd, []); | 4089 _reportErrorForToken(ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyw
ord, []); |
| 4107 } | 4090 } |
| 4108 } else { | 4091 } else { |
| 4109 if (constKeyword != null) { | 4092 if (constKeyword != null) { |
| 4110 reportErrorForNode(ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body,
[]); | 4093 _reportErrorForNode(ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body,
[]); |
| 4111 } else if (!bodyAllowed) { | 4094 } else if (!bodyAllowed) { |
| 4112 reportErrorForNode(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, bod
y, []); | 4095 _reportErrorForNode(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, bo
dy, []); |
| 4113 } | 4096 } |
| 4114 } | 4097 } |
| 4115 } | 4098 } |
| 4116 return new ConstructorDeclaration(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, constKeyword, factoryKeyword, returnType, period
, name, parameters, separator, initializers, redirectedConstructor, body); | 4099 return new ConstructorDeclaration(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, constKeyword, factoryKeyword, returnType, period
, name, parameters, separator, initializers, redirectedConstructor, body); |
| 4117 } | 4100 } |
| 4118 | 4101 |
| 4119 /** | 4102 /** |
| 4120 * Parse a field initializer within a constructor. | 4103 * Parse a field initializer within a constructor. |
| 4121 * | 4104 * |
| 4122 * <pre> | 4105 * <pre> |
| 4123 * fieldInitializer: | 4106 * fieldInitializer: |
| 4124 * ('this' '.')? identifier '=' conditionalExpression cascadeSection* | 4107 * ('this' '.')? identifier '=' conditionalExpression cascadeSection* |
| 4125 * </pre> | 4108 * </pre> |
| 4126 * | 4109 * |
| 4127 * @return the field initializer that was parsed | 4110 * @return the field initializer that was parsed |
| 4128 */ | 4111 */ |
| 4129 ConstructorFieldInitializer parseConstructorFieldInitializer() { | 4112 ConstructorFieldInitializer _parseConstructorFieldInitializer() { |
| 4130 Token keyword = null; | 4113 Token keyword = null; |
| 4131 Token period = null; | 4114 Token period = null; |
| 4132 if (matchesKeyword(Keyword.THIS)) { | 4115 if (_matchesKeyword(Keyword.THIS)) { |
| 4133 keyword = andAdvance; | 4116 keyword = andAdvance; |
| 4134 period = expect(TokenType.PERIOD); | 4117 period = _expect(TokenType.PERIOD); |
| 4135 } | 4118 } |
| 4136 SimpleIdentifier fieldName = parseSimpleIdentifier(); | 4119 SimpleIdentifier fieldName = parseSimpleIdentifier(); |
| 4137 Token equals = expect(TokenType.EQ); | 4120 Token equals = _expect(TokenType.EQ); |
| 4138 Expression expression = parseConditionalExpression(); | 4121 Expression expression = parseConditionalExpression(); |
| 4139 TokenType tokenType = _currentToken.type; | 4122 TokenType tokenType = _currentToken.type; |
| 4140 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { | 4123 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { |
| 4141 List<Expression> cascadeSections = new List<Expression>(); | 4124 List<Expression> cascadeSections = new List<Expression>(); |
| 4142 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { | 4125 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { |
| 4143 Expression section = parseCascadeSection(); | 4126 Expression section = _parseCascadeSection(); |
| 4144 if (section != null) { | 4127 if (section != null) { |
| 4145 cascadeSections.add(section); | 4128 cascadeSections.add(section); |
| 4146 } | 4129 } |
| 4147 tokenType = _currentToken.type; | 4130 tokenType = _currentToken.type; |
| 4148 } | 4131 } |
| 4149 expression = new CascadeExpression(expression, cascadeSections); | 4132 expression = new CascadeExpression(expression, cascadeSections); |
| 4150 } | 4133 } |
| 4151 return new ConstructorFieldInitializer(keyword, period, fieldName, equals, e
xpression); | 4134 return new ConstructorFieldInitializer(keyword, period, fieldName, equals, e
xpression); |
| 4152 } | 4135 } |
| 4153 | 4136 |
| 4154 /** | 4137 /** |
| 4155 * Parse a continue statement. | 4138 * Parse a continue statement. |
| 4156 * | 4139 * |
| 4157 * <pre> | 4140 * <pre> |
| 4158 * continueStatement ::= | 4141 * continueStatement ::= |
| 4159 * 'continue' identifier? ';' | 4142 * 'continue' identifier? ';' |
| 4160 * </pre> | 4143 * </pre> |
| 4161 * | 4144 * |
| 4162 * @return the continue statement that was parsed | 4145 * @return the continue statement that was parsed |
| 4163 */ | 4146 */ |
| 4164 Statement parseContinueStatement() { | 4147 Statement _parseContinueStatement() { |
| 4165 Token continueKeyword = expectKeyword(Keyword.CONTINUE); | 4148 Token continueKeyword = _expectKeyword(Keyword.CONTINUE); |
| 4166 if (!_inLoop && !_inSwitch) { | 4149 if (!_inLoop && !_inSwitch) { |
| 4167 reportErrorForToken(ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKeyw
ord, []); | 4150 _reportErrorForToken(ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKey
word, []); |
| 4168 } | 4151 } |
| 4169 SimpleIdentifier label = null; | 4152 SimpleIdentifier label = null; |
| 4170 if (matchesIdentifier()) { | 4153 if (_matchesIdentifier()) { |
| 4171 label = parseSimpleIdentifier(); | 4154 label = parseSimpleIdentifier(); |
| 4172 } | 4155 } |
| 4173 if (_inSwitch && !_inLoop && label == null) { | 4156 if (_inSwitch && !_inLoop && label == null) { |
| 4174 reportErrorForToken(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, contin
ueKeyword, []); | 4157 _reportErrorForToken(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, conti
nueKeyword, []); |
| 4175 } | 4158 } |
| 4176 Token semicolon = expect(TokenType.SEMICOLON); | 4159 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4177 return new ContinueStatement(continueKeyword, label, semicolon); | 4160 return new ContinueStatement(continueKeyword, label, semicolon); |
| 4178 } | 4161 } |
| 4179 | 4162 |
| 4180 /** | 4163 /** |
| 4181 * Parse a directive. | 4164 * Parse a directive. |
| 4182 * | 4165 * |
| 4183 * <pre> | 4166 * <pre> |
| 4184 * directive ::= | 4167 * directive ::= |
| 4185 * exportDirective | 4168 * exportDirective |
| 4186 * | libraryDirective | 4169 * | libraryDirective |
| 4187 * | importDirective | 4170 * | importDirective |
| 4188 * | partDirective | 4171 * | partDirective |
| 4189 * </pre> | 4172 * </pre> |
| 4190 * | 4173 * |
| 4191 * @param commentAndMetadata the metadata to be associated with the directive | 4174 * @param commentAndMetadata the metadata to be associated with the directive |
| 4192 * @return the directive that was parsed | 4175 * @return the directive that was parsed |
| 4193 */ | 4176 */ |
| 4194 Directive parseDirective(CommentAndMetadata commentAndMetadata) { | 4177 Directive _parseDirective(CommentAndMetadata commentAndMetadata) { |
| 4195 if (matchesKeyword(Keyword.IMPORT)) { | 4178 if (_matchesKeyword(Keyword.IMPORT)) { |
| 4196 return parseImportDirective(commentAndMetadata); | 4179 return _parseImportDirective(commentAndMetadata); |
| 4197 } else if (matchesKeyword(Keyword.EXPORT)) { | 4180 } else if (_matchesKeyword(Keyword.EXPORT)) { |
| 4198 return parseExportDirective(commentAndMetadata); | 4181 return _parseExportDirective(commentAndMetadata); |
| 4199 } else if (matchesKeyword(Keyword.LIBRARY)) { | 4182 } else if (_matchesKeyword(Keyword.LIBRARY)) { |
| 4200 return parseLibraryDirective(commentAndMetadata); | 4183 return _parseLibraryDirective(commentAndMetadata); |
| 4201 } else if (matchesKeyword(Keyword.PART)) { | 4184 } else if (_matchesKeyword(Keyword.PART)) { |
| 4202 return parsePartDirective(commentAndMetadata); | 4185 return _parsePartDirective(commentAndMetadata); |
| 4203 } else { | 4186 } else { |
| 4204 // Internal error: this method should not have been invoked if the current
token was something | 4187 // Internal error: this method should not have been invoked if the current
token was something |
| 4205 // other than one of the above. | 4188 // other than one of the above. |
| 4206 throw new IllegalStateException("parseDirective invoked in an invalid stat
e; currentToken = ${_currentToken}"); | 4189 throw new IllegalStateException("parseDirective invoked in an invalid stat
e; currentToken = ${_currentToken}"); |
| 4207 } | 4190 } |
| 4208 } | 4191 } |
| 4209 | 4192 |
| 4210 /** | 4193 /** |
| 4211 * Parse a documentation comment. | 4194 * Parse a documentation comment. |
| 4212 * | 4195 * |
| 4213 * <pre> | 4196 * <pre> |
| 4214 * documentationComment ::= | 4197 * documentationComment ::= |
| 4215 * multiLineComment? | 4198 * multiLineComment? |
| 4216 * | singleLineComment* | 4199 * | singleLineComment* |
| 4217 * </pre> | 4200 * </pre> |
| 4218 * | 4201 * |
| 4219 * @return the documentation comment that was parsed, or `null` if there was n
o comment | 4202 * @return the documentation comment that was parsed, or `null` if there was n
o comment |
| 4220 */ | 4203 */ |
| 4221 Comment parseDocumentationComment() { | 4204 Comment _parseDocumentationComment() { |
| 4222 List<Token> commentTokens = new List<Token>(); | 4205 List<Token> commentTokens = new List<Token>(); |
| 4223 Token commentToken = _currentToken.precedingComments; | 4206 Token commentToken = _currentToken.precedingComments; |
| 4224 while (commentToken != null) { | 4207 while (commentToken != null) { |
| 4225 if (identical(commentToken.type, TokenType.SINGLE_LINE_COMMENT)) { | 4208 if (identical(commentToken.type, TokenType.SINGLE_LINE_COMMENT)) { |
| 4226 if (StringUtilities.startsWith3(commentToken.lexeme, 0, 0x2F, 0x2F, 0x2F
)) { | 4209 if (StringUtilities.startsWith3(commentToken.lexeme, 0, 0x2F, 0x2F, 0x2F
)) { |
| 4227 if (commentTokens.length == 1 && StringUtilities.startsWith3(commentTo
kens[0].lexeme, 0, 0x2F, 0x2A, 0x2A)) { | 4210 if (commentTokens.length == 1 && StringUtilities.startsWith3(commentTo
kens[0].lexeme, 0, 0x2F, 0x2A, 0x2A)) { |
| 4228 commentTokens.clear(); | 4211 commentTokens.clear(); |
| 4229 } | 4212 } |
| 4230 commentTokens.add(commentToken); | 4213 commentTokens.add(commentToken); |
| 4231 } | 4214 } |
| 4232 } else { | 4215 } else { |
| 4233 if (StringUtilities.startsWith3(commentToken.lexeme, 0, 0x2F, 0x2A, 0x2A
)) { | 4216 if (StringUtilities.startsWith3(commentToken.lexeme, 0, 0x2F, 0x2A, 0x2A
)) { |
| 4234 commentTokens.clear(); | 4217 commentTokens.clear(); |
| 4235 commentTokens.add(commentToken); | 4218 commentTokens.add(commentToken); |
| 4236 } | 4219 } |
| 4237 } | 4220 } |
| 4238 commentToken = commentToken.next; | 4221 commentToken = commentToken.next; |
| 4239 } | 4222 } |
| 4240 if (commentTokens.isEmpty) { | 4223 if (commentTokens.isEmpty) { |
| 4241 return null; | 4224 return null; |
| 4242 } | 4225 } |
| 4243 List<Token> tokens = new List.from(commentTokens); | 4226 List<Token> tokens = new List.from(commentTokens); |
| 4244 List<CommentReference> references = parseCommentReferences(tokens); | 4227 List<CommentReference> references = _parseCommentReferences(tokens); |
| 4245 return Comment.createDocumentationCommentWithReferences(tokens, references); | 4228 return Comment.createDocumentationCommentWithReferences(tokens, references); |
| 4246 } | 4229 } |
| 4247 | 4230 |
| 4248 /** | 4231 /** |
| 4249 * Parse a do statement. | 4232 * Parse a do statement. |
| 4250 * | 4233 * |
| 4251 * <pre> | 4234 * <pre> |
| 4252 * doStatement ::= | 4235 * doStatement ::= |
| 4253 * 'do' statement 'while' '(' expression ')' ';' | 4236 * 'do' statement 'while' '(' expression ')' ';' |
| 4254 * </pre> | 4237 * </pre> |
| 4255 * | 4238 * |
| 4256 * @return the do statement that was parsed | 4239 * @return the do statement that was parsed |
| 4257 */ | 4240 */ |
| 4258 Statement parseDoStatement() { | 4241 Statement _parseDoStatement() { |
| 4259 bool wasInLoop = _inLoop; | 4242 bool wasInLoop = _inLoop; |
| 4260 _inLoop = true; | 4243 _inLoop = true; |
| 4261 try { | 4244 try { |
| 4262 Token doKeyword = expectKeyword(Keyword.DO); | 4245 Token doKeyword = _expectKeyword(Keyword.DO); |
| 4263 Statement body = parseStatement2(); | 4246 Statement body = parseStatement2(); |
| 4264 Token whileKeyword = expectKeyword(Keyword.WHILE); | 4247 Token whileKeyword = _expectKeyword(Keyword.WHILE); |
| 4265 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 4248 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 4266 Expression condition = parseExpression2(); | 4249 Expression condition = parseExpression2(); |
| 4267 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 4250 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 4268 Token semicolon = expect(TokenType.SEMICOLON); | 4251 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4269 return new DoStatement(doKeyword, body, whileKeyword, leftParenthesis, con
dition, rightParenthesis, semicolon); | 4252 return new DoStatement(doKeyword, body, whileKeyword, leftParenthesis, con
dition, rightParenthesis, semicolon); |
| 4270 } finally { | 4253 } finally { |
| 4271 _inLoop = wasInLoop; | 4254 _inLoop = wasInLoop; |
| 4272 } | 4255 } |
| 4273 } | 4256 } |
| 4274 | 4257 |
| 4275 /** | 4258 /** |
| 4276 * Parse an empty statement. | 4259 * Parse an empty statement. |
| 4277 * | 4260 * |
| 4278 * <pre> | 4261 * <pre> |
| 4279 * emptyStatement ::= | 4262 * emptyStatement ::= |
| 4280 * ';' | 4263 * ';' |
| 4281 * </pre> | 4264 * </pre> |
| 4282 * | 4265 * |
| 4283 * @return the empty statement that was parsed | 4266 * @return the empty statement that was parsed |
| 4284 */ | 4267 */ |
| 4285 Statement parseEmptyStatement() => new EmptyStatement(andAdvance); | 4268 Statement _parseEmptyStatement() => new EmptyStatement(andAdvance); |
| 4286 | 4269 |
| 4287 /** | 4270 /** |
| 4288 * Parse an equality expression. | 4271 * Parse an equality expression. |
| 4289 * | 4272 * |
| 4290 * <pre> | 4273 * <pre> |
| 4291 * equalityExpression ::= | 4274 * equalityExpression ::= |
| 4292 * relationalExpression (equalityOperator relationalExpression)? | 4275 * relationalExpression (equalityOperator relationalExpression)? |
| 4293 * | 'super' equalityOperator relationalExpression | 4276 * | 'super' equalityOperator relationalExpression |
| 4294 * </pre> | 4277 * </pre> |
| 4295 * | 4278 * |
| 4296 * @return the equality expression that was parsed | 4279 * @return the equality expression that was parsed |
| 4297 */ | 4280 */ |
| 4298 Expression parseEqualityExpression() { | 4281 Expression _parseEqualityExpression() { |
| 4299 Expression expression; | 4282 Expression expression; |
| 4300 if (matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isEqualityOpera
tor) { | 4283 if (_matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isEqualityOper
ator) { |
| 4301 expression = new SuperExpression(andAdvance); | 4284 expression = new SuperExpression(andAdvance); |
| 4302 } else { | 4285 } else { |
| 4303 expression = parseRelationalExpression(); | 4286 expression = _parseRelationalExpression(); |
| 4304 } | 4287 } |
| 4305 bool leftEqualityExpression = false; | 4288 bool leftEqualityExpression = false; |
| 4306 while (_currentToken.type.isEqualityOperator) { | 4289 while (_currentToken.type.isEqualityOperator) { |
| 4307 Token operator = andAdvance; | 4290 Token operator = andAdvance; |
| 4308 if (leftEqualityExpression) { | 4291 if (leftEqualityExpression) { |
| 4309 reportErrorForNode(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND,
expression, []); | 4292 _reportErrorForNode(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND,
expression, []); |
| 4310 } | 4293 } |
| 4311 expression = new BinaryExpression(expression, operator, parseRelationalExp
ression()); | 4294 expression = new BinaryExpression(expression, operator, _parseRelationalEx
pression()); |
| 4312 leftEqualityExpression = true; | 4295 leftEqualityExpression = true; |
| 4313 } | 4296 } |
| 4314 return expression; | 4297 return expression; |
| 4315 } | 4298 } |
| 4316 | 4299 |
| 4317 /** | 4300 /** |
| 4318 * Parse an export directive. | 4301 * Parse an export directive. |
| 4319 * | 4302 * |
| 4320 * <pre> | 4303 * <pre> |
| 4321 * exportDirective ::= | 4304 * exportDirective ::= |
| 4322 * metadata 'export' stringLiteral combinator*';' | 4305 * metadata 'export' stringLiteral combinator*';' |
| 4323 * </pre> | 4306 * </pre> |
| 4324 * | 4307 * |
| 4325 * @param commentAndMetadata the metadata to be associated with the directive | 4308 * @param commentAndMetadata the metadata to be associated with the directive |
| 4326 * @return the export directive that was parsed | 4309 * @return the export directive that was parsed |
| 4327 */ | 4310 */ |
| 4328 ExportDirective parseExportDirective(CommentAndMetadata commentAndMetadata) { | 4311 ExportDirective _parseExportDirective(CommentAndMetadata commentAndMetadata) { |
| 4329 Token exportKeyword = expectKeyword(Keyword.EXPORT); | 4312 Token exportKeyword = _expectKeyword(Keyword.EXPORT); |
| 4330 StringLiteral libraryUri = parseStringLiteral(); | 4313 StringLiteral libraryUri = parseStringLiteral(); |
| 4331 List<Combinator> combinators = parseCombinators(); | 4314 List<Combinator> combinators = _parseCombinators(); |
| 4332 Token semicolon = expectSemicolon(); | 4315 Token semicolon = _expectSemicolon(); |
| 4333 return new ExportDirective(commentAndMetadata.comment, commentAndMetadata.me
tadata, exportKeyword, libraryUri, combinators, semicolon); | 4316 return new ExportDirective(commentAndMetadata.comment, commentAndMetadata.me
tadata, exportKeyword, libraryUri, combinators, semicolon); |
| 4334 } | 4317 } |
| 4335 | 4318 |
| 4336 /** | 4319 /** |
| 4337 * Parse a list of expressions. | 4320 * Parse a list of expressions. |
| 4338 * | 4321 * |
| 4339 * <pre> | 4322 * <pre> |
| 4340 * expressionList ::= | 4323 * expressionList ::= |
| 4341 * expression (',' expression)* | 4324 * expression (',' expression)* |
| 4342 * </pre> | 4325 * </pre> |
| 4343 * | 4326 * |
| 4344 * @return the expression that was parsed | 4327 * @return the expression that was parsed |
| 4345 */ | 4328 */ |
| 4346 List<Expression> parseExpressionList() { | 4329 List<Expression> _parseExpressionList() { |
| 4347 List<Expression> expressions = new List<Expression>(); | 4330 List<Expression> expressions = new List<Expression>(); |
| 4348 expressions.add(parseExpression2()); | 4331 expressions.add(parseExpression2()); |
| 4349 while (optional(TokenType.COMMA)) { | 4332 while (_optional(TokenType.COMMA)) { |
| 4350 expressions.add(parseExpression2()); | 4333 expressions.add(parseExpression2()); |
| 4351 } | 4334 } |
| 4352 return expressions; | 4335 return expressions; |
| 4353 } | 4336 } |
| 4354 | 4337 |
| 4355 /** | 4338 /** |
| 4356 * Parse the 'final', 'const', 'var' or type preceding a variable declaration. | 4339 * Parse the 'final', 'const', 'var' or type preceding a variable declaration. |
| 4357 * | 4340 * |
| 4358 * <pre> | 4341 * <pre> |
| 4359 * finalConstVarOrType ::= | 4342 * finalConstVarOrType ::= |
| 4360 * | 'final' type? | 4343 * | 'final' type? |
| 4361 * | 'const' type? | 4344 * | 'const' type? |
| 4362 * | 'var' | 4345 * | 'var' |
| 4363 * | type | 4346 * | type |
| 4364 * </pre> | 4347 * </pre> |
| 4365 * | 4348 * |
| 4366 * @param optional `true` if the keyword and type are optional | 4349 * @param optional `true` if the keyword and type are optional |
| 4367 * @return the 'final', 'const', 'var' or type that was parsed | 4350 * @return the 'final', 'const', 'var' or type that was parsed |
| 4368 */ | 4351 */ |
| 4369 FinalConstVarOrType parseFinalConstVarOrType(bool optional) { | 4352 FinalConstVarOrType _parseFinalConstVarOrType(bool optional) { |
| 4370 Token keyword = null; | 4353 Token keyword = null; |
| 4371 TypeName type = null; | 4354 TypeName type = null; |
| 4372 if (matchesKeyword(Keyword.FINAL) || matchesKeyword(Keyword.CONST)) { | 4355 if (_matchesKeyword(Keyword.FINAL) || _matchesKeyword(Keyword.CONST)) { |
| 4373 keyword = andAdvance; | 4356 keyword = andAdvance; |
| 4374 if (isTypedIdentifier(_currentToken)) { | 4357 if (_isTypedIdentifier(_currentToken)) { |
| 4375 type = parseTypeName(); | 4358 type = parseTypeName(); |
| 4376 } | 4359 } |
| 4377 } else if (matchesKeyword(Keyword.VAR)) { | 4360 } else if (_matchesKeyword(Keyword.VAR)) { |
| 4378 keyword = andAdvance; | 4361 keyword = andAdvance; |
| 4379 } else { | 4362 } else { |
| 4380 if (isTypedIdentifier(_currentToken)) { | 4363 if (_isTypedIdentifier(_currentToken)) { |
| 4381 type = parseReturnType(); | 4364 type = parseReturnType(); |
| 4382 } else if (!optional) { | 4365 } else if (!optional) { |
| 4383 reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TY
PE, []); | 4366 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_T
YPE, []); |
| 4384 } | 4367 } |
| 4385 } | 4368 } |
| 4386 return new FinalConstVarOrType(keyword, type); | 4369 return new FinalConstVarOrType(keyword, type); |
| 4387 } | 4370 } |
| 4388 | 4371 |
| 4389 /** | 4372 /** |
| 4390 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be | 4373 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be |
| 4391 * `true`. | 4374 * `true`. |
| 4392 * | 4375 * |
| 4393 * <pre> | 4376 * <pre> |
| 4394 * defaultFormalParameter ::= | 4377 * defaultFormalParameter ::= |
| 4395 * normalFormalParameter ('=' expression)? | 4378 * normalFormalParameter ('=' expression)? |
| 4396 * | 4379 * |
| 4397 * defaultNamedParameter ::= | 4380 * defaultNamedParameter ::= |
| 4398 * normalFormalParameter (':' expression)? | 4381 * normalFormalParameter (':' expression)? |
| 4399 * </pre> | 4382 * </pre> |
| 4400 * | 4383 * |
| 4401 * @param kind the kind of parameter being expected based on the presence or a
bsence of group | 4384 * @param kind the kind of parameter being expected based on the presence or a
bsence of group |
| 4402 * delimiters | 4385 * delimiters |
| 4403 * @return the formal parameter that was parsed | 4386 * @return the formal parameter that was parsed |
| 4404 */ | 4387 */ |
| 4405 FormalParameter parseFormalParameter(ParameterKind kind) { | 4388 FormalParameter _parseFormalParameter(ParameterKind kind) { |
| 4406 NormalFormalParameter parameter = parseNormalFormalParameter(); | 4389 NormalFormalParameter parameter = parseNormalFormalParameter(); |
| 4407 if (matches(TokenType.EQ)) { | 4390 if (_matches(TokenType.EQ)) { |
| 4408 Token seperator = andAdvance; | 4391 Token seperator = andAdvance; |
| 4409 Expression defaultValue = parseExpression2(); | 4392 Expression defaultValue = parseExpression2(); |
| 4410 if (identical(kind, ParameterKind.NAMED)) { | 4393 if (identical(kind, ParameterKind.NAMED)) { |
| 4411 reportErrorForToken(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER,
seperator, []); | 4394 _reportErrorForToken(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER
, seperator, []); |
| 4412 } else if (identical(kind, ParameterKind.REQUIRED)) { | 4395 } else if (identical(kind, ParameterKind.REQUIRED)) { |
| 4413 reportErrorForNode(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, p
arameter, []); | 4396 _reportErrorForNode(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP,
parameter, []); |
| 4414 } | 4397 } |
| 4415 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue
); | 4398 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue
); |
| 4416 } else if (matches(TokenType.COLON)) { | 4399 } else if (_matches(TokenType.COLON)) { |
| 4417 Token seperator = andAdvance; | 4400 Token seperator = andAdvance; |
| 4418 Expression defaultValue = parseExpression2(); | 4401 Expression defaultValue = parseExpression2(); |
| 4419 if (identical(kind, ParameterKind.POSITIONAL)) { | 4402 if (identical(kind, ParameterKind.POSITIONAL)) { |
| 4420 reportErrorForToken(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAM
ETER, seperator, []); | 4403 _reportErrorForToken(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARA
METER, seperator, []); |
| 4421 } else if (identical(kind, ParameterKind.REQUIRED)) { | 4404 } else if (identical(kind, ParameterKind.REQUIRED)) { |
| 4422 reportErrorForNode(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parame
ter, []); | 4405 _reportErrorForNode(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, param
eter, []); |
| 4423 } | 4406 } |
| 4424 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue
); | 4407 return new DefaultFormalParameter(parameter, kind, seperator, defaultValue
); |
| 4425 } else if (kind != ParameterKind.REQUIRED) { | 4408 } else if (kind != ParameterKind.REQUIRED) { |
| 4426 return new DefaultFormalParameter(parameter, kind, null, null); | 4409 return new DefaultFormalParameter(parameter, kind, null, null); |
| 4427 } | 4410 } |
| 4428 return parameter; | 4411 return parameter; |
| 4429 } | 4412 } |
| 4430 | 4413 |
| 4431 /** | 4414 /** |
| 4432 * Parse a for statement. | 4415 * Parse a for statement. |
| 4433 * | 4416 * |
| 4434 * <pre> | 4417 * <pre> |
| 4435 * forStatement ::= | 4418 * forStatement ::= |
| 4436 * 'for' '(' forLoopParts ')' statement | 4419 * 'for' '(' forLoopParts ')' statement |
| 4437 * | 4420 * |
| 4438 * forLoopParts ::= | 4421 * forLoopParts ::= |
| 4439 * forInitializerStatement expression? ';' expressionList? | 4422 * forInitializerStatement expression? ';' expressionList? |
| 4440 * | declaredIdentifier 'in' expression | 4423 * | declaredIdentifier 'in' expression |
| 4441 * | identifier 'in' expression | 4424 * | identifier 'in' expression |
| 4442 * | 4425 * |
| 4443 * forInitializerStatement ::= | 4426 * forInitializerStatement ::= |
| 4444 * localVariableDeclaration ';' | 4427 * localVariableDeclaration ';' |
| 4445 * | expression? ';' | 4428 * | expression? ';' |
| 4446 * </pre> | 4429 * </pre> |
| 4447 * | 4430 * |
| 4448 * @return the for statement that was parsed | 4431 * @return the for statement that was parsed |
| 4449 */ | 4432 */ |
| 4450 Statement parseForStatement() { | 4433 Statement _parseForStatement() { |
| 4451 bool wasInLoop = _inLoop; | 4434 bool wasInLoop = _inLoop; |
| 4452 _inLoop = true; | 4435 _inLoop = true; |
| 4453 try { | 4436 try { |
| 4454 Token forKeyword = expectKeyword(Keyword.FOR); | 4437 Token forKeyword = _expectKeyword(Keyword.FOR); |
| 4455 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 4438 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 4456 VariableDeclarationList variableList = null; | 4439 VariableDeclarationList variableList = null; |
| 4457 Expression initialization = null; | 4440 Expression initialization = null; |
| 4458 if (!matches(TokenType.SEMICOLON)) { | 4441 if (!_matches(TokenType.SEMICOLON)) { |
| 4459 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 4442 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 4460 if (matchesIdentifier() && tokenMatchesKeyword(peek(), Keyword.IN)) { | 4443 if (_matchesIdentifier() && _tokenMatchesKeyword(_peek(), Keyword.IN)) { |
| 4461 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 4444 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
| 4462 SimpleIdentifier variableName = parseSimpleIdentifier(); | 4445 SimpleIdentifier variableName = parseSimpleIdentifier(); |
| 4463 variables.add(new VariableDeclaration(null, null, variableName, null,
null)); | 4446 variables.add(new VariableDeclaration(null, null, variableName, null,
null)); |
| 4464 variableList = new VariableDeclarationList(commentAndMetadata.comment,
commentAndMetadata.metadata, null, null, variables); | 4447 variableList = new VariableDeclarationList(commentAndMetadata.comment,
commentAndMetadata.metadata, null, null, variables); |
| 4465 } else if (isInitializedVariableDeclaration()) { | 4448 } else if (_isInitializedVariableDeclaration()) { |
| 4466 variableList = parseVariableDeclarationListAfterMetadata(commentAndMet
adata); | 4449 variableList = _parseVariableDeclarationListAfterMetadata(commentAndMe
tadata); |
| 4467 } else { | 4450 } else { |
| 4468 initialization = parseExpression2(); | 4451 initialization = parseExpression2(); |
| 4469 } | 4452 } |
| 4470 if (matchesKeyword(Keyword.IN)) { | 4453 if (_matchesKeyword(Keyword.IN)) { |
| 4471 DeclaredIdentifier loopVariable = null; | 4454 DeclaredIdentifier loopVariable = null; |
| 4472 SimpleIdentifier identifier = null; | 4455 SimpleIdentifier identifier = null; |
| 4473 if (variableList == null) { | 4456 if (variableList == null) { |
| 4474 // We found: <expression> 'in' | 4457 // We found: <expression> 'in' |
| 4475 reportErrorForCurrentToken(ParserErrorCode.MISSING_VARIABLE_IN_FOR_E
ACH, []); | 4458 _reportErrorForCurrentToken(ParserErrorCode.MISSING_VARIABLE_IN_FOR_
EACH, []); |
| 4476 } else { | 4459 } else { |
| 4477 NodeList<VariableDeclaration> variables = variableList.variables; | 4460 NodeList<VariableDeclaration> variables = variableList.variables; |
| 4478 if (variables.length > 1) { | 4461 if (variables.length > 1) { |
| 4479 reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_VARIABLES_IN_F
OR_EACH, [variables.length.toString()]); | 4462 _reportErrorForCurrentToken(ParserErrorCode.MULTIPLE_VARIABLES_IN_
FOR_EACH, [variables.length.toString()]); |
| 4480 } | 4463 } |
| 4481 VariableDeclaration variable = variables[0]; | 4464 VariableDeclaration variable = variables[0]; |
| 4482 if (variable.initializer != null) { | 4465 if (variable.initializer != null) { |
| 4483 reportErrorForCurrentToken(ParserErrorCode.INITIALIZED_VARIABLE_IN
_FOR_EACH, []); | 4466 _reportErrorForCurrentToken(ParserErrorCode.INITIALIZED_VARIABLE_I
N_FOR_EACH, []); |
| 4484 } | 4467 } |
| 4485 Token keyword = variableList.keyword; | 4468 Token keyword = variableList.keyword; |
| 4486 TypeName type = variableList.type; | 4469 TypeName type = variableList.type; |
| 4487 if (keyword != null || type != null) { | 4470 if (keyword != null || type != null) { |
| 4488 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment,
commentAndMetadata.metadata, keyword, type, variable.name); | 4471 loopVariable = new DeclaredIdentifier(commentAndMetadata.comment,
commentAndMetadata.metadata, keyword, type, variable.name); |
| 4489 } else { | 4472 } else { |
| 4490 if (!commentAndMetadata.metadata.isEmpty) { | 4473 if (!commentAndMetadata.metadata.isEmpty) { |
| 4491 } | 4474 } |
| 4492 identifier = variable.name; | 4475 identifier = variable.name; |
| 4493 } | 4476 } |
| 4494 } | 4477 } |
| 4495 Token inKeyword = expectKeyword(Keyword.IN); | 4478 Token inKeyword = _expectKeyword(Keyword.IN); |
| 4496 Expression iterator = parseExpression2(); | 4479 Expression iterator = parseExpression2(); |
| 4497 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 4480 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 4498 Statement body = parseStatement2(); | 4481 Statement body = parseStatement2(); |
| 4499 if (loopVariable == null) { | 4482 if (loopVariable == null) { |
| 4500 return new ForEachStatement.con2(forKeyword, leftParenthesis, identi
fier, inKeyword, iterator, rightParenthesis, body); | 4483 return new ForEachStatement.con2(forKeyword, leftParenthesis, identi
fier, inKeyword, iterator, rightParenthesis, body); |
| 4501 } | 4484 } |
| 4502 return new ForEachStatement.con1(forKeyword, leftParenthesis, loopVari
able, inKeyword, iterator, rightParenthesis, body); | 4485 return new ForEachStatement.con1(forKeyword, leftParenthesis, loopVari
able, inKeyword, iterator, rightParenthesis, body); |
| 4503 } | 4486 } |
| 4504 } | 4487 } |
| 4505 Token leftSeparator = expect(TokenType.SEMICOLON); | 4488 Token leftSeparator = _expect(TokenType.SEMICOLON); |
| 4506 Expression condition = null; | 4489 Expression condition = null; |
| 4507 if (!matches(TokenType.SEMICOLON)) { | 4490 if (!_matches(TokenType.SEMICOLON)) { |
| 4508 condition = parseExpression2(); | 4491 condition = parseExpression2(); |
| 4509 } | 4492 } |
| 4510 Token rightSeparator = expect(TokenType.SEMICOLON); | 4493 Token rightSeparator = _expect(TokenType.SEMICOLON); |
| 4511 List<Expression> updaters = null; | 4494 List<Expression> updaters = null; |
| 4512 if (!matches(TokenType.CLOSE_PAREN)) { | 4495 if (!_matches(TokenType.CLOSE_PAREN)) { |
| 4513 updaters = parseExpressionList(); | 4496 updaters = _parseExpressionList(); |
| 4514 } | 4497 } |
| 4515 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 4498 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 4516 Statement body = parseStatement2(); | 4499 Statement body = parseStatement2(); |
| 4517 return new ForStatement(forKeyword, leftParenthesis, variableList, initial
ization, leftSeparator, condition, rightSeparator, updaters, rightParenthesis, b
ody); | 4500 return new ForStatement(forKeyword, leftParenthesis, variableList, initial
ization, leftSeparator, condition, rightSeparator, updaters, rightParenthesis, b
ody); |
| 4518 } finally { | 4501 } finally { |
| 4519 _inLoop = wasInLoop; | 4502 _inLoop = wasInLoop; |
| 4520 } | 4503 } |
| 4521 } | 4504 } |
| 4522 | 4505 |
| 4523 /** | 4506 /** |
| 4524 * Parse a function body. | 4507 * Parse a function body. |
| 4525 * | 4508 * |
| 4526 * <pre> | 4509 * <pre> |
| 4527 * functionBody ::= | 4510 * functionBody ::= |
| 4528 * '=>' expression ';' | 4511 * '=>' expression ';' |
| 4529 * | block | 4512 * | block |
| 4530 * | 4513 * |
| 4531 * functionExpressionBody ::= | 4514 * functionExpressionBody ::= |
| 4532 * '=>' expression | 4515 * '=>' expression |
| 4533 * | block | 4516 * | block |
| 4534 * </pre> | 4517 * </pre> |
| 4535 * | 4518 * |
| 4536 * @param mayBeEmpty `true` if the function body is allowed to be empty | 4519 * @param mayBeEmpty `true` if the function body is allowed to be empty |
| 4537 * @param emptyErrorCode the error code to report if function body expected, b
ut not found | 4520 * @param emptyErrorCode the error code to report if function body expected, b
ut not found |
| 4538 * @param inExpression `true` if the function body is being parsed as part of
an expression | 4521 * @param inExpression `true` if the function body is being parsed as part of
an expression |
| 4539 * and therefore does not have a terminating semicolon | 4522 * and therefore does not have a terminating semicolon |
| 4540 * @return the function body that was parsed | 4523 * @return the function body that was parsed |
| 4541 */ | 4524 */ |
| 4542 FunctionBody parseFunctionBody(bool mayBeEmpty, ParserErrorCode emptyErrorCode
, bool inExpression) { | 4525 FunctionBody _parseFunctionBody(bool mayBeEmpty, ParserErrorCode emptyErrorCod
e, bool inExpression) { |
| 4543 bool wasInLoop = _inLoop; | 4526 bool wasInLoop = _inLoop; |
| 4544 bool wasInSwitch = _inSwitch; | 4527 bool wasInSwitch = _inSwitch; |
| 4545 _inLoop = false; | 4528 _inLoop = false; |
| 4546 _inSwitch = false; | 4529 _inSwitch = false; |
| 4547 try { | 4530 try { |
| 4548 if (matches(TokenType.SEMICOLON)) { | 4531 if (_matches(TokenType.SEMICOLON)) { |
| 4549 if (!mayBeEmpty) { | 4532 if (!mayBeEmpty) { |
| 4550 reportErrorForCurrentToken(emptyErrorCode, []); | 4533 _reportErrorForCurrentToken(emptyErrorCode, []); |
| 4551 } | 4534 } |
| 4552 return new EmptyFunctionBody(andAdvance); | 4535 return new EmptyFunctionBody(andAdvance); |
| 4553 } else if (matches(TokenType.FUNCTION)) { | 4536 } else if (_matches(TokenType.FUNCTION)) { |
| 4554 Token functionDefinition = andAdvance; | 4537 Token functionDefinition = andAdvance; |
| 4555 Expression expression = parseExpression2(); | 4538 Expression expression = parseExpression2(); |
| 4556 Token semicolon = null; | 4539 Token semicolon = null; |
| 4557 if (!inExpression) { | 4540 if (!inExpression) { |
| 4558 semicolon = expect(TokenType.SEMICOLON); | 4541 semicolon = _expect(TokenType.SEMICOLON); |
| 4559 } | 4542 } |
| 4560 if (!_parseFunctionBodies) { | 4543 if (!_parseFunctionBodies) { |
| 4561 return new EmptyFunctionBody(createSyntheticToken(TokenType.SEMICOLON)
); | 4544 return new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON
)); |
| 4562 } | 4545 } |
| 4563 return new ExpressionFunctionBody(functionDefinition, expression, semico
lon); | 4546 return new ExpressionFunctionBody(functionDefinition, expression, semico
lon); |
| 4564 } else if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 4547 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 4565 if (!_parseFunctionBodies) { | 4548 if (!_parseFunctionBodies) { |
| 4566 skipBlock(); | 4549 _skipBlock(); |
| 4567 return new EmptyFunctionBody(createSyntheticToken(TokenType.SEMICOLON)
); | 4550 return new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON
)); |
| 4568 } | 4551 } |
| 4569 return new BlockFunctionBody(parseBlock()); | 4552 return new BlockFunctionBody(parseBlock()); |
| 4570 } else if (matchesString(_NATIVE)) { | 4553 } else if (_matchesString(_NATIVE)) { |
| 4571 Token nativeToken = andAdvance; | 4554 Token nativeToken = andAdvance; |
| 4572 StringLiteral stringLiteral = null; | 4555 StringLiteral stringLiteral = null; |
| 4573 if (matches(TokenType.STRING)) { | 4556 if (_matches(TokenType.STRING)) { |
| 4574 stringLiteral = parseStringLiteral(); | 4557 stringLiteral = parseStringLiteral(); |
| 4575 } | 4558 } |
| 4576 return new NativeFunctionBody(nativeToken, stringLiteral, expect(TokenTy
pe.SEMICOLON)); | 4559 return new NativeFunctionBody(nativeToken, stringLiteral, _expect(TokenT
ype.SEMICOLON)); |
| 4577 } else { | 4560 } else { |
| 4578 // Invalid function body | 4561 // Invalid function body |
| 4579 reportErrorForCurrentToken(emptyErrorCode, []); | 4562 _reportErrorForCurrentToken(emptyErrorCode, []); |
| 4580 return new EmptyFunctionBody(createSyntheticToken(TokenType.SEMICOLON)); | 4563 return new EmptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON))
; |
| 4581 } | 4564 } |
| 4582 } finally { | 4565 } finally { |
| 4583 _inLoop = wasInLoop; | 4566 _inLoop = wasInLoop; |
| 4584 _inSwitch = wasInSwitch; | 4567 _inSwitch = wasInSwitch; |
| 4585 } | 4568 } |
| 4586 } | 4569 } |
| 4587 | 4570 |
| 4588 /** | 4571 /** |
| 4589 * Parse a function declaration. | 4572 * Parse a function declaration. |
| 4590 * | 4573 * |
| 4591 * <pre> | 4574 * <pre> |
| 4592 * functionDeclaration ::= | 4575 * functionDeclaration ::= |
| 4593 * functionSignature functionBody | 4576 * functionSignature functionBody |
| 4594 * | returnType? getOrSet identifier formalParameterList functionBody | 4577 * | returnType? getOrSet identifier formalParameterList functionBody |
| 4595 * </pre> | 4578 * </pre> |
| 4596 * | 4579 * |
| 4597 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 4580 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 4598 * declaration | 4581 * declaration |
| 4599 * @param externalKeyword the 'external' keyword, or `null` if the function is
not external | 4582 * @param externalKeyword the 'external' keyword, or `null` if the function is
not external |
| 4600 * @param returnType the return type, or `null` if there is no return type | 4583 * @param returnType the return type, or `null` if there is no return type |
| 4601 * @param isStatement `true` if the function declaration is being parsed as a
statement | 4584 * @param isStatement `true` if the function declaration is being parsed as a
statement |
| 4602 * @return the function declaration that was parsed | 4585 * @return the function declaration that was parsed |
| 4603 */ | 4586 */ |
| 4604 FunctionDeclaration parseFunctionDeclaration(CommentAndMetadata commentAndMeta
data, Token externalKeyword, TypeName returnType) { | 4587 FunctionDeclaration _parseFunctionDeclaration(CommentAndMetadata commentAndMet
adata, Token externalKeyword, TypeName returnType) { |
| 4605 Token keyword = null; | 4588 Token keyword = null; |
| 4606 bool isGetter = false; | 4589 bool isGetter = false; |
| 4607 if (matchesKeyword(Keyword.GET) && !tokenMatches(peek(), TokenType.OPEN_PARE
N)) { | 4590 if (_matchesKeyword(Keyword.GET) && !_tokenMatches(_peek(), TokenType.OPEN_P
AREN)) { |
| 4608 keyword = andAdvance; | 4591 keyword = andAdvance; |
| 4609 isGetter = true; | 4592 isGetter = true; |
| 4610 } else if (matchesKeyword(Keyword.SET) && !tokenMatches(peek(), TokenType.OP
EN_PAREN)) { | 4593 } else if (_matchesKeyword(Keyword.SET) && !_tokenMatches(_peek(), TokenType
.OPEN_PAREN)) { |
| 4611 keyword = andAdvance; | 4594 keyword = andAdvance; |
| 4612 } | 4595 } |
| 4613 SimpleIdentifier name = parseSimpleIdentifier(); | 4596 SimpleIdentifier name = parseSimpleIdentifier(); |
| 4614 FormalParameterList parameters = null; | 4597 FormalParameterList parameters = null; |
| 4615 if (!isGetter) { | 4598 if (!isGetter) { |
| 4616 if (matches(TokenType.OPEN_PAREN)) { | 4599 if (_matches(TokenType.OPEN_PAREN)) { |
| 4617 parameters = parseFormalParameterList(); | 4600 parameters = parseFormalParameterList(); |
| 4618 validateFormalParameterList(parameters); | 4601 _validateFormalParameterList(parameters); |
| 4619 } else { | 4602 } else { |
| 4620 reportErrorForCurrentToken(ParserErrorCode.MISSING_FUNCTION_PARAMETERS,
[]); | 4603 _reportErrorForCurrentToken(ParserErrorCode.MISSING_FUNCTION_PARAMETERS,
[]); |
| 4621 } | 4604 } |
| 4622 } else if (matches(TokenType.OPEN_PAREN)) { | 4605 } else if (_matches(TokenType.OPEN_PAREN)) { |
| 4623 reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS, []); | 4606 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS, []); |
| 4624 parseFormalParameterList(); | 4607 parseFormalParameterList(); |
| 4625 } | 4608 } |
| 4626 FunctionBody body; | 4609 FunctionBody body; |
| 4627 if (externalKeyword == null) { | 4610 if (externalKeyword == null) { |
| 4628 body = parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, fal
se); | 4611 body = _parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, fa
lse); |
| 4629 } else { | 4612 } else { |
| 4630 body = new EmptyFunctionBody(expect(TokenType.SEMICOLON)); | 4613 body = new EmptyFunctionBody(_expect(TokenType.SEMICOLON)); |
| 4631 } | 4614 } |
| 4632 // if (!isStatement && matches(TokenType.SEMICOLON)) { | 4615 // if (!isStatement && matches(TokenType.SEMICOLON)) { |
| 4633 // // TODO(brianwilkerson) Improve this error message. | 4616 // // TODO(brianwilkerson) Improve this error message. |
| 4634 // reportError(ParserErrorCode.UNEXPECTED_TOKEN, currentToken.getLexeme
()); | 4617 // reportError(ParserErrorCode.UNEXPECTED_TOKEN, currentToken.getLexeme
()); |
| 4635 // advance(); | 4618 // advance(); |
| 4636 // } | 4619 // } |
| 4637 return new FunctionDeclaration(commentAndMetadata.comment, commentAndMetadat
a.metadata, externalKeyword, returnType, keyword, name, new FunctionExpression(p
arameters, body)); | 4620 return new FunctionDeclaration(commentAndMetadata.comment, commentAndMetadat
a.metadata, externalKeyword, returnType, keyword, name, new FunctionExpression(p
arameters, body)); |
| 4638 } | 4621 } |
| 4639 | 4622 |
| 4640 /** | 4623 /** |
| 4641 * Parse a function declaration statement. | 4624 * Parse a function declaration statement. |
| 4642 * | 4625 * |
| 4643 * <pre> | 4626 * <pre> |
| 4644 * functionDeclarationStatement ::= | 4627 * functionDeclarationStatement ::= |
| 4645 * functionSignature functionBody | 4628 * functionSignature functionBody |
| 4646 * </pre> | 4629 * </pre> |
| 4647 * | 4630 * |
| 4648 * @return the function declaration statement that was parsed | 4631 * @return the function declaration statement that was parsed |
| 4649 */ | 4632 */ |
| 4650 Statement parseFunctionDeclarationStatement() { | 4633 Statement _parseFunctionDeclarationStatement() { |
| 4651 Modifiers modifiers = parseModifiers(); | 4634 Modifiers modifiers = _parseModifiers(); |
| 4652 validateModifiersForFunctionDeclarationStatement(modifiers); | 4635 _validateModifiersForFunctionDeclarationStatement(modifiers); |
| 4653 return parseFunctionDeclarationStatementAfterReturnType(parseCommentAndMetad
ata(), parseOptionalReturnType()); | 4636 return _parseFunctionDeclarationStatementAfterReturnType(_parseCommentAndMet
adata(), _parseOptionalReturnType()); |
| 4654 } | 4637 } |
| 4655 | 4638 |
| 4656 /** | 4639 /** |
| 4657 * Parse a function declaration statement. | 4640 * Parse a function declaration statement. |
| 4658 * | 4641 * |
| 4659 * <pre> | 4642 * <pre> |
| 4660 * functionDeclarationStatement ::= | 4643 * functionDeclarationStatement ::= |
| 4661 * functionSignature functionBody | 4644 * functionSignature functionBody |
| 4662 * </pre> | 4645 * </pre> |
| 4663 * | 4646 * |
| 4664 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 4647 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 4665 * declaration | 4648 * declaration |
| 4666 * @param returnType the return type, or `null` if there is no return type | 4649 * @param returnType the return type, or `null` if there is no return type |
| 4667 * @return the function declaration statement that was parsed | 4650 * @return the function declaration statement that was parsed |
| 4668 */ | 4651 */ |
| 4669 Statement parseFunctionDeclarationStatementAfterReturnType(CommentAndMetadata
commentAndMetadata, TypeName returnType) { | 4652 Statement _parseFunctionDeclarationStatementAfterReturnType(CommentAndMetadata
commentAndMetadata, TypeName returnType) { |
| 4670 FunctionDeclaration declaration = parseFunctionDeclaration(commentAndMetadat
a, null, returnType); | 4653 FunctionDeclaration declaration = _parseFunctionDeclaration(commentAndMetada
ta, null, returnType); |
| 4671 Token propertyKeyword = declaration.propertyKeyword; | 4654 Token propertyKeyword = declaration.propertyKeyword; |
| 4672 if (propertyKeyword != null) { | 4655 if (propertyKeyword != null) { |
| 4673 if (identical((propertyKeyword as KeywordToken).keyword, Keyword.GET)) { | 4656 if (identical((propertyKeyword as KeywordToken).keyword, Keyword.GET)) { |
| 4674 reportErrorForToken(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword,
[]); | 4657 _reportErrorForToken(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword
, []); |
| 4675 } else { | 4658 } else { |
| 4676 reportErrorForToken(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword,
[]); | 4659 _reportErrorForToken(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword
, []); |
| 4677 } | 4660 } |
| 4678 } | 4661 } |
| 4679 return new FunctionDeclarationStatement(declaration); | 4662 return new FunctionDeclarationStatement(declaration); |
| 4680 } | 4663 } |
| 4681 | 4664 |
| 4682 /** | 4665 /** |
| 4683 * Parse a function type alias. | 4666 * Parse a function type alias. |
| 4684 * | 4667 * |
| 4685 * <pre> | 4668 * <pre> |
| 4686 * functionTypeAlias ::= | 4669 * functionTypeAlias ::= |
| 4687 * functionPrefix typeParameterList? formalParameterList ';' | 4670 * functionPrefix typeParameterList? formalParameterList ';' |
| 4688 * | 4671 * |
| 4689 * functionPrefix ::= | 4672 * functionPrefix ::= |
| 4690 * returnType? name | 4673 * returnType? name |
| 4691 * </pre> | 4674 * </pre> |
| 4692 * | 4675 * |
| 4693 * @param commentAndMetadata the metadata to be associated with the member | 4676 * @param commentAndMetadata the metadata to be associated with the member |
| 4694 * @param keyword the token representing the 'typedef' keyword | 4677 * @param keyword the token representing the 'typedef' keyword |
| 4695 * @return the function type alias that was parsed | 4678 * @return the function type alias that was parsed |
| 4696 */ | 4679 */ |
| 4697 FunctionTypeAlias parseFunctionTypeAlias(CommentAndMetadata commentAndMetadata
, Token keyword) { | 4680 FunctionTypeAlias _parseFunctionTypeAlias(CommentAndMetadata commentAndMetadat
a, Token keyword) { |
| 4698 TypeName returnType = null; | 4681 TypeName returnType = null; |
| 4699 if (hasReturnTypeInTypeAlias) { | 4682 if (hasReturnTypeInTypeAlias) { |
| 4700 returnType = parseReturnType(); | 4683 returnType = parseReturnType(); |
| 4701 } | 4684 } |
| 4702 SimpleIdentifier name = parseSimpleIdentifier(); | 4685 SimpleIdentifier name = parseSimpleIdentifier(); |
| 4703 TypeParameterList typeParameters = null; | 4686 TypeParameterList typeParameters = null; |
| 4704 if (matches(TokenType.LT)) { | 4687 if (_matches(TokenType.LT)) { |
| 4705 typeParameters = parseTypeParameterList(); | 4688 typeParameters = parseTypeParameterList(); |
| 4706 } | 4689 } |
| 4707 if (matches(TokenType.SEMICOLON) || matches(TokenType.EOF)) { | 4690 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.EOF)) { |
| 4708 reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, [])
; | 4691 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []
); |
| 4709 FormalParameterList parameters = new FormalParameterList(createSyntheticTo
ken(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken(TokenType.CLOS
E_PAREN)); | 4692 FormalParameterList parameters = new FormalParameterList(_createSyntheticT
oken(TokenType.OPEN_PAREN), null, null, null, _createSyntheticToken(TokenType.CL
OSE_PAREN)); |
| 4710 Token semicolon = expect(TokenType.SEMICOLON); | 4693 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4711 return new FunctionTypeAlias(commentAndMetadata.comment, commentAndMetadat
a.metadata, keyword, returnType, name, typeParameters, parameters, semicolon); | 4694 return new FunctionTypeAlias(commentAndMetadata.comment, commentAndMetadat
a.metadata, keyword, returnType, name, typeParameters, parameters, semicolon); |
| 4712 } else if (!matches(TokenType.OPEN_PAREN)) { | 4695 } else if (!_matches(TokenType.OPEN_PAREN)) { |
| 4713 reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, [])
; | 4696 _reportErrorForCurrentToken(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []
); |
| 4714 // TODO(brianwilkerson) Recover from this error. At the very least we shou
ld skip to the start | 4697 // TODO(brianwilkerson) Recover from this error. At the very least we shou
ld skip to the start |
| 4715 // of the next valid compilation unit member, allowing for the possibility
of finding the | 4698 // of the next valid compilation unit member, allowing for the possibility
of finding the |
| 4716 // typedef parameters before that point. | 4699 // typedef parameters before that point. |
| 4717 return new FunctionTypeAlias(commentAndMetadata.comment, commentAndMetadat
a.metadata, keyword, returnType, name, typeParameters, new FormalParameterList(c
reateSyntheticToken(TokenType.OPEN_PAREN), null, null, null, createSyntheticToke
n(TokenType.CLOSE_PAREN)), createSyntheticToken(TokenType.SEMICOLON)); | 4700 return new FunctionTypeAlias(commentAndMetadata.comment, commentAndMetadat
a.metadata, keyword, returnType, name, typeParameters, new FormalParameterList(_
createSyntheticToken(TokenType.OPEN_PAREN), null, null, null, _createSyntheticTo
ken(TokenType.CLOSE_PAREN)), _createSyntheticToken(TokenType.SEMICOLON)); |
| 4718 } | 4701 } |
| 4719 FormalParameterList parameters = parseFormalParameterList(); | 4702 FormalParameterList parameters = parseFormalParameterList(); |
| 4720 validateFormalParameterList(parameters); | 4703 _validateFormalParameterList(parameters); |
| 4721 Token semicolon = expect(TokenType.SEMICOLON); | 4704 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4722 return new FunctionTypeAlias(commentAndMetadata.comment, commentAndMetadata.
metadata, keyword, returnType, name, typeParameters, parameters, semicolon); | 4705 return new FunctionTypeAlias(commentAndMetadata.comment, commentAndMetadata.
metadata, keyword, returnType, name, typeParameters, parameters, semicolon); |
| 4723 } | 4706 } |
| 4724 | 4707 |
| 4725 /** | 4708 /** |
| 4726 * Parse a getter. | 4709 * Parse a getter. |
| 4727 * | 4710 * |
| 4728 * <pre> | 4711 * <pre> |
| 4729 * getter ::= | 4712 * getter ::= |
| 4730 * getterSignature functionBody? | 4713 * getterSignature functionBody? |
| 4731 * | 4714 * |
| 4732 * getterSignature ::= | 4715 * getterSignature ::= |
| 4733 * 'external'? 'static'? returnType? 'get' identifier | 4716 * 'external'? 'static'? returnType? 'get' identifier |
| 4734 * </pre> | 4717 * </pre> |
| 4735 * | 4718 * |
| 4736 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 4719 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 4737 * declaration | 4720 * declaration |
| 4738 * @param externalKeyword the 'external' token | 4721 * @param externalKeyword the 'external' token |
| 4739 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic | 4722 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic |
| 4740 * @param the return type that has already been parsed, or `null` if there was
no return | 4723 * @param the return type that has already been parsed, or `null` if there was
no return |
| 4741 * type | 4724 * type |
| 4742 * @return the getter that was parsed | 4725 * @return the getter that was parsed |
| 4743 */ | 4726 */ |
| 4744 MethodDeclaration parseGetter(CommentAndMetadata commentAndMetadata, Token ext
ernalKeyword, Token staticKeyword, TypeName returnType) { | 4727 MethodDeclaration _parseGetter(CommentAndMetadata commentAndMetadata, Token ex
ternalKeyword, Token staticKeyword, TypeName returnType) { |
| 4745 Token propertyKeyword = expectKeyword(Keyword.GET); | 4728 Token propertyKeyword = _expectKeyword(Keyword.GET); |
| 4746 SimpleIdentifier name = parseSimpleIdentifier(); | 4729 SimpleIdentifier name = parseSimpleIdentifier(); |
| 4747 if (matches(TokenType.OPEN_PAREN) && tokenMatches(peek(), TokenType.CLOSE_PA
REN)) { | 4730 if (_matches(TokenType.OPEN_PAREN) && _tokenMatches(_peek(), TokenType.CLOSE
_PAREN)) { |
| 4748 reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS, []); | 4731 _reportErrorForCurrentToken(ParserErrorCode.GETTER_WITH_PARAMETERS, []); |
| 4749 advance(); | 4732 _advance(); |
| 4750 advance(); | 4733 _advance(); |
| 4751 } | 4734 } |
| 4752 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo
rd == null, ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, false); | 4735 FunctionBody body = _parseFunctionBody(externalKeyword != null || staticKeyw
ord == null, ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, false); |
| 4753 if (externalKeyword != null && body is! EmptyFunctionBody) { | 4736 if (externalKeyword != null && body is! EmptyFunctionBody) { |
| 4754 reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, []); | 4737 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, [])
; |
| 4755 } | 4738 } |
| 4756 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null, nam
e, null, body); | 4739 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null, nam
e, null, body); |
| 4757 } | 4740 } |
| 4758 | 4741 |
| 4759 /** | 4742 /** |
| 4760 * Parse a list of identifiers. | 4743 * Parse a list of identifiers. |
| 4761 * | 4744 * |
| 4762 * <pre> | 4745 * <pre> |
| 4763 * identifierList ::= | 4746 * identifierList ::= |
| 4764 * identifier (',' identifier)* | 4747 * identifier (',' identifier)* |
| 4765 * </pre> | 4748 * </pre> |
| 4766 * | 4749 * |
| 4767 * @return the list of identifiers that were parsed | 4750 * @return the list of identifiers that were parsed |
| 4768 */ | 4751 */ |
| 4769 List<SimpleIdentifier> parseIdentifierList() { | 4752 List<SimpleIdentifier> _parseIdentifierList() { |
| 4770 List<SimpleIdentifier> identifiers = new List<SimpleIdentifier>(); | 4753 List<SimpleIdentifier> identifiers = new List<SimpleIdentifier>(); |
| 4771 identifiers.add(parseSimpleIdentifier()); | 4754 identifiers.add(parseSimpleIdentifier()); |
| 4772 while (matches(TokenType.COMMA)) { | 4755 while (_matches(TokenType.COMMA)) { |
| 4773 advance(); | 4756 _advance(); |
| 4774 identifiers.add(parseSimpleIdentifier()); | 4757 identifiers.add(parseSimpleIdentifier()); |
| 4775 } | 4758 } |
| 4776 return identifiers; | 4759 return identifiers; |
| 4777 } | 4760 } |
| 4778 | 4761 |
| 4779 /** | 4762 /** |
| 4780 * Parse an if statement. | 4763 * Parse an if statement. |
| 4781 * | 4764 * |
| 4782 * <pre> | 4765 * <pre> |
| 4783 * ifStatement ::= | 4766 * ifStatement ::= |
| 4784 * 'if' '(' expression ')' statement ('else' statement)? | 4767 * 'if' '(' expression ')' statement ('else' statement)? |
| 4785 * </pre> | 4768 * </pre> |
| 4786 * | 4769 * |
| 4787 * @return the if statement that was parsed | 4770 * @return the if statement that was parsed |
| 4788 */ | 4771 */ |
| 4789 Statement parseIfStatement() { | 4772 Statement _parseIfStatement() { |
| 4790 Token ifKeyword = expectKeyword(Keyword.IF); | 4773 Token ifKeyword = _expectKeyword(Keyword.IF); |
| 4791 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 4774 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 4792 Expression condition = parseExpression2(); | 4775 Expression condition = parseExpression2(); |
| 4793 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 4776 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 4794 Statement thenStatement = parseStatement2(); | 4777 Statement thenStatement = parseStatement2(); |
| 4795 Token elseKeyword = null; | 4778 Token elseKeyword = null; |
| 4796 Statement elseStatement = null; | 4779 Statement elseStatement = null; |
| 4797 if (matchesKeyword(Keyword.ELSE)) { | 4780 if (_matchesKeyword(Keyword.ELSE)) { |
| 4798 elseKeyword = andAdvance; | 4781 elseKeyword = andAdvance; |
| 4799 elseStatement = parseStatement2(); | 4782 elseStatement = parseStatement2(); |
| 4800 } | 4783 } |
| 4801 return new IfStatement(ifKeyword, leftParenthesis, condition, rightParenthes
is, thenStatement, elseKeyword, elseStatement); | 4784 return new IfStatement(ifKeyword, leftParenthesis, condition, rightParenthes
is, thenStatement, elseKeyword, elseStatement); |
| 4802 } | 4785 } |
| 4803 | 4786 |
| 4804 /** | 4787 /** |
| 4805 * Parse an import directive. | 4788 * Parse an import directive. |
| 4806 * | 4789 * |
| 4807 * <pre> | 4790 * <pre> |
| 4808 * importDirective ::= | 4791 * importDirective ::= |
| 4809 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' | 4792 * metadata 'import' stringLiteral ('as' identifier)? combinator*';' |
| 4810 * </pre> | 4793 * </pre> |
| 4811 * | 4794 * |
| 4812 * @param commentAndMetadata the metadata to be associated with the directive | 4795 * @param commentAndMetadata the metadata to be associated with the directive |
| 4813 * @return the import directive that was parsed | 4796 * @return the import directive that was parsed |
| 4814 */ | 4797 */ |
| 4815 ImportDirective parseImportDirective(CommentAndMetadata commentAndMetadata) { | 4798 ImportDirective _parseImportDirective(CommentAndMetadata commentAndMetadata) { |
| 4816 Token importKeyword = expectKeyword(Keyword.IMPORT); | 4799 Token importKeyword = _expectKeyword(Keyword.IMPORT); |
| 4817 StringLiteral libraryUri = parseStringLiteral(); | 4800 StringLiteral libraryUri = parseStringLiteral(); |
| 4818 Token asToken = null; | 4801 Token asToken = null; |
| 4819 SimpleIdentifier prefix = null; | 4802 SimpleIdentifier prefix = null; |
| 4820 if (matchesKeyword(Keyword.AS)) { | 4803 if (_matchesKeyword(Keyword.AS)) { |
| 4821 asToken = andAdvance; | 4804 asToken = andAdvance; |
| 4822 prefix = parseSimpleIdentifier(); | 4805 prefix = parseSimpleIdentifier(); |
| 4823 } | 4806 } |
| 4824 List<Combinator> combinators = parseCombinators(); | 4807 List<Combinator> combinators = _parseCombinators(); |
| 4825 Token semicolon = expectSemicolon(); | 4808 Token semicolon = _expectSemicolon(); |
| 4826 return new ImportDirective(commentAndMetadata.comment, commentAndMetadata.me
tadata, importKeyword, libraryUri, asToken, prefix, combinators, semicolon); | 4809 return new ImportDirective(commentAndMetadata.comment, commentAndMetadata.me
tadata, importKeyword, libraryUri, asToken, prefix, combinators, semicolon); |
| 4827 } | 4810 } |
| 4828 | 4811 |
| 4829 /** | 4812 /** |
| 4830 * Parse a list of initialized identifiers. | 4813 * Parse a list of initialized identifiers. |
| 4831 * | 4814 * |
| 4832 * <pre> | 4815 * <pre> |
| 4833 * ?? ::= | 4816 * ?? ::= |
| 4834 * 'static'? ('var' | type) initializedIdentifierList ';' | 4817 * 'static'? ('var' | type) initializedIdentifierList ';' |
| 4835 * | 'final' type? initializedIdentifierList ';' | 4818 * | 'final' type? initializedIdentifierList ';' |
| 4836 * | 4819 * |
| 4837 * initializedIdentifierList ::= | 4820 * initializedIdentifierList ::= |
| 4838 * initializedIdentifier (',' initializedIdentifier)* | 4821 * initializedIdentifier (',' initializedIdentifier)* |
| 4839 * | 4822 * |
| 4840 * initializedIdentifier ::= | 4823 * initializedIdentifier ::= |
| 4841 * identifier ('=' expression)? | 4824 * identifier ('=' expression)? |
| 4842 * </pre> | 4825 * </pre> |
| 4843 * | 4826 * |
| 4844 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 4827 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 4845 * declaration | 4828 * declaration |
| 4846 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic | 4829 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic |
| 4847 * @param keyword the token representing the 'final', 'const' or 'var' keyword
, or `null` if | 4830 * @param keyword the token representing the 'final', 'const' or 'var' keyword
, or `null` if |
| 4848 * there is no keyword | 4831 * there is no keyword |
| 4849 * @param type the type that has already been parsed, or `null` if 'var' was p
rovided | 4832 * @param type the type that has already been parsed, or `null` if 'var' was p
rovided |
| 4850 * @return the getter that was parsed | 4833 * @return the getter that was parsed |
| 4851 */ | 4834 */ |
| 4852 FieldDeclaration parseInitializedIdentifierList(CommentAndMetadata commentAndM
etadata, Token staticKeyword, Token keyword, TypeName type) { | 4835 FieldDeclaration _parseInitializedIdentifierList(CommentAndMetadata commentAnd
Metadata, Token staticKeyword, Token keyword, TypeName type) { |
| 4853 VariableDeclarationList fieldList = parseVariableDeclarationListAfterType(nu
ll, keyword, type); | 4836 VariableDeclarationList fieldList = _parseVariableDeclarationListAfterType(n
ull, keyword, type); |
| 4854 return new FieldDeclaration(commentAndMetadata.comment, commentAndMetadata.m
etadata, staticKeyword, fieldList, expect(TokenType.SEMICOLON)); | 4837 return new FieldDeclaration(commentAndMetadata.comment, commentAndMetadata.m
etadata, staticKeyword, fieldList, _expect(TokenType.SEMICOLON)); |
| 4855 } | 4838 } |
| 4856 | 4839 |
| 4857 /** | 4840 /** |
| 4858 * Parse an instance creation expression. | 4841 * Parse an instance creation expression. |
| 4859 * | 4842 * |
| 4860 * <pre> | 4843 * <pre> |
| 4861 * instanceCreationExpression ::= | 4844 * instanceCreationExpression ::= |
| 4862 * ('new' | 'const') type ('.' identifier)? argumentList | 4845 * ('new' | 'const') type ('.' identifier)? argumentList |
| 4863 * </pre> | 4846 * </pre> |
| 4864 * | 4847 * |
| 4865 * @param keyword the 'new' or 'const' keyword that introduces the expression | 4848 * @param keyword the 'new' or 'const' keyword that introduces the expression |
| 4866 * @return the instance creation expression that was parsed | 4849 * @return the instance creation expression that was parsed |
| 4867 */ | 4850 */ |
| 4868 InstanceCreationExpression parseInstanceCreationExpression(Token keyword) { | 4851 InstanceCreationExpression _parseInstanceCreationExpression(Token keyword) { |
| 4869 ConstructorName constructorName = parseConstructorName(); | 4852 ConstructorName constructorName = parseConstructorName(); |
| 4870 ArgumentList argumentList = parseArgumentList(); | 4853 ArgumentList argumentList = parseArgumentList(); |
| 4871 return new InstanceCreationExpression(keyword, constructorName, argumentList
); | 4854 return new InstanceCreationExpression(keyword, constructorName, argumentList
); |
| 4872 } | 4855 } |
| 4873 | 4856 |
| 4874 /** | 4857 /** |
| 4875 * Parse a library directive. | 4858 * Parse a library directive. |
| 4876 * | 4859 * |
| 4877 * <pre> | 4860 * <pre> |
| 4878 * libraryDirective ::= | 4861 * libraryDirective ::= |
| 4879 * metadata 'library' identifier ';' | 4862 * metadata 'library' identifier ';' |
| 4880 * </pre> | 4863 * </pre> |
| 4881 * | 4864 * |
| 4882 * @param commentAndMetadata the metadata to be associated with the directive | 4865 * @param commentAndMetadata the metadata to be associated with the directive |
| 4883 * @return the library directive that was parsed | 4866 * @return the library directive that was parsed |
| 4884 */ | 4867 */ |
| 4885 LibraryDirective parseLibraryDirective(CommentAndMetadata commentAndMetadata)
{ | 4868 LibraryDirective _parseLibraryDirective(CommentAndMetadata commentAndMetadata)
{ |
| 4886 Token keyword = expectKeyword(Keyword.LIBRARY); | 4869 Token keyword = _expectKeyword(Keyword.LIBRARY); |
| 4887 LibraryIdentifier libraryName = parseLibraryName(ParserErrorCode.MISSING_NAM
E_IN_LIBRARY_DIRECTIVE, keyword); | 4870 LibraryIdentifier libraryName = _parseLibraryName(ParserErrorCode.MISSING_NA
ME_IN_LIBRARY_DIRECTIVE, keyword); |
| 4888 Token semicolon = expect(TokenType.SEMICOLON); | 4871 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4889 return new LibraryDirective(commentAndMetadata.comment, commentAndMetadata.m
etadata, keyword, libraryName, semicolon); | 4872 return new LibraryDirective(commentAndMetadata.comment, commentAndMetadata.m
etadata, keyword, libraryName, semicolon); |
| 4890 } | 4873 } |
| 4891 | 4874 |
| 4892 /** | 4875 /** |
| 4893 * Parse a library name. | 4876 * Parse a library name. |
| 4894 * | 4877 * |
| 4895 * <pre> | 4878 * <pre> |
| 4896 * libraryName ::= | 4879 * libraryName ::= |
| 4897 * libraryIdentifier | 4880 * libraryIdentifier |
| 4898 * </pre> | 4881 * </pre> |
| 4899 * | 4882 * |
| 4900 * @param missingNameError the error code to be used if the library name is mi
ssing | 4883 * @param missingNameError the error code to be used if the library name is mi
ssing |
| 4901 * @param missingNameToken the token associated with the error produced if the
library name is | 4884 * @param missingNameToken the token associated with the error produced if the
library name is |
| 4902 * missing | 4885 * missing |
| 4903 * @return the library name that was parsed | 4886 * @return the library name that was parsed |
| 4904 */ | 4887 */ |
| 4905 LibraryIdentifier parseLibraryName(ParserErrorCode missingNameError, Token mis
singNameToken) { | 4888 LibraryIdentifier _parseLibraryName(ParserErrorCode missingNameError, Token mi
ssingNameToken) { |
| 4906 if (matchesIdentifier()) { | 4889 if (_matchesIdentifier()) { |
| 4907 return parseLibraryIdentifier(); | 4890 return parseLibraryIdentifier(); |
| 4908 } else if (matches(TokenType.STRING)) { | 4891 } else if (_matches(TokenType.STRING)) { |
| 4909 // TODO(brianwilkerson) Recovery: This should be extended to handle arbitr
ary tokens until we | 4892 // TODO(brianwilkerson) Recovery: This should be extended to handle arbitr
ary tokens until we |
| 4910 // can find a token that can start a compilation unit member. | 4893 // can find a token that can start a compilation unit member. |
| 4911 StringLiteral string = parseStringLiteral(); | 4894 StringLiteral string = parseStringLiteral(); |
| 4912 reportErrorForNode(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string, []
); | 4895 _reportErrorForNode(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string, [
]); |
| 4913 } else { | 4896 } else { |
| 4914 reportErrorForToken(missingNameError, missingNameToken, []); | 4897 _reportErrorForToken(missingNameError, missingNameToken, []); |
| 4915 } | 4898 } |
| 4916 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); | 4899 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); |
| 4917 components.add(createSyntheticIdentifier()); | 4900 components.add(_createSyntheticIdentifier()); |
| 4918 return new LibraryIdentifier(components); | 4901 return new LibraryIdentifier(components); |
| 4919 } | 4902 } |
| 4920 | 4903 |
| 4921 /** | 4904 /** |
| 4922 * Parse a list literal. | 4905 * Parse a list literal. |
| 4923 * | 4906 * |
| 4924 * <pre> | 4907 * <pre> |
| 4925 * listLiteral ::= | 4908 * listLiteral ::= |
| 4926 * 'const'? typeArguments? '[' (expressionList ','?)? ']' | 4909 * 'const'? typeArguments? '[' (expressionList ','?)? ']' |
| 4927 * </pre> | 4910 * </pre> |
| 4928 * | 4911 * |
| 4929 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is | 4912 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is |
| 4930 * no modifier | 4913 * no modifier |
| 4931 * @param typeArguments the type arguments appearing before the literal, or `n
ull` if there | 4914 * @param typeArguments the type arguments appearing before the literal, or `n
ull` if there |
| 4932 * are no type arguments | 4915 * are no type arguments |
| 4933 * @return the list literal that was parsed | 4916 * @return the list literal that was parsed |
| 4934 */ | 4917 */ |
| 4935 ListLiteral parseListLiteral(Token modifier, TypeArgumentList typeArguments) { | 4918 ListLiteral _parseListLiteral(Token modifier, TypeArgumentList typeArguments)
{ |
| 4936 // may be empty list literal | 4919 // may be empty list literal |
| 4937 if (matches(TokenType.INDEX)) { | 4920 if (_matches(TokenType.INDEX)) { |
| 4938 BeginToken leftBracket = new BeginToken(TokenType.OPEN_SQUARE_BRACKET, _cu
rrentToken.offset); | 4921 BeginToken leftBracket = new BeginToken(TokenType.OPEN_SQUARE_BRACKET, _cu
rrentToken.offset); |
| 4939 Token rightBracket = new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentTok
en.offset + 1); | 4922 Token rightBracket = new Token(TokenType.CLOSE_SQUARE_BRACKET, _currentTok
en.offset + 1); |
| 4940 leftBracket.endToken = rightBracket; | 4923 leftBracket.endToken = rightBracket; |
| 4941 rightBracket.setNext(_currentToken.next); | 4924 rightBracket.setNext(_currentToken.next); |
| 4942 leftBracket.setNext(rightBracket); | 4925 leftBracket.setNext(rightBracket); |
| 4943 _currentToken.previous.setNext(leftBracket); | 4926 _currentToken.previous.setNext(leftBracket); |
| 4944 _currentToken = _currentToken.next; | 4927 _currentToken = _currentToken.next; |
| 4945 return new ListLiteral(modifier, typeArguments, leftBracket, null, rightBr
acket); | 4928 return new ListLiteral(modifier, typeArguments, leftBracket, null, rightBr
acket); |
| 4946 } | 4929 } |
| 4947 // open | 4930 // open |
| 4948 Token leftBracket = expect(TokenType.OPEN_SQUARE_BRACKET); | 4931 Token leftBracket = _expect(TokenType.OPEN_SQUARE_BRACKET); |
| 4949 if (matches(TokenType.CLOSE_SQUARE_BRACKET)) { | 4932 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) { |
| 4950 return new ListLiteral(modifier, typeArguments, leftBracket, null, andAdva
nce); | 4933 return new ListLiteral(modifier, typeArguments, leftBracket, null, andAdva
nce); |
| 4951 } | 4934 } |
| 4952 List<Expression> elements = new List<Expression>(); | 4935 List<Expression> elements = new List<Expression>(); |
| 4953 elements.add(parseExpression2()); | 4936 elements.add(parseExpression2()); |
| 4954 while (optional(TokenType.COMMA)) { | 4937 while (_optional(TokenType.COMMA)) { |
| 4955 if (matches(TokenType.CLOSE_SQUARE_BRACKET)) { | 4938 if (_matches(TokenType.CLOSE_SQUARE_BRACKET)) { |
| 4956 return new ListLiteral(modifier, typeArguments, leftBracket, elements, a
ndAdvance); | 4939 return new ListLiteral(modifier, typeArguments, leftBracket, elements, a
ndAdvance); |
| 4957 } | 4940 } |
| 4958 elements.add(parseExpression2()); | 4941 elements.add(parseExpression2()); |
| 4959 } | 4942 } |
| 4960 Token rightBracket = expect(TokenType.CLOSE_SQUARE_BRACKET); | 4943 Token rightBracket = _expect(TokenType.CLOSE_SQUARE_BRACKET); |
| 4961 return new ListLiteral(modifier, typeArguments, leftBracket, elements, right
Bracket); | 4944 return new ListLiteral(modifier, typeArguments, leftBracket, elements, right
Bracket); |
| 4962 } | 4945 } |
| 4963 | 4946 |
| 4964 /** | 4947 /** |
| 4965 * Parse a list or map literal. | 4948 * Parse a list or map literal. |
| 4966 * | 4949 * |
| 4967 * <pre> | 4950 * <pre> |
| 4968 * listOrMapLiteral ::= | 4951 * listOrMapLiteral ::= |
| 4969 * listLiteral | 4952 * listLiteral |
| 4970 * | mapLiteral | 4953 * | mapLiteral |
| 4971 * </pre> | 4954 * </pre> |
| 4972 * | 4955 * |
| 4973 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is | 4956 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is |
| 4974 * no modifier | 4957 * no modifier |
| 4975 * @return the list or map literal that was parsed | 4958 * @return the list or map literal that was parsed |
| 4976 */ | 4959 */ |
| 4977 TypedLiteral parseListOrMapLiteral(Token modifier) { | 4960 TypedLiteral _parseListOrMapLiteral(Token modifier) { |
| 4978 TypeArgumentList typeArguments = null; | 4961 TypeArgumentList typeArguments = null; |
| 4979 if (matches(TokenType.LT)) { | 4962 if (_matches(TokenType.LT)) { |
| 4980 typeArguments = parseTypeArgumentList(); | 4963 typeArguments = parseTypeArgumentList(); |
| 4981 } | 4964 } |
| 4982 if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 4965 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 4983 return parseMapLiteral(modifier, typeArguments); | 4966 return _parseMapLiteral(modifier, typeArguments); |
| 4984 } else if (matches(TokenType.OPEN_SQUARE_BRACKET) || matches(TokenType.INDEX
)) { | 4967 } else if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.IND
EX)) { |
| 4985 return parseListLiteral(modifier, typeArguments); | 4968 return _parseListLiteral(modifier, typeArguments); |
| 4986 } | 4969 } |
| 4987 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, [])
; | 4970 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, []
); |
| 4988 return new ListLiteral(modifier, typeArguments, createSyntheticToken(TokenTy
pe.OPEN_SQUARE_BRACKET), null, createSyntheticToken(TokenType.CLOSE_SQUARE_BRACK
ET)); | 4971 return new ListLiteral(modifier, typeArguments, _createSyntheticToken(TokenT
ype.OPEN_SQUARE_BRACKET), null, _createSyntheticToken(TokenType.CLOSE_SQUARE_BRA
CKET)); |
| 4989 } | 4972 } |
| 4990 | 4973 |
| 4991 /** | 4974 /** |
| 4992 * Parse a logical and expression. | 4975 * Parse a logical and expression. |
| 4993 * | 4976 * |
| 4994 * <pre> | 4977 * <pre> |
| 4995 * logicalAndExpression ::= | 4978 * logicalAndExpression ::= |
| 4996 * equalityExpression ('&&' equalityExpression)* | 4979 * equalityExpression ('&&' equalityExpression)* |
| 4997 * </pre> | 4980 * </pre> |
| 4998 * | 4981 * |
| 4999 * @return the logical and expression that was parsed | 4982 * @return the logical and expression that was parsed |
| 5000 */ | 4983 */ |
| 5001 Expression parseLogicalAndExpression() { | 4984 Expression _parseLogicalAndExpression() { |
| 5002 Expression expression = parseEqualityExpression(); | 4985 Expression expression = _parseEqualityExpression(); |
| 5003 while (matches(TokenType.AMPERSAND_AMPERSAND)) { | 4986 while (_matches(TokenType.AMPERSAND_AMPERSAND)) { |
| 5004 Token operator = andAdvance; | 4987 Token operator = andAdvance; |
| 5005 expression = new BinaryExpression(expression, operator, parseEqualityExpre
ssion()); | 4988 expression = new BinaryExpression(expression, operator, _parseEqualityExpr
ession()); |
| 5006 } | 4989 } |
| 5007 return expression; | 4990 return expression; |
| 5008 } | 4991 } |
| 5009 | 4992 |
| 5010 /** | 4993 /** |
| 5011 * Parse a map literal. | 4994 * Parse a map literal. |
| 5012 * | 4995 * |
| 5013 * <pre> | 4996 * <pre> |
| 5014 * mapLiteral ::= | 4997 * mapLiteral ::= |
| 5015 * 'const'? typeArguments? '{' (mapLiteralEntry (',' mapLiteralEntry)* ','
?)? '}' | 4998 * 'const'? typeArguments? '{' (mapLiteralEntry (',' mapLiteralEntry)* ','
?)? '}' |
| 5016 * </pre> | 4999 * </pre> |
| 5017 * | 5000 * |
| 5018 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is | 5001 * @param modifier the 'const' modifier appearing before the literal, or `null
` if there is |
| 5019 * no modifier | 5002 * no modifier |
| 5020 * @param typeArguments the type arguments that were declared, or `null` if th
ere are no | 5003 * @param typeArguments the type arguments that were declared, or `null` if th
ere are no |
| 5021 * type arguments | 5004 * type arguments |
| 5022 * @return the map literal that was parsed | 5005 * @return the map literal that was parsed |
| 5023 */ | 5006 */ |
| 5024 MapLiteral parseMapLiteral(Token modifier, TypeArgumentList typeArguments) { | 5007 MapLiteral _parseMapLiteral(Token modifier, TypeArgumentList typeArguments) { |
| 5025 Token leftBracket = expect(TokenType.OPEN_CURLY_BRACKET); | 5008 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); |
| 5026 List<MapLiteralEntry> entries = new List<MapLiteralEntry>(); | 5009 List<MapLiteralEntry> entries = new List<MapLiteralEntry>(); |
| 5027 if (matches(TokenType.CLOSE_CURLY_BRACKET)) { | 5010 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
| 5028 return new MapLiteral(modifier, typeArguments, leftBracket, entries, andAd
vance); | 5011 return new MapLiteral(modifier, typeArguments, leftBracket, entries, andAd
vance); |
| 5029 } | 5012 } |
| 5030 entries.add(parseMapLiteralEntry()); | 5013 entries.add(parseMapLiteralEntry()); |
| 5031 while (optional(TokenType.COMMA)) { | 5014 while (_optional(TokenType.COMMA)) { |
| 5032 if (matches(TokenType.CLOSE_CURLY_BRACKET)) { | 5015 if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
| 5033 return new MapLiteral(modifier, typeArguments, leftBracket, entries, and
Advance); | 5016 return new MapLiteral(modifier, typeArguments, leftBracket, entries, and
Advance); |
| 5034 } | 5017 } |
| 5035 entries.add(parseMapLiteralEntry()); | 5018 entries.add(parseMapLiteralEntry()); |
| 5036 } | 5019 } |
| 5037 Token rightBracket = expect(TokenType.CLOSE_CURLY_BRACKET); | 5020 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
| 5038 return new MapLiteral(modifier, typeArguments, leftBracket, entries, rightBr
acket); | 5021 return new MapLiteral(modifier, typeArguments, leftBracket, entries, rightBr
acket); |
| 5039 } | 5022 } |
| 5040 | 5023 |
| 5041 /** | 5024 /** |
| 5042 * Parse a method declaration. | 5025 * Parse a method declaration. |
| 5043 * | 5026 * |
| 5044 * <pre> | 5027 * <pre> |
| 5045 * functionDeclaration ::= | 5028 * functionDeclaration ::= |
| 5046 * ('external' 'static'?)? functionSignature functionBody | 5029 * ('external' 'static'?)? functionSignature functionBody |
| 5047 * | 'external'? functionSignature ';' | 5030 * | 'external'? functionSignature ';' |
| 5048 * </pre> | 5031 * </pre> |
| 5049 * | 5032 * |
| 5050 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 5033 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 5051 * declaration | 5034 * declaration |
| 5052 * @param externalKeyword the 'external' token | 5035 * @param externalKeyword the 'external' token |
| 5053 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic | 5036 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic |
| 5054 * @param returnType the return type of the method | 5037 * @param returnType the return type of the method |
| 5055 * @param name the name of the method | 5038 * @param name the name of the method |
| 5056 * @param parameters the parameters to the method | 5039 * @param parameters the parameters to the method |
| 5057 * @return the method declaration that was parsed | 5040 * @return the method declaration that was parsed |
| 5058 */ | 5041 */ |
| 5059 MethodDeclaration parseMethodDeclarationAfterParameters(CommentAndMetadata com
mentAndMetadata, Token externalKeyword, Token staticKeyword, TypeName returnType
, SimpleIdentifier name, FormalParameterList parameters) { | 5042 MethodDeclaration _parseMethodDeclarationAfterParameters(CommentAndMetadata co
mmentAndMetadata, Token externalKeyword, Token staticKeyword, TypeName returnTyp
e, SimpleIdentifier name, FormalParameterList parameters) { |
| 5060 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo
rd == null, ParserErrorCode.MISSING_FUNCTION_BODY, false); | 5043 FunctionBody body = _parseFunctionBody(externalKeyword != null || staticKeyw
ord == null, ParserErrorCode.MISSING_FUNCTION_BODY, false); |
| 5061 if (externalKeyword != null) { | 5044 if (externalKeyword != null) { |
| 5062 if (body is! EmptyFunctionBody) { | 5045 if (body is! EmptyFunctionBody) { |
| 5063 reportErrorForNode(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body, []); | 5046 _reportErrorForNode(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body, [])
; |
| 5064 } | 5047 } |
| 5065 } else if (staticKeyword != null) { | 5048 } else if (staticKeyword != null) { |
| 5066 if (body is EmptyFunctionBody) { | 5049 if (body is EmptyFunctionBody) { |
| 5067 reportErrorForNode(ParserErrorCode.ABSTRACT_STATIC_METHOD, body, []); | 5050 _reportErrorForNode(ParserErrorCode.ABSTRACT_STATIC_METHOD, body, []); |
| 5068 } | 5051 } |
| 5069 } | 5052 } |
| 5070 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, staticKeyword, returnType, null, null, name, paramete
rs, body); | 5053 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, staticKeyword, returnType, null, null, name, paramete
rs, body); |
| 5071 } | 5054 } |
| 5072 | 5055 |
| 5073 /** | 5056 /** |
| 5074 * Parse a method declaration. | 5057 * Parse a method declaration. |
| 5075 * | 5058 * |
| 5076 * <pre> | 5059 * <pre> |
| 5077 * functionDeclaration ::= | 5060 * functionDeclaration ::= |
| 5078 * 'external'? 'static'? functionSignature functionBody | 5061 * 'external'? 'static'? functionSignature functionBody |
| 5079 * | 'external'? functionSignature ';' | 5062 * | 'external'? functionSignature ';' |
| 5080 * </pre> | 5063 * </pre> |
| 5081 * | 5064 * |
| 5082 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 5065 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 5083 * declaration | 5066 * declaration |
| 5084 * @param externalKeyword the 'external' token | 5067 * @param externalKeyword the 'external' token |
| 5085 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic | 5068 * @param staticKeyword the static keyword, or `null` if the getter is not sta
tic |
| 5086 * @param returnType the return type of the method | 5069 * @param returnType the return type of the method |
| 5087 * @return the method declaration that was parsed | 5070 * @return the method declaration that was parsed |
| 5088 */ | 5071 */ |
| 5089 MethodDeclaration parseMethodDeclarationAfterReturnType(CommentAndMetadata com
mentAndMetadata, Token externalKeyword, Token staticKeyword, TypeName returnType
) { | 5072 MethodDeclaration _parseMethodDeclarationAfterReturnType(CommentAndMetadata co
mmentAndMetadata, Token externalKeyword, Token staticKeyword, TypeName returnTyp
e) { |
| 5090 SimpleIdentifier methodName = parseSimpleIdentifier(); | 5073 SimpleIdentifier methodName = parseSimpleIdentifier(); |
| 5091 FormalParameterList parameters = parseFormalParameterList(); | 5074 FormalParameterList parameters = parseFormalParameterList(); |
| 5092 validateFormalParameterList(parameters); | 5075 _validateFormalParameterList(parameters); |
| 5093 return parseMethodDeclarationAfterParameters(commentAndMetadata, externalKey
word, staticKeyword, returnType, methodName, parameters); | 5076 return _parseMethodDeclarationAfterParameters(commentAndMetadata, externalKe
yword, staticKeyword, returnType, methodName, parameters); |
| 5094 } | 5077 } |
| 5095 | 5078 |
| 5096 /** | 5079 /** |
| 5097 * Parse the modifiers preceding a declaration. This method allows the modifie
rs to appear in any | 5080 * Parse the modifiers preceding a declaration. This method allows the modifie
rs to appear in any |
| 5098 * order but does generate errors for duplicated modifiers. Checks for other p
roblems, such as | 5081 * order but does generate errors for duplicated modifiers. Checks for other p
roblems, such as |
| 5099 * having the modifiers appear in the wrong order or specifying both 'const' a
nd 'final', are | 5082 * having the modifiers appear in the wrong order or specifying both 'const' a
nd 'final', are |
| 5100 * reported in one of the methods whose name is prefixed with `validateModifie
rsFor`. | 5083 * reported in one of the methods whose name is prefixed with `validateModifie
rsFor`. |
| 5101 * | 5084 * |
| 5102 * <pre> | 5085 * <pre> |
| 5103 * modifiers ::= | 5086 * modifiers ::= |
| 5104 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | '
var')* | 5087 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | '
var')* |
| 5105 * </pre> | 5088 * </pre> |
| 5106 * | 5089 * |
| 5107 * @return the modifiers that were parsed | 5090 * @return the modifiers that were parsed |
| 5108 */ | 5091 */ |
| 5109 Modifiers parseModifiers() { | 5092 Modifiers _parseModifiers() { |
| 5110 Modifiers modifiers = new Modifiers(); | 5093 Modifiers modifiers = new Modifiers(); |
| 5111 bool progress = true; | 5094 bool progress = true; |
| 5112 while (progress) { | 5095 while (progress) { |
| 5113 if (tokenMatches(peek(), TokenType.PERIOD) || tokenMatches(peek(), TokenTy
pe.LT) || tokenMatches(peek(), TokenType.OPEN_PAREN)) { | 5096 if (_tokenMatches(_peek(), TokenType.PERIOD) || _tokenMatches(_peek(), Tok
enType.LT) || _tokenMatches(_peek(), TokenType.OPEN_PAREN)) { |
| 5114 return modifiers; | 5097 return modifiers; |
| 5115 } | 5098 } |
| 5116 if (matchesKeyword(Keyword.ABSTRACT)) { | 5099 if (_matchesKeyword(Keyword.ABSTRACT)) { |
| 5117 if (modifiers.abstractKeyword != null) { | 5100 if (modifiers.abstractKeyword != null) { |
| 5118 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5101 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5119 advance(); | 5102 _advance(); |
| 5120 } else { | 5103 } else { |
| 5121 modifiers.abstractKeyword = andAdvance; | 5104 modifiers.abstractKeyword = andAdvance; |
| 5122 } | 5105 } |
| 5123 } else if (matchesKeyword(Keyword.CONST)) { | 5106 } else if (_matchesKeyword(Keyword.CONST)) { |
| 5124 if (modifiers.constKeyword != null) { | 5107 if (modifiers.constKeyword != null) { |
| 5125 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5108 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5126 advance(); | 5109 _advance(); |
| 5127 } else { | 5110 } else { |
| 5128 modifiers.constKeyword = andAdvance; | 5111 modifiers.constKeyword = andAdvance; |
| 5129 } | 5112 } |
| 5130 } else if (matchesKeyword(Keyword.EXTERNAL) && !tokenMatches(peek(), Token
Type.PERIOD) && !tokenMatches(peek(), TokenType.LT)) { | 5113 } else if (_matchesKeyword(Keyword.EXTERNAL) && !_tokenMatches(_peek(), To
kenType.PERIOD) && !_tokenMatches(_peek(), TokenType.LT)) { |
| 5131 if (modifiers.externalKeyword != null) { | 5114 if (modifiers.externalKeyword != null) { |
| 5132 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5115 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5133 advance(); | 5116 _advance(); |
| 5134 } else { | 5117 } else { |
| 5135 modifiers.externalKeyword = andAdvance; | 5118 modifiers.externalKeyword = andAdvance; |
| 5136 } | 5119 } |
| 5137 } else if (matchesKeyword(Keyword.FACTORY) && !tokenMatches(peek(), TokenT
ype.PERIOD) && !tokenMatches(peek(), TokenType.LT)) { | 5120 } else if (_matchesKeyword(Keyword.FACTORY) && !_tokenMatches(_peek(), Tok
enType.PERIOD) && !_tokenMatches(_peek(), TokenType.LT)) { |
| 5138 if (modifiers.factoryKeyword != null) { | 5121 if (modifiers.factoryKeyword != null) { |
| 5139 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5122 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5140 advance(); | 5123 _advance(); |
| 5141 } else { | 5124 } else { |
| 5142 modifiers.factoryKeyword = andAdvance; | 5125 modifiers.factoryKeyword = andAdvance; |
| 5143 } | 5126 } |
| 5144 } else if (matchesKeyword(Keyword.FINAL)) { | 5127 } else if (_matchesKeyword(Keyword.FINAL)) { |
| 5145 if (modifiers.finalKeyword != null) { | 5128 if (modifiers.finalKeyword != null) { |
| 5146 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5129 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5147 advance(); | 5130 _advance(); |
| 5148 } else { | 5131 } else { |
| 5149 modifiers.finalKeyword = andAdvance; | 5132 modifiers.finalKeyword = andAdvance; |
| 5150 } | 5133 } |
| 5151 } else if (matchesKeyword(Keyword.STATIC) && !tokenMatches(peek(), TokenTy
pe.PERIOD) && !tokenMatches(peek(), TokenType.LT)) { | 5134 } else if (_matchesKeyword(Keyword.STATIC) && !_tokenMatches(_peek(), Toke
nType.PERIOD) && !_tokenMatches(_peek(), TokenType.LT)) { |
| 5152 if (modifiers.staticKeyword != null) { | 5135 if (modifiers.staticKeyword != null) { |
| 5153 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5136 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5154 advance(); | 5137 _advance(); |
| 5155 } else { | 5138 } else { |
| 5156 modifiers.staticKeyword = andAdvance; | 5139 modifiers.staticKeyword = andAdvance; |
| 5157 } | 5140 } |
| 5158 } else if (matchesKeyword(Keyword.VAR)) { | 5141 } else if (_matchesKeyword(Keyword.VAR)) { |
| 5159 if (modifiers.varKeyword != null) { | 5142 if (modifiers.varKeyword != null) { |
| 5160 reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_curr
entToken.lexeme]); | 5143 _reportErrorForCurrentToken(ParserErrorCode.DUPLICATED_MODIFIER, [_cur
rentToken.lexeme]); |
| 5161 advance(); | 5144 _advance(); |
| 5162 } else { | 5145 } else { |
| 5163 modifiers.varKeyword = andAdvance; | 5146 modifiers.varKeyword = andAdvance; |
| 5164 } | 5147 } |
| 5165 } else { | 5148 } else { |
| 5166 progress = false; | 5149 progress = false; |
| 5167 } | 5150 } |
| 5168 } | 5151 } |
| 5169 return modifiers; | 5152 return modifiers; |
| 5170 } | 5153 } |
| 5171 | 5154 |
| 5172 /** | 5155 /** |
| 5173 * Parse a multiplicative expression. | 5156 * Parse a multiplicative expression. |
| 5174 * | 5157 * |
| 5175 * <pre> | 5158 * <pre> |
| 5176 * multiplicativeExpression ::= | 5159 * multiplicativeExpression ::= |
| 5177 * unaryExpression (multiplicativeOperator unaryExpression)* | 5160 * unaryExpression (multiplicativeOperator unaryExpression)* |
| 5178 * | 'super' (multiplicativeOperator unaryExpression)+ | 5161 * | 'super' (multiplicativeOperator unaryExpression)+ |
| 5179 * </pre> | 5162 * </pre> |
| 5180 * | 5163 * |
| 5181 * @return the multiplicative expression that was parsed | 5164 * @return the multiplicative expression that was parsed |
| 5182 */ | 5165 */ |
| 5183 Expression parseMultiplicativeExpression() { | 5166 Expression _parseMultiplicativeExpression() { |
| 5184 Expression expression; | 5167 Expression expression; |
| 5185 if (matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isMultiplicativ
eOperator) { | 5168 if (_matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isMultiplicati
veOperator) { |
| 5186 expression = new SuperExpression(andAdvance); | 5169 expression = new SuperExpression(andAdvance); |
| 5187 } else { | 5170 } else { |
| 5188 expression = parseUnaryExpression(); | 5171 expression = _parseUnaryExpression(); |
| 5189 } | 5172 } |
| 5190 while (_currentToken.type.isMultiplicativeOperator) { | 5173 while (_currentToken.type.isMultiplicativeOperator) { |
| 5191 Token operator = andAdvance; | 5174 Token operator = andAdvance; |
| 5192 expression = new BinaryExpression(expression, operator, parseUnaryExpressi
on()); | 5175 expression = new BinaryExpression(expression, operator, _parseUnaryExpress
ion()); |
| 5193 } | 5176 } |
| 5194 return expression; | 5177 return expression; |
| 5195 } | 5178 } |
| 5196 | 5179 |
| 5197 /** | 5180 /** |
| 5198 * Parse a class native clause. | 5181 * Parse a class native clause. |
| 5199 * | 5182 * |
| 5200 * <pre> | 5183 * <pre> |
| 5201 * classNativeClause ::= | 5184 * classNativeClause ::= |
| 5202 * 'native' name | 5185 * 'native' name |
| 5203 * </pre> | 5186 * </pre> |
| 5204 * | 5187 * |
| 5205 * @return the class native clause that was parsed | 5188 * @return the class native clause that was parsed |
| 5206 */ | 5189 */ |
| 5207 NativeClause parseNativeClause() { | 5190 NativeClause _parseNativeClause() { |
| 5208 Token keyword = andAdvance; | 5191 Token keyword = andAdvance; |
| 5209 StringLiteral name = parseStringLiteral(); | 5192 StringLiteral name = parseStringLiteral(); |
| 5210 return new NativeClause(keyword, name); | 5193 return new NativeClause(keyword, name); |
| 5211 } | 5194 } |
| 5212 | 5195 |
| 5213 /** | 5196 /** |
| 5214 * Parse a new expression. | 5197 * Parse a new expression. |
| 5215 * | 5198 * |
| 5216 * <pre> | 5199 * <pre> |
| 5217 * newExpression ::= | 5200 * newExpression ::= |
| 5218 * instanceCreationExpression | 5201 * instanceCreationExpression |
| 5219 * </pre> | 5202 * </pre> |
| 5220 * | 5203 * |
| 5221 * @return the new expression that was parsed | 5204 * @return the new expression that was parsed |
| 5222 */ | 5205 */ |
| 5223 InstanceCreationExpression parseNewExpression() => parseInstanceCreationExpres
sion(expectKeyword(Keyword.NEW)); | 5206 InstanceCreationExpression _parseNewExpression() => _parseInstanceCreationExpr
ession(_expectKeyword(Keyword.NEW)); |
| 5224 | 5207 |
| 5225 /** | 5208 /** |
| 5226 * Parse a non-labeled statement. | 5209 * Parse a non-labeled statement. |
| 5227 * | 5210 * |
| 5228 * <pre> | 5211 * <pre> |
| 5229 * nonLabeledStatement ::= | 5212 * nonLabeledStatement ::= |
| 5230 * block | 5213 * block |
| 5231 * | assertStatement | 5214 * | assertStatement |
| 5232 * | breakStatement | 5215 * | breakStatement |
| 5233 * | continueStatement | 5216 * | continueStatement |
| 5234 * | doStatement | 5217 * | doStatement |
| 5235 * | forStatement | 5218 * | forStatement |
| 5236 * | ifStatement | 5219 * | ifStatement |
| 5237 * | returnStatement | 5220 * | returnStatement |
| 5238 * | switchStatement | 5221 * | switchStatement |
| 5239 * | tryStatement | 5222 * | tryStatement |
| 5240 * | whileStatement | 5223 * | whileStatement |
| 5241 * | variableDeclarationList ';' | 5224 * | variableDeclarationList ';' |
| 5242 * | expressionStatement | 5225 * | expressionStatement |
| 5243 * | functionSignature functionBody | 5226 * | functionSignature functionBody |
| 5244 * </pre> | 5227 * </pre> |
| 5245 * | 5228 * |
| 5246 * @return the non-labeled statement that was parsed | 5229 * @return the non-labeled statement that was parsed |
| 5247 */ | 5230 */ |
| 5248 Statement parseNonLabeledStatement() { | 5231 Statement _parseNonLabeledStatement() { |
| 5249 // TODO(brianwilkerson) Pass the comment and metadata on where appropriate. | 5232 // TODO(brianwilkerson) Pass the comment and metadata on where appropriate. |
| 5250 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 5233 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 5251 if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 5234 if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 5252 if (tokenMatches(peek(), TokenType.STRING)) { | 5235 if (_tokenMatches(_peek(), TokenType.STRING)) { |
| 5253 Token afterString = skipStringLiteral(_currentToken.next); | 5236 Token afterString = _skipStringLiteral(_currentToken.next); |
| 5254 if (afterString != null && identical(afterString.type, TokenType.COLON))
{ | 5237 if (afterString != null && identical(afterString.type, TokenType.COLON))
{ |
| 5255 return new ExpressionStatement(parseExpression2(), expect(TokenType.SE
MICOLON)); | 5238 return new ExpressionStatement(parseExpression2(), _expect(TokenType.S
EMICOLON)); |
| 5256 } | 5239 } |
| 5257 } | 5240 } |
| 5258 return parseBlock(); | 5241 return parseBlock(); |
| 5259 } else if (matches(TokenType.KEYWORD) && !(_currentToken as KeywordToken).ke
yword.isPseudoKeyword) { | 5242 } else if (_matches(TokenType.KEYWORD) && !(_currentToken as KeywordToken).k
eyword.isPseudoKeyword) { |
| 5260 Keyword keyword = (_currentToken as KeywordToken).keyword; | 5243 Keyword keyword = (_currentToken as KeywordToken).keyword; |
| 5261 // TODO(jwren) compute some metrics to figure out a better order for this
if-then sequence to optimize performance | 5244 // TODO(jwren) compute some metrics to figure out a better order for this
if-then sequence to optimize performance |
| 5262 if (identical(keyword, Keyword.ASSERT)) { | 5245 if (identical(keyword, Keyword.ASSERT)) { |
| 5263 return parseAssertStatement(); | 5246 return _parseAssertStatement(); |
| 5264 } else if (identical(keyword, Keyword.BREAK)) { | 5247 } else if (identical(keyword, Keyword.BREAK)) { |
| 5265 return parseBreakStatement(); | 5248 return _parseBreakStatement(); |
| 5266 } else if (identical(keyword, Keyword.CONTINUE)) { | 5249 } else if (identical(keyword, Keyword.CONTINUE)) { |
| 5267 return parseContinueStatement(); | 5250 return _parseContinueStatement(); |
| 5268 } else if (identical(keyword, Keyword.DO)) { | 5251 } else if (identical(keyword, Keyword.DO)) { |
| 5269 return parseDoStatement(); | 5252 return _parseDoStatement(); |
| 5270 } else if (identical(keyword, Keyword.FOR)) { | 5253 } else if (identical(keyword, Keyword.FOR)) { |
| 5271 return parseForStatement(); | 5254 return _parseForStatement(); |
| 5272 } else if (identical(keyword, Keyword.IF)) { | 5255 } else if (identical(keyword, Keyword.IF)) { |
| 5273 return parseIfStatement(); | 5256 return _parseIfStatement(); |
| 5274 } else if (identical(keyword, Keyword.RETHROW)) { | 5257 } else if (identical(keyword, Keyword.RETHROW)) { |
| 5275 return new ExpressionStatement(parseRethrowExpression(), expect(TokenTyp
e.SEMICOLON)); | 5258 return new ExpressionStatement(_parseRethrowExpression(), _expect(TokenT
ype.SEMICOLON)); |
| 5276 } else if (identical(keyword, Keyword.RETURN)) { | 5259 } else if (identical(keyword, Keyword.RETURN)) { |
| 5277 return parseReturnStatement(); | 5260 return _parseReturnStatement(); |
| 5278 } else if (identical(keyword, Keyword.SWITCH)) { | 5261 } else if (identical(keyword, Keyword.SWITCH)) { |
| 5279 return parseSwitchStatement(); | 5262 return _parseSwitchStatement(); |
| 5280 } else if (identical(keyword, Keyword.THROW)) { | 5263 } else if (identical(keyword, Keyword.THROW)) { |
| 5281 return new ExpressionStatement(parseThrowExpression(), expect(TokenType.
SEMICOLON)); | 5264 return new ExpressionStatement(_parseThrowExpression(), _expect(TokenTyp
e.SEMICOLON)); |
| 5282 } else if (identical(keyword, Keyword.TRY)) { | 5265 } else if (identical(keyword, Keyword.TRY)) { |
| 5283 return parseTryStatement(); | 5266 return _parseTryStatement(); |
| 5284 } else if (identical(keyword, Keyword.WHILE)) { | 5267 } else if (identical(keyword, Keyword.WHILE)) { |
| 5285 return parseWhileStatement(); | 5268 return _parseWhileStatement(); |
| 5286 } else if (identical(keyword, Keyword.VAR) || identical(keyword, Keyword.F
INAL)) { | 5269 } else if (identical(keyword, Keyword.VAR) || identical(keyword, Keyword.F
INAL)) { |
| 5287 return parseVariableDeclarationStatementAfterMetadata(commentAndMetadata
); | 5270 return _parseVariableDeclarationStatementAfterMetadata(commentAndMetadat
a); |
| 5288 } else if (identical(keyword, Keyword.VOID)) { | 5271 } else if (identical(keyword, Keyword.VOID)) { |
| 5289 TypeName returnType = parseReturnType(); | 5272 TypeName returnType = parseReturnType(); |
| 5290 if (matchesIdentifier() && matchesAny(peek(), [ | 5273 if (_matchesIdentifier() && _peek().matchesAny([ |
| 5291 TokenType.OPEN_PAREN, | 5274 TokenType.OPEN_PAREN, |
| 5292 TokenType.OPEN_CURLY_BRACKET, | 5275 TokenType.OPEN_CURLY_BRACKET, |
| 5293 TokenType.FUNCTION])) { | 5276 TokenType.FUNCTION])) { |
| 5294 return parseFunctionDeclarationStatementAfterReturnType(commentAndMeta
data, returnType); | 5277 return _parseFunctionDeclarationStatementAfterReturnType(commentAndMet
adata, returnType); |
| 5295 } else { | 5278 } else { |
| 5296 // | 5279 // |
| 5297 // We have found an error of some kind. Try to recover. | 5280 // We have found an error of some kind. Try to recover. |
| 5298 // | 5281 // |
| 5299 if (matchesIdentifier()) { | 5282 if (_matchesIdentifier()) { |
| 5300 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM
ICOLON])) { | 5283 if (_peek().matchesAny([TokenType.EQ, TokenType.COMMA, TokenType.SEM
ICOLON])) { |
| 5301 // | 5284 // |
| 5302 // We appear to have a variable declaration with a type of "void". | 5285 // We appear to have a variable declaration with a type of "void". |
| 5303 // | 5286 // |
| 5304 reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType, []); | 5287 _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType, [])
; |
| 5305 return parseVariableDeclarationStatementAfterMetadata(commentAndMe
tadata); | 5288 return _parseVariableDeclarationStatementAfterMetadata(commentAndM
etadata); |
| 5306 } | 5289 } |
| 5307 } else if (matches(TokenType.CLOSE_CURLY_BRACKET)) { | 5290 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
| 5308 // | 5291 // |
| 5309 // We appear to have found an incomplete statement at the end of a b
lock. Parse it as a | 5292 // We appear to have found an incomplete statement at the end of a b
lock. Parse it as a |
| 5310 // variable declaration. | 5293 // variable declaration. |
| 5311 // | 5294 // |
| 5312 return parseVariableDeclarationStatementAfterType(commentAndMetadata
, null, returnType); | 5295 return _parseVariableDeclarationStatementAfterType(commentAndMetadat
a, null, returnType); |
| 5313 } | 5296 } |
| 5314 reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT, []); | 5297 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT, []); |
| 5315 // TODO(brianwilkerson) Recover from this error. | 5298 // TODO(brianwilkerson) Recover from this error. |
| 5316 return new EmptyStatement(createSyntheticToken(TokenType.SEMICOLON)); | 5299 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); |
| 5317 } | 5300 } |
| 5318 } else if (identical(keyword, Keyword.CONST)) { | 5301 } else if (identical(keyword, Keyword.CONST)) { |
| 5319 if (matchesAny(peek(), [ | 5302 if (_peek().matchesAny([ |
| 5320 TokenType.LT, | 5303 TokenType.LT, |
| 5321 TokenType.OPEN_CURLY_BRACKET, | 5304 TokenType.OPEN_CURLY_BRACKET, |
| 5322 TokenType.OPEN_SQUARE_BRACKET, | 5305 TokenType.OPEN_SQUARE_BRACKET, |
| 5323 TokenType.INDEX])) { | 5306 TokenType.INDEX])) { |
| 5324 return new ExpressionStatement(parseExpression2(), expect(TokenType.SE
MICOLON)); | 5307 return new ExpressionStatement(parseExpression2(), _expect(TokenType.S
EMICOLON)); |
| 5325 } else if (tokenMatches(peek(), TokenType.IDENTIFIER)) { | 5308 } else if (_tokenMatches(_peek(), TokenType.IDENTIFIER)) { |
| 5326 Token afterType = skipTypeName(peek()); | 5309 Token afterType = _skipTypeName(_peek()); |
| 5327 if (afterType != null) { | 5310 if (afterType != null) { |
| 5328 if (tokenMatches(afterType, TokenType.OPEN_PAREN) || (tokenMatches(a
fterType, TokenType.PERIOD) && tokenMatches(afterType.next, TokenType.IDENTIFIER
) && tokenMatches(afterType.next.next, TokenType.OPEN_PAREN))) { | 5311 if (_tokenMatches(afterType, TokenType.OPEN_PAREN) || (_tokenMatches
(afterType, TokenType.PERIOD) && _tokenMatches(afterType.next, TokenType.IDENTIF
IER) && _tokenMatches(afterType.next.next, TokenType.OPEN_PAREN))) { |
| 5329 return new ExpressionStatement(parseExpression2(), expect(TokenTyp
e.SEMICOLON)); | 5312 return new ExpressionStatement(parseExpression2(), _expect(TokenTy
pe.SEMICOLON)); |
| 5330 } | 5313 } |
| 5331 } | 5314 } |
| 5332 } | 5315 } |
| 5333 return parseVariableDeclarationStatementAfterMetadata(commentAndMetadata
); | 5316 return _parseVariableDeclarationStatementAfterMetadata(commentAndMetadat
a); |
| 5334 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T
RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) ||
identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) { | 5317 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T
RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) ||
identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) { |
| 5335 return new ExpressionStatement(parseExpression2(), expect(TokenType.SEMI
COLON)); | 5318 return new ExpressionStatement(parseExpression2(), _expect(TokenType.SEM
ICOLON)); |
| 5336 } else { | 5319 } else { |
| 5337 // | 5320 // |
| 5338 // We have found an error of some kind. Try to recover. | 5321 // We have found an error of some kind. Try to recover. |
| 5339 // | 5322 // |
| 5340 reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT, []); | 5323 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT, []); |
| 5341 return new EmptyStatement(createSyntheticToken(TokenType.SEMICOLON)); | 5324 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); |
| 5342 } | 5325 } |
| 5343 } else if (matches(TokenType.SEMICOLON)) { | 5326 } else if (_matches(TokenType.SEMICOLON)) { |
| 5344 return parseEmptyStatement(); | 5327 return _parseEmptyStatement(); |
| 5345 } else if (isInitializedVariableDeclaration()) { | 5328 } else if (_isInitializedVariableDeclaration()) { |
| 5346 return parseVariableDeclarationStatementAfterMetadata(commentAndMetadata); | 5329 return _parseVariableDeclarationStatementAfterMetadata(commentAndMetadata)
; |
| 5347 } else if (isFunctionDeclaration()) { | 5330 } else if (_isFunctionDeclaration()) { |
| 5348 return parseFunctionDeclarationStatement(); | 5331 return _parseFunctionDeclarationStatement(); |
| 5349 } else if (matches(TokenType.CLOSE_CURLY_BRACKET)) { | 5332 } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) { |
| 5350 reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT, []); | 5333 _reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT, []); |
| 5351 return new EmptyStatement(createSyntheticToken(TokenType.SEMICOLON)); | 5334 return new EmptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); |
| 5352 } else { | 5335 } else { |
| 5353 return new ExpressionStatement(parseExpression2(), expect(TokenType.SEMICO
LON)); | 5336 return new ExpressionStatement(parseExpression2(), _expect(TokenType.SEMIC
OLON)); |
| 5354 } | 5337 } |
| 5355 } | 5338 } |
| 5356 | 5339 |
| 5357 /** | 5340 /** |
| 5358 * Parse an operator declaration. | 5341 * Parse an operator declaration. |
| 5359 * | 5342 * |
| 5360 * <pre> | 5343 * <pre> |
| 5361 * operatorDeclaration ::= | 5344 * operatorDeclaration ::= |
| 5362 * operatorSignature (';' | functionBody) | 5345 * operatorSignature (';' | functionBody) |
| 5363 * | 5346 * |
| 5364 * operatorSignature ::= | 5347 * operatorSignature ::= |
| 5365 * 'external'? returnType? 'operator' operator formalParameterList | 5348 * 'external'? returnType? 'operator' operator formalParameterList |
| 5366 * </pre> | 5349 * </pre> |
| 5367 * | 5350 * |
| 5368 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 5351 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 5369 * declaration | 5352 * declaration |
| 5370 * @param externalKeyword the 'external' token | 5353 * @param externalKeyword the 'external' token |
| 5371 * @param the return type that has already been parsed, or `null` if there was
no return | 5354 * @param the return type that has already been parsed, or `null` if there was
no return |
| 5372 * type | 5355 * type |
| 5373 * @return the operator declaration that was parsed | 5356 * @return the operator declaration that was parsed |
| 5374 */ | 5357 */ |
| 5375 MethodDeclaration parseOperator(CommentAndMetadata commentAndMetadata, Token e
xternalKeyword, TypeName returnType) { | 5358 MethodDeclaration _parseOperator(CommentAndMetadata commentAndMetadata, Token
externalKeyword, TypeName returnType) { |
| 5376 Token operatorKeyword; | 5359 Token operatorKeyword; |
| 5377 if (matchesKeyword(Keyword.OPERATOR)) { | 5360 if (_matchesKeyword(Keyword.OPERATOR)) { |
| 5378 operatorKeyword = andAdvance; | 5361 operatorKeyword = andAdvance; |
| 5379 } else { | 5362 } else { |
| 5380 reportErrorForToken(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToke
n, []); | 5363 _reportErrorForToken(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentTok
en, []); |
| 5381 operatorKeyword = createSyntheticKeyword(Keyword.OPERATOR); | 5364 operatorKeyword = _createSyntheticKeyword(Keyword.OPERATOR); |
| 5382 } | 5365 } |
| 5383 if (!_currentToken.isUserDefinableOperator) { | 5366 if (!_currentToken.isUserDefinableOperator) { |
| 5384 reportErrorForCurrentToken(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_
currentToken.lexeme]); | 5367 _reportErrorForCurrentToken(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [
_currentToken.lexeme]); |
| 5385 } | 5368 } |
| 5386 SimpleIdentifier name = new SimpleIdentifier(andAdvance); | 5369 SimpleIdentifier name = new SimpleIdentifier(andAdvance); |
| 5387 if (matches(TokenType.EQ)) { | 5370 if (_matches(TokenType.EQ)) { |
| 5388 Token previous = _currentToken.previous; | 5371 Token previous = _currentToken.previous; |
| 5389 if ((tokenMatches(previous, TokenType.EQ_EQ) || tokenMatches(previous, Tok
enType.BANG_EQ)) && _currentToken.offset == previous.offset + 2) { | 5372 if ((_tokenMatches(previous, TokenType.EQ_EQ) || _tokenMatches(previous, T
okenType.BANG_EQ)) && _currentToken.offset == previous.offset + 2) { |
| 5390 reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR, ["${previou
s.lexeme}${_currentToken.lexeme}"]); | 5373 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR, ["${previo
us.lexeme}${_currentToken.lexeme}"]); |
| 5391 advance(); | 5374 _advance(); |
| 5392 } | 5375 } |
| 5393 } | 5376 } |
| 5394 FormalParameterList parameters = parseFormalParameterList(); | 5377 FormalParameterList parameters = parseFormalParameterList(); |
| 5395 validateFormalParameterList(parameters); | 5378 _validateFormalParameterList(parameters); |
| 5396 FunctionBody body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION
_BODY, false); | 5379 FunctionBody body = _parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTIO
N_BODY, false); |
| 5397 if (externalKeyword != null && body is! EmptyFunctionBody) { | 5380 if (externalKeyword != null && body is! EmptyFunctionBody) { |
| 5398 reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []
); | 5381 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, [
]); |
| 5399 } | 5382 } |
| 5400 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, null, returnType, null, operatorKeyword, name, parame
ters, body); | 5383 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, null, returnType, null, operatorKeyword, name, parame
ters, body); |
| 5401 } | 5384 } |
| 5402 | 5385 |
| 5403 /** | 5386 /** |
| 5404 * Parse a return type if one is given, otherwise return `null` without advanc
ing. | 5387 * Parse a return type if one is given, otherwise return `null` without advanc
ing. |
| 5405 * | 5388 * |
| 5406 * @return the return type that was parsed | 5389 * @return the return type that was parsed |
| 5407 */ | 5390 */ |
| 5408 TypeName parseOptionalReturnType() { | 5391 TypeName _parseOptionalReturnType() { |
| 5409 if (matchesKeyword(Keyword.VOID)) { | 5392 if (_matchesKeyword(Keyword.VOID)) { |
| 5410 return parseReturnType(); | 5393 return parseReturnType(); |
| 5411 } else if (matchesIdentifier() && !matchesKeyword(Keyword.GET) && !matchesKe
yword(Keyword.SET) && !matchesKeyword(Keyword.OPERATOR) && (tokenMatchesIdentifi
er(peek()) || tokenMatches(peek(), TokenType.LT))) { | 5394 } else if (_matchesIdentifier() && !_matchesKeyword(Keyword.GET) && !_matche
sKeyword(Keyword.SET) && !_matchesKeyword(Keyword.OPERATOR) && (_tokenMatchesIde
ntifier(_peek()) || _tokenMatches(_peek(), TokenType.LT))) { |
| 5412 return parseReturnType(); | 5395 return parseReturnType(); |
| 5413 } else if (matchesIdentifier() && tokenMatches(peek(), TokenType.PERIOD) &&
tokenMatchesIdentifier(peekAt(2)) && (tokenMatchesIdentifier(peekAt(3)) || token
Matches(peekAt(3), TokenType.LT))) { | 5396 } else if (_matchesIdentifier() && _tokenMatches(_peek(), TokenType.PERIOD)
&& _tokenMatchesIdentifier(_peekAt(2)) && (_tokenMatchesIdentifier(_peekAt(3)) |
| _tokenMatches(_peekAt(3), TokenType.LT))) { |
| 5414 return parseReturnType(); | 5397 return parseReturnType(); |
| 5415 } | 5398 } |
| 5416 return null; | 5399 return null; |
| 5417 } | 5400 } |
| 5418 | 5401 |
| 5419 /** | 5402 /** |
| 5420 * Parse a part or part-of directive. | 5403 * Parse a part or part-of directive. |
| 5421 * | 5404 * |
| 5422 * <pre> | 5405 * <pre> |
| 5423 * partDirective ::= | 5406 * partDirective ::= |
| 5424 * metadata 'part' stringLiteral ';' | 5407 * metadata 'part' stringLiteral ';' |
| 5425 * | 5408 * |
| 5426 * partOfDirective ::= | 5409 * partOfDirective ::= |
| 5427 * metadata 'part' 'of' identifier ';' | 5410 * metadata 'part' 'of' identifier ';' |
| 5428 * </pre> | 5411 * </pre> |
| 5429 * | 5412 * |
| 5430 * @param commentAndMetadata the metadata to be associated with the directive | 5413 * @param commentAndMetadata the metadata to be associated with the directive |
| 5431 * @return the part or part-of directive that was parsed | 5414 * @return the part or part-of directive that was parsed |
| 5432 */ | 5415 */ |
| 5433 Directive parsePartDirective(CommentAndMetadata commentAndMetadata) { | 5416 Directive _parsePartDirective(CommentAndMetadata commentAndMetadata) { |
| 5434 Token partKeyword = expectKeyword(Keyword.PART); | 5417 Token partKeyword = _expectKeyword(Keyword.PART); |
| 5435 if (matchesString(_OF)) { | 5418 if (_matchesString(_OF)) { |
| 5436 Token ofKeyword = andAdvance; | 5419 Token ofKeyword = andAdvance; |
| 5437 LibraryIdentifier libraryName = parseLibraryName(ParserErrorCode.MISSING_N
AME_IN_PART_OF_DIRECTIVE, ofKeyword); | 5420 LibraryIdentifier libraryName = _parseLibraryName(ParserErrorCode.MISSING_
NAME_IN_PART_OF_DIRECTIVE, ofKeyword); |
| 5438 Token semicolon = expect(TokenType.SEMICOLON); | 5421 Token semicolon = _expect(TokenType.SEMICOLON); |
| 5439 return new PartOfDirective(commentAndMetadata.comment, commentAndMetadata.
metadata, partKeyword, ofKeyword, libraryName, semicolon); | 5422 return new PartOfDirective(commentAndMetadata.comment, commentAndMetadata.
metadata, partKeyword, ofKeyword, libraryName, semicolon); |
| 5440 } | 5423 } |
| 5441 StringLiteral partUri = parseStringLiteral(); | 5424 StringLiteral partUri = parseStringLiteral(); |
| 5442 Token semicolon = expect(TokenType.SEMICOLON); | 5425 Token semicolon = _expect(TokenType.SEMICOLON); |
| 5443 return new PartDirective(commentAndMetadata.comment, commentAndMetadata.meta
data, partKeyword, partUri, semicolon); | 5426 return new PartDirective(commentAndMetadata.comment, commentAndMetadata.meta
data, partKeyword, partUri, semicolon); |
| 5444 } | 5427 } |
| 5445 | 5428 |
| 5446 /** | 5429 /** |
| 5447 * Parse a postfix expression. | 5430 * Parse a postfix expression. |
| 5448 * | 5431 * |
| 5449 * <pre> | 5432 * <pre> |
| 5450 * postfixExpression ::= | 5433 * postfixExpression ::= |
| 5451 * assignableExpression postfixOperator | 5434 * assignableExpression postfixOperator |
| 5452 * | primary selector* | 5435 * | primary selector* |
| 5453 * | 5436 * |
| 5454 * selector ::= | 5437 * selector ::= |
| 5455 * assignableSelector | 5438 * assignableSelector |
| 5456 * | argumentList | 5439 * | argumentList |
| 5457 * </pre> | 5440 * </pre> |
| 5458 * | 5441 * |
| 5459 * @return the postfix expression that was parsed | 5442 * @return the postfix expression that was parsed |
| 5460 */ | 5443 */ |
| 5461 Expression parsePostfixExpression() { | 5444 Expression _parsePostfixExpression() { |
| 5462 Expression operand = parseAssignableExpression(true); | 5445 Expression operand = _parseAssignableExpression(true); |
| 5463 if (matches(TokenType.OPEN_SQUARE_BRACKET) || matches(TokenType.PERIOD) || m
atches(TokenType.OPEN_PAREN)) { | 5446 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.PERIOD) ||
_matches(TokenType.OPEN_PAREN)) { |
| 5464 do { | 5447 do { |
| 5465 if (matches(TokenType.OPEN_PAREN)) { | 5448 if (_matches(TokenType.OPEN_PAREN)) { |
| 5466 ArgumentList argumentList = parseArgumentList(); | 5449 ArgumentList argumentList = parseArgumentList(); |
| 5467 if (operand is PropertyAccess) { | 5450 if (operand is PropertyAccess) { |
| 5468 PropertyAccess access = operand as PropertyAccess; | 5451 PropertyAccess access = operand as PropertyAccess; |
| 5469 operand = new MethodInvocation(access.target, access.operator, acces
s.propertyName, argumentList); | 5452 operand = new MethodInvocation(access.target, access.operator, acces
s.propertyName, argumentList); |
| 5470 } else { | 5453 } else { |
| 5471 operand = new FunctionExpressionInvocation(operand, argumentList); | 5454 operand = new FunctionExpressionInvocation(operand, argumentList); |
| 5472 } | 5455 } |
| 5473 } else { | 5456 } else { |
| 5474 operand = parseAssignableSelector(operand, true); | 5457 operand = _parseAssignableSelector(operand, true); |
| 5475 } | 5458 } |
| 5476 } while (matches(TokenType.OPEN_SQUARE_BRACKET) || matches(TokenType.PERIO
D) || matches(TokenType.OPEN_PAREN)); | 5459 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.PER
IOD) || _matches(TokenType.OPEN_PAREN)); |
| 5477 return operand; | 5460 return operand; |
| 5478 } | 5461 } |
| 5479 if (!_currentToken.type.isIncrementOperator) { | 5462 if (!_currentToken.type.isIncrementOperator) { |
| 5480 return operand; | 5463 return operand; |
| 5481 } | 5464 } |
| 5482 ensureAssignable(operand); | 5465 _ensureAssignable(operand); |
| 5483 Token operator = andAdvance; | 5466 Token operator = andAdvance; |
| 5484 return new PostfixExpression(operand, operator); | 5467 return new PostfixExpression(operand, operator); |
| 5485 } | 5468 } |
| 5486 | 5469 |
| 5487 /** | 5470 /** |
| 5488 * Parse a primary expression. | 5471 * Parse a primary expression. |
| 5489 * | 5472 * |
| 5490 * <pre> | 5473 * <pre> |
| 5491 * primary ::= | 5474 * primary ::= |
| 5492 * thisExpression | 5475 * thisExpression |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5504 * | booleanLiteral | 5487 * | booleanLiteral |
| 5505 * | numericLiteral | 5488 * | numericLiteral |
| 5506 * | stringLiteral | 5489 * | stringLiteral |
| 5507 * | symbolLiteral | 5490 * | symbolLiteral |
| 5508 * | mapLiteral | 5491 * | mapLiteral |
| 5509 * | listLiteral | 5492 * | listLiteral |
| 5510 * </pre> | 5493 * </pre> |
| 5511 * | 5494 * |
| 5512 * @return the primary expression that was parsed | 5495 * @return the primary expression that was parsed |
| 5513 */ | 5496 */ |
| 5514 Expression parsePrimaryExpression() { | 5497 Expression _parsePrimaryExpression() { |
| 5515 if (matchesKeyword(Keyword.THIS)) { | 5498 if (_matchesKeyword(Keyword.THIS)) { |
| 5516 return new ThisExpression(andAdvance); | 5499 return new ThisExpression(andAdvance); |
| 5517 } else if (matchesKeyword(Keyword.SUPER)) { | 5500 } else if (_matchesKeyword(Keyword.SUPER)) { |
| 5518 return parseAssignableSelector(new SuperExpression(andAdvance), false); | 5501 return _parseAssignableSelector(new SuperExpression(andAdvance), false); |
| 5519 } else if (matchesKeyword(Keyword.NULL)) { | 5502 } else if (_matchesKeyword(Keyword.NULL)) { |
| 5520 return new NullLiteral(andAdvance); | 5503 return new NullLiteral(andAdvance); |
| 5521 } else if (matchesKeyword(Keyword.FALSE)) { | 5504 } else if (_matchesKeyword(Keyword.FALSE)) { |
| 5522 return new BooleanLiteral(andAdvance, false); | 5505 return new BooleanLiteral(andAdvance, false); |
| 5523 } else if (matchesKeyword(Keyword.TRUE)) { | 5506 } else if (_matchesKeyword(Keyword.TRUE)) { |
| 5524 return new BooleanLiteral(andAdvance, true); | 5507 return new BooleanLiteral(andAdvance, true); |
| 5525 } else if (matches(TokenType.DOUBLE)) { | 5508 } else if (_matches(TokenType.DOUBLE)) { |
| 5526 Token token = andAdvance; | 5509 Token token = andAdvance; |
| 5527 double value = 0.0; | 5510 double value = 0.0; |
| 5528 try { | 5511 try { |
| 5529 value = double.parse(token.lexeme); | 5512 value = double.parse(token.lexeme); |
| 5530 } on FormatException catch (exception) { | 5513 } on FormatException catch (exception) { |
| 5531 } | 5514 } |
| 5532 return new DoubleLiteral(token, value); | 5515 return new DoubleLiteral(token, value); |
| 5533 } else if (matches(TokenType.HEXADECIMAL)) { | 5516 } else if (_matches(TokenType.HEXADECIMAL)) { |
| 5534 Token token = andAdvance; | 5517 Token token = andAdvance; |
| 5535 int value = null; | 5518 int value = null; |
| 5536 try { | 5519 try { |
| 5537 value = int.parse(token.lexeme.substring(2), radix: 16); | 5520 value = int.parse(token.lexeme.substring(2), radix: 16); |
| 5538 } on FormatException catch (exception) { | 5521 } on FormatException catch (exception) { |
| 5539 } | 5522 } |
| 5540 return new IntegerLiteral(token, value); | 5523 return new IntegerLiteral(token, value); |
| 5541 } else if (matches(TokenType.INT)) { | 5524 } else if (_matches(TokenType.INT)) { |
| 5542 Token token = andAdvance; | 5525 Token token = andAdvance; |
| 5543 int value = null; | 5526 int value = null; |
| 5544 try { | 5527 try { |
| 5545 value = int.parse(token.lexeme); | 5528 value = int.parse(token.lexeme); |
| 5546 } on FormatException catch (exception) { | 5529 } on FormatException catch (exception) { |
| 5547 } | 5530 } |
| 5548 return new IntegerLiteral(token, value); | 5531 return new IntegerLiteral(token, value); |
| 5549 } else if (matches(TokenType.STRING)) { | 5532 } else if (_matches(TokenType.STRING)) { |
| 5550 return parseStringLiteral(); | 5533 return parseStringLiteral(); |
| 5551 } else if (matches(TokenType.OPEN_CURLY_BRACKET)) { | 5534 } else if (_matches(TokenType.OPEN_CURLY_BRACKET)) { |
| 5552 return parseMapLiteral(null, null); | 5535 return _parseMapLiteral(null, null); |
| 5553 } else if (matches(TokenType.OPEN_SQUARE_BRACKET) || matches(TokenType.INDEX
)) { | 5536 } else if (_matches(TokenType.OPEN_SQUARE_BRACKET) || _matches(TokenType.IND
EX)) { |
| 5554 return parseListLiteral(null, null); | 5537 return _parseListLiteral(null, null); |
| 5555 } else if (matchesIdentifier()) { | 5538 } else if (_matchesIdentifier()) { |
| 5556 // TODO(brianwilkerson) The code below was an attempt to recover from an e
rror case, but it | 5539 // TODO(brianwilkerson) The code below was an attempt to recover from an e
rror case, but it |
| 5557 // needs to be applied as a recovery only after we know that parsing it as
an identifier | 5540 // needs to be applied as a recovery only after we know that parsing it as
an identifier |
| 5558 // doesn't work. Leaving the code as a reminder of how to recover. | 5541 // doesn't work. Leaving the code as a reminder of how to recover. |
| 5559 // if (isFunctionExpression(peek())) { | 5542 // if (isFunctionExpression(peek())) { |
| 5560 // // | 5543 // // |
| 5561 // // Function expressions were allowed to have names at one point,
but this is now illegal. | 5544 // // Function expressions were allowed to have names at one point,
but this is now illegal. |
| 5562 // // | 5545 // // |
| 5563 // reportError(ParserErrorCode.NAMED_FUNCTION_EXPRESSION, getAndAdv
ance()); | 5546 // reportError(ParserErrorCode.NAMED_FUNCTION_EXPRESSION, getAndAdv
ance()); |
| 5564 // return parseFunctionExpression(); | 5547 // return parseFunctionExpression(); |
| 5565 // } | 5548 // } |
| 5566 return parsePrefixedIdentifier(); | 5549 return parsePrefixedIdentifier(); |
| 5567 } else if (matchesKeyword(Keyword.NEW)) { | 5550 } else if (_matchesKeyword(Keyword.NEW)) { |
| 5568 return parseNewExpression(); | 5551 return _parseNewExpression(); |
| 5569 } else if (matchesKeyword(Keyword.CONST)) { | 5552 } else if (_matchesKeyword(Keyword.CONST)) { |
| 5570 return parseConstExpression(); | 5553 return _parseConstExpression(); |
| 5571 } else if (matches(TokenType.OPEN_PAREN)) { | 5554 } else if (_matches(TokenType.OPEN_PAREN)) { |
| 5572 if (isFunctionExpression(_currentToken)) { | 5555 if (_isFunctionExpression(_currentToken)) { |
| 5573 return parseFunctionExpression(); | 5556 return parseFunctionExpression(); |
| 5574 } | 5557 } |
| 5575 Token leftParenthesis = andAdvance; | 5558 Token leftParenthesis = andAdvance; |
| 5576 Expression expression = parseExpression2(); | 5559 Expression expression = parseExpression2(); |
| 5577 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 5560 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 5578 return new ParenthesizedExpression(leftParenthesis, expression, rightParen
thesis); | 5561 return new ParenthesizedExpression(leftParenthesis, expression, rightParen
thesis); |
| 5579 } else if (matches(TokenType.LT)) { | 5562 } else if (_matches(TokenType.LT)) { |
| 5580 return parseListOrMapLiteral(null); | 5563 return _parseListOrMapLiteral(null); |
| 5581 } else if (matches(TokenType.QUESTION)) { | 5564 } else if (_matches(TokenType.QUESTION)) { |
| 5582 return parseArgumentDefinitionTest(); | 5565 return _parseArgumentDefinitionTest(); |
| 5583 } else if (matchesKeyword(Keyword.VOID)) { | 5566 } else if (_matchesKeyword(Keyword.VOID)) { |
| 5584 // | 5567 // |
| 5585 // Recover from having a return type of "void" where a return type is not
expected. | 5568 // Recover from having a return type of "void" where a return type is not
expected. |
| 5586 // | 5569 // |
| 5587 // TODO(brianwilkerson) Improve this error message. | 5570 // TODO(brianwilkerson) Improve this error message. |
| 5588 reportErrorForCurrentToken(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToke
n.lexeme]); | 5571 _reportErrorForCurrentToken(ParserErrorCode.UNEXPECTED_TOKEN, [_currentTok
en.lexeme]); |
| 5589 advance(); | 5572 _advance(); |
| 5590 return parsePrimaryExpression(); | 5573 return _parsePrimaryExpression(); |
| 5591 } else if (matches(TokenType.HASH)) { | 5574 } else if (_matches(TokenType.HASH)) { |
| 5592 return parseSymbolLiteral(); | 5575 return _parseSymbolLiteral(); |
| 5593 } else { | 5576 } else { |
| 5594 reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); | 5577 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 5595 return createSyntheticIdentifier(); | 5578 return _createSyntheticIdentifier(); |
| 5596 } | 5579 } |
| 5597 } | 5580 } |
| 5598 | 5581 |
| 5599 /** | 5582 /** |
| 5600 * Parse a redirecting constructor invocation. | 5583 * Parse a redirecting constructor invocation. |
| 5601 * | 5584 * |
| 5602 * <pre> | 5585 * <pre> |
| 5603 * redirectingConstructorInvocation ::= | 5586 * redirectingConstructorInvocation ::= |
| 5604 * 'this' ('.' identifier)? arguments | 5587 * 'this' ('.' identifier)? arguments |
| 5605 * </pre> | 5588 * </pre> |
| 5606 * | 5589 * |
| 5607 * @return the redirecting constructor invocation that was parsed | 5590 * @return the redirecting constructor invocation that was parsed |
| 5608 */ | 5591 */ |
| 5609 RedirectingConstructorInvocation parseRedirectingConstructorInvocation() { | 5592 RedirectingConstructorInvocation _parseRedirectingConstructorInvocation() { |
| 5610 Token keyword = expectKeyword(Keyword.THIS); | 5593 Token keyword = _expectKeyword(Keyword.THIS); |
| 5611 Token period = null; | 5594 Token period = null; |
| 5612 SimpleIdentifier constructorName = null; | 5595 SimpleIdentifier constructorName = null; |
| 5613 if (matches(TokenType.PERIOD)) { | 5596 if (_matches(TokenType.PERIOD)) { |
| 5614 period = andAdvance; | 5597 period = andAdvance; |
| 5615 constructorName = parseSimpleIdentifier(); | 5598 constructorName = parseSimpleIdentifier(); |
| 5616 } | 5599 } |
| 5617 ArgumentList argumentList = parseArgumentList(); | 5600 ArgumentList argumentList = parseArgumentList(); |
| 5618 return new RedirectingConstructorInvocation(keyword, period, constructorName
, argumentList); | 5601 return new RedirectingConstructorInvocation(keyword, period, constructorName
, argumentList); |
| 5619 } | 5602 } |
| 5620 | 5603 |
| 5621 /** | 5604 /** |
| 5622 * Parse a relational expression. | 5605 * Parse a relational expression. |
| 5623 * | 5606 * |
| 5624 * <pre> | 5607 * <pre> |
| 5625 * relationalExpression ::= | 5608 * relationalExpression ::= |
| 5626 * bitwiseOrExpression ('is' '!'? type | 'as' type | relationalOperator bi
twiseOrExpression)? | 5609 * bitwiseOrExpression ('is' '!'? type | 'as' type | relationalOperator bi
twiseOrExpression)? |
| 5627 * | 'super' relationalOperator bitwiseOrExpression | 5610 * | 'super' relationalOperator bitwiseOrExpression |
| 5628 * </pre> | 5611 * </pre> |
| 5629 * | 5612 * |
| 5630 * @return the relational expression that was parsed | 5613 * @return the relational expression that was parsed |
| 5631 */ | 5614 */ |
| 5632 Expression parseRelationalExpression() { | 5615 Expression _parseRelationalExpression() { |
| 5633 if (matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isRelationalOpe
rator) { | 5616 if (_matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isRelationalOp
erator) { |
| 5634 Expression expression = new SuperExpression(andAdvance); | 5617 Expression expression = new SuperExpression(andAdvance); |
| 5635 Token operator = andAdvance; | 5618 Token operator = andAdvance; |
| 5636 expression = new BinaryExpression(expression, operator, parseBitwiseOrExpr
ession()); | 5619 expression = new BinaryExpression(expression, operator, parseBitwiseOrExpr
ession()); |
| 5637 return expression; | 5620 return expression; |
| 5638 } | 5621 } |
| 5639 Expression expression = parseBitwiseOrExpression(); | 5622 Expression expression = parseBitwiseOrExpression(); |
| 5640 if (matchesKeyword(Keyword.AS)) { | 5623 if (_matchesKeyword(Keyword.AS)) { |
| 5641 Token asOperator = andAdvance; | 5624 Token asOperator = andAdvance; |
| 5642 expression = new AsExpression(expression, asOperator, parseTypeName()); | 5625 expression = new AsExpression(expression, asOperator, parseTypeName()); |
| 5643 } else if (matchesKeyword(Keyword.IS)) { | 5626 } else if (_matchesKeyword(Keyword.IS)) { |
| 5644 Token isOperator = andAdvance; | 5627 Token isOperator = andAdvance; |
| 5645 Token notOperator = null; | 5628 Token notOperator = null; |
| 5646 if (matches(TokenType.BANG)) { | 5629 if (_matches(TokenType.BANG)) { |
| 5647 notOperator = andAdvance; | 5630 notOperator = andAdvance; |
| 5648 } | 5631 } |
| 5649 expression = new IsExpression(expression, isOperator, notOperator, parseTy
peName()); | 5632 expression = new IsExpression(expression, isOperator, notOperator, parseTy
peName()); |
| 5650 } else if (_currentToken.type.isRelationalOperator) { | 5633 } else if (_currentToken.type.isRelationalOperator) { |
| 5651 Token operator = andAdvance; | 5634 Token operator = andAdvance; |
| 5652 expression = new BinaryExpression(expression, operator, parseBitwiseOrExpr
ession()); | 5635 expression = new BinaryExpression(expression, operator, parseBitwiseOrExpr
ession()); |
| 5653 } | 5636 } |
| 5654 return expression; | 5637 return expression; |
| 5655 } | 5638 } |
| 5656 | 5639 |
| 5657 /** | 5640 /** |
| 5658 * Parse a rethrow expression. | 5641 * Parse a rethrow expression. |
| 5659 * | 5642 * |
| 5660 * <pre> | 5643 * <pre> |
| 5661 * rethrowExpression ::= | 5644 * rethrowExpression ::= |
| 5662 * 'rethrow' | 5645 * 'rethrow' |
| 5663 * </pre> | 5646 * </pre> |
| 5664 * | 5647 * |
| 5665 * @return the rethrow expression that was parsed | 5648 * @return the rethrow expression that was parsed |
| 5666 */ | 5649 */ |
| 5667 Expression parseRethrowExpression() => new RethrowExpression(expectKeyword(Key
word.RETHROW)); | 5650 Expression _parseRethrowExpression() => new RethrowExpression(_expectKeyword(K
eyword.RETHROW)); |
| 5668 | 5651 |
| 5669 /** | 5652 /** |
| 5670 * Parse a return statement. | 5653 * Parse a return statement. |
| 5671 * | 5654 * |
| 5672 * <pre> | 5655 * <pre> |
| 5673 * returnStatement ::= | 5656 * returnStatement ::= |
| 5674 * 'return' expression? ';' | 5657 * 'return' expression? ';' |
| 5675 * </pre> | 5658 * </pre> |
| 5676 * | 5659 * |
| 5677 * @return the return statement that was parsed | 5660 * @return the return statement that was parsed |
| 5678 */ | 5661 */ |
| 5679 Statement parseReturnStatement() { | 5662 Statement _parseReturnStatement() { |
| 5680 Token returnKeyword = expectKeyword(Keyword.RETURN); | 5663 Token returnKeyword = _expectKeyword(Keyword.RETURN); |
| 5681 if (matches(TokenType.SEMICOLON)) { | 5664 if (_matches(TokenType.SEMICOLON)) { |
| 5682 return new ReturnStatement(returnKeyword, null, andAdvance); | 5665 return new ReturnStatement(returnKeyword, null, andAdvance); |
| 5683 } | 5666 } |
| 5684 Expression expression = parseExpression2(); | 5667 Expression expression = parseExpression2(); |
| 5685 Token semicolon = expect(TokenType.SEMICOLON); | 5668 Token semicolon = _expect(TokenType.SEMICOLON); |
| 5686 return new ReturnStatement(returnKeyword, expression, semicolon); | 5669 return new ReturnStatement(returnKeyword, expression, semicolon); |
| 5687 } | 5670 } |
| 5688 | 5671 |
| 5689 /** | 5672 /** |
| 5690 * Parse a setter. | 5673 * Parse a setter. |
| 5691 * | 5674 * |
| 5692 * <pre> | 5675 * <pre> |
| 5693 * setter ::= | 5676 * setter ::= |
| 5694 * setterSignature functionBody? | 5677 * setterSignature functionBody? |
| 5695 * | 5678 * |
| 5696 * setterSignature ::= | 5679 * setterSignature ::= |
| 5697 * 'external'? 'static'? returnType? 'set' identifier formalParameterList | 5680 * 'external'? 'static'? returnType? 'set' identifier formalParameterList |
| 5698 * </pre> | 5681 * </pre> |
| 5699 * | 5682 * |
| 5700 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 5683 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 5701 * declaration | 5684 * declaration |
| 5702 * @param externalKeyword the 'external' token | 5685 * @param externalKeyword the 'external' token |
| 5703 * @param staticKeyword the static keyword, or `null` if the setter is not sta
tic | 5686 * @param staticKeyword the static keyword, or `null` if the setter is not sta
tic |
| 5704 * @param the return type that has already been parsed, or `null` if there was
no return | 5687 * @param the return type that has already been parsed, or `null` if there was
no return |
| 5705 * type | 5688 * type |
| 5706 * @return the setter that was parsed | 5689 * @return the setter that was parsed |
| 5707 */ | 5690 */ |
| 5708 MethodDeclaration parseSetter(CommentAndMetadata commentAndMetadata, Token ext
ernalKeyword, Token staticKeyword, TypeName returnType) { | 5691 MethodDeclaration _parseSetter(CommentAndMetadata commentAndMetadata, Token ex
ternalKeyword, Token staticKeyword, TypeName returnType) { |
| 5709 Token propertyKeyword = expectKeyword(Keyword.SET); | 5692 Token propertyKeyword = _expectKeyword(Keyword.SET); |
| 5710 SimpleIdentifier name = parseSimpleIdentifier(); | 5693 SimpleIdentifier name = parseSimpleIdentifier(); |
| 5711 FormalParameterList parameters = parseFormalParameterList(); | 5694 FormalParameterList parameters = parseFormalParameterList(); |
| 5712 validateFormalParameterList(parameters); | 5695 _validateFormalParameterList(parameters); |
| 5713 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo
rd == null, ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, false); | 5696 FunctionBody body = _parseFunctionBody(externalKeyword != null || staticKeyw
ord == null, ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, false); |
| 5714 if (externalKeyword != null && body is! EmptyFunctionBody) { | 5697 if (externalKeyword != null && body is! EmptyFunctionBody) { |
| 5715 reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, []); | 5698 _reportErrorForCurrentToken(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, [])
; |
| 5716 } | 5699 } |
| 5717 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null, nam
e, parameters, body); | 5700 return new MethodDeclaration(commentAndMetadata.comment, commentAndMetadata.
metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null, nam
e, parameters, body); |
| 5718 } | 5701 } |
| 5719 | 5702 |
| 5720 /** | 5703 /** |
| 5721 * Parse a shift expression. | 5704 * Parse a shift expression. |
| 5722 * | 5705 * |
| 5723 * <pre> | 5706 * <pre> |
| 5724 * shiftExpression ::= | 5707 * shiftExpression ::= |
| 5725 * additiveExpression (shiftOperator additiveExpression)* | 5708 * additiveExpression (shiftOperator additiveExpression)* |
| 5726 * | 'super' (shiftOperator additiveExpression)+ | 5709 * | 'super' (shiftOperator additiveExpression)+ |
| 5727 * </pre> | 5710 * </pre> |
| 5728 * | 5711 * |
| 5729 * @return the shift expression that was parsed | 5712 * @return the shift expression that was parsed |
| 5730 */ | 5713 */ |
| 5731 Expression parseShiftExpression() { | 5714 Expression _parseShiftExpression() { |
| 5732 Expression expression; | 5715 Expression expression; |
| 5733 if (matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isShiftOperator
) { | 5716 if (_matchesKeyword(Keyword.SUPER) && _currentToken.next.type.isShiftOperato
r) { |
| 5734 expression = new SuperExpression(andAdvance); | 5717 expression = new SuperExpression(andAdvance); |
| 5735 } else { | 5718 } else { |
| 5736 expression = parseAdditiveExpression(); | 5719 expression = _parseAdditiveExpression(); |
| 5737 } | 5720 } |
| 5738 while (_currentToken.type.isShiftOperator) { | 5721 while (_currentToken.type.isShiftOperator) { |
| 5739 Token operator = andAdvance; | 5722 Token operator = andAdvance; |
| 5740 expression = new BinaryExpression(expression, operator, parseAdditiveExpre
ssion()); | 5723 expression = new BinaryExpression(expression, operator, _parseAdditiveExpr
ession()); |
| 5741 } | 5724 } |
| 5742 return expression; | 5725 return expression; |
| 5743 } | 5726 } |
| 5744 | 5727 |
| 5745 /** | 5728 /** |
| 5746 * Parse a list of statements within a switch statement. | 5729 * Parse a list of statements within a switch statement. |
| 5747 * | 5730 * |
| 5748 * <pre> | 5731 * <pre> |
| 5749 * statements ::= | 5732 * statements ::= |
| 5750 * statement* | 5733 * statement* |
| 5751 * </pre> | 5734 * </pre> |
| 5752 * | 5735 * |
| 5753 * @return the statements that were parsed | 5736 * @return the statements that were parsed |
| 5754 */ | 5737 */ |
| 5755 List<Statement> parseStatementList() { | 5738 List<Statement> _parseStatementList() { |
| 5756 List<Statement> statements = new List<Statement>(); | 5739 List<Statement> statements = new List<Statement>(); |
| 5757 Token statementStart = _currentToken; | 5740 Token statementStart = _currentToken; |
| 5758 while (!matches(TokenType.EOF) && !matches(TokenType.CLOSE_CURLY_BRACKET) &&
!isSwitchMember()) { | 5741 while (!_matches(TokenType.EOF) && !_matches(TokenType.CLOSE_CURLY_BRACKET)
&& !_isSwitchMember()) { |
| 5759 statements.add(parseStatement2()); | 5742 statements.add(parseStatement2()); |
| 5760 if (identical(_currentToken, statementStart)) { | 5743 if (identical(_currentToken, statementStart)) { |
| 5761 reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_c
urrentToken.lexeme]); | 5744 _reportErrorForToken(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_
currentToken.lexeme]); |
| 5762 advance(); | 5745 _advance(); |
| 5763 } | 5746 } |
| 5764 statementStart = _currentToken; | 5747 statementStart = _currentToken; |
| 5765 } | 5748 } |
| 5766 return statements; | 5749 return statements; |
| 5767 } | 5750 } |
| 5768 | 5751 |
| 5769 /** | 5752 /** |
| 5770 * Parse a string literal that contains interpolations. | 5753 * Parse a string literal that contains interpolations. |
| 5771 * | 5754 * |
| 5772 * @return the string literal that was parsed | 5755 * @return the string literal that was parsed |
| 5773 */ | 5756 */ |
| 5774 StringInterpolation parseStringInterpolation(Token string) { | 5757 StringInterpolation _parseStringInterpolation(Token string) { |
| 5775 List<InterpolationElement> elements = new List<InterpolationElement>(); | 5758 List<InterpolationElement> elements = new List<InterpolationElement>(); |
| 5776 bool hasMore = matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches
(TokenType.STRING_INTERPOLATION_IDENTIFIER); | 5759 bool hasMore = _matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || _match
es(TokenType.STRING_INTERPOLATION_IDENTIFIER); |
| 5777 elements.add(new InterpolationString(string, computeStringValue(string.lexem
e, true, !hasMore))); | 5760 elements.add(new InterpolationString(string, _computeStringValue(string.lexe
me, true, !hasMore))); |
| 5778 while (hasMore) { | 5761 while (hasMore) { |
| 5779 if (matches(TokenType.STRING_INTERPOLATION_EXPRESSION)) { | 5762 if (_matches(TokenType.STRING_INTERPOLATION_EXPRESSION)) { |
| 5780 Token openToken = andAdvance; | 5763 Token openToken = andAdvance; |
| 5781 Expression expression = parseExpression2(); | 5764 Expression expression = parseExpression2(); |
| 5782 Token rightBracket = expect(TokenType.CLOSE_CURLY_BRACKET); | 5765 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
| 5783 elements.add(new InterpolationExpression(openToken, expression, rightBra
cket)); | 5766 elements.add(new InterpolationExpression(openToken, expression, rightBra
cket)); |
| 5784 } else { | 5767 } else { |
| 5785 Token openToken = andAdvance; | 5768 Token openToken = andAdvance; |
| 5786 Expression expression = null; | 5769 Expression expression = null; |
| 5787 if (matchesKeyword(Keyword.THIS)) { | 5770 if (_matchesKeyword(Keyword.THIS)) { |
| 5788 expression = new ThisExpression(andAdvance); | 5771 expression = new ThisExpression(andAdvance); |
| 5789 } else { | 5772 } else { |
| 5790 expression = parseSimpleIdentifier(); | 5773 expression = parseSimpleIdentifier(); |
| 5791 } | 5774 } |
| 5792 elements.add(new InterpolationExpression(openToken, expression, null)); | 5775 elements.add(new InterpolationExpression(openToken, expression, null)); |
| 5793 } | 5776 } |
| 5794 if (matches(TokenType.STRING)) { | 5777 if (_matches(TokenType.STRING)) { |
| 5795 string = andAdvance; | 5778 string = andAdvance; |
| 5796 hasMore = matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches(
TokenType.STRING_INTERPOLATION_IDENTIFIER); | 5779 hasMore = _matches(TokenType.STRING_INTERPOLATION_EXPRESSION) || _matche
s(TokenType.STRING_INTERPOLATION_IDENTIFIER); |
| 5797 elements.add(new InterpolationString(string, computeStringValue(string.l
exeme, false, !hasMore))); | 5780 elements.add(new InterpolationString(string, _computeStringValue(string.
lexeme, false, !hasMore))); |
| 5798 } | 5781 } |
| 5799 } | 5782 } |
| 5800 return new StringInterpolation(elements); | 5783 return new StringInterpolation(elements); |
| 5801 } | 5784 } |
| 5802 | 5785 |
| 5803 /** | 5786 /** |
| 5804 * Parse a super constructor invocation. | 5787 * Parse a super constructor invocation. |
| 5805 * | 5788 * |
| 5806 * <pre> | 5789 * <pre> |
| 5807 * superConstructorInvocation ::= | 5790 * superConstructorInvocation ::= |
| 5808 * 'super' ('.' identifier)? arguments | 5791 * 'super' ('.' identifier)? arguments |
| 5809 * </pre> | 5792 * </pre> |
| 5810 * | 5793 * |
| 5811 * @return the super constructor invocation that was parsed | 5794 * @return the super constructor invocation that was parsed |
| 5812 */ | 5795 */ |
| 5813 SuperConstructorInvocation parseSuperConstructorInvocation() { | 5796 SuperConstructorInvocation _parseSuperConstructorInvocation() { |
| 5814 Token keyword = expectKeyword(Keyword.SUPER); | 5797 Token keyword = _expectKeyword(Keyword.SUPER); |
| 5815 Token period = null; | 5798 Token period = null; |
| 5816 SimpleIdentifier constructorName = null; | 5799 SimpleIdentifier constructorName = null; |
| 5817 if (matches(TokenType.PERIOD)) { | 5800 if (_matches(TokenType.PERIOD)) { |
| 5818 period = andAdvance; | 5801 period = andAdvance; |
| 5819 constructorName = parseSimpleIdentifier(); | 5802 constructorName = parseSimpleIdentifier(); |
| 5820 } | 5803 } |
| 5821 ArgumentList argumentList = parseArgumentList(); | 5804 ArgumentList argumentList = parseArgumentList(); |
| 5822 return new SuperConstructorInvocation(keyword, period, constructorName, argu
mentList); | 5805 return new SuperConstructorInvocation(keyword, period, constructorName, argu
mentList); |
| 5823 } | 5806 } |
| 5824 | 5807 |
| 5825 /** | 5808 /** |
| 5826 * Parse a switch statement. | 5809 * Parse a switch statement. |
| 5827 * | 5810 * |
| 5828 * <pre> | 5811 * <pre> |
| 5829 * switchStatement ::= | 5812 * switchStatement ::= |
| 5830 * 'switch' '(' expression ')' '{' switchCase* defaultCase? '}' | 5813 * 'switch' '(' expression ')' '{' switchCase* defaultCase? '}' |
| 5831 * | 5814 * |
| 5832 * switchCase ::= | 5815 * switchCase ::= |
| 5833 * label* ('case' expression ':') statements | 5816 * label* ('case' expression ':') statements |
| 5834 * | 5817 * |
| 5835 * defaultCase ::= | 5818 * defaultCase ::= |
| 5836 * label* 'default' ':' statements | 5819 * label* 'default' ':' statements |
| 5837 * </pre> | 5820 * </pre> |
| 5838 * | 5821 * |
| 5839 * @return the switch statement that was parsed | 5822 * @return the switch statement that was parsed |
| 5840 */ | 5823 */ |
| 5841 SwitchStatement parseSwitchStatement() { | 5824 SwitchStatement _parseSwitchStatement() { |
| 5842 bool wasInSwitch = _inSwitch; | 5825 bool wasInSwitch = _inSwitch; |
| 5843 _inSwitch = true; | 5826 _inSwitch = true; |
| 5844 try { | 5827 try { |
| 5845 Set<String> definedLabels = new Set<String>(); | 5828 Set<String> definedLabels = new Set<String>(); |
| 5846 Token keyword = expectKeyword(Keyword.SWITCH); | 5829 Token keyword = _expectKeyword(Keyword.SWITCH); |
| 5847 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 5830 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 5848 Expression expression = parseExpression2(); | 5831 Expression expression = parseExpression2(); |
| 5849 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 5832 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 5850 Token leftBracket = expect(TokenType.OPEN_CURLY_BRACKET); | 5833 Token leftBracket = _expect(TokenType.OPEN_CURLY_BRACKET); |
| 5851 Token defaultKeyword = null; | 5834 Token defaultKeyword = null; |
| 5852 List<SwitchMember> members = new List<SwitchMember>(); | 5835 List<SwitchMember> members = new List<SwitchMember>(); |
| 5853 while (!matches(TokenType.EOF) && !matches(TokenType.CLOSE_CURLY_BRACKET))
{ | 5836 while (!_matches(TokenType.EOF) && !_matches(TokenType.CLOSE_CURLY_BRACKET
)) { |
| 5854 List<Label> labels = new List<Label>(); | 5837 List<Label> labels = new List<Label>(); |
| 5855 while (matchesIdentifier() && tokenMatches(peek(), TokenType.COLON)) { | 5838 while (_matchesIdentifier() && _tokenMatches(_peek(), TokenType.COLON))
{ |
| 5856 SimpleIdentifier identifier = parseSimpleIdentifier(); | 5839 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 5857 String label = identifier.token.lexeme; | 5840 String label = identifier.token.lexeme; |
| 5858 if (definedLabels.contains(label)) { | 5841 if (definedLabels.contains(label)) { |
| 5859 reportErrorForToken(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEM
ENT, identifier.token, [label]); | 5842 _reportErrorForToken(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATE
MENT, identifier.token, [label]); |
| 5860 } else { | 5843 } else { |
| 5861 definedLabels.add(label); | 5844 definedLabels.add(label); |
| 5862 } | 5845 } |
| 5863 Token colon = expect(TokenType.COLON); | 5846 Token colon = _expect(TokenType.COLON); |
| 5864 labels.add(new Label(identifier, colon)); | 5847 labels.add(new Label(identifier, colon)); |
| 5865 } | 5848 } |
| 5866 if (matchesKeyword(Keyword.CASE)) { | 5849 if (_matchesKeyword(Keyword.CASE)) { |
| 5867 Token caseKeyword = andAdvance; | 5850 Token caseKeyword = andAdvance; |
| 5868 Expression caseExpression = parseExpression2(); | 5851 Expression caseExpression = parseExpression2(); |
| 5869 Token colon = expect(TokenType.COLON); | 5852 Token colon = _expect(TokenType.COLON); |
| 5870 members.add(new SwitchCase(labels, caseKeyword, caseExpression, colon,
parseStatementList())); | 5853 members.add(new SwitchCase(labels, caseKeyword, caseExpression, colon,
_parseStatementList())); |
| 5871 if (defaultKeyword != null) { | 5854 if (defaultKeyword != null) { |
| 5872 reportErrorForToken(ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CA
SE, caseKeyword, []); | 5855 _reportErrorForToken(ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_C
ASE, caseKeyword, []); |
| 5873 } | 5856 } |
| 5874 } else if (matchesKeyword(Keyword.DEFAULT)) { | 5857 } else if (_matchesKeyword(Keyword.DEFAULT)) { |
| 5875 if (defaultKeyword != null) { | 5858 if (defaultKeyword != null) { |
| 5876 reportErrorForToken(ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASE
S, peek(), []); | 5859 _reportErrorForToken(ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CAS
ES, _peek(), []); |
| 5877 } | 5860 } |
| 5878 defaultKeyword = andAdvance; | 5861 defaultKeyword = andAdvance; |
| 5879 Token colon = expect(TokenType.COLON); | 5862 Token colon = _expect(TokenType.COLON); |
| 5880 members.add(new SwitchDefault(labels, defaultKeyword, colon, parseStat
ementList())); | 5863 members.add(new SwitchDefault(labels, defaultKeyword, colon, _parseSta
tementList())); |
| 5881 } else { | 5864 } else { |
| 5882 // We need to advance, otherwise we could end up in an infinite loop,
but this could be a | 5865 // We need to advance, otherwise we could end up in an infinite loop,
but this could be a |
| 5883 // lot smarter about recovering from the error. | 5866 // lot smarter about recovering from the error. |
| 5884 reportErrorForCurrentToken(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, [
]); | 5867 _reportErrorForCurrentToken(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT,
[]); |
| 5885 while (!matches(TokenType.EOF) && !matches(TokenType.CLOSE_CURLY_BRACK
ET) && !matchesKeyword(Keyword.CASE) && !matchesKeyword(Keyword.DEFAULT)) { | 5868 while (!_matches(TokenType.EOF) && !_matches(TokenType.CLOSE_CURLY_BRA
CKET) && !_matchesKeyword(Keyword.CASE) && !_matchesKeyword(Keyword.DEFAULT)) { |
| 5886 advance(); | 5869 _advance(); |
| 5887 } | 5870 } |
| 5888 } | 5871 } |
| 5889 } | 5872 } |
| 5890 Token rightBracket = expect(TokenType.CLOSE_CURLY_BRACKET); | 5873 Token rightBracket = _expect(TokenType.CLOSE_CURLY_BRACKET); |
| 5891 return new SwitchStatement(keyword, leftParenthesis, expression, rightPare
nthesis, leftBracket, members, rightBracket); | 5874 return new SwitchStatement(keyword, leftParenthesis, expression, rightPare
nthesis, leftBracket, members, rightBracket); |
| 5892 } finally { | 5875 } finally { |
| 5893 _inSwitch = wasInSwitch; | 5876 _inSwitch = wasInSwitch; |
| 5894 } | 5877 } |
| 5895 } | 5878 } |
| 5896 | 5879 |
| 5897 /** | 5880 /** |
| 5898 * Parse a symbol literal. | 5881 * Parse a symbol literal. |
| 5899 * | 5882 * |
| 5900 * <pre> | 5883 * <pre> |
| 5901 * symbolLiteral ::= | 5884 * symbolLiteral ::= |
| 5902 * '#' identifier ('.' identifier)* | 5885 * '#' identifier ('.' identifier)* |
| 5903 * </pre> | 5886 * </pre> |
| 5904 * | 5887 * |
| 5905 * @return the symbol literal that was parsed | 5888 * @return the symbol literal that was parsed |
| 5906 */ | 5889 */ |
| 5907 SymbolLiteral parseSymbolLiteral() { | 5890 SymbolLiteral _parseSymbolLiteral() { |
| 5908 Token poundSign = andAdvance; | 5891 Token poundSign = andAdvance; |
| 5909 List<Token> components = new List<Token>(); | 5892 List<Token> components = new List<Token>(); |
| 5910 if (matchesIdentifier()) { | 5893 if (_matchesIdentifier()) { |
| 5911 components.add(andAdvance); | 5894 components.add(andAdvance); |
| 5912 while (matches(TokenType.PERIOD)) { | 5895 while (_matches(TokenType.PERIOD)) { |
| 5913 advance(); | 5896 _advance(); |
| 5914 if (matchesIdentifier()) { | 5897 if (_matchesIdentifier()) { |
| 5915 components.add(andAdvance); | 5898 components.add(andAdvance); |
| 5916 } else { | 5899 } else { |
| 5917 reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); | 5900 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 5918 components.add(createSyntheticToken(TokenType.IDENTIFIER)); | 5901 components.add(_createSyntheticToken(TokenType.IDENTIFIER)); |
| 5919 break; | 5902 break; |
| 5920 } | 5903 } |
| 5921 } | 5904 } |
| 5922 } else if (_currentToken.isOperator) { | 5905 } else if (_currentToken.isOperator) { |
| 5923 components.add(andAdvance); | 5906 components.add(andAdvance); |
| 5924 } else { | 5907 } else { |
| 5925 reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); | 5908 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 5926 components.add(createSyntheticToken(TokenType.IDENTIFIER)); | 5909 components.add(_createSyntheticToken(TokenType.IDENTIFIER)); |
| 5927 } | 5910 } |
| 5928 return new SymbolLiteral(poundSign, new List.from(components)); | 5911 return new SymbolLiteral(poundSign, new List.from(components)); |
| 5929 } | 5912 } |
| 5930 | 5913 |
| 5931 /** | 5914 /** |
| 5932 * Parse a throw expression. | 5915 * Parse a throw expression. |
| 5933 * | 5916 * |
| 5934 * <pre> | 5917 * <pre> |
| 5935 * throwExpression ::= | 5918 * throwExpression ::= |
| 5936 * 'throw' expression | 5919 * 'throw' expression |
| 5937 * </pre> | 5920 * </pre> |
| 5938 * | 5921 * |
| 5939 * @return the throw expression that was parsed | 5922 * @return the throw expression that was parsed |
| 5940 */ | 5923 */ |
| 5941 Expression parseThrowExpression() { | 5924 Expression _parseThrowExpression() { |
| 5942 Token keyword = expectKeyword(Keyword.THROW); | 5925 Token keyword = _expectKeyword(Keyword.THROW); |
| 5943 if (matches(TokenType.SEMICOLON) || matches(TokenType.CLOSE_PAREN)) { | 5926 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.CLOSE_PAREN)) { |
| 5944 reportErrorForToken(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentT
oken, []); | 5927 _reportErrorForToken(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _current
Token, []); |
| 5945 return new ThrowExpression(keyword, createSyntheticIdentifier()); | 5928 return new ThrowExpression(keyword, _createSyntheticIdentifier()); |
| 5946 } | 5929 } |
| 5947 Expression expression = parseExpression2(); | 5930 Expression expression = parseExpression2(); |
| 5948 return new ThrowExpression(keyword, expression); | 5931 return new ThrowExpression(keyword, expression); |
| 5949 } | 5932 } |
| 5950 | 5933 |
| 5951 /** | 5934 /** |
| 5952 * Parse a throw expression. | 5935 * Parse a throw expression. |
| 5953 * | 5936 * |
| 5954 * <pre> | 5937 * <pre> |
| 5955 * throwExpressionWithoutCascade ::= | 5938 * throwExpressionWithoutCascade ::= |
| 5956 * 'throw' expressionWithoutCascade | 5939 * 'throw' expressionWithoutCascade |
| 5957 * </pre> | 5940 * </pre> |
| 5958 * | 5941 * |
| 5959 * @return the throw expression that was parsed | 5942 * @return the throw expression that was parsed |
| 5960 */ | 5943 */ |
| 5961 Expression parseThrowExpressionWithoutCascade() { | 5944 Expression _parseThrowExpressionWithoutCascade() { |
| 5962 Token keyword = expectKeyword(Keyword.THROW); | 5945 Token keyword = _expectKeyword(Keyword.THROW); |
| 5963 if (matches(TokenType.SEMICOLON) || matches(TokenType.CLOSE_PAREN)) { | 5946 if (_matches(TokenType.SEMICOLON) || _matches(TokenType.CLOSE_PAREN)) { |
| 5964 reportErrorForToken(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentT
oken, []); | 5947 _reportErrorForToken(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _current
Token, []); |
| 5965 return new ThrowExpression(keyword, createSyntheticIdentifier()); | 5948 return new ThrowExpression(keyword, _createSyntheticIdentifier()); |
| 5966 } | 5949 } |
| 5967 Expression expression = parseExpressionWithoutCascade(); | 5950 Expression expression = parseExpressionWithoutCascade(); |
| 5968 return new ThrowExpression(keyword, expression); | 5951 return new ThrowExpression(keyword, expression); |
| 5969 } | 5952 } |
| 5970 | 5953 |
| 5971 /** | 5954 /** |
| 5972 * Parse a try statement. | 5955 * Parse a try statement. |
| 5973 * | 5956 * |
| 5974 * <pre> | 5957 * <pre> |
| 5975 * tryStatement ::= | 5958 * tryStatement ::= |
| 5976 * 'try' block (onPart+ finallyPart? | finallyPart) | 5959 * 'try' block (onPart+ finallyPart? | finallyPart) |
| 5977 * | 5960 * |
| 5978 * onPart ::= | 5961 * onPart ::= |
| 5979 * catchPart block | 5962 * catchPart block |
| 5980 * | 'on' type catchPart? block | 5963 * | 'on' type catchPart? block |
| 5981 * | 5964 * |
| 5982 * catchPart ::= | 5965 * catchPart ::= |
| 5983 * 'catch' '(' identifier (',' identifier)? ')' | 5966 * 'catch' '(' identifier (',' identifier)? ')' |
| 5984 * | 5967 * |
| 5985 * finallyPart ::= | 5968 * finallyPart ::= |
| 5986 * 'finally' block | 5969 * 'finally' block |
| 5987 * </pre> | 5970 * </pre> |
| 5988 * | 5971 * |
| 5989 * @return the try statement that was parsed | 5972 * @return the try statement that was parsed |
| 5990 */ | 5973 */ |
| 5991 Statement parseTryStatement() { | 5974 Statement _parseTryStatement() { |
| 5992 Token tryKeyword = expectKeyword(Keyword.TRY); | 5975 Token tryKeyword = _expectKeyword(Keyword.TRY); |
| 5993 Block body = parseBlock(); | 5976 Block body = parseBlock(); |
| 5994 List<CatchClause> catchClauses = new List<CatchClause>(); | 5977 List<CatchClause> catchClauses = new List<CatchClause>(); |
| 5995 Block finallyClause = null; | 5978 Block finallyClause = null; |
| 5996 while (matchesString(_ON) || matchesKeyword(Keyword.CATCH)) { | 5979 while (_matchesString(_ON) || _matchesKeyword(Keyword.CATCH)) { |
| 5997 Token onKeyword = null; | 5980 Token onKeyword = null; |
| 5998 TypeName exceptionType = null; | 5981 TypeName exceptionType = null; |
| 5999 if (matchesString(_ON)) { | 5982 if (_matchesString(_ON)) { |
| 6000 onKeyword = andAdvance; | 5983 onKeyword = andAdvance; |
| 6001 exceptionType = parseTypeName(); | 5984 exceptionType = parseTypeName(); |
| 6002 } | 5985 } |
| 6003 Token catchKeyword = null; | 5986 Token catchKeyword = null; |
| 6004 Token leftParenthesis = null; | 5987 Token leftParenthesis = null; |
| 6005 SimpleIdentifier exceptionParameter = null; | 5988 SimpleIdentifier exceptionParameter = null; |
| 6006 Token comma = null; | 5989 Token comma = null; |
| 6007 SimpleIdentifier stackTraceParameter = null; | 5990 SimpleIdentifier stackTraceParameter = null; |
| 6008 Token rightParenthesis = null; | 5991 Token rightParenthesis = null; |
| 6009 if (matchesKeyword(Keyword.CATCH)) { | 5992 if (_matchesKeyword(Keyword.CATCH)) { |
| 6010 catchKeyword = andAdvance; | 5993 catchKeyword = andAdvance; |
| 6011 leftParenthesis = expect(TokenType.OPEN_PAREN); | 5994 leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 6012 exceptionParameter = parseSimpleIdentifier(); | 5995 exceptionParameter = parseSimpleIdentifier(); |
| 6013 if (matches(TokenType.COMMA)) { | 5996 if (_matches(TokenType.COMMA)) { |
| 6014 comma = andAdvance; | 5997 comma = andAdvance; |
| 6015 stackTraceParameter = parseSimpleIdentifier(); | 5998 stackTraceParameter = parseSimpleIdentifier(); |
| 6016 } | 5999 } |
| 6017 rightParenthesis = expect(TokenType.CLOSE_PAREN); | 6000 rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 6018 } | 6001 } |
| 6019 Block catchBody = parseBlock(); | 6002 Block catchBody = parseBlock(); |
| 6020 catchClauses.add(new CatchClause(onKeyword, exceptionType, catchKeyword, l
eftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParenthesis
, catchBody)); | 6003 catchClauses.add(new CatchClause(onKeyword, exceptionType, catchKeyword, l
eftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParenthesis
, catchBody)); |
| 6021 } | 6004 } |
| 6022 Token finallyKeyword = null; | 6005 Token finallyKeyword = null; |
| 6023 if (matchesKeyword(Keyword.FINALLY)) { | 6006 if (_matchesKeyword(Keyword.FINALLY)) { |
| 6024 finallyKeyword = andAdvance; | 6007 finallyKeyword = andAdvance; |
| 6025 finallyClause = parseBlock(); | 6008 finallyClause = parseBlock(); |
| 6026 } else { | 6009 } else { |
| 6027 if (catchClauses.isEmpty) { | 6010 if (catchClauses.isEmpty) { |
| 6028 reportErrorForCurrentToken(ParserErrorCode.MISSING_CATCH_OR_FINALLY, [])
; | 6011 _reportErrorForCurrentToken(ParserErrorCode.MISSING_CATCH_OR_FINALLY, []
); |
| 6029 } | 6012 } |
| 6030 } | 6013 } |
| 6031 return new TryStatement(tryKeyword, body, catchClauses, finallyKeyword, fina
llyClause); | 6014 return new TryStatement(tryKeyword, body, catchClauses, finallyKeyword, fina
llyClause); |
| 6032 } | 6015 } |
| 6033 | 6016 |
| 6034 /** | 6017 /** |
| 6035 * Parse a type alias. | 6018 * Parse a type alias. |
| 6036 * | 6019 * |
| 6037 * <pre> | 6020 * <pre> |
| 6038 * typeAlias ::= | 6021 * typeAlias ::= |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6051 * functionTypeAlias ::= | 6034 * functionTypeAlias ::= |
| 6052 * functionPrefix typeParameterList? formalParameterList ';' | 6035 * functionPrefix typeParameterList? formalParameterList ';' |
| 6053 * | 6036 * |
| 6054 * functionPrefix ::= | 6037 * functionPrefix ::= |
| 6055 * returnType? name | 6038 * returnType? name |
| 6056 * </pre> | 6039 * </pre> |
| 6057 * | 6040 * |
| 6058 * @param commentAndMetadata the metadata to be associated with the member | 6041 * @param commentAndMetadata the metadata to be associated with the member |
| 6059 * @return the type alias that was parsed | 6042 * @return the type alias that was parsed |
| 6060 */ | 6043 */ |
| 6061 TypeAlias parseTypeAlias(CommentAndMetadata commentAndMetadata) { | 6044 TypeAlias _parseTypeAlias(CommentAndMetadata commentAndMetadata) { |
| 6062 Token keyword = expectKeyword(Keyword.TYPEDEF); | 6045 Token keyword = _expectKeyword(Keyword.TYPEDEF); |
| 6063 if (matchesIdentifier()) { | 6046 if (_matchesIdentifier()) { |
| 6064 Token next = peek(); | 6047 Token next = _peek(); |
| 6065 if (tokenMatches(next, TokenType.LT)) { | 6048 if (_tokenMatches(next, TokenType.LT)) { |
| 6066 next = skipTypeParameterList(next); | 6049 next = _skipTypeParameterList(next); |
| 6067 if (next != null && tokenMatches(next, TokenType.EQ)) { | 6050 if (next != null && _tokenMatches(next, TokenType.EQ)) { |
| 6068 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, null, ke
yword); | 6051 TypeAlias typeAlias = _parseClassTypeAlias(commentAndMetadata, null, k
eyword); |
| 6069 reportErrorForToken(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keywo
rd, []); | 6052 _reportErrorForToken(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyw
ord, []); |
| 6070 return typeAlias; | 6053 return typeAlias; |
| 6071 } | 6054 } |
| 6072 } else if (tokenMatches(next, TokenType.EQ)) { | 6055 } else if (_tokenMatches(next, TokenType.EQ)) { |
| 6073 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, null, keyw
ord); | 6056 TypeAlias typeAlias = _parseClassTypeAlias(commentAndMetadata, null, key
word); |
| 6074 reportErrorForToken(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword
, []); | 6057 _reportErrorForToken(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keywor
d, []); |
| 6075 return typeAlias; | 6058 return typeAlias; |
| 6076 } | 6059 } |
| 6077 } | 6060 } |
| 6078 return parseFunctionTypeAlias(commentAndMetadata, keyword); | 6061 return _parseFunctionTypeAlias(commentAndMetadata, keyword); |
| 6079 } | 6062 } |
| 6080 | 6063 |
| 6081 /** | 6064 /** |
| 6082 * Parse a unary expression. | 6065 * Parse a unary expression. |
| 6083 * | 6066 * |
| 6084 * <pre> | 6067 * <pre> |
| 6085 * unaryExpression ::= | 6068 * unaryExpression ::= |
| 6086 * prefixOperator unaryExpression | 6069 * prefixOperator unaryExpression |
| 6087 * | postfixExpression | 6070 * | postfixExpression |
| 6088 * | unaryOperator 'super' | 6071 * | unaryOperator 'super' |
| 6089 * | '-' 'super' | 6072 * | '-' 'super' |
| 6090 * | incrementOperator assignableExpression | 6073 * | incrementOperator assignableExpression |
| 6091 * </pre> | 6074 * </pre> |
| 6092 * | 6075 * |
| 6093 * @return the unary expression that was parsed | 6076 * @return the unary expression that was parsed |
| 6094 */ | 6077 */ |
| 6095 Expression parseUnaryExpression() { | 6078 Expression _parseUnaryExpression() { |
| 6096 if (matches(TokenType.MINUS) || matches(TokenType.BANG) || matches(TokenType
.TILDE)) { | 6079 if (_matches(TokenType.MINUS) || _matches(TokenType.BANG) || _matches(TokenT
ype.TILDE)) { |
| 6097 Token operator = andAdvance; | 6080 Token operator = andAdvance; |
| 6098 if (matchesKeyword(Keyword.SUPER)) { | 6081 if (_matchesKeyword(Keyword.SUPER)) { |
| 6099 if (tokenMatches(peek(), TokenType.OPEN_SQUARE_BRACKET) || tokenMatches(
peek(), TokenType.PERIOD)) { | 6082 if (_tokenMatches(_peek(), TokenType.OPEN_SQUARE_BRACKET) || _tokenMatch
es(_peek(), TokenType.PERIOD)) { |
| 6100 // "prefixOperator unaryExpression" | 6083 // "prefixOperator unaryExpression" |
| 6101 // --> "prefixOperator postfixExpression" | 6084 // --> "prefixOperator postfixExpression" |
| 6102 // --> "prefixOperator primary selector*" | 6085 // --> "prefixOperator primary selector*" |
| 6103 // --> "prefixOperator 'super' assignableSelector selector*" | 6086 // --> "prefixOperator 'super' assignableSelector selector*" |
| 6104 return new PrefixExpression(operator, parseUnaryExpression()); | 6087 return new PrefixExpression(operator, _parseUnaryExpression()); |
| 6105 } | 6088 } |
| 6106 return new PrefixExpression(operator, new SuperExpression(andAdvance)); | 6089 return new PrefixExpression(operator, new SuperExpression(andAdvance)); |
| 6107 } | 6090 } |
| 6108 return new PrefixExpression(operator, parseUnaryExpression()); | 6091 return new PrefixExpression(operator, _parseUnaryExpression()); |
| 6109 } else if (_currentToken.type.isIncrementOperator) { | 6092 } else if (_currentToken.type.isIncrementOperator) { |
| 6110 Token operator = andAdvance; | 6093 Token operator = andAdvance; |
| 6111 if (matchesKeyword(Keyword.SUPER)) { | 6094 if (_matchesKeyword(Keyword.SUPER)) { |
| 6112 if (tokenMatches(peek(), TokenType.OPEN_SQUARE_BRACKET) || tokenMatches(
peek(), TokenType.PERIOD)) { | 6095 if (_tokenMatches(_peek(), TokenType.OPEN_SQUARE_BRACKET) || _tokenMatch
es(_peek(), TokenType.PERIOD)) { |
| 6113 // --> "prefixOperator 'super' assignableSelector selector*" | 6096 // --> "prefixOperator 'super' assignableSelector selector*" |
| 6114 return new PrefixExpression(operator, parseUnaryExpression()); | 6097 return new PrefixExpression(operator, _parseUnaryExpression()); |
| 6115 } | 6098 } |
| 6116 // | 6099 // |
| 6117 // Even though it is not valid to use an incrementing operator ('++' or
'--') before 'super', | 6100 // Even though it is not valid to use an incrementing operator ('++' or
'--') before 'super', |
| 6118 // we can (and therefore must) interpret "--super" as semantically equiv
alent to "-(-super)". | 6101 // we can (and therefore must) interpret "--super" as semantically equiv
alent to "-(-super)". |
| 6119 // Unfortunately, we cannot do the same for "++super" because "+super" i
s also not valid. | 6102 // Unfortunately, we cannot do the same for "++super" because "+super" i
s also not valid. |
| 6120 // | 6103 // |
| 6121 if (identical(operator.type, TokenType.MINUS_MINUS)) { | 6104 if (identical(operator.type, TokenType.MINUS_MINUS)) { |
| 6122 int offset = operator.offset; | 6105 int offset = operator.offset; |
| 6123 Token firstOperator = new Token(TokenType.MINUS, offset); | 6106 Token firstOperator = new Token(TokenType.MINUS, offset); |
| 6124 Token secondOperator = new Token(TokenType.MINUS, offset + 1); | 6107 Token secondOperator = new Token(TokenType.MINUS, offset + 1); |
| 6125 secondOperator.setNext(_currentToken); | 6108 secondOperator.setNext(_currentToken); |
| 6126 firstOperator.setNext(secondOperator); | 6109 firstOperator.setNext(secondOperator); |
| 6127 operator.previous.setNext(firstOperator); | 6110 operator.previous.setNext(firstOperator); |
| 6128 return new PrefixExpression(firstOperator, new PrefixExpression(second
Operator, new SuperExpression(andAdvance))); | 6111 return new PrefixExpression(firstOperator, new PrefixExpression(second
Operator, new SuperExpression(andAdvance))); |
| 6129 } else { | 6112 } else { |
| 6130 // Invalid operator before 'super' | 6113 // Invalid operator before 'super' |
| 6131 reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER,
[operator.lexeme]); | 6114 _reportErrorForCurrentToken(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER
, [operator.lexeme]); |
| 6132 return new PrefixExpression(operator, new SuperExpression(andAdvance))
; | 6115 return new PrefixExpression(operator, new SuperExpression(andAdvance))
; |
| 6133 } | 6116 } |
| 6134 } | 6117 } |
| 6135 return new PrefixExpression(operator, parseAssignableExpression(false)); | 6118 return new PrefixExpression(operator, _parseAssignableExpression(false)); |
| 6136 } else if (matches(TokenType.PLUS)) { | 6119 } else if (_matches(TokenType.PLUS)) { |
| 6137 reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); | 6120 _reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 6138 return createSyntheticIdentifier(); | 6121 return _createSyntheticIdentifier(); |
| 6139 } | 6122 } |
| 6140 return parsePostfixExpression(); | 6123 return _parsePostfixExpression(); |
| 6141 } | 6124 } |
| 6142 | 6125 |
| 6143 /** | 6126 /** |
| 6144 * Parse a variable declaration. | 6127 * Parse a variable declaration. |
| 6145 * | 6128 * |
| 6146 * <pre> | 6129 * <pre> |
| 6147 * variableDeclaration ::= | 6130 * variableDeclaration ::= |
| 6148 * identifier ('=' expression)? | 6131 * identifier ('=' expression)? |
| 6149 * </pre> | 6132 * </pre> |
| 6150 * | 6133 * |
| 6151 * @return the variable declaration that was parsed | 6134 * @return the variable declaration that was parsed |
| 6152 */ | 6135 */ |
| 6153 VariableDeclaration parseVariableDeclaration() { | 6136 VariableDeclaration _parseVariableDeclaration() { |
| 6154 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 6137 CommentAndMetadata commentAndMetadata = _parseCommentAndMetadata(); |
| 6155 SimpleIdentifier name = parseSimpleIdentifier(); | 6138 SimpleIdentifier name = parseSimpleIdentifier(); |
| 6156 Token equals = null; | 6139 Token equals = null; |
| 6157 Expression initializer = null; | 6140 Expression initializer = null; |
| 6158 if (matches(TokenType.EQ)) { | 6141 if (_matches(TokenType.EQ)) { |
| 6159 equals = andAdvance; | 6142 equals = andAdvance; |
| 6160 initializer = parseExpression2(); | 6143 initializer = parseExpression2(); |
| 6161 } | 6144 } |
| 6162 return new VariableDeclaration(commentAndMetadata.comment, commentAndMetadat
a.metadata, name, equals, initializer); | 6145 return new VariableDeclaration(commentAndMetadata.comment, commentAndMetadat
a.metadata, name, equals, initializer); |
| 6163 } | 6146 } |
| 6164 | 6147 |
| 6165 /** | 6148 /** |
| 6166 * Parse a variable declaration list. | 6149 * Parse a variable declaration list. |
| 6167 * | 6150 * |
| 6168 * <pre> | 6151 * <pre> |
| 6169 * variableDeclarationList ::= | 6152 * variableDeclarationList ::= |
| 6170 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* | 6153 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* |
| 6171 * </pre> | 6154 * </pre> |
| 6172 * | 6155 * |
| 6173 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration list | 6156 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration list |
| 6174 * @return the variable declaration list that was parsed | 6157 * @return the variable declaration list that was parsed |
| 6175 */ | 6158 */ |
| 6176 VariableDeclarationList parseVariableDeclarationListAfterMetadata(CommentAndMe
tadata commentAndMetadata) { | 6159 VariableDeclarationList _parseVariableDeclarationListAfterMetadata(CommentAndM
etadata commentAndMetadata) { |
| 6177 FinalConstVarOrType holder = parseFinalConstVarOrType(false); | 6160 FinalConstVarOrType holder = _parseFinalConstVarOrType(false); |
| 6178 return parseVariableDeclarationListAfterType(commentAndMetadata, holder.keyw
ord, holder.type); | 6161 return _parseVariableDeclarationListAfterType(commentAndMetadata, holder.key
word, holder.type); |
| 6179 } | 6162 } |
| 6180 | 6163 |
| 6181 /** | 6164 /** |
| 6182 * Parse a variable declaration list. | 6165 * Parse a variable declaration list. |
| 6183 * | 6166 * |
| 6184 * <pre> | 6167 * <pre> |
| 6185 * variableDeclarationList ::= | 6168 * variableDeclarationList ::= |
| 6186 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* | 6169 * finalConstVarOrType variableDeclaration (',' variableDeclaration)* |
| 6187 * </pre> | 6170 * </pre> |
| 6188 * | 6171 * |
| 6189 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration list, or | 6172 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration list, or |
| 6190 * `null` if there is no attempt at parsing the comment and metadata | 6173 * `null` if there is no attempt at parsing the comment and metadata |
| 6191 * @param keyword the token representing the 'final', 'const' or 'var' keyword
, or `null` if | 6174 * @param keyword the token representing the 'final', 'const' or 'var' keyword
, or `null` if |
| 6192 * there is no keyword | 6175 * there is no keyword |
| 6193 * @param type the type of the variables in the list | 6176 * @param type the type of the variables in the list |
| 6194 * @return the variable declaration list that was parsed | 6177 * @return the variable declaration list that was parsed |
| 6195 */ | 6178 */ |
| 6196 VariableDeclarationList parseVariableDeclarationListAfterType(CommentAndMetada
ta commentAndMetadata, Token keyword, TypeName type) { | 6179 VariableDeclarationList _parseVariableDeclarationListAfterType(CommentAndMetad
ata commentAndMetadata, Token keyword, TypeName type) { |
| 6197 if (type != null && keyword != null && tokenMatchesKeyword(keyword, Keyword.
VAR)) { | 6180 if (type != null && keyword != null && _tokenMatchesKeyword(keyword, Keyword
.VAR)) { |
| 6198 reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, keyword, []); | 6181 _reportErrorForToken(ParserErrorCode.VAR_AND_TYPE, keyword, []); |
| 6199 } | 6182 } |
| 6200 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 6183 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
| 6201 variables.add(parseVariableDeclaration()); | 6184 variables.add(_parseVariableDeclaration()); |
| 6202 while (matches(TokenType.COMMA)) { | 6185 while (_matches(TokenType.COMMA)) { |
| 6203 advance(); | 6186 _advance(); |
| 6204 variables.add(parseVariableDeclaration()); | 6187 variables.add(_parseVariableDeclaration()); |
| 6205 } | 6188 } |
| 6206 return new VariableDeclarationList(commentAndMetadata != null ? commentAndMe
tadata.comment : null, commentAndMetadata != null ? commentAndMetadata.metadata
: null, keyword, type, variables); | 6189 return new VariableDeclarationList(commentAndMetadata != null ? commentAndMe
tadata.comment : null, commentAndMetadata != null ? commentAndMetadata.metadata
: null, keyword, type, variables); |
| 6207 } | 6190 } |
| 6208 | 6191 |
| 6209 /** | 6192 /** |
| 6210 * Parse a variable declaration statement. | 6193 * Parse a variable declaration statement. |
| 6211 * | 6194 * |
| 6212 * <pre> | 6195 * <pre> |
| 6213 * variableDeclarationStatement ::= | 6196 * variableDeclarationStatement ::= |
| 6214 * variableDeclarationList ';' | 6197 * variableDeclarationList ';' |
| 6215 * </pre> | 6198 * </pre> |
| 6216 * | 6199 * |
| 6217 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration | 6200 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration |
| 6218 * statement, or `null` if there is no attempt at parsing the comment
and metadata | 6201 * statement, or `null` if there is no attempt at parsing the comment
and metadata |
| 6219 * @return the variable declaration statement that was parsed | 6202 * @return the variable declaration statement that was parsed |
| 6220 */ | 6203 */ |
| 6221 VariableDeclarationStatement parseVariableDeclarationStatementAfterMetadata(Co
mmentAndMetadata commentAndMetadata) { | 6204 VariableDeclarationStatement _parseVariableDeclarationStatementAfterMetadata(C
ommentAndMetadata commentAndMetadata) { |
| 6222 // Token startToken = currentToken; | 6205 // Token startToken = currentToken; |
| 6223 VariableDeclarationList variableList = parseVariableDeclarationListAfterMeta
data(commentAndMetadata); | 6206 VariableDeclarationList variableList = _parseVariableDeclarationListAfterMet
adata(commentAndMetadata); |
| 6224 // if (!matches(TokenType.SEMICOLON)) { | 6207 // if (!matches(TokenType.SEMICOLON)) { |
| 6225 // if (matches(startToken, Keyword.VAR) && isTypedIdentifier(startToken
.getNext())) { | 6208 // if (matches(startToken, Keyword.VAR) && isTypedIdentifier(startToken
.getNext())) { |
| 6226 // // TODO(brianwilkerson) This appears to be of the form "var type v
ariable". We should do | 6209 // // TODO(brianwilkerson) This appears to be of the form "var type v
ariable". We should do |
| 6227 // // a better job of recovering in this case. | 6210 // // a better job of recovering in this case. |
| 6228 // } | 6211 // } |
| 6229 // } | 6212 // } |
| 6230 Token semicolon = expect(TokenType.SEMICOLON); | 6213 Token semicolon = _expect(TokenType.SEMICOLON); |
| 6231 return new VariableDeclarationStatement(variableList, semicolon); | 6214 return new VariableDeclarationStatement(variableList, semicolon); |
| 6232 } | 6215 } |
| 6233 | 6216 |
| 6234 /** | 6217 /** |
| 6235 * Parse a variable declaration statement. | 6218 * Parse a variable declaration statement. |
| 6236 * | 6219 * |
| 6237 * <pre> | 6220 * <pre> |
| 6238 * variableDeclarationStatement ::= | 6221 * variableDeclarationStatement ::= |
| 6239 * variableDeclarationList ';' | 6222 * variableDeclarationList ';' |
| 6240 * </pre> | 6223 * </pre> |
| 6241 * | 6224 * |
| 6242 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration | 6225 * @param commentAndMetadata the metadata to be associated with the variable d
eclaration |
| 6243 * statement, or `null` if there is no attempt at parsing the comment
and metadata | 6226 * statement, or `null` if there is no attempt at parsing the comment
and metadata |
| 6244 * @param keyword the token representing the 'final', 'const' or 'var' keyword
, or `null` if | 6227 * @param keyword the token representing the 'final', 'const' or 'var' keyword
, or `null` if |
| 6245 * there is no keyword | 6228 * there is no keyword |
| 6246 * @param type the type of the variables in the list | 6229 * @param type the type of the variables in the list |
| 6247 * @return the variable declaration statement that was parsed | 6230 * @return the variable declaration statement that was parsed |
| 6248 */ | 6231 */ |
| 6249 VariableDeclarationStatement parseVariableDeclarationStatementAfterType(Commen
tAndMetadata commentAndMetadata, Token keyword, TypeName type) { | 6232 VariableDeclarationStatement _parseVariableDeclarationStatementAfterType(Comme
ntAndMetadata commentAndMetadata, Token keyword, TypeName type) { |
| 6250 VariableDeclarationList variableList = parseVariableDeclarationListAfterType
(commentAndMetadata, keyword, type); | 6233 VariableDeclarationList variableList = _parseVariableDeclarationListAfterTyp
e(commentAndMetadata, keyword, type); |
| 6251 Token semicolon = expect(TokenType.SEMICOLON); | 6234 Token semicolon = _expect(TokenType.SEMICOLON); |
| 6252 return new VariableDeclarationStatement(variableList, semicolon); | 6235 return new VariableDeclarationStatement(variableList, semicolon); |
| 6253 } | 6236 } |
| 6254 | 6237 |
| 6255 /** | 6238 /** |
| 6256 * Parse a while statement. | 6239 * Parse a while statement. |
| 6257 * | 6240 * |
| 6258 * <pre> | 6241 * <pre> |
| 6259 * whileStatement ::= | 6242 * whileStatement ::= |
| 6260 * 'while' '(' expression ')' statement | 6243 * 'while' '(' expression ')' statement |
| 6261 * </pre> | 6244 * </pre> |
| 6262 * | 6245 * |
| 6263 * @return the while statement that was parsed | 6246 * @return the while statement that was parsed |
| 6264 */ | 6247 */ |
| 6265 Statement parseWhileStatement() { | 6248 Statement _parseWhileStatement() { |
| 6266 bool wasInLoop = _inLoop; | 6249 bool wasInLoop = _inLoop; |
| 6267 _inLoop = true; | 6250 _inLoop = true; |
| 6268 try { | 6251 try { |
| 6269 Token keyword = expectKeyword(Keyword.WHILE); | 6252 Token keyword = _expectKeyword(Keyword.WHILE); |
| 6270 Token leftParenthesis = expect(TokenType.OPEN_PAREN); | 6253 Token leftParenthesis = _expect(TokenType.OPEN_PAREN); |
| 6271 Expression condition = parseExpression2(); | 6254 Expression condition = parseExpression2(); |
| 6272 Token rightParenthesis = expect(TokenType.CLOSE_PAREN); | 6255 Token rightParenthesis = _expect(TokenType.CLOSE_PAREN); |
| 6273 Statement body = parseStatement2(); | 6256 Statement body = parseStatement2(); |
| 6274 return new WhileStatement(keyword, leftParenthesis, condition, rightParent
hesis, body); | 6257 return new WhileStatement(keyword, leftParenthesis, condition, rightParent
hesis, body); |
| 6275 } finally { | 6258 } finally { |
| 6276 _inLoop = wasInLoop; | 6259 _inLoop = wasInLoop; |
| 6277 } | 6260 } |
| 6278 } | 6261 } |
| 6279 | 6262 |
| 6280 /** | 6263 /** |
| 6281 * Return the token that is immediately after the current token. This is equiv
alent to | 6264 * Return the token that is immediately after the current token. This is equiv
alent to |
| 6282 * [peekAt]. | 6265 * [peekAt]. |
| 6283 * | 6266 * |
| 6284 * @return the token that is immediately after the current token | 6267 * @return the token that is immediately after the current token |
| 6285 */ | 6268 */ |
| 6286 Token peek() => _currentToken.next; | 6269 Token _peek() => _currentToken.next; |
| 6287 | 6270 |
| 6288 /** | 6271 /** |
| 6289 * Return the token that is the given distance after the current token. | 6272 * Return the token that is the given distance after the current token. |
| 6290 * | 6273 * |
| 6291 * @param distance the number of tokens to look ahead, where `0` is the curren
t token, | 6274 * @param distance the number of tokens to look ahead, where `0` is the curren
t token, |
| 6292 * `1` is the next token, etc. | 6275 * `1` is the next token, etc. |
| 6293 * @return the token that is the given distance after the current token | 6276 * @return the token that is the given distance after the current token |
| 6294 */ | 6277 */ |
| 6295 Token peekAt(int distance) { | 6278 Token _peekAt(int distance) { |
| 6296 Token token = _currentToken; | 6279 Token token = _currentToken; |
| 6297 for (int i = 0; i < distance; i++) { | 6280 for (int i = 0; i < distance; i++) { |
| 6298 token = token.next; | 6281 token = token.next; |
| 6299 } | 6282 } |
| 6300 return token; | 6283 return token; |
| 6301 } | 6284 } |
| 6302 | 6285 |
| 6303 /** | 6286 /** |
| 6304 * Report the given [AnalysisError]. | 6287 * Report the given [AnalysisError]. |
| 6305 * | 6288 * |
| 6306 * @param error the error to be reported | 6289 * @param error the error to be reported |
| 6307 */ | 6290 */ |
| 6308 void reportError(AnalysisError error) { | 6291 void _reportError(AnalysisError error) { |
| 6309 if (_errorListenerLock != 0) { | 6292 if (_errorListenerLock != 0) { |
| 6310 return; | 6293 return; |
| 6311 } | 6294 } |
| 6312 _errorListener.onError(error); | 6295 _errorListener.onError(error); |
| 6313 } | 6296 } |
| 6314 | 6297 |
| 6315 /** | 6298 /** |
| 6316 * Report an error with the given error code and arguments. | 6299 * Report an error with the given error code and arguments. |
| 6317 * | 6300 * |
| 6318 * @param errorCode the error code of the error to be reported | 6301 * @param errorCode the error code of the error to be reported |
| 6319 * @param arguments the arguments to the error, used to compose the error mess
age | 6302 * @param arguments the arguments to the error, used to compose the error mess
age |
| 6320 */ | 6303 */ |
| 6321 void reportErrorForCurrentToken(ParserErrorCode errorCode, List<Object> argume
nts) { | 6304 void _reportErrorForCurrentToken(ParserErrorCode errorCode, List<Object> argum
ents) { |
| 6322 reportErrorForToken(errorCode, _currentToken, arguments); | 6305 _reportErrorForToken(errorCode, _currentToken, arguments); |
| 6323 } | 6306 } |
| 6324 | 6307 |
| 6325 /** | 6308 /** |
| 6326 * Report an error with the given error code and arguments. | 6309 * Report an error with the given error code and arguments. |
| 6327 * | 6310 * |
| 6328 * @param errorCode the error code of the error to be reported | 6311 * @param errorCode the error code of the error to be reported |
| 6329 * @param node the node specifying the location of the error | 6312 * @param node the node specifying the location of the error |
| 6330 * @param arguments the arguments to the error, used to compose the error mess
age | 6313 * @param arguments the arguments to the error, used to compose the error mess
age |
| 6331 */ | 6314 */ |
| 6332 void reportErrorForNode(ParserErrorCode errorCode, AstNode node, List<Object>
arguments) { | 6315 void _reportErrorForNode(ParserErrorCode errorCode, AstNode node, List<Object>
arguments) { |
| 6333 reportError(new AnalysisError.con2(_source, node.offset, node.length, errorC
ode, arguments)); | 6316 _reportError(new AnalysisError.con2(_source, node.offset, node.length, error
Code, arguments)); |
| 6334 } | 6317 } |
| 6335 | 6318 |
| 6336 /** | 6319 /** |
| 6337 * Report an error with the given error code and arguments. | 6320 * Report an error with the given error code and arguments. |
| 6338 * | 6321 * |
| 6339 * @param errorCode the error code of the error to be reported | 6322 * @param errorCode the error code of the error to be reported |
| 6340 * @param token the token specifying the location of the error | 6323 * @param token the token specifying the location of the error |
| 6341 * @param arguments the arguments to the error, used to compose the error mess
age | 6324 * @param arguments the arguments to the error, used to compose the error mess
age |
| 6342 */ | 6325 */ |
| 6343 void reportErrorForToken(ParserErrorCode errorCode, Token token, List<Object>
arguments) { | 6326 void _reportErrorForToken(ParserErrorCode errorCode, Token token, List<Object>
arguments) { |
| 6344 reportError(new AnalysisError.con2(_source, token.offset, token.length, erro
rCode, arguments)); | 6327 _reportError(new AnalysisError.con2(_source, token.offset, token.length, err
orCode, arguments)); |
| 6345 } | 6328 } |
| 6346 | 6329 |
| 6347 /** | 6330 /** |
| 6348 * Skips a block with all containing blocks. | 6331 * Skips a block with all containing blocks. |
| 6349 */ | 6332 */ |
| 6350 void skipBlock() { | 6333 void _skipBlock() { |
| 6351 _currentToken = (_currentToken as BeginToken).endToken.next; | 6334 _currentToken = (_currentToken as BeginToken).endToken.next; |
| 6352 } | 6335 } |
| 6353 | 6336 |
| 6354 /** | 6337 /** |
| 6355 * Parse the 'final', 'const', 'var' or type preceding a variable declaration,
starting at the | 6338 * Parse the 'final', 'const', 'var' or type preceding a variable declaration,
starting at the |
| 6356 * given token, without actually creating a type or changing the current token
. Return the token | 6339 * given token, without actually creating a type or changing the current token
. Return the token |
| 6357 * following the type that was parsed, or `null` if the given token is not the
first token | 6340 * following the type that was parsed, or `null` if the given token is not the
first token |
| 6358 * in a valid type. | 6341 * in a valid type. |
| 6359 * | 6342 * |
| 6360 * <pre> | 6343 * <pre> |
| 6361 * finalConstVarOrType ::= | 6344 * finalConstVarOrType ::= |
| 6362 * | 'final' type? | 6345 * | 'final' type? |
| 6363 * | 'const' type? | 6346 * | 'const' type? |
| 6364 * | 'var' | 6347 * | 'var' |
| 6365 * | type | 6348 * | type |
| 6366 * </pre> | 6349 * </pre> |
| 6367 * | 6350 * |
| 6368 * @param startToken the token at which parsing is to begin | 6351 * @param startToken the token at which parsing is to begin |
| 6369 * @return the token following the type that was parsed | 6352 * @return the token following the type that was parsed |
| 6370 */ | 6353 */ |
| 6371 Token skipFinalConstVarOrType(Token startToken) { | 6354 Token _skipFinalConstVarOrType(Token startToken) { |
| 6372 if (tokenMatchesKeyword(startToken, Keyword.FINAL) || tokenMatchesKeyword(st
artToken, Keyword.CONST)) { | 6355 if (_tokenMatchesKeyword(startToken, Keyword.FINAL) || _tokenMatchesKeyword(
startToken, Keyword.CONST)) { |
| 6373 Token next = startToken.next; | 6356 Token next = startToken.next; |
| 6374 if (tokenMatchesIdentifier(next)) { | 6357 if (_tokenMatchesIdentifier(next)) { |
| 6375 Token next2 = next.next; | 6358 Token next2 = next.next; |
| 6376 // "Type parameter" or "Type<" or "prefix.Type" | 6359 // "Type parameter" or "Type<" or "prefix.Type" |
| 6377 if (tokenMatchesIdentifier(next2) || tokenMatches(next2, TokenType.LT) |
| tokenMatches(next2, TokenType.PERIOD)) { | 6360 if (_tokenMatchesIdentifier(next2) || _tokenMatches(next2, TokenType.LT)
|| _tokenMatches(next2, TokenType.PERIOD)) { |
| 6378 return skipTypeName(next); | 6361 return _skipTypeName(next); |
| 6379 } | 6362 } |
| 6380 // "parameter" | 6363 // "parameter" |
| 6381 return next; | 6364 return next; |
| 6382 } | 6365 } |
| 6383 } else if (tokenMatchesKeyword(startToken, Keyword.VAR)) { | 6366 } else if (_tokenMatchesKeyword(startToken, Keyword.VAR)) { |
| 6384 return startToken.next; | 6367 return startToken.next; |
| 6385 } else if (tokenMatchesIdentifier(startToken)) { | 6368 } else if (_tokenMatchesIdentifier(startToken)) { |
| 6386 Token next = startToken.next; | 6369 Token next = startToken.next; |
| 6387 if (tokenMatchesIdentifier(next) || tokenMatches(next, TokenType.LT) || to
kenMatchesKeyword(next, Keyword.THIS) || (tokenMatches(next, TokenType.PERIOD) &
& tokenMatchesIdentifier(next.next) && (tokenMatchesIdentifier(next.next.next) |
| tokenMatches(next.next.next, TokenType.LT) || tokenMatchesKeyword(next.next.ne
xt, Keyword.THIS)))) { | 6370 if (_tokenMatchesIdentifier(next) || _tokenMatches(next, TokenType.LT) ||
_tokenMatchesKeyword(next, Keyword.THIS) || (_tokenMatches(next, TokenType.PERIO
D) && _tokenMatchesIdentifier(next.next) && (_tokenMatchesIdentifier(next.next.n
ext) || _tokenMatches(next.next.next, TokenType.LT) || _tokenMatchesKeyword(next
.next.next, Keyword.THIS)))) { |
| 6388 return skipReturnType(startToken); | 6371 return _skipReturnType(startToken); |
| 6389 } | 6372 } |
| 6390 } | 6373 } |
| 6391 return null; | 6374 return null; |
| 6392 } | 6375 } |
| 6393 | 6376 |
| 6394 /** | 6377 /** |
| 6395 * Parse a list of formal parameters, starting at the given token, without act
ually creating a | 6378 * Parse a list of formal parameters, starting at the given token, without act
ually creating a |
| 6396 * formal parameter list or changing the current token. Return the token follo
wing the formal | 6379 * formal parameter list or changing the current token. Return the token follo
wing the formal |
| 6397 * parameter list that was parsed, or `null` if the given token is not the fir
st token in a | 6380 * parameter list that was parsed, or `null` if the given token is not the fir
st token in a |
| 6398 * valid list of formal parameter. | 6381 * valid list of formal parameter. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6421 * optionalPositionalFormalParameters ::= | 6404 * optionalPositionalFormalParameters ::= |
| 6422 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' | 6405 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' |
| 6423 * | 6406 * |
| 6424 * namedFormalParameters ::= | 6407 * namedFormalParameters ::= |
| 6425 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' | 6408 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' |
| 6426 * </pre> | 6409 * </pre> |
| 6427 * | 6410 * |
| 6428 * @param startToken the token at which parsing is to begin | 6411 * @param startToken the token at which parsing is to begin |
| 6429 * @return the token following the formal parameter list that was parsed | 6412 * @return the token following the formal parameter list that was parsed |
| 6430 */ | 6413 */ |
| 6431 Token skipFormalParameterList(Token startToken) { | 6414 Token _skipFormalParameterList(Token startToken) { |
| 6432 if (!tokenMatches(startToken, TokenType.OPEN_PAREN)) { | 6415 if (!_tokenMatches(startToken, TokenType.OPEN_PAREN)) { |
| 6433 return null; | 6416 return null; |
| 6434 } | 6417 } |
| 6435 Token next = startToken.next; | 6418 Token next = startToken.next; |
| 6436 if (tokenMatches(next, TokenType.CLOSE_PAREN)) { | 6419 if (_tokenMatches(next, TokenType.CLOSE_PAREN)) { |
| 6437 return next.next; | 6420 return next.next; |
| 6438 } | 6421 } |
| 6439 // | 6422 // |
| 6440 // Look to see whether the token after the open parenthesis is something tha
t should only occur | 6423 // Look to see whether the token after the open parenthesis is something tha
t should only occur |
| 6441 // at the beginning of a parameter list. | 6424 // at the beginning of a parameter list. |
| 6442 // | 6425 // |
| 6443 if (matchesAny(next, [ | 6426 if (next.matchesAny([ |
| 6444 TokenType.AT, | 6427 TokenType.AT, |
| 6445 TokenType.OPEN_SQUARE_BRACKET, | 6428 TokenType.OPEN_SQUARE_BRACKET, |
| 6446 TokenType.OPEN_CURLY_BRACKET]) || tokenMatchesKeyword(next, Keyword.VOID
) || (tokenMatchesIdentifier(next) && (matchesAny(next.next, [TokenType.COMMA, T
okenType.CLOSE_PAREN])))) { | 6429 TokenType.OPEN_CURLY_BRACKET]) || _tokenMatchesKeyword(next, Keyword.VOI
D) || (_tokenMatchesIdentifier(next) && (next.next.matchesAny([TokenType.COMMA,
TokenType.CLOSE_PAREN])))) { |
| 6447 return skipPastMatchingToken(startToken); | 6430 return _skipPastMatchingToken(startToken); |
| 6448 } | 6431 } |
| 6449 // | 6432 // |
| 6450 // Look to see whether the first parameter is a function typed parameter wit
hout a return type. | 6433 // Look to see whether the first parameter is a function typed parameter wit
hout a return type. |
| 6451 // | 6434 // |
| 6452 if (tokenMatchesIdentifier(next) && tokenMatches(next.next, TokenType.OPEN_P
AREN)) { | 6435 if (_tokenMatchesIdentifier(next) && _tokenMatches(next.next, TokenType.OPEN
_PAREN)) { |
| 6453 Token afterParameters = skipFormalParameterList(next.next); | 6436 Token afterParameters = _skipFormalParameterList(next.next); |
| 6454 if (afterParameters != null && (matchesAny(afterParameters, [TokenType.COM
MA, TokenType.CLOSE_PAREN]))) { | 6437 if (afterParameters != null && (afterParameters.matchesAny([TokenType.COMM
A, TokenType.CLOSE_PAREN]))) { |
| 6455 return skipPastMatchingToken(startToken); | 6438 return _skipPastMatchingToken(startToken); |
| 6456 } | 6439 } |
| 6457 } | 6440 } |
| 6458 // | 6441 // |
| 6459 // Look to see whether the first parameter has a type or is a function typed
parameter with a | 6442 // Look to see whether the first parameter has a type or is a function typed
parameter with a |
| 6460 // return type. | 6443 // return type. |
| 6461 // | 6444 // |
| 6462 Token afterType = skipFinalConstVarOrType(next); | 6445 Token afterType = _skipFinalConstVarOrType(next); |
| 6463 if (afterType == null) { | 6446 if (afterType == null) { |
| 6464 return null; | 6447 return null; |
| 6465 } | 6448 } |
| 6466 if (skipSimpleIdentifier(afterType) == null) { | 6449 if (_skipSimpleIdentifier(afterType) == null) { |
| 6467 return null; | 6450 return null; |
| 6468 } | 6451 } |
| 6469 return skipPastMatchingToken(startToken); | 6452 return _skipPastMatchingToken(startToken); |
| 6470 } | 6453 } |
| 6471 | 6454 |
| 6472 /** | 6455 /** |
| 6473 * If the given token is a begin token with an associated end token, then retu
rn the token | 6456 * If the given token is a begin token with an associated end token, then retu
rn the token |
| 6474 * following the end token. Otherwise, return `null`. | 6457 * following the end token. Otherwise, return `null`. |
| 6475 * | 6458 * |
| 6476 * @param startToken the token that is assumed to be a being token | 6459 * @param startToken the token that is assumed to be a being token |
| 6477 * @return the token following the matching end token | 6460 * @return the token following the matching end token |
| 6478 */ | 6461 */ |
| 6479 Token skipPastMatchingToken(Token startToken) { | 6462 Token _skipPastMatchingToken(Token startToken) { |
| 6480 if (startToken is! BeginToken) { | 6463 if (startToken is! BeginToken) { |
| 6481 return null; | 6464 return null; |
| 6482 } | 6465 } |
| 6483 Token closeParen = (startToken as BeginToken).endToken; | 6466 Token closeParen = (startToken as BeginToken).endToken; |
| 6484 if (closeParen == null) { | 6467 if (closeParen == null) { |
| 6485 return null; | 6468 return null; |
| 6486 } | 6469 } |
| 6487 return closeParen.next; | 6470 return closeParen.next; |
| 6488 } | 6471 } |
| 6489 | 6472 |
| 6490 /** | 6473 /** |
| 6491 * Parse a prefixed identifier, starting at the given token, without actually
creating a prefixed | 6474 * Parse a prefixed identifier, starting at the given token, without actually
creating a prefixed |
| 6492 * identifier or changing the current token. Return the token following the pr
efixed identifier | 6475 * identifier or changing the current token. Return the token following the pr
efixed identifier |
| 6493 * that was parsed, or `null` if the given token is not the first token in a v
alid prefixed | 6476 * that was parsed, or `null` if the given token is not the first token in a v
alid prefixed |
| 6494 * identifier. | 6477 * identifier. |
| 6495 * | 6478 * |
| 6496 * This method must be kept in sync with [parsePrefixedIdentifier]. | 6479 * This method must be kept in sync with [parsePrefixedIdentifier]. |
| 6497 * | 6480 * |
| 6498 * <pre> | 6481 * <pre> |
| 6499 * prefixedIdentifier ::= | 6482 * prefixedIdentifier ::= |
| 6500 * identifier ('.' identifier)? | 6483 * identifier ('.' identifier)? |
| 6501 * </pre> | 6484 * </pre> |
| 6502 * | 6485 * |
| 6503 * @param startToken the token at which parsing is to begin | 6486 * @param startToken the token at which parsing is to begin |
| 6504 * @return the token following the prefixed identifier that was parsed | 6487 * @return the token following the prefixed identifier that was parsed |
| 6505 */ | 6488 */ |
| 6506 Token skipPrefixedIdentifier(Token startToken) { | 6489 Token _skipPrefixedIdentifier(Token startToken) { |
| 6507 Token token = skipSimpleIdentifier(startToken); | 6490 Token token = _skipSimpleIdentifier(startToken); |
| 6508 if (token == null) { | 6491 if (token == null) { |
| 6509 return null; | 6492 return null; |
| 6510 } else if (!tokenMatches(token, TokenType.PERIOD)) { | 6493 } else if (!_tokenMatches(token, TokenType.PERIOD)) { |
| 6511 return token; | 6494 return token; |
| 6512 } | 6495 } |
| 6513 return skipSimpleIdentifier(token.next); | 6496 return _skipSimpleIdentifier(token.next); |
| 6514 } | 6497 } |
| 6515 | 6498 |
| 6516 /** | 6499 /** |
| 6517 * Parse a return type, starting at the given token, without actually creating
a return type or | 6500 * Parse a return type, starting at the given token, without actually creating
a return type or |
| 6518 * changing the current token. Return the token following the return type that
was parsed, or | 6501 * changing the current token. Return the token following the return type that
was parsed, or |
| 6519 * `null` if the given token is not the first token in a valid return type. | 6502 * `null` if the given token is not the first token in a valid return type. |
| 6520 * | 6503 * |
| 6521 * This method must be kept in sync with [parseReturnType]. | 6504 * This method must be kept in sync with [parseReturnType]. |
| 6522 * | 6505 * |
| 6523 * <pre> | 6506 * <pre> |
| 6524 * returnType ::= | 6507 * returnType ::= |
| 6525 * 'void' | 6508 * 'void' |
| 6526 * | type | 6509 * | type |
| 6527 * </pre> | 6510 * </pre> |
| 6528 * | 6511 * |
| 6529 * @param startToken the token at which parsing is to begin | 6512 * @param startToken the token at which parsing is to begin |
| 6530 * @return the token following the return type that was parsed | 6513 * @return the token following the return type that was parsed |
| 6531 */ | 6514 */ |
| 6532 Token skipReturnType(Token startToken) { | 6515 Token _skipReturnType(Token startToken) { |
| 6533 if (tokenMatchesKeyword(startToken, Keyword.VOID)) { | 6516 if (_tokenMatchesKeyword(startToken, Keyword.VOID)) { |
| 6534 return startToken.next; | 6517 return startToken.next; |
| 6535 } else { | 6518 } else { |
| 6536 return skipTypeName(startToken); | 6519 return _skipTypeName(startToken); |
| 6537 } | 6520 } |
| 6538 } | 6521 } |
| 6539 | 6522 |
| 6540 /** | 6523 /** |
| 6541 * Parse a simple identifier, starting at the given token, without actually cr
eating a simple | 6524 * Parse a simple identifier, starting at the given token, without actually cr
eating a simple |
| 6542 * identifier or changing the current token. Return the token following the si
mple identifier that | 6525 * identifier or changing the current token. Return the token following the si
mple identifier that |
| 6543 * was parsed, or `null` if the given token is not the first token in a valid
simple | 6526 * was parsed, or `null` if the given token is not the first token in a valid
simple |
| 6544 * identifier. | 6527 * identifier. |
| 6545 * | 6528 * |
| 6546 * This method must be kept in sync with [parseSimpleIdentifier]. | 6529 * This method must be kept in sync with [parseSimpleIdentifier]. |
| 6547 * | 6530 * |
| 6548 * <pre> | 6531 * <pre> |
| 6549 * identifier ::= | 6532 * identifier ::= |
| 6550 * IDENTIFIER | 6533 * IDENTIFIER |
| 6551 * </pre> | 6534 * </pre> |
| 6552 * | 6535 * |
| 6553 * @param startToken the token at which parsing is to begin | 6536 * @param startToken the token at which parsing is to begin |
| 6554 * @return the token following the simple identifier that was parsed | 6537 * @return the token following the simple identifier that was parsed |
| 6555 */ | 6538 */ |
| 6556 Token skipSimpleIdentifier(Token startToken) { | 6539 Token _skipSimpleIdentifier(Token startToken) { |
| 6557 if (tokenMatches(startToken, TokenType.IDENTIFIER) || (tokenMatches(startTok
en, TokenType.KEYWORD) && (startToken as KeywordToken).keyword.isPseudoKeyword))
{ | 6540 if (_tokenMatches(startToken, TokenType.IDENTIFIER) || (_tokenMatches(startT
oken, TokenType.KEYWORD) && (startToken as KeywordToken).keyword.isPseudoKeyword
)) { |
| 6558 return startToken.next; | 6541 return startToken.next; |
| 6559 } | 6542 } |
| 6560 return null; | 6543 return null; |
| 6561 } | 6544 } |
| 6562 | 6545 |
| 6563 /** | 6546 /** |
| 6564 * Parse a string literal that contains interpolations, starting at the given
token, without | 6547 * Parse a string literal that contains interpolations, starting at the given
token, without |
| 6565 * actually creating a string literal or changing the current token. Return th
e token following | 6548 * actually creating a string literal or changing the current token. Return th
e token following |
| 6566 * the string literal that was parsed, or `null` if the given token is not the
first token | 6549 * the string literal that was parsed, or `null` if the given token is not the
first token |
| 6567 * in a valid string literal. | 6550 * in a valid string literal. |
| 6568 * | 6551 * |
| 6569 * This method must be kept in sync with [parseStringInterpolation]. | 6552 * This method must be kept in sync with [parseStringInterpolation]. |
| 6570 * | 6553 * |
| 6571 * @param startToken the token at which parsing is to begin | 6554 * @param startToken the token at which parsing is to begin |
| 6572 * @return the string literal that was parsed | 6555 * @return the string literal that was parsed |
| 6573 */ | 6556 */ |
| 6574 Token skipStringInterpolation(Token startToken) { | 6557 Token _skipStringInterpolation(Token startToken) { |
| 6575 Token token = startToken; | 6558 Token token = startToken; |
| 6576 TokenType type = token.type; | 6559 TokenType type = token.type; |
| 6577 while (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION) || identic
al(type, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { | 6560 while (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION) || identic
al(type, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { |
| 6578 if (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { | 6561 if (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION)) { |
| 6579 token = token.next; | 6562 token = token.next; |
| 6580 type = token.type; | 6563 type = token.type; |
| 6581 // | 6564 // |
| 6582 // Rather than verify that the following tokens represent a valid expres
sion, we simply skip | 6565 // Rather than verify that the following tokens represent a valid expres
sion, we simply skip |
| 6583 // tokens until we reach the end of the interpolation, being careful to
handle nested string | 6566 // tokens until we reach the end of the interpolation, being careful to
handle nested string |
| 6584 // literals. | 6567 // literals. |
| 6585 // | 6568 // |
| 6586 int bracketNestingLevel = 1; | 6569 int bracketNestingLevel = 1; |
| 6587 while (bracketNestingLevel > 0) { | 6570 while (bracketNestingLevel > 0) { |
| 6588 if (identical(type, TokenType.EOF)) { | 6571 if (identical(type, TokenType.EOF)) { |
| 6589 return null; | 6572 return null; |
| 6590 } else if (identical(type, TokenType.OPEN_CURLY_BRACKET)) { | 6573 } else if (identical(type, TokenType.OPEN_CURLY_BRACKET)) { |
| 6591 bracketNestingLevel++; | 6574 bracketNestingLevel++; |
| 6592 } else if (identical(type, TokenType.CLOSE_CURLY_BRACKET)) { | 6575 } else if (identical(type, TokenType.CLOSE_CURLY_BRACKET)) { |
| 6593 bracketNestingLevel--; | 6576 bracketNestingLevel--; |
| 6594 } else if (identical(type, TokenType.STRING)) { | 6577 } else if (identical(type, TokenType.STRING)) { |
| 6595 token = skipStringLiteral(token); | 6578 token = _skipStringLiteral(token); |
| 6596 if (token == null) { | 6579 if (token == null) { |
| 6597 return null; | 6580 return null; |
| 6598 } | 6581 } |
| 6599 } else { | 6582 } else { |
| 6600 token = token.next; | 6583 token = token.next; |
| 6601 } | 6584 } |
| 6602 type = token.type; | 6585 type = token.type; |
| 6603 } | 6586 } |
| 6604 token = token.next; | 6587 token = token.next; |
| 6605 type = token.type; | 6588 type = token.type; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6628 * | 6611 * |
| 6629 * <pre> | 6612 * <pre> |
| 6630 * stringLiteral ::= | 6613 * stringLiteral ::= |
| 6631 * MULTI_LINE_STRING+ | 6614 * MULTI_LINE_STRING+ |
| 6632 * | SINGLE_LINE_STRING+ | 6615 * | SINGLE_LINE_STRING+ |
| 6633 * </pre> | 6616 * </pre> |
| 6634 * | 6617 * |
| 6635 * @param startToken the token at which parsing is to begin | 6618 * @param startToken the token at which parsing is to begin |
| 6636 * @return the token following the string literal that was parsed | 6619 * @return the token following the string literal that was parsed |
| 6637 */ | 6620 */ |
| 6638 Token skipStringLiteral(Token startToken) { | 6621 Token _skipStringLiteral(Token startToken) { |
| 6639 Token token = startToken; | 6622 Token token = startToken; |
| 6640 while (token != null && tokenMatches(token, TokenType.STRING)) { | 6623 while (token != null && _tokenMatches(token, TokenType.STRING)) { |
| 6641 token = token.next; | 6624 token = token.next; |
| 6642 TokenType type = token.type; | 6625 TokenType type = token.type; |
| 6643 if (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION) || identica
l(type, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { | 6626 if (identical(type, TokenType.STRING_INTERPOLATION_EXPRESSION) || identica
l(type, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { |
| 6644 token = skipStringInterpolation(token); | 6627 token = _skipStringInterpolation(token); |
| 6645 } | 6628 } |
| 6646 } | 6629 } |
| 6647 if (identical(token, startToken)) { | 6630 if (identical(token, startToken)) { |
| 6648 return null; | 6631 return null; |
| 6649 } | 6632 } |
| 6650 return token; | 6633 return token; |
| 6651 } | 6634 } |
| 6652 | 6635 |
| 6653 /** | 6636 /** |
| 6654 * Parse a list of type arguments, starting at the given token, without actual
ly creating a type argument list | 6637 * Parse a list of type arguments, starting at the given token, without actual
ly creating a type argument list |
| 6655 * or changing the current token. Return the token following the type argument
list that was parsed, | 6638 * or changing the current token. Return the token following the type argument
list that was parsed, |
| 6656 * or `null` if the given token is not the first token in a valid type argumen
t list. | 6639 * or `null` if the given token is not the first token in a valid type argumen
t list. |
| 6657 * | 6640 * |
| 6658 * This method must be kept in sync with [parseTypeArgumentList]. | 6641 * This method must be kept in sync with [parseTypeArgumentList]. |
| 6659 * | 6642 * |
| 6660 * <pre> | 6643 * <pre> |
| 6661 * typeArguments ::= | 6644 * typeArguments ::= |
| 6662 * '<' typeList '>' | 6645 * '<' typeList '>' |
| 6663 * | 6646 * |
| 6664 * typeList ::= | 6647 * typeList ::= |
| 6665 * type (',' type)* | 6648 * type (',' type)* |
| 6666 * </pre> | 6649 * </pre> |
| 6667 * | 6650 * |
| 6668 * @param startToken the token at which parsing is to begin | 6651 * @param startToken the token at which parsing is to begin |
| 6669 * @return the token following the type argument list that was parsed | 6652 * @return the token following the type argument list that was parsed |
| 6670 */ | 6653 */ |
| 6671 Token skipTypeArgumentList(Token startToken) { | 6654 Token _skipTypeArgumentList(Token startToken) { |
| 6672 Token token = startToken; | 6655 Token token = startToken; |
| 6673 if (!tokenMatches(token, TokenType.LT)) { | 6656 if (!_tokenMatches(token, TokenType.LT)) { |
| 6674 return null; | 6657 return null; |
| 6675 } | 6658 } |
| 6676 token = skipTypeName(token.next); | 6659 token = _skipTypeName(token.next); |
| 6677 if (token == null) { | 6660 if (token == null) { |
| 6678 return null; | 6661 return null; |
| 6679 } | 6662 } |
| 6680 while (tokenMatches(token, TokenType.COMMA)) { | 6663 while (_tokenMatches(token, TokenType.COMMA)) { |
| 6681 token = skipTypeName(token.next); | 6664 token = _skipTypeName(token.next); |
| 6682 if (token == null) { | 6665 if (token == null) { |
| 6683 return null; | 6666 return null; |
| 6684 } | 6667 } |
| 6685 } | 6668 } |
| 6686 if (identical(token.type, TokenType.GT)) { | 6669 if (identical(token.type, TokenType.GT)) { |
| 6687 return token.next; | 6670 return token.next; |
| 6688 } else if (identical(token.type, TokenType.GT_GT)) { | 6671 } else if (identical(token.type, TokenType.GT_GT)) { |
| 6689 Token second = new Token(TokenType.GT, token.offset + 1); | 6672 Token second = new Token(TokenType.GT, token.offset + 1); |
| 6690 second.setNextWithoutSettingPrevious(token.next); | 6673 second.setNextWithoutSettingPrevious(token.next); |
| 6691 return second; | 6674 return second; |
| 6692 } | 6675 } |
| 6693 return null; | 6676 return null; |
| 6694 } | 6677 } |
| 6695 | 6678 |
| 6696 /** | 6679 /** |
| 6697 * Parse a type name, starting at the given token, without actually creating a
type name or | 6680 * Parse a type name, starting at the given token, without actually creating a
type name or |
| 6698 * changing the current token. Return the token following the type name that w
as parsed, or | 6681 * changing the current token. Return the token following the type name that w
as parsed, or |
| 6699 * `null` if the given token is not the first token in a valid type name. | 6682 * `null` if the given token is not the first token in a valid type name. |
| 6700 * | 6683 * |
| 6701 * This method must be kept in sync with [parseTypeName]. | 6684 * This method must be kept in sync with [parseTypeName]. |
| 6702 * | 6685 * |
| 6703 * <pre> | 6686 * <pre> |
| 6704 * type ::= | 6687 * type ::= |
| 6705 * qualified typeArguments? | 6688 * qualified typeArguments? |
| 6706 * </pre> | 6689 * </pre> |
| 6707 * | 6690 * |
| 6708 * @param startToken the token at which parsing is to begin | 6691 * @param startToken the token at which parsing is to begin |
| 6709 * @return the token following the type name that was parsed | 6692 * @return the token following the type name that was parsed |
| 6710 */ | 6693 */ |
| 6711 Token skipTypeName(Token startToken) { | 6694 Token _skipTypeName(Token startToken) { |
| 6712 Token token = skipPrefixedIdentifier(startToken); | 6695 Token token = _skipPrefixedIdentifier(startToken); |
| 6713 if (token == null) { | 6696 if (token == null) { |
| 6714 return null; | 6697 return null; |
| 6715 } | 6698 } |
| 6716 if (tokenMatches(token, TokenType.LT)) { | 6699 if (_tokenMatches(token, TokenType.LT)) { |
| 6717 token = skipTypeArgumentList(token); | 6700 token = _skipTypeArgumentList(token); |
| 6718 } | 6701 } |
| 6719 return token; | 6702 return token; |
| 6720 } | 6703 } |
| 6721 | 6704 |
| 6722 /** | 6705 /** |
| 6723 * Parse a list of type parameters, starting at the given token, without actua
lly creating a type | 6706 * Parse a list of type parameters, starting at the given token, without actua
lly creating a type |
| 6724 * parameter list or changing the current token. Return the token following th
e type parameter | 6707 * parameter list or changing the current token. Return the token following th
e type parameter |
| 6725 * list that was parsed, or `null` if the given token is not the first token i
n a valid type | 6708 * list that was parsed, or `null` if the given token is not the first token i
n a valid type |
| 6726 * parameter list. | 6709 * parameter list. |
| 6727 * | 6710 * |
| 6728 * This method must be kept in sync with [parseTypeParameterList]. | 6711 * This method must be kept in sync with [parseTypeParameterList]. |
| 6729 * | 6712 * |
| 6730 * <pre> | 6713 * <pre> |
| 6731 * typeParameterList ::= | 6714 * typeParameterList ::= |
| 6732 * '<' typeParameter (',' typeParameter)* '>' | 6715 * '<' typeParameter (',' typeParameter)* '>' |
| 6733 * </pre> | 6716 * </pre> |
| 6734 * | 6717 * |
| 6735 * @param startToken the token at which parsing is to begin | 6718 * @param startToken the token at which parsing is to begin |
| 6736 * @return the token following the type parameter list that was parsed | 6719 * @return the token following the type parameter list that was parsed |
| 6737 */ | 6720 */ |
| 6738 Token skipTypeParameterList(Token startToken) { | 6721 Token _skipTypeParameterList(Token startToken) { |
| 6739 if (!tokenMatches(startToken, TokenType.LT)) { | 6722 if (!_tokenMatches(startToken, TokenType.LT)) { |
| 6740 return null; | 6723 return null; |
| 6741 } | 6724 } |
| 6742 // | 6725 // |
| 6743 // We can't skip a type parameter because it can be preceeded by metadata, s
o we just assume | 6726 // We can't skip a type parameter because it can be preceeded by metadata, s
o we just assume |
| 6744 // that everything before the matching end token is valid. | 6727 // that everything before the matching end token is valid. |
| 6745 // | 6728 // |
| 6746 int depth = 1; | 6729 int depth = 1; |
| 6747 Token next = startToken.next; | 6730 Token next = startToken.next; |
| 6748 while (depth > 0) { | 6731 while (depth > 0) { |
| 6749 if (tokenMatches(next, TokenType.EOF)) { | 6732 if (_tokenMatches(next, TokenType.EOF)) { |
| 6750 return null; | 6733 return null; |
| 6751 } else if (tokenMatches(next, TokenType.LT)) { | 6734 } else if (_tokenMatches(next, TokenType.LT)) { |
| 6752 depth++; | 6735 depth++; |
| 6753 } else if (tokenMatches(next, TokenType.GT)) { | 6736 } else if (_tokenMatches(next, TokenType.GT)) { |
| 6754 depth--; | 6737 depth--; |
| 6755 } else if (tokenMatches(next, TokenType.GT_EQ)) { | 6738 } else if (_tokenMatches(next, TokenType.GT_EQ)) { |
| 6756 if (depth == 1) { | 6739 if (depth == 1) { |
| 6757 Token fakeEquals = new Token(TokenType.EQ, next.offset + 2); | 6740 Token fakeEquals = new Token(TokenType.EQ, next.offset + 2); |
| 6758 fakeEquals.setNextWithoutSettingPrevious(next.next); | 6741 fakeEquals.setNextWithoutSettingPrevious(next.next); |
| 6759 return fakeEquals; | 6742 return fakeEquals; |
| 6760 } | 6743 } |
| 6761 depth--; | 6744 depth--; |
| 6762 } else if (tokenMatches(next, TokenType.GT_GT)) { | 6745 } else if (_tokenMatches(next, TokenType.GT_GT)) { |
| 6763 depth -= 2; | 6746 depth -= 2; |
| 6764 } else if (tokenMatches(next, TokenType.GT_GT_EQ)) { | 6747 } else if (_tokenMatches(next, TokenType.GT_GT_EQ)) { |
| 6765 if (depth < 2) { | 6748 if (depth < 2) { |
| 6766 return null; | 6749 return null; |
| 6767 } else if (depth == 2) { | 6750 } else if (depth == 2) { |
| 6768 Token fakeEquals = new Token(TokenType.EQ, next.offset + 2); | 6751 Token fakeEquals = new Token(TokenType.EQ, next.offset + 2); |
| 6769 fakeEquals.setNextWithoutSettingPrevious(next.next); | 6752 fakeEquals.setNextWithoutSettingPrevious(next.next); |
| 6770 return fakeEquals; | 6753 return fakeEquals; |
| 6771 } | 6754 } |
| 6772 depth -= 2; | 6755 depth -= 2; |
| 6773 } | 6756 } |
| 6774 next = next.next; | 6757 next = next.next; |
| 6775 } | 6758 } |
| 6776 return next; | 6759 return next; |
| 6777 } | 6760 } |
| 6778 | 6761 |
| 6779 /** | 6762 /** |
| 6780 * Return `true` if the given token has the given type. | 6763 * Return `true` if the given token has the given type. |
| 6781 * | 6764 * |
| 6782 * @param token the token being tested | 6765 * @param token the token being tested |
| 6783 * @param type the type of token that is being tested for | 6766 * @param type the type of token that is being tested for |
| 6784 * @return `true` if the given token has the given type | 6767 * @return `true` if the given token has the given type |
| 6785 */ | 6768 */ |
| 6786 bool tokenMatches(Token token, TokenType type) => identical(token.type, type); | 6769 bool _tokenMatches(Token token, TokenType type) => identical(token.type, type)
; |
| 6787 | 6770 |
| 6788 /** | 6771 /** |
| 6789 * Return `true` if the given token is a valid identifier. Valid identifiers i
nclude | 6772 * Return `true` if the given token is a valid identifier. Valid identifiers i
nclude |
| 6790 * built-in identifiers (pseudo-keywords). | 6773 * built-in identifiers (pseudo-keywords). |
| 6791 * | 6774 * |
| 6792 * @return `true` if the given token is a valid identifier | 6775 * @return `true` if the given token is a valid identifier |
| 6793 */ | 6776 */ |
| 6794 bool tokenMatchesIdentifier(Token token) => tokenMatches(token, TokenType.IDEN
TIFIER) || (tokenMatches(token, TokenType.KEYWORD) && (token as KeywordToken).ke
yword.isPseudoKeyword); | 6777 bool _tokenMatchesIdentifier(Token token) => _tokenMatches(token, TokenType.ID
ENTIFIER) || (_tokenMatches(token, TokenType.KEYWORD) && (token as KeywordToken)
.keyword.isPseudoKeyword); |
| 6795 | 6778 |
| 6796 /** | 6779 /** |
| 6797 * Return `true` if the given token matches the given keyword. | 6780 * Return `true` if the given token matches the given keyword. |
| 6798 * | 6781 * |
| 6799 * @param token the token being tested | 6782 * @param token the token being tested |
| 6800 * @param keyword the keyword that is being tested for | 6783 * @param keyword the keyword that is being tested for |
| 6801 * @return `true` if the given token matches the given keyword | 6784 * @return `true` if the given token matches the given keyword |
| 6802 */ | 6785 */ |
| 6803 bool tokenMatchesKeyword(Token token, Keyword keyword) => identical(token.type
, TokenType.KEYWORD) && identical((token as KeywordToken).keyword, keyword); | 6786 bool _tokenMatchesKeyword(Token token, Keyword keyword) => identical(token.typ
e, TokenType.KEYWORD) && identical((token as KeywordToken).keyword, keyword); |
| 6804 | 6787 |
| 6805 /** | 6788 /** |
| 6806 * Translate the characters at the given index in the given string, appending
the translated | 6789 * Translate the characters at the given index in the given string, appending
the translated |
| 6807 * character to the given builder. The index is assumed to be valid. | 6790 * character to the given builder. The index is assumed to be valid. |
| 6808 * | 6791 * |
| 6809 * @param builder the builder to which the translated character is to be appen
ded | 6792 * @param builder the builder to which the translated character is to be appen
ded |
| 6810 * @param lexeme the string containing the character(s) to be translated | 6793 * @param lexeme the string containing the character(s) to be translated |
| 6811 * @param index the index of the character to be translated | 6794 * @param index the index of the character to be translated |
| 6812 * @return the index of the next character to be translated | 6795 * @return the index of the next character to be translated |
| 6813 */ | 6796 */ |
| 6814 int translateCharacter(JavaStringBuilder builder, String lexeme, int index) { | 6797 int _translateCharacter(JavaStringBuilder builder, String lexeme, int index) { |
| 6815 int currentChar = lexeme.codeUnitAt(index); | 6798 int currentChar = lexeme.codeUnitAt(index); |
| 6816 if (currentChar != 0x5C) { | 6799 if (currentChar != 0x5C) { |
| 6817 builder.appendChar(currentChar); | 6800 builder.appendChar(currentChar); |
| 6818 return index + 1; | 6801 return index + 1; |
| 6819 } | 6802 } |
| 6820 // | 6803 // |
| 6821 // We have found an escape sequence, so we parse the string to determine wha
t kind of escape | 6804 // We have found an escape sequence, so we parse the string to determine wha
t kind of escape |
| 6822 // sequence and what character to add to the builder. | 6805 // sequence and what character to add to the builder. |
| 6823 // | 6806 // |
| 6824 int length = lexeme.length; | 6807 int length = lexeme.length; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 6840 builder.appendChar(0xC); | 6823 builder.appendChar(0xC); |
| 6841 } else if (currentChar == 0x62) { | 6824 } else if (currentChar == 0x62) { |
| 6842 builder.appendChar(0x8); | 6825 builder.appendChar(0x8); |
| 6843 } else if (currentChar == 0x74) { | 6826 } else if (currentChar == 0x74) { |
| 6844 builder.appendChar(0x9); | 6827 builder.appendChar(0x9); |
| 6845 } else if (currentChar == 0x76) { | 6828 } else if (currentChar == 0x76) { |
| 6846 builder.appendChar(0xB); | 6829 builder.appendChar(0xB); |
| 6847 } else if (currentChar == 0x78) { | 6830 } else if (currentChar == 0x78) { |
| 6848 if (currentIndex + 2 >= length) { | 6831 if (currentIndex + 2 >= length) { |
| 6849 // Illegal escape sequence: not enough hex digits | 6832 // Illegal escape sequence: not enough hex digits |
| 6850 reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE, []); | 6833 _reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE, []); |
| 6851 return length; | 6834 return length; |
| 6852 } | 6835 } |
| 6853 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); | 6836 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); |
| 6854 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); | 6837 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); |
| 6855 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) { | 6838 if (!_isHexDigit(firstDigit) || !_isHexDigit(secondDigit)) { |
| 6856 // Illegal escape sequence: invalid hex digit | 6839 // Illegal escape sequence: invalid hex digit |
| 6857 reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE, []); | 6840 _reportErrorForCurrentToken(ParserErrorCode.INVALID_HEX_ESCAPE, []); |
| 6858 } else { | 6841 } else { |
| 6859 builder.appendChar(((Character.digit(firstDigit, 16) << 4) + Character.d
igit(secondDigit, 16))); | 6842 builder.appendChar(((Character.digit(firstDigit, 16) << 4) + Character.d
igit(secondDigit, 16))); |
| 6860 } | 6843 } |
| 6861 return currentIndex + 3; | 6844 return currentIndex + 3; |
| 6862 } else if (currentChar == 0x75) { | 6845 } else if (currentChar == 0x75) { |
| 6863 currentIndex++; | 6846 currentIndex++; |
| 6864 if (currentIndex >= length) { | 6847 if (currentIndex >= length) { |
| 6865 // Illegal escape sequence: not enough hex digits | 6848 // Illegal escape sequence: not enough hex digits |
| 6866 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 6849 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 6867 return length; | 6850 return length; |
| 6868 } | 6851 } |
| 6869 currentChar = lexeme.codeUnitAt(currentIndex); | 6852 currentChar = lexeme.codeUnitAt(currentIndex); |
| 6870 if (currentChar == 0x7B) { | 6853 if (currentChar == 0x7B) { |
| 6871 currentIndex++; | 6854 currentIndex++; |
| 6872 if (currentIndex >= length) { | 6855 if (currentIndex >= length) { |
| 6873 // Illegal escape sequence: incomplete escape | 6856 // Illegal escape sequence: incomplete escape |
| 6874 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, [])
; | 6857 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, []
); |
| 6875 return length; | 6858 return length; |
| 6876 } | 6859 } |
| 6877 currentChar = lexeme.codeUnitAt(currentIndex); | 6860 currentChar = lexeme.codeUnitAt(currentIndex); |
| 6878 int digitCount = 0; | 6861 int digitCount = 0; |
| 6879 int value = 0; | 6862 int value = 0; |
| 6880 while (currentChar != 0x7D) { | 6863 while (currentChar != 0x7D) { |
| 6881 if (!isHexDigit(currentChar)) { | 6864 if (!_isHexDigit(currentChar)) { |
| 6882 // Illegal escape sequence: invalid hex digit | 6865 // Illegal escape sequence: invalid hex digit |
| 6883 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, [
]); | 6866 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE,
[]); |
| 6884 currentIndex++; | 6867 currentIndex++; |
| 6885 while (currentIndex < length && lexeme.codeUnitAt(currentIndex) != 0
x7D) { | 6868 while (currentIndex < length && lexeme.codeUnitAt(currentIndex) != 0
x7D) { |
| 6886 currentIndex++; | 6869 currentIndex++; |
| 6887 } | 6870 } |
| 6888 return currentIndex + 1; | 6871 return currentIndex + 1; |
| 6889 } | 6872 } |
| 6890 digitCount++; | 6873 digitCount++; |
| 6891 value = (value << 4) + Character.digit(currentChar, 16); | 6874 value = (value << 4) + Character.digit(currentChar, 16); |
| 6892 currentIndex++; | 6875 currentIndex++; |
| 6893 if (currentIndex >= length) { | 6876 if (currentIndex >= length) { |
| 6894 // Illegal escape sequence: incomplete escape | 6877 // Illegal escape sequence: incomplete escape |
| 6895 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, [
]); | 6878 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE,
[]); |
| 6896 return length; | 6879 return length; |
| 6897 } | 6880 } |
| 6898 currentChar = lexeme.codeUnitAt(currentIndex); | 6881 currentChar = lexeme.codeUnitAt(currentIndex); |
| 6899 } | 6882 } |
| 6900 if (digitCount < 1 || digitCount > 6) { | 6883 if (digitCount < 1 || digitCount > 6) { |
| 6901 // Illegal escape sequence: not enough or too many hex digits | 6884 // Illegal escape sequence: not enough or too many hex digits |
| 6902 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, [])
; | 6885 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, []
); |
| 6903 } | 6886 } |
| 6904 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va
lue, index, currentIndex); | 6887 _appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), v
alue, index, currentIndex); |
| 6905 return currentIndex + 1; | 6888 return currentIndex + 1; |
| 6906 } else { | 6889 } else { |
| 6907 if (currentIndex + 3 >= length) { | 6890 if (currentIndex + 3 >= length) { |
| 6908 // Illegal escape sequence: not enough hex digits | 6891 // Illegal escape sequence: not enough hex digits |
| 6909 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, [])
; | 6892 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, []
); |
| 6910 return length; | 6893 return length; |
| 6911 } | 6894 } |
| 6912 int firstDigit = currentChar; | 6895 int firstDigit = currentChar; |
| 6913 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); | 6896 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); |
| 6914 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); | 6897 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); |
| 6915 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); | 6898 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); |
| 6916 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t
hirdDigit) || !isHexDigit(fourthDigit)) { | 6899 if (!_isHexDigit(firstDigit) || !_isHexDigit(secondDigit) || !_isHexDigi
t(thirdDigit) || !_isHexDigit(fourthDigit)) { |
| 6917 // Illegal escape sequence: invalid hex digits | 6900 // Illegal escape sequence: invalid hex digits |
| 6918 reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, [])
; | 6901 _reportErrorForCurrentToken(ParserErrorCode.INVALID_UNICODE_ESCAPE, []
); |
| 6919 } else { | 6902 } else { |
| 6920 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1),
(((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16)) <
< 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16)
, index, currentIndex + 3); | 6903 _appendScalarValue(builder, lexeme.substring(index, currentIndex + 1),
(((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16))
<< 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16
), index, currentIndex + 3); |
| 6921 } | 6904 } |
| 6922 return currentIndex + 4; | 6905 return currentIndex + 4; |
| 6923 } | 6906 } |
| 6924 } else { | 6907 } else { |
| 6925 builder.appendChar(currentChar); | 6908 builder.appendChar(currentChar); |
| 6926 } | 6909 } |
| 6927 return currentIndex + 1; | 6910 return currentIndex + 1; |
| 6928 } | 6911 } |
| 6929 | 6912 |
| 6930 /** | 6913 /** |
| 6931 * Decrements the error reporting lock level. If level is more than `0`, then | 6914 * Decrements the error reporting lock level. If level is more than `0`, then |
| 6932 * [reportError] wont report any error. | 6915 * [reportError] wont report any error. |
| 6933 */ | 6916 */ |
| 6934 void unlockErrorListener() { | 6917 void _unlockErrorListener() { |
| 6935 if (_errorListenerLock == 0) { | 6918 if (_errorListenerLock == 0) { |
| 6936 throw new IllegalStateException("Attempt to unlock not locked error listen
er."); | 6919 throw new IllegalStateException("Attempt to unlock not locked error listen
er."); |
| 6937 } | 6920 } |
| 6938 _errorListenerLock--; | 6921 _errorListenerLock--; |
| 6939 } | 6922 } |
| 6940 | 6923 |
| 6941 /** | 6924 /** |
| 6942 * Validate that the given parameter list does not contain any field initializ
ers. | 6925 * Validate that the given parameter list does not contain any field initializ
ers. |
| 6943 * | 6926 * |
| 6944 * @param parameterList the parameter list to be validated | 6927 * @param parameterList the parameter list to be validated |
| 6945 */ | 6928 */ |
| 6946 void validateFormalParameterList(FormalParameterList parameterList) { | 6929 void _validateFormalParameterList(FormalParameterList parameterList) { |
| 6947 for (FormalParameter parameter in parameterList.parameters) { | 6930 for (FormalParameter parameter in parameterList.parameters) { |
| 6948 if (parameter is FieldFormalParameter) { | 6931 if (parameter is FieldFormalParameter) { |
| 6949 reportErrorForNode(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR
, parameter.identifier, []); | 6932 _reportErrorForNode(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTO
R, parameter.identifier, []); |
| 6950 } | 6933 } |
| 6951 } | 6934 } |
| 6952 } | 6935 } |
| 6953 | 6936 |
| 6954 /** | 6937 /** |
| 6955 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' | 6938 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' |
| 6956 * keyword if there is one. | 6939 * keyword if there is one. |
| 6957 * | 6940 * |
| 6958 * @param modifiers the modifiers being validated | 6941 * @param modifiers the modifiers being validated |
| 6959 */ | 6942 */ |
| 6960 Token validateModifiersForClass(Modifiers modifiers) { | 6943 Token _validateModifiersForClass(Modifiers modifiers) { |
| 6961 validateModifiersForTopLevelDeclaration(modifiers); | 6944 _validateModifiersForTopLevelDeclaration(modifiers); |
| 6962 if (modifiers.constKeyword != null) { | 6945 if (modifiers.constKeyword != null) { |
| 6963 reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, [
]); | 6946 _reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword,
[]); |
| 6964 } | 6947 } |
| 6965 if (modifiers.externalKeyword != null) { | 6948 if (modifiers.externalKeyword != null) { |
| 6966 reportErrorForToken(ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKeyw
ord, []); | 6949 _reportErrorForToken(ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKey
word, []); |
| 6967 } | 6950 } |
| 6968 if (modifiers.finalKeyword != null) { | 6951 if (modifiers.finalKeyword != null) { |
| 6969 reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, [
]); | 6952 _reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword,
[]); |
| 6970 } | 6953 } |
| 6971 if (modifiers.varKeyword != null) { | 6954 if (modifiers.varKeyword != null) { |
| 6972 reportErrorForToken(ParserErrorCode.VAR_CLASS, modifiers.varKeyword, []); | 6955 _reportErrorForToken(ParserErrorCode.VAR_CLASS, modifiers.varKeyword, []); |
| 6973 } | 6956 } |
| 6974 return modifiers.abstractKeyword; | 6957 return modifiers.abstractKeyword; |
| 6975 } | 6958 } |
| 6976 | 6959 |
| 6977 /** | 6960 /** |
| 6978 * Validate that the given set of modifiers is appropriate for a constructor a
nd return the | 6961 * Validate that the given set of modifiers is appropriate for a constructor a
nd return the |
| 6979 * 'const' keyword if there is one. | 6962 * 'const' keyword if there is one. |
| 6980 * | 6963 * |
| 6981 * @param modifiers the modifiers being validated | 6964 * @param modifiers the modifiers being validated |
| 6982 * @return the 'const' or 'final' keyword associated with the constructor | 6965 * @return the 'const' or 'final' keyword associated with the constructor |
| 6983 */ | 6966 */ |
| 6984 Token validateModifiersForConstructor(Modifiers modifiers) { | 6967 Token _validateModifiersForConstructor(Modifiers modifiers) { |
| 6985 if (modifiers.abstractKeyword != null) { | 6968 if (modifiers.abstractKeyword != null) { |
| 6986 reportErrorForToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, modifiers.abstr
actKeyword, []); | 6969 _reportErrorForToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, modifiers.abst
ractKeyword, []); |
| 6987 } | 6970 } |
| 6988 if (modifiers.finalKeyword != null) { | 6971 if (modifiers.finalKeyword != null) { |
| 6989 reportErrorForToken(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyw
ord, []); | 6972 _reportErrorForToken(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKey
word, []); |
| 6990 } | 6973 } |
| 6991 if (modifiers.staticKeyword != null) { | 6974 if (modifiers.staticKeyword != null) { |
| 6992 reportErrorForToken(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKe
yword, []); | 6975 _reportErrorForToken(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticK
eyword, []); |
| 6993 } | 6976 } |
| 6994 if (modifiers.varKeyword != null) { | 6977 if (modifiers.varKeyword != null) { |
| 6995 reportErrorForToken(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifier
s.varKeyword, []); | 6978 _reportErrorForToken(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifie
rs.varKeyword, []); |
| 6996 } | 6979 } |
| 6997 Token externalKeyword = modifiers.externalKeyword; | 6980 Token externalKeyword = modifiers.externalKeyword; |
| 6998 Token constKeyword = modifiers.constKeyword; | 6981 Token constKeyword = modifiers.constKeyword; |
| 6999 Token factoryKeyword = modifiers.factoryKeyword; | 6982 Token factoryKeyword = modifiers.factoryKeyword; |
| 7000 if (externalKeyword != null && constKeyword != null && constKeyword.offset <
externalKeyword.offset) { | 6983 if (externalKeyword != null && constKeyword != null && constKeyword.offset <
externalKeyword.offset) { |
| 7001 reportErrorForToken(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword,
[]); | 6984 _reportErrorForToken(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword
, []); |
| 7002 } | 6985 } |
| 7003 if (externalKeyword != null && factoryKeyword != null && factoryKeyword.offs
et < externalKeyword.offset) { | 6986 if (externalKeyword != null && factoryKeyword != null && factoryKeyword.offs
et < externalKeyword.offset) { |
| 7004 reportErrorForToken(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeywor
d, []); | 6987 _reportErrorForToken(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeywo
rd, []); |
| 7005 } | 6988 } |
| 7006 return constKeyword; | 6989 return constKeyword; |
| 7007 } | 6990 } |
| 7008 | 6991 |
| 7009 /** | 6992 /** |
| 7010 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', | 6993 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', |
| 7011 * 'const' or 'var' keyword if there is one. | 6994 * 'const' or 'var' keyword if there is one. |
| 7012 * | 6995 * |
| 7013 * @param modifiers the modifiers being validated | 6996 * @param modifiers the modifiers being validated |
| 7014 * @return the 'final', 'const' or 'var' keyword associated with the field | 6997 * @return the 'final', 'const' or 'var' keyword associated with the field |
| 7015 */ | 6998 */ |
| 7016 Token validateModifiersForField(Modifiers modifiers) { | 6999 Token _validateModifiersForField(Modifiers modifiers) { |
| 7017 if (modifiers.abstractKeyword != null) { | 7000 if (modifiers.abstractKeyword != null) { |
| 7018 reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 7001 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 7019 } | 7002 } |
| 7020 if (modifiers.externalKeyword != null) { | 7003 if (modifiers.externalKeyword != null) { |
| 7021 reportErrorForToken(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyw
ord, []); | 7004 _reportErrorForToken(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKey
word, []); |
| 7022 } | 7005 } |
| 7023 if (modifiers.factoryKeyword != null) { | 7006 if (modifiers.factoryKeyword != null) { |
| 7024 reportErrorForToken(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.fac
toryKeyword, []); | 7007 _reportErrorForToken(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.fa
ctoryKeyword, []); |
| 7025 } | 7008 } |
| 7026 Token staticKeyword = modifiers.staticKeyword; | 7009 Token staticKeyword = modifiers.staticKeyword; |
| 7027 Token constKeyword = modifiers.constKeyword; | 7010 Token constKeyword = modifiers.constKeyword; |
| 7028 Token finalKeyword = modifiers.finalKeyword; | 7011 Token finalKeyword = modifiers.finalKeyword; |
| 7029 Token varKeyword = modifiers.varKeyword; | 7012 Token varKeyword = modifiers.varKeyword; |
| 7030 if (constKeyword != null) { | 7013 if (constKeyword != null) { |
| 7031 if (finalKeyword != null) { | 7014 if (finalKeyword != null) { |
| 7032 reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []); | 7015 _reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []); |
| 7033 } | 7016 } |
| 7034 if (varKeyword != null) { | 7017 if (varKeyword != null) { |
| 7035 reportErrorForToken(ParserErrorCode.CONST_AND_VAR, varKeyword, []); | 7018 _reportErrorForToken(ParserErrorCode.CONST_AND_VAR, varKeyword, []); |
| 7036 } | 7019 } |
| 7037 if (staticKeyword != null && constKeyword.offset < staticKeyword.offset) { | 7020 if (staticKeyword != null && constKeyword.offset < staticKeyword.offset) { |
| 7038 reportErrorForToken(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword, [
]); | 7021 _reportErrorForToken(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword,
[]); |
| 7039 } | 7022 } |
| 7040 } else if (finalKeyword != null) { | 7023 } else if (finalKeyword != null) { |
| 7041 if (varKeyword != null) { | 7024 if (varKeyword != null) { |
| 7042 reportErrorForToken(ParserErrorCode.FINAL_AND_VAR, varKeyword, []); | 7025 _reportErrorForToken(ParserErrorCode.FINAL_AND_VAR, varKeyword, []); |
| 7043 } | 7026 } |
| 7044 if (staticKeyword != null && finalKeyword.offset < staticKeyword.offset) { | 7027 if (staticKeyword != null && finalKeyword.offset < staticKeyword.offset) { |
| 7045 reportErrorForToken(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword, [
]); | 7028 _reportErrorForToken(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword,
[]); |
| 7046 } | 7029 } |
| 7047 } else if (varKeyword != null && staticKeyword != null && varKeyword.offset
< staticKeyword.offset) { | 7030 } else if (varKeyword != null && staticKeyword != null && varKeyword.offset
< staticKeyword.offset) { |
| 7048 reportErrorForToken(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword, []); | 7031 _reportErrorForToken(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword, []); |
| 7049 } | 7032 } |
| 7050 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]); | 7033 return _lexicallyFirst([constKeyword, finalKeyword, varKeyword]); |
| 7051 } | 7034 } |
| 7052 | 7035 |
| 7053 /** | 7036 /** |
| 7054 * Validate that the given set of modifiers is appropriate for a local functio
n. | 7037 * Validate that the given set of modifiers is appropriate for a local functio
n. |
| 7055 * | 7038 * |
| 7056 * @param modifiers the modifiers being validated | 7039 * @param modifiers the modifiers being validated |
| 7057 */ | 7040 */ |
| 7058 void validateModifiersForFunctionDeclarationStatement(Modifiers modifiers) { | 7041 void _validateModifiersForFunctionDeclarationStatement(Modifiers modifiers) { |
| 7059 if (modifiers.abstractKeyword != null || modifiers.constKeyword != null || m
odifiers.externalKeyword != null || modifiers.factoryKeyword != null || modifier
s.finalKeyword != null || modifiers.staticKeyword != null || modifiers.varKeywor
d != null) { | 7042 if (modifiers.abstractKeyword != null || modifiers.constKeyword != null || m
odifiers.externalKeyword != null || modifiers.factoryKeyword != null || modifier
s.finalKeyword != null || modifiers.staticKeyword != null || modifiers.varKeywor
d != null) { |
| 7060 reportErrorForCurrentToken(ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODI
FIER, []); | 7043 _reportErrorForCurrentToken(ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MOD
IFIER, []); |
| 7061 } | 7044 } |
| 7062 } | 7045 } |
| 7063 | 7046 |
| 7064 /** | 7047 /** |
| 7065 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. | 7048 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. |
| 7066 * | 7049 * |
| 7067 * @param modifiers the modifiers being validated | 7050 * @param modifiers the modifiers being validated |
| 7068 */ | 7051 */ |
| 7069 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { | 7052 void _validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { |
| 7070 if (modifiers.abstractKeyword != null) { | 7053 if (modifiers.abstractKeyword != null) { |
| 7071 reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 7054 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 7072 } | 7055 } |
| 7073 if (modifiers.constKeyword != null) { | 7056 if (modifiers.constKeyword != null) { |
| 7074 reportErrorForToken(ParserErrorCode.CONST_METHOD, modifiers.constKeyword,
[]); | 7057 _reportErrorForToken(ParserErrorCode.CONST_METHOD, modifiers.constKeyword,
[]); |
| 7075 } | 7058 } |
| 7076 if (modifiers.factoryKeyword != null) { | 7059 if (modifiers.factoryKeyword != null) { |
| 7077 reportErrorForToken(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.fac
toryKeyword, []); | 7060 _reportErrorForToken(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.fa
ctoryKeyword, []); |
| 7078 } | 7061 } |
| 7079 if (modifiers.finalKeyword != null) { | 7062 if (modifiers.finalKeyword != null) { |
| 7080 reportErrorForToken(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword,
[]); | 7063 _reportErrorForToken(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword,
[]); |
| 7081 } | 7064 } |
| 7082 if (modifiers.varKeyword != null) { | 7065 if (modifiers.varKeyword != null) { |
| 7083 reportErrorForToken(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword,
[]); | 7066 _reportErrorForToken(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword
, []); |
| 7084 } | 7067 } |
| 7085 Token externalKeyword = modifiers.externalKeyword; | 7068 Token externalKeyword = modifiers.externalKeyword; |
| 7086 Token staticKeyword = modifiers.staticKeyword; | 7069 Token staticKeyword = modifiers.staticKeyword; |
| 7087 if (externalKeyword != null && staticKeyword != null && staticKeyword.offset
< externalKeyword.offset) { | 7070 if (externalKeyword != null && staticKeyword != null && staticKeyword.offset
< externalKeyword.offset) { |
| 7088 reportErrorForToken(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword
, []); | 7071 _reportErrorForToken(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeywor
d, []); |
| 7089 } | 7072 } |
| 7090 } | 7073 } |
| 7091 | 7074 |
| 7092 /** | 7075 /** |
| 7093 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. | 7076 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. |
| 7094 * | 7077 * |
| 7095 * @param modifiers the modifiers being validated | 7078 * @param modifiers the modifiers being validated |
| 7096 */ | 7079 */ |
| 7097 void validateModifiersForOperator(Modifiers modifiers) { | 7080 void _validateModifiersForOperator(Modifiers modifiers) { |
| 7098 if (modifiers.abstractKeyword != null) { | 7081 if (modifiers.abstractKeyword != null) { |
| 7099 reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 7082 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 7100 } | 7083 } |
| 7101 if (modifiers.constKeyword != null) { | 7084 if (modifiers.constKeyword != null) { |
| 7102 reportErrorForToken(ParserErrorCode.CONST_METHOD, modifiers.constKeyword,
[]); | 7085 _reportErrorForToken(ParserErrorCode.CONST_METHOD, modifiers.constKeyword,
[]); |
| 7103 } | 7086 } |
| 7104 if (modifiers.factoryKeyword != null) { | 7087 if (modifiers.factoryKeyword != null) { |
| 7105 reportErrorForToken(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.fac
toryKeyword, []); | 7088 _reportErrorForToken(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.fa
ctoryKeyword, []); |
| 7106 } | 7089 } |
| 7107 if (modifiers.finalKeyword != null) { | 7090 if (modifiers.finalKeyword != null) { |
| 7108 reportErrorForToken(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword,
[]); | 7091 _reportErrorForToken(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword,
[]); |
| 7109 } | 7092 } |
| 7110 if (modifiers.staticKeyword != null) { | 7093 if (modifiers.staticKeyword != null) { |
| 7111 reportErrorForToken(ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeywo
rd, []); | 7094 _reportErrorForToken(ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeyw
ord, []); |
| 7112 } | 7095 } |
| 7113 if (modifiers.varKeyword != null) { | 7096 if (modifiers.varKeyword != null) { |
| 7114 reportErrorForToken(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword,
[]); | 7097 _reportErrorForToken(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword
, []); |
| 7115 } | 7098 } |
| 7116 } | 7099 } |
| 7117 | 7100 |
| 7118 /** | 7101 /** |
| 7119 * Validate that the given set of modifiers is appropriate for a top-level dec
laration. | 7102 * Validate that the given set of modifiers is appropriate for a top-level dec
laration. |
| 7120 * | 7103 * |
| 7121 * @param modifiers the modifiers being validated | 7104 * @param modifiers the modifiers being validated |
| 7122 */ | 7105 */ |
| 7123 void validateModifiersForTopLevelDeclaration(Modifiers modifiers) { | 7106 void _validateModifiersForTopLevelDeclaration(Modifiers modifiers) { |
| 7124 if (modifiers.factoryKeyword != null) { | 7107 if (modifiers.factoryKeyword != null) { |
| 7125 reportErrorForToken(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, modifie
rs.factoryKeyword, []); | 7108 _reportErrorForToken(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, modifi
ers.factoryKeyword, []); |
| 7126 } | 7109 } |
| 7127 if (modifiers.staticKeyword != null) { | 7110 if (modifiers.staticKeyword != null) { |
| 7128 reportErrorForToken(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, modifier
s.staticKeyword, []); | 7111 _reportErrorForToken(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, modifie
rs.staticKeyword, []); |
| 7129 } | 7112 } |
| 7130 } | 7113 } |
| 7131 | 7114 |
| 7132 /** | 7115 /** |
| 7133 * Validate that the given set of modifiers is appropriate for a top-level fun
ction. | 7116 * Validate that the given set of modifiers is appropriate for a top-level fun
ction. |
| 7134 * | 7117 * |
| 7135 * @param modifiers the modifiers being validated | 7118 * @param modifiers the modifiers being validated |
| 7136 */ | 7119 */ |
| 7137 void validateModifiersForTopLevelFunction(Modifiers modifiers) { | 7120 void _validateModifiersForTopLevelFunction(Modifiers modifiers) { |
| 7138 validateModifiersForTopLevelDeclaration(modifiers); | 7121 _validateModifiersForTopLevelDeclaration(modifiers); |
| 7139 if (modifiers.abstractKeyword != null) { | 7122 if (modifiers.abstractKeyword != null) { |
| 7140 reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, []
); | 7123 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, [
]); |
| 7141 } | 7124 } |
| 7142 if (modifiers.constKeyword != null) { | 7125 if (modifiers.constKeyword != null) { |
| 7143 reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, [
]); | 7126 _reportErrorForToken(ParserErrorCode.CONST_CLASS, modifiers.constKeyword,
[]); |
| 7144 } | 7127 } |
| 7145 if (modifiers.finalKeyword != null) { | 7128 if (modifiers.finalKeyword != null) { |
| 7146 reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, [
]); | 7129 _reportErrorForToken(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword,
[]); |
| 7147 } | 7130 } |
| 7148 if (modifiers.varKeyword != null) { | 7131 if (modifiers.varKeyword != null) { |
| 7149 reportErrorForToken(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword,
[]); | 7132 _reportErrorForToken(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword
, []); |
| 7150 } | 7133 } |
| 7151 } | 7134 } |
| 7152 | 7135 |
| 7153 /** | 7136 /** |
| 7154 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', | 7137 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', |
| 7155 * 'const' or 'var' keyword if there is one. | 7138 * 'const' or 'var' keyword if there is one. |
| 7156 * | 7139 * |
| 7157 * @param modifiers the modifiers being validated | 7140 * @param modifiers the modifiers being validated |
| 7158 * @return the 'final', 'const' or 'var' keyword associated with the field | 7141 * @return the 'final', 'const' or 'var' keyword associated with the field |
| 7159 */ | 7142 */ |
| 7160 Token validateModifiersForTopLevelVariable(Modifiers modifiers) { | 7143 Token _validateModifiersForTopLevelVariable(Modifiers modifiers) { |
| 7161 validateModifiersForTopLevelDeclaration(modifiers); | 7144 _validateModifiersForTopLevelDeclaration(modifiers); |
| 7162 if (modifiers.abstractKeyword != null) { | 7145 if (modifiers.abstractKeyword != null) { |
| 7163 reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []
); | 7146 _reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, [
]); |
| 7164 } | 7147 } |
| 7165 if (modifiers.externalKeyword != null) { | 7148 if (modifiers.externalKeyword != null) { |
| 7166 reportErrorForToken(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyw
ord, []); | 7149 _reportErrorForToken(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKey
word, []); |
| 7167 } | 7150 } |
| 7168 Token constKeyword = modifiers.constKeyword; | 7151 Token constKeyword = modifiers.constKeyword; |
| 7169 Token finalKeyword = modifiers.finalKeyword; | 7152 Token finalKeyword = modifiers.finalKeyword; |
| 7170 Token varKeyword = modifiers.varKeyword; | 7153 Token varKeyword = modifiers.varKeyword; |
| 7171 if (constKeyword != null) { | 7154 if (constKeyword != null) { |
| 7172 if (finalKeyword != null) { | 7155 if (finalKeyword != null) { |
| 7173 reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []); | 7156 _reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []); |
| 7174 } | 7157 } |
| 7175 if (varKeyword != null) { | 7158 if (varKeyword != null) { |
| 7176 reportErrorForToken(ParserErrorCode.CONST_AND_VAR, varKeyword, []); | 7159 _reportErrorForToken(ParserErrorCode.CONST_AND_VAR, varKeyword, []); |
| 7177 } | 7160 } |
| 7178 } else if (finalKeyword != null) { | 7161 } else if (finalKeyword != null) { |
| 7179 if (varKeyword != null) { | 7162 if (varKeyword != null) { |
| 7180 reportErrorForToken(ParserErrorCode.FINAL_AND_VAR, varKeyword, []); | 7163 _reportErrorForToken(ParserErrorCode.FINAL_AND_VAR, varKeyword, []); |
| 7181 } | 7164 } |
| 7182 } | 7165 } |
| 7183 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]); | 7166 return _lexicallyFirst([constKeyword, finalKeyword, varKeyword]); |
| 7184 } | 7167 } |
| 7185 | 7168 |
| 7186 /** | 7169 /** |
| 7187 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' | 7170 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' |
| 7188 * keyword if there is one. | 7171 * keyword if there is one. |
| 7189 * | 7172 * |
| 7190 * @param modifiers the modifiers being validated | 7173 * @param modifiers the modifiers being validated |
| 7191 */ | 7174 */ |
| 7192 void validateModifiersForTypedef(Modifiers modifiers) { | 7175 void _validateModifiersForTypedef(Modifiers modifiers) { |
| 7193 validateModifiersForTopLevelDeclaration(modifiers); | 7176 _validateModifiersForTopLevelDeclaration(modifiers); |
| 7194 if (modifiers.abstractKeyword != null) { | 7177 if (modifiers.abstractKeyword != null) { |
| 7195 reportErrorForToken(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKe
yword, []); | 7178 _reportErrorForToken(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractK
eyword, []); |
| 7196 } | 7179 } |
| 7197 if (modifiers.constKeyword != null) { | 7180 if (modifiers.constKeyword != null) { |
| 7198 reportErrorForToken(ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword,
[]); | 7181 _reportErrorForToken(ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword
, []); |
| 7199 } | 7182 } |
| 7200 if (modifiers.externalKeyword != null) { | 7183 if (modifiers.externalKeyword != null) { |
| 7201 reportErrorForToken(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKe
yword, []); | 7184 _reportErrorForToken(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalK
eyword, []); |
| 7202 } | 7185 } |
| 7203 if (modifiers.finalKeyword != null) { | 7186 if (modifiers.finalKeyword != null) { |
| 7204 reportErrorForToken(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword,
[]); | 7187 _reportErrorForToken(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword
, []); |
| 7205 } | 7188 } |
| 7206 if (modifiers.varKeyword != null) { | 7189 if (modifiers.varKeyword != null) { |
| 7207 reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, [])
; | 7190 _reportErrorForToken(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []
); |
| 7208 } | 7191 } |
| 7209 } | 7192 } |
| 7210 } | 7193 } |
| 7211 | 7194 |
| 7212 /** | 7195 /** |
| 7213 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword
token. | 7196 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword
token. |
| 7214 */ | 7197 */ |
| 7215 class Parser_SyntheticKeywordToken extends KeywordToken { | 7198 class Parser_SyntheticKeywordToken extends KeywordToken { |
| 7216 /** | 7199 /** |
| 7217 * Initialize a newly created token to represent the given keyword. | 7200 * Initialize a newly created token to represent the given keyword. |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7694 */ | 7677 */ |
| 7695 class ResolutionCopier implements AstVisitor<bool> { | 7678 class ResolutionCopier implements AstVisitor<bool> { |
| 7696 /** | 7679 /** |
| 7697 * Copy resolution data from one node to another. | 7680 * Copy resolution data from one node to another. |
| 7698 * | 7681 * |
| 7699 * @param fromNode the node from which resolution information will be copied | 7682 * @param fromNode the node from which resolution information will be copied |
| 7700 * @param toNode the node to which resolution information will be copied | 7683 * @param toNode the node to which resolution information will be copied |
| 7701 */ | 7684 */ |
| 7702 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 7685 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 7703 ResolutionCopier copier = new ResolutionCopier(); | 7686 ResolutionCopier copier = new ResolutionCopier(); |
| 7704 copier.isEqualNodes(fromNode, toNode); | 7687 copier._isEqualNodes(fromNode, toNode); |
| 7705 } | 7688 } |
| 7706 | 7689 |
| 7707 /** | 7690 /** |
| 7708 * The AST node with which the node being visited is to be compared. This is o
nly valid at the | 7691 * The AST node with which the node being visited is to be compared. This is o
nly valid at the |
| 7709 * beginning of each visit method (until [isEqualNodes] is invoked). | 7692 * beginning of each visit method (until [isEqualNodes] is invoked). |
| 7710 */ | 7693 */ |
| 7711 AstNode _toNode; | 7694 AstNode _toNode; |
| 7712 | 7695 |
| 7713 bool visitAdjacentStrings(AdjacentStrings node) { | 7696 bool visitAdjacentStrings(AdjacentStrings node) { |
| 7714 AdjacentStrings toNode = this._toNode as AdjacentStrings; | 7697 AdjacentStrings toNode = this._toNode as AdjacentStrings; |
| 7715 return isEqualNodeLists(node.strings, toNode.strings); | 7698 return _isEqualNodeLists(node.strings, toNode.strings); |
| 7716 } | 7699 } |
| 7717 | 7700 |
| 7718 bool visitAnnotation(Annotation node) { | 7701 bool visitAnnotation(Annotation node) { |
| 7719 Annotation toNode = this._toNode as Annotation; | 7702 Annotation toNode = this._toNode as Annotation; |
| 7720 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualToken
s(node.atSign, toNode.atSign), isEqualNodes(node.name, toNode.name)), isEqualTok
ens(node.period, toNode.period)), isEqualNodes(node.constructorName, toNode.cons
tructorName)), isEqualNodes(node.arguments, toNode.arguments))) { | 7703 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualToke
ns(node.atSign, toNode.atSign), _isEqualNodes(node.name, toNode.name)), _isEqual
Tokens(node.period, toNode.period)), _isEqualNodes(node.constructorName, toNode.
constructorName)), _isEqualNodes(node.arguments, toNode.arguments))) { |
| 7721 toNode.element = node.element; | 7704 toNode.element = node.element; |
| 7722 return true; | 7705 return true; |
| 7723 } | 7706 } |
| 7724 return false; | 7707 return false; |
| 7725 } | 7708 } |
| 7726 | 7709 |
| 7727 bool visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | 7710 bool visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 7728 ArgumentDefinitionTest toNode = this._toNode as ArgumentDefinitionTest; | 7711 ArgumentDefinitionTest toNode = this._toNode as ArgumentDefinitionTest; |
| 7729 if (javaBooleanAnd(isEqualTokens(node.question, toNode.question), isEqualNod
es(node.identifier, toNode.identifier))) { | 7712 if (javaBooleanAnd(_isEqualTokens(node.question, toNode.question), _isEqualN
odes(node.identifier, toNode.identifier))) { |
| 7730 toNode.propagatedType = node.propagatedType; | 7713 toNode.propagatedType = node.propagatedType; |
| 7731 toNode.staticType = node.staticType; | 7714 toNode.staticType = node.staticType; |
| 7732 return true; | 7715 return true; |
| 7733 } | 7716 } |
| 7734 return false; | 7717 return false; |
| 7735 } | 7718 } |
| 7736 | 7719 |
| 7737 bool visitArgumentList(ArgumentList node) { | 7720 bool visitArgumentList(ArgumentList node) { |
| 7738 ArgumentList toNode = this._toNode as ArgumentList; | 7721 ArgumentList toNode = this._toNode as ArgumentList; |
| 7739 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.leftParenthesis, toN
ode.leftParenthesis), isEqualNodeLists(node.arguments, toNode.arguments)), isEqu
alTokens(node.rightParenthesis, toNode.rightParenthesis)); | 7722 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.leftParenthesis, to
Node.leftParenthesis), _isEqualNodeLists(node.arguments, toNode.arguments)), _is
EqualTokens(node.rightParenthesis, toNode.rightParenthesis)); |
| 7740 } | 7723 } |
| 7741 | 7724 |
| 7742 bool visitAsExpression(AsExpression node) { | 7725 bool visitAsExpression(AsExpression node) { |
| 7743 AsExpression toNode = this._toNode as AsExpression; | 7726 AsExpression toNode = this._toNode as AsExpression; |
| 7744 if (javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.expression, toNode.expre
ssion), isEqualTokens(node.asOperator, toNode.asOperator)), isEqualNodes(node.ty
pe, toNode.type))) { | 7727 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.expression, toNode.expr
ession), _isEqualTokens(node.asOperator, toNode.asOperator)), _isEqualNodes(node
.type, toNode.type))) { |
| 7745 toNode.propagatedType = node.propagatedType; | 7728 toNode.propagatedType = node.propagatedType; |
| 7746 toNode.staticType = node.staticType; | 7729 toNode.staticType = node.staticType; |
| 7747 return true; | 7730 return true; |
| 7748 } | 7731 } |
| 7749 return false; | 7732 return false; |
| 7750 } | 7733 } |
| 7751 | 7734 |
| 7752 bool visitAssertStatement(AssertStatement node) { | 7735 bool visitAssertStatement(AssertStatement node) { |
| 7753 AssertStatement toNode = this._toNode as AssertStatement; | 7736 AssertStatement toNode = this._toNode as AssertStatement; |
| 7754 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTo
kens(node.keyword, toNode.keyword), isEqualTokens(node.leftParenthesis, toNode.l
eftParenthesis)), isEqualNodes(node.condition, toNode.condition)), isEqualTokens
(node.rightParenthesis, toNode.rightParenthesis)), isEqualTokens(node.semicolon,
toNode.semicolon)); | 7737 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualT
okens(node.keyword, toNode.keyword), _isEqualTokens(node.leftParenthesis, toNode
.leftParenthesis)), _isEqualNodes(node.condition, toNode.condition)), _isEqualTo
kens(node.rightParenthesis, toNode.rightParenthesis)), _isEqualTokens(node.semic
olon, toNode.semicolon)); |
| 7755 } | 7738 } |
| 7756 | 7739 |
| 7757 bool visitAssignmentExpression(AssignmentExpression node) { | 7740 bool visitAssignmentExpression(AssignmentExpression node) { |
| 7758 AssignmentExpression toNode = this._toNode as AssignmentExpression; | 7741 AssignmentExpression toNode = this._toNode as AssignmentExpression; |
| 7759 if (javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.leftHandSide, toNode.lef
tHandSide), isEqualTokens(node.operator, toNode.operator)), isEqualNodes(node.ri
ghtHandSide, toNode.rightHandSide))) { | 7742 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.leftHandSide, toNode.le
ftHandSide), _isEqualTokens(node.operator, toNode.operator)), _isEqualNodes(node
.rightHandSide, toNode.rightHandSide))) { |
| 7760 toNode.propagatedElement = node.propagatedElement; | 7743 toNode.propagatedElement = node.propagatedElement; |
| 7761 toNode.propagatedType = node.propagatedType; | 7744 toNode.propagatedType = node.propagatedType; |
| 7762 toNode.staticElement = node.staticElement; | 7745 toNode.staticElement = node.staticElement; |
| 7763 toNode.staticType = node.staticType; | 7746 toNode.staticType = node.staticType; |
| 7764 return true; | 7747 return true; |
| 7765 } | 7748 } |
| 7766 return false; | 7749 return false; |
| 7767 } | 7750 } |
| 7768 | 7751 |
| 7769 bool visitBinaryExpression(BinaryExpression node) { | 7752 bool visitBinaryExpression(BinaryExpression node) { |
| 7770 BinaryExpression toNode = this._toNode as BinaryExpression; | 7753 BinaryExpression toNode = this._toNode as BinaryExpression; |
| 7771 if (javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.leftOperand, toNode.left
Operand), isEqualTokens(node.operator, toNode.operator)), isEqualNodes(node.righ
tOperand, toNode.rightOperand))) { | 7754 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.leftOperand, toNode.lef
tOperand), _isEqualTokens(node.operator, toNode.operator)), _isEqualNodes(node.r
ightOperand, toNode.rightOperand))) { |
| 7772 toNode.propagatedElement = node.propagatedElement; | 7755 toNode.propagatedElement = node.propagatedElement; |
| 7773 toNode.propagatedType = node.propagatedType; | 7756 toNode.propagatedType = node.propagatedType; |
| 7774 toNode.staticElement = node.staticElement; | 7757 toNode.staticElement = node.staticElement; |
| 7775 toNode.staticType = node.staticType; | 7758 toNode.staticType = node.staticType; |
| 7776 return true; | 7759 return true; |
| 7777 } | 7760 } |
| 7778 return false; | 7761 return false; |
| 7779 } | 7762 } |
| 7780 | 7763 |
| 7781 bool visitBlock(Block node) { | 7764 bool visitBlock(Block node) { |
| 7782 Block toNode = this._toNode as Block; | 7765 Block toNode = this._toNode as Block; |
| 7783 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.leftBracket, toNode.
leftBracket), isEqualNodeLists(node.statements, toNode.statements)), isEqualToke
ns(node.rightBracket, toNode.rightBracket)); | 7766 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.leftBracket, toNode
.leftBracket), _isEqualNodeLists(node.statements, toNode.statements)), _isEqualT
okens(node.rightBracket, toNode.rightBracket)); |
| 7784 } | 7767 } |
| 7785 | 7768 |
| 7786 bool visitBlockFunctionBody(BlockFunctionBody node) { | 7769 bool visitBlockFunctionBody(BlockFunctionBody node) { |
| 7787 BlockFunctionBody toNode = this._toNode as BlockFunctionBody; | 7770 BlockFunctionBody toNode = this._toNode as BlockFunctionBody; |
| 7788 return isEqualNodes(node.block, toNode.block); | 7771 return _isEqualNodes(node.block, toNode.block); |
| 7789 } | 7772 } |
| 7790 | 7773 |
| 7791 bool visitBooleanLiteral(BooleanLiteral node) { | 7774 bool visitBooleanLiteral(BooleanLiteral node) { |
| 7792 BooleanLiteral toNode = this._toNode as BooleanLiteral; | 7775 BooleanLiteral toNode = this._toNode as BooleanLiteral; |
| 7793 if (javaBooleanAnd(isEqualTokens(node.literal, toNode.literal), identical(no
de.value, toNode.value))) { | 7776 if (javaBooleanAnd(_isEqualTokens(node.literal, toNode.literal), identical(n
ode.value, toNode.value))) { |
| 7794 toNode.propagatedType = node.propagatedType; | 7777 toNode.propagatedType = node.propagatedType; |
| 7795 toNode.staticType = node.staticType; | 7778 toNode.staticType = node.staticType; |
| 7796 return true; | 7779 return true; |
| 7797 } | 7780 } |
| 7798 return false; | 7781 return false; |
| 7799 } | 7782 } |
| 7800 | 7783 |
| 7801 bool visitBreakStatement(BreakStatement node) { | 7784 bool visitBreakStatement(BreakStatement node) { |
| 7802 BreakStatement toNode = this._toNode as BreakStatement; | 7785 BreakStatement toNode = this._toNode as BreakStatement; |
| 7803 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyw
ord), isEqualNodes(node.label, toNode.label)), isEqualTokens(node.semicolon, toN
ode.semicolon)); | 7786 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.keyword, toNode.key
word), _isEqualNodes(node.label, toNode.label)), _isEqualTokens(node.semicolon,
toNode.semicolon)); |
| 7804 } | 7787 } |
| 7805 | 7788 |
| 7806 bool visitCascadeExpression(CascadeExpression node) { | 7789 bool visitCascadeExpression(CascadeExpression node) { |
| 7807 CascadeExpression toNode = this._toNode as CascadeExpression; | 7790 CascadeExpression toNode = this._toNode as CascadeExpression; |
| 7808 if (javaBooleanAnd(isEqualNodes(node.target, toNode.target), isEqualNodeList
s(node.cascadeSections, toNode.cascadeSections))) { | 7791 if (javaBooleanAnd(_isEqualNodes(node.target, toNode.target), _isEqualNodeLi
sts(node.cascadeSections, toNode.cascadeSections))) { |
| 7809 toNode.propagatedType = node.propagatedType; | 7792 toNode.propagatedType = node.propagatedType; |
| 7810 toNode.staticType = node.staticType; | 7793 toNode.staticType = node.staticType; |
| 7811 return true; | 7794 return true; |
| 7812 } | 7795 } |
| 7813 return false; | 7796 return false; |
| 7814 } | 7797 } |
| 7815 | 7798 |
| 7816 bool visitCatchClause(CatchClause node) { | 7799 bool visitCatchClause(CatchClause node) { |
| 7817 CatchClause toNode = this._toNode as CatchClause; | 7800 CatchClause toNode = this._toNode as CatchClause; |
| 7818 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.onKeyword,
toNode.onKeyword), isEqualNodes(node.exceptionType, toNode.exceptionType)), isE
qualTokens(node.catchKeyword, toNode.catchKeyword)), isEqualTokens(node.leftPare
nthesis, toNode.leftParenthesis)), isEqualNodes(node.exceptionParameter, toNode.
exceptionParameter)), isEqualTokens(node.comma, toNode.comma)), isEqualNodes(nod
e.stackTraceParameter, toNode.stackTraceParameter)), isEqualTokens(node.rightPar
enthesis, toNode.rightParenthesis)), isEqualNodes(node.body, toNode.body)); | 7801 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.onKeyword
, toNode.onKeyword), _isEqualNodes(node.exceptionType, toNode.exceptionType)), _
isEqualTokens(node.catchKeyword, toNode.catchKeyword)), _isEqualTokens(node.left
Parenthesis, toNode.leftParenthesis)), _isEqualNodes(node.exceptionParameter, to
Node.exceptionParameter)), _isEqualTokens(node.comma, toNode.comma)), _isEqualNo
des(node.stackTraceParameter, toNode.stackTraceParameter)), _isEqualTokens(node.
rightParenthesis, toNode.rightParenthesis)), _isEqualNodes(node.body, toNode.bod
y)); |
| 7819 } | 7802 } |
| 7820 | 7803 |
| 7821 bool visitClassDeclaration(ClassDeclaration node) { | 7804 bool visitClassDeclaration(ClassDeclaration node) { |
| 7822 ClassDeclaration toNode = this._toNode as ClassDeclaration; | 7805 ClassDeclaration toNode = this._toNode as ClassDeclaration; |
| 7823 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd
(javaBooleanAnd(isEqualNodes(node.documentationComment, toNode.documentationComm
ent), isEqualNodeLists(node.metadata, toNode.metadata)), isEqualTokens(node.abst
ractKeyword, toNode.abstractKeyword)), isEqualTokens(node.classKeyword, toNode.c
lassKeyword)), isEqualNodes(node.name, toNode.name)), isEqualNodes(node.typePara
meters, toNode.typeParameters)), isEqualNodes(node.extendsClause, toNode.extends
Clause)), isEqualNodes(node.withClause, toNode.withClause)), isEqualNodes(node.i
mplementsClause, toNode.implementsClause)), isEqualTokens(node.leftBracket, toNo
de.leftBracket)), isEqualNodeLists(node.members, toNode.members)), isEqualTokens
(node.rightBracket, toNode.rightBracket)); | 7806 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd
(javaBooleanAnd(_isEqualNodes(node.documentationComment, toNode.documentationCom
ment), _isEqualNodeLists(node.metadata, toNode.metadata)), _isEqualTokens(node.a
bstractKeyword, toNode.abstractKeyword)), _isEqualTokens(node.classKeyword, toNo
de.classKeyword)), _isEqualNodes(node.name, toNode.name)), _isEqualNodes(node.ty
peParameters, toNode.typeParameters)), _isEqualNodes(node.extendsClause, toNode.
extendsClause)), _isEqualNodes(node.withClause, toNode.withClause)), _isEqualNod
es(node.implementsClause, toNode.implementsClause)), _isEqualTokens(node.leftBra
cket, toNode.leftBracket)), _isEqualNodeLists(node.members, toNode.members)), _i
sEqualTokens(node.rightBracket, toNode.rightBracket)); |
| 7824 } | 7807 } |
| 7825 | 7808 |
| 7826 bool visitClassTypeAlias(ClassTypeAlias node) { | 7809 bool visitClassTypeAlias(ClassTypeAlias node) { |
| 7827 ClassTypeAlias toNode = this._toNode as ClassTypeAlias; | 7810 ClassTypeAlias toNode = this._toNode as ClassTypeAlias; |
| 7828 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd
(isEqualNodes(node.documentationComment, toNode.documentationComment), isEqualNo
deLists(node.metadata, toNode.metadata)), isEqualTokens(node.keyword, toNode.key
word)), isEqualNodes(node.name, toNode.name)), isEqualNodes(node.typeParameters,
toNode.typeParameters)), isEqualTokens(node.equals, toNode.equals)), isEqualTok
ens(node.abstractKeyword, toNode.abstractKeyword)), isEqualNodes(node.superclass
, toNode.superclass)), isEqualNodes(node.withClause, toNode.withClause)), isEqua
lNodes(node.implementsClause, toNode.implementsClause)), isEqualTokens(node.semi
colon, toNode.semicolon)); | 7811 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd
(_isEqualNodes(node.documentationComment, toNode.documentationComment), _isEqual
NodeLists(node.metadata, toNode.metadata)), _isEqualTokens(node.keyword, toNode.
keyword)), _isEqualNodes(node.name, toNode.name)), _isEqualNodes(node.typeParame
ters, toNode.typeParameters)), _isEqualTokens(node.equals, toNode.equals)), _isE
qualTokens(node.abstractKeyword, toNode.abstractKeyword)), _isEqualNodes(node.su
perclass, toNode.superclass)), _isEqualNodes(node.withClause, toNode.withClause)
), _isEqualNodes(node.implementsClause, toNode.implementsClause)), _isEqualToken
s(node.semicolon, toNode.semicolon)); |
| 7829 } | 7812 } |
| 7830 | 7813 |
| 7831 bool visitComment(Comment node) { | 7814 bool visitComment(Comment node) { |
| 7832 Comment toNode = this._toNode as Comment; | 7815 Comment toNode = this._toNode as Comment; |
| 7833 return isEqualNodeLists(node.references, toNode.references); | 7816 return _isEqualNodeLists(node.references, toNode.references); |
| 7834 } | 7817 } |
| 7835 | 7818 |
| 7836 bool visitCommentReference(CommentReference node) { | 7819 bool visitCommentReference(CommentReference node) { |
| 7837 CommentReference toNode = this._toNode as CommentReference; | 7820 CommentReference toNode = this._toNode as CommentReference; |
| 7838 return javaBooleanAnd(isEqualTokens(node.newKeyword, toNode.newKeyword), isE
qualNodes(node.identifier, toNode.identifier)); | 7821 return javaBooleanAnd(_isEqualTokens(node.newKeyword, toNode.newKeyword), _i
sEqualNodes(node.identifier, toNode.identifier)); |
| 7839 } | 7822 } |
| 7840 | 7823 |
| 7841 bool visitCompilationUnit(CompilationUnit node) { | 7824 bool visitCompilationUnit(CompilationUnit node) { |
| 7842 CompilationUnit toNode = this._toNode as CompilationUnit; | 7825 CompilationUnit toNode = this._toNode as CompilationUnit; |
| 7843 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualToken
s(node.beginToken, toNode.beginToken), isEqualNodes(node.scriptTag, toNode.scrip
tTag)), isEqualNodeLists(node.directives, toNode.directives)), isEqualNodeLists(
node.declarations, toNode.declarations)), isEqualTokens(node.endToken, toNode.en
dToken))) { | 7826 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualToke
ns(node.beginToken, toNode.beginToken), _isEqualNodes(node.scriptTag, toNode.scr
iptTag)), _isEqualNodeLists(node.directives, toNode.directives)), _isEqualNodeLi
sts(node.declarations, toNode.declarations)), _isEqualTokens(node.endToken, toNo
de.endToken))) { |
| 7844 toNode.element = node.element; | 7827 toNode.element = node.element; |
| 7845 return true; | 7828 return true; |
| 7846 } | 7829 } |
| 7847 return false; | 7830 return false; |
| 7848 } | 7831 } |
| 7849 | 7832 |
| 7850 bool visitConditionalExpression(ConditionalExpression node) { | 7833 bool visitConditionalExpression(ConditionalExpression node) { |
| 7851 ConditionalExpression toNode = this._toNode as ConditionalExpression; | 7834 ConditionalExpression toNode = this._toNode as ConditionalExpression; |
| 7852 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes
(node.condition, toNode.condition), isEqualTokens(node.question, toNode.question
)), isEqualNodes(node.thenExpression, toNode.thenExpression)), isEqualTokens(nod
e.colon, toNode.colon)), isEqualNodes(node.elseExpression, toNode.elseExpression
))) { | 7835 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNode
s(node.condition, toNode.condition), _isEqualTokens(node.question, toNode.questi
on)), _isEqualNodes(node.thenExpression, toNode.thenExpression)), _isEqualTokens
(node.colon, toNode.colon)), _isEqualNodes(node.elseExpression, toNode.elseExpre
ssion))) { |
| 7853 toNode.propagatedType = node.propagatedType; | 7836 toNode.propagatedType = node.propagatedType; |
| 7854 toNode.staticType = node.staticType; | 7837 toNode.staticType = node.staticType; |
| 7855 return true; | 7838 return true; |
| 7856 } | 7839 } |
| 7857 return false; | 7840 return false; |
| 7858 } | 7841 } |
| 7859 | 7842 |
| 7860 bool visitConstructorDeclaration(ConstructorDeclaration node) { | 7843 bool visitConstructorDeclaration(ConstructorDeclaration node) { |
| 7861 ConstructorDeclaration toNode = this._toNode as ConstructorDeclaration; | 7844 ConstructorDeclaration toNode = this._toNode as ConstructorDeclaration; |
| 7862 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(ja
vaBooleanAnd(javaBooleanAnd(isEqualNodes(node.documentationComment, toNode.docum
entationComment), isEqualNodeLists(node.metadata, toNode.metadata)), isEqualToke
ns(node.externalKeyword, toNode.externalKeyword)), isEqualTokens(node.constKeywo
rd, toNode.constKeyword)), isEqualTokens(node.factoryKeyword, toNode.factoryKeyw
ord)), isEqualNodes(node.returnType, toNode.returnType)), isEqualTokens(node.per
iod, toNode.period)), isEqualNodes(node.name, toNode.name)), isEqualNodes(node.p
arameters, toNode.parameters)), isEqualTokens(node.separator, toNode.separator))
, isEqualNodeLists(node.initializers, toNode.initializers)), isEqualNodes(node.r
edirectedConstructor, toNode.redirectedConstructor)), isEqualNodes(node.body, to
Node.body))) { | 7845 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(ja
vaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.documentationComment, toNode.docu
mentationComment), _isEqualNodeLists(node.metadata, toNode.metadata)), _isEqualT
okens(node.externalKeyword, toNode.externalKeyword)), _isEqualTokens(node.constK
eyword, toNode.constKeyword)), _isEqualTokens(node.factoryKeyword, toNode.factor
yKeyword)), _isEqualNodes(node.returnType, toNode.returnType)), _isEqualTokens(n
ode.period, toNode.period)), _isEqualNodes(node.name, toNode.name)), _isEqualNod
es(node.parameters, toNode.parameters)), _isEqualTokens(node.separator, toNode.s
eparator)), _isEqualNodeLists(node.initializers, toNode.initializers)), _isEqual
Nodes(node.redirectedConstructor, toNode.redirectedConstructor)), _isEqualNodes(
node.body, toNode.body))) { |
| 7863 toNode.element = node.element; | 7846 toNode.element = node.element; |
| 7864 return true; | 7847 return true; |
| 7865 } | 7848 } |
| 7866 return false; | 7849 return false; |
| 7867 } | 7850 } |
| 7868 | 7851 |
| 7869 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 7852 bool visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 7870 ConstructorFieldInitializer toNode = this._toNode as ConstructorFieldInitial
izer; | 7853 ConstructorFieldInitializer toNode = this._toNode as ConstructorFieldInitial
izer; |
| 7871 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTo
kens(node.keyword, toNode.keyword), isEqualTokens(node.period, toNode.period)),
isEqualNodes(node.fieldName, toNode.fieldName)), isEqualTokens(node.equals, toNo
de.equals)), isEqualNodes(node.expression, toNode.expression)); | 7854 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualT
okens(node.keyword, toNode.keyword), _isEqualTokens(node.period, toNode.period))
, _isEqualNodes(node.fieldName, toNode.fieldName)), _isEqualTokens(node.equals,
toNode.equals)), _isEqualNodes(node.expression, toNode.expression)); |
| 7872 } | 7855 } |
| 7873 | 7856 |
| 7874 bool visitConstructorName(ConstructorName node) { | 7857 bool visitConstructorName(ConstructorName node) { |
| 7875 ConstructorName toNode = this._toNode as ConstructorName; | 7858 ConstructorName toNode = this._toNode as ConstructorName; |
| 7876 if (javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.type, toNode.type), isEq
ualTokens(node.period, toNode.period)), isEqualNodes(node.name, toNode.name))) { | 7859 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.type, toNode.type), _is
EqualTokens(node.period, toNode.period)), _isEqualNodes(node.name, toNode.name))
) { |
| 7877 toNode.staticElement = node.staticElement; | 7860 toNode.staticElement = node.staticElement; |
| 7878 return true; | 7861 return true; |
| 7879 } | 7862 } |
| 7880 return false; | 7863 return false; |
| 7881 } | 7864 } |
| 7882 | 7865 |
| 7883 bool visitContinueStatement(ContinueStatement node) { | 7866 bool visitContinueStatement(ContinueStatement node) { |
| 7884 ContinueStatement toNode = this._toNode as ContinueStatement; | 7867 ContinueStatement toNode = this._toNode as ContinueStatement; |
| 7885 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyw
ord), isEqualNodes(node.label, toNode.label)), isEqualTokens(node.semicolon, toN
ode.semicolon)); | 7868 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.keyword, toNode.key
word), _isEqualNodes(node.label, toNode.label)), _isEqualTokens(node.semicolon,
toNode.semicolon)); |
| 7886 } | 7869 } |
| 7887 | 7870 |
| 7888 bool visitDeclaredIdentifier(DeclaredIdentifier node) { | 7871 bool visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 7889 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier; | 7872 DeclaredIdentifier toNode = this._toNode as DeclaredIdentifier; |
| 7890 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualTokens(node.keyword, toNode.keyword)), is
EqualNodes(node.type, toNode.type)), isEqualNodes(node.identifier, toNode.identi
fier)); | 7873 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualTokens(node.keyword, toNode.keyword)),
_isEqualNodes(node.type, toNode.type)), _isEqualNodes(node.identifier, toNode.i
dentifier)); |
| 7891 } | 7874 } |
| 7892 | 7875 |
| 7893 bool visitDefaultFormalParameter(DefaultFormalParameter node) { | 7876 bool visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 7894 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter; | 7877 DefaultFormalParameter toNode = this._toNode as DefaultFormalParameter; |
| 7895 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.parame
ter, toNode.parameter), identical(node.kind, toNode.kind)), isEqualTokens(node.s
eparator, toNode.separator)), isEqualNodes(node.defaultValue, toNode.defaultValu
e)); | 7878 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.param
eter, toNode.parameter), identical(node.kind, toNode.kind)), _isEqualTokens(node
.separator, toNode.separator)), _isEqualNodes(node.defaultValue, toNode.defaultV
alue)); |
| 7896 } | 7879 } |
| 7897 | 7880 |
| 7898 bool visitDoStatement(DoStatement node) { | 7881 bool visitDoStatement(DoStatement node) { |
| 7899 DoStatement toNode = this._toNode as DoStatement; | 7882 DoStatement toNode = this._toNode as DoStatement; |
| 7900 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqualTokens(node.doKeyword, toNode.doKeyword), isEqualNod
es(node.body, toNode.body)), isEqualTokens(node.whileKeyword, toNode.whileKeywor
d)), isEqualTokens(node.leftParenthesis, toNode.leftParenthesis)), isEqualNodes(
node.condition, toNode.condition)), isEqualTokens(node.rightParenthesis, toNode.
rightParenthesis)), isEqualTokens(node.semicolon, toNode.semicolon)); | 7883 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(_isEqualTokens(node.doKeyword, toNode.doKeyword), _isEqualN
odes(node.body, toNode.body)), _isEqualTokens(node.whileKeyword, toNode.whileKey
word)), _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis)), _isEqualN
odes(node.condition, toNode.condition)), _isEqualTokens(node.rightParenthesis, t
oNode.rightParenthesis)), _isEqualTokens(node.semicolon, toNode.semicolon)); |
| 7901 } | 7884 } |
| 7902 | 7885 |
| 7903 bool visitDoubleLiteral(DoubleLiteral node) { | 7886 bool visitDoubleLiteral(DoubleLiteral node) { |
| 7904 DoubleLiteral toNode = this._toNode as DoubleLiteral; | 7887 DoubleLiteral toNode = this._toNode as DoubleLiteral; |
| 7905 if (javaBooleanAnd(isEqualTokens(node.literal, toNode.literal), node.value =
= toNode.value)) { | 7888 if (javaBooleanAnd(_isEqualTokens(node.literal, toNode.literal), node.value
== toNode.value)) { |
| 7906 toNode.propagatedType = node.propagatedType; | 7889 toNode.propagatedType = node.propagatedType; |
| 7907 toNode.staticType = node.staticType; | 7890 toNode.staticType = node.staticType; |
| 7908 return true; | 7891 return true; |
| 7909 } | 7892 } |
| 7910 return false; | 7893 return false; |
| 7911 } | 7894 } |
| 7912 | 7895 |
| 7913 bool visitEmptyFunctionBody(EmptyFunctionBody node) { | 7896 bool visitEmptyFunctionBody(EmptyFunctionBody node) { |
| 7914 EmptyFunctionBody toNode = this._toNode as EmptyFunctionBody; | 7897 EmptyFunctionBody toNode = this._toNode as EmptyFunctionBody; |
| 7915 return isEqualTokens(node.semicolon, toNode.semicolon); | 7898 return _isEqualTokens(node.semicolon, toNode.semicolon); |
| 7916 } | 7899 } |
| 7917 | 7900 |
| 7918 bool visitEmptyStatement(EmptyStatement node) { | 7901 bool visitEmptyStatement(EmptyStatement node) { |
| 7919 EmptyStatement toNode = this._toNode as EmptyStatement; | 7902 EmptyStatement toNode = this._toNode as EmptyStatement; |
| 7920 return isEqualTokens(node.semicolon, toNode.semicolon); | 7903 return _isEqualTokens(node.semicolon, toNode.semicolon); |
| 7921 } | 7904 } |
| 7922 | 7905 |
| 7923 bool visitExportDirective(ExportDirective node) { | 7906 bool visitExportDirective(ExportDirective node) { |
| 7924 ExportDirective toNode = this._toNode as ExportDirective; | 7907 ExportDirective toNode = this._toNode as ExportDirective; |
| 7925 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(isEqualNodes(node.documentationComment, toNode.documentationComment), isEqual
NodeLists(node.metadata, toNode.metadata)), isEqualTokens(node.keyword, toNode.k
eyword)), isEqualNodes(node.uri, toNode.uri)), isEqualNodeLists(node.combinators
, toNode.combinators)), isEqualTokens(node.semicolon, toNode.semicolon))) { | 7908 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(_isEqualNodes(node.documentationComment, toNode.documentationComment), _isEqu
alNodeLists(node.metadata, toNode.metadata)), _isEqualTokens(node.keyword, toNod
e.keyword)), _isEqualNodes(node.uri, toNode.uri)), _isEqualNodeLists(node.combin
ators, toNode.combinators)), _isEqualTokens(node.semicolon, toNode.semicolon)))
{ |
| 7926 toNode.element = node.element; | 7909 toNode.element = node.element; |
| 7927 return true; | 7910 return true; |
| 7928 } | 7911 } |
| 7929 return false; | 7912 return false; |
| 7930 } | 7913 } |
| 7931 | 7914 |
| 7932 bool visitExpressionFunctionBody(ExpressionFunctionBody node) { | 7915 bool visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 7933 ExpressionFunctionBody toNode = this._toNode as ExpressionFunctionBody; | 7916 ExpressionFunctionBody toNode = this._toNode as ExpressionFunctionBody; |
| 7934 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.functionDefinition,
toNode.functionDefinition), isEqualNodes(node.expression, toNode.expression)), i
sEqualTokens(node.semicolon, toNode.semicolon)); | 7917 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.functionDefinition,
toNode.functionDefinition), _isEqualNodes(node.expression, toNode.expression)),
_isEqualTokens(node.semicolon, toNode.semicolon)); |
| 7935 } | 7918 } |
| 7936 | 7919 |
| 7937 bool visitExpressionStatement(ExpressionStatement node) { | 7920 bool visitExpressionStatement(ExpressionStatement node) { |
| 7938 ExpressionStatement toNode = this._toNode as ExpressionStatement; | 7921 ExpressionStatement toNode = this._toNode as ExpressionStatement; |
| 7939 return javaBooleanAnd(isEqualNodes(node.expression, toNode.expression), isEq
ualTokens(node.semicolon, toNode.semicolon)); | 7922 return javaBooleanAnd(_isEqualNodes(node.expression, toNode.expression), _is
EqualTokens(node.semicolon, toNode.semicolon)); |
| 7940 } | 7923 } |
| 7941 | 7924 |
| 7942 bool visitExtendsClause(ExtendsClause node) { | 7925 bool visitExtendsClause(ExtendsClause node) { |
| 7943 ExtendsClause toNode = this._toNode as ExtendsClause; | 7926 ExtendsClause toNode = this._toNode as ExtendsClause; |
| 7944 return javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualNo
des(node.superclass, toNode.superclass)); | 7927 return javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqual
Nodes(node.superclass, toNode.superclass)); |
| 7945 } | 7928 } |
| 7946 | 7929 |
| 7947 bool visitFieldDeclaration(FieldDeclaration node) { | 7930 bool visitFieldDeclaration(FieldDeclaration node) { |
| 7948 FieldDeclaration toNode = this._toNode as FieldDeclaration; | 7931 FieldDeclaration toNode = this._toNode as FieldDeclaration; |
| 7949 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualTokens(node.staticKeyword, toNode.staticK
eyword)), isEqualNodes(node.fields, toNode.fields)), isEqualTokens(node.semicolo
n, toNode.semicolon)); | 7932 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualTokens(node.staticKeyword, toNode.stat
icKeyword)), _isEqualNodes(node.fields, toNode.fields)), _isEqualTokens(node.sem
icolon, toNode.semicolon)); |
| 7950 } | 7933 } |
| 7951 | 7934 |
| 7952 bool visitFieldFormalParameter(FieldFormalParameter node) { | 7935 bool visitFieldFormalParameter(FieldFormalParameter node) { |
| 7953 FieldFormalParameter toNode = this._toNode as FieldFormalParameter; | 7936 FieldFormalParameter toNode = this._toNode as FieldFormalParameter; |
| 7954 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqualNodes(node.documentationComment, toNode.documentatio
nComment), isEqualNodeLists(node.metadata, toNode.metadata)), isEqualTokens(node
.keyword, toNode.keyword)), isEqualNodes(node.type, toNode.type)), isEqualTokens
(node.thisToken, toNode.thisToken)), isEqualTokens(node.period, toNode.period)),
isEqualNodes(node.identifier, toNode.identifier)); | 7937 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(_isEqualNodes(node.documentationComment, toNode.documentati
onComment), _isEqualNodeLists(node.metadata, toNode.metadata)), _isEqualTokens(n
ode.keyword, toNode.keyword)), _isEqualNodes(node.type, toNode.type)), _isEqualT
okens(node.thisToken, toNode.thisToken)), _isEqualTokens(node.period, toNode.per
iod)), _isEqualNodes(node.identifier, toNode.identifier)); |
| 7955 } | 7938 } |
| 7956 | 7939 |
| 7957 bool visitForEachStatement(ForEachStatement node) { | 7940 bool visitForEachStatement(ForEachStatement node) { |
| 7958 ForEachStatement toNode = this._toNode as ForEachStatement; | 7941 ForEachStatement toNode = this._toNode as ForEachStatement; |
| 7959 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqualTokens(node.forKeyword, toNode.forKeyword), isEqualT
okens(node.leftParenthesis, toNode.leftParenthesis)), isEqualNodes(node.loopVari
able, toNode.loopVariable)), isEqualTokens(node.inKeyword, toNode.inKeyword)), i
sEqualNodes(node.iterator, toNode.iterator)), isEqualTokens(node.rightParenthesi
s, toNode.rightParenthesis)), isEqualNodes(node.body, toNode.body)); | 7942 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(_isEqualTokens(node.forKeyword, toNode.forKeyword), _isEqua
lTokens(node.leftParenthesis, toNode.leftParenthesis)), _isEqualNodes(node.loopV
ariable, toNode.loopVariable)), _isEqualTokens(node.inKeyword, toNode.inKeyword)
), _isEqualNodes(node.iterator, toNode.iterator)), _isEqualTokens(node.rightPare
nthesis, toNode.rightParenthesis)), _isEqualNodes(node.body, toNode.body)); |
| 7960 } | 7943 } |
| 7961 | 7944 |
| 7962 bool visitFormalParameterList(FormalParameterList node) { | 7945 bool visitFormalParameterList(FormalParameterList node) { |
| 7963 FormalParameterList toNode = this._toNode as FormalParameterList; | 7946 FormalParameterList toNode = this._toNode as FormalParameterList; |
| 7964 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTo
kens(node.leftParenthesis, toNode.leftParenthesis), isEqualNodeLists(node.parame
ters, toNode.parameters)), isEqualTokens(node.leftDelimiter, toNode.leftDelimite
r)), isEqualTokens(node.rightDelimiter, toNode.rightDelimiter)), isEqualTokens(n
ode.rightParenthesis, toNode.rightParenthesis)); | 7947 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualT
okens(node.leftParenthesis, toNode.leftParenthesis), _isEqualNodeLists(node.para
meters, toNode.parameters)), _isEqualTokens(node.leftDelimiter, toNode.leftDelim
iter)), _isEqualTokens(node.rightDelimiter, toNode.rightDelimiter)), _isEqualTok
ens(node.rightParenthesis, toNode.rightParenthesis)); |
| 7965 } | 7948 } |
| 7966 | 7949 |
| 7967 bool visitForStatement(ForStatement node) { | 7950 bool visitForStatement(ForStatement node) { |
| 7968 ForStatement toNode = this._toNode as ForStatement; | 7951 ForStatement toNode = this._toNode as ForStatement; |
| 7969 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTokens(
node.forKeyword, toNode.forKeyword), isEqualTokens(node.leftParenthesis, toNode.
leftParenthesis)), isEqualNodes(node.variables, toNode.variables)), isEqualNodes
(node.initialization, toNode.initialization)), isEqualTokens(node.leftSeparator,
toNode.leftSeparator)), isEqualNodes(node.condition, toNode.condition)), isEqua
lTokens(node.rightSeparator, toNode.rightSeparator)), isEqualNodeLists(node.upda
ters, toNode.updaters)), isEqualTokens(node.rightParenthesis, toNode.rightParent
hesis)), isEqualNodes(node.body, toNode.body)); | 7952 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualTokens
(node.forKeyword, toNode.forKeyword), _isEqualTokens(node.leftParenthesis, toNod
e.leftParenthesis)), _isEqualNodes(node.variables, toNode.variables)), _isEqualN
odes(node.initialization, toNode.initialization)), _isEqualTokens(node.leftSepar
ator, toNode.leftSeparator)), _isEqualNodes(node.condition, toNode.condition)),
_isEqualTokens(node.rightSeparator, toNode.rightSeparator)), _isEqualNodeLists(n
ode.updaters, toNode.updaters)), _isEqualTokens(node.rightParenthesis, toNode.ri
ghtParenthesis)), _isEqualNodes(node.body, toNode.body)); |
| 7970 } | 7953 } |
| 7971 | 7954 |
| 7972 bool visitFunctionDeclaration(FunctionDeclaration node) { | 7955 bool visitFunctionDeclaration(FunctionDeclaration node) { |
| 7973 FunctionDeclaration toNode = this._toNode as FunctionDeclaration; | 7956 FunctionDeclaration toNode = this._toNode as FunctionDeclaration; |
| 7974 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqualNodes(node.documentationComment, toNode.documentatio
nComment), isEqualNodeLists(node.metadata, toNode.metadata)), isEqualTokens(node
.externalKeyword, toNode.externalKeyword)), isEqualNodes(node.returnType, toNode
.returnType)), isEqualTokens(node.propertyKeyword, toNode.propertyKeyword)), isE
qualNodes(node.name, toNode.name)), isEqualNodes(node.functionExpression, toNode
.functionExpression)); | 7957 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(_isEqualNodes(node.documentationComment, toNode.documentati
onComment), _isEqualNodeLists(node.metadata, toNode.metadata)), _isEqualTokens(n
ode.externalKeyword, toNode.externalKeyword)), _isEqualNodes(node.returnType, to
Node.returnType)), _isEqualTokens(node.propertyKeyword, toNode.propertyKeyword))
, _isEqualNodes(node.name, toNode.name)), _isEqualNodes(node.functionExpression,
toNode.functionExpression)); |
| 7975 } | 7958 } |
| 7976 | 7959 |
| 7977 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | 7960 bool visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 7978 FunctionDeclarationStatement toNode = this._toNode as FunctionDeclarationSta
tement; | 7961 FunctionDeclarationStatement toNode = this._toNode as FunctionDeclarationSta
tement; |
| 7979 return isEqualNodes(node.functionDeclaration, toNode.functionDeclaration); | 7962 return _isEqualNodes(node.functionDeclaration, toNode.functionDeclaration); |
| 7980 } | 7963 } |
| 7981 | 7964 |
| 7982 bool visitFunctionExpression(FunctionExpression node) { | 7965 bool visitFunctionExpression(FunctionExpression node) { |
| 7983 FunctionExpression toNode = this._toNode as FunctionExpression; | 7966 FunctionExpression toNode = this._toNode as FunctionExpression; |
| 7984 if (javaBooleanAnd(isEqualNodes(node.parameters, toNode.parameters), isEqual
Nodes(node.body, toNode.body))) { | 7967 if (javaBooleanAnd(_isEqualNodes(node.parameters, toNode.parameters), _isEqu
alNodes(node.body, toNode.body))) { |
| 7985 toNode.element = node.element; | 7968 toNode.element = node.element; |
| 7986 toNode.propagatedType = node.propagatedType; | 7969 toNode.propagatedType = node.propagatedType; |
| 7987 toNode.staticType = node.staticType; | 7970 toNode.staticType = node.staticType; |
| 7988 return true; | 7971 return true; |
| 7989 } | 7972 } |
| 7990 return false; | 7973 return false; |
| 7991 } | 7974 } |
| 7992 | 7975 |
| 7993 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 7976 bool visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 7994 FunctionExpressionInvocation toNode = this._toNode as FunctionExpressionInvo
cation; | 7977 FunctionExpressionInvocation toNode = this._toNode as FunctionExpressionInvo
cation; |
| 7995 if (javaBooleanAnd(isEqualNodes(node.function, toNode.function), isEqualNode
s(node.argumentList, toNode.argumentList))) { | 7978 if (javaBooleanAnd(_isEqualNodes(node.function, toNode.function), _isEqualNo
des(node.argumentList, toNode.argumentList))) { |
| 7996 toNode.propagatedElement = node.propagatedElement; | 7979 toNode.propagatedElement = node.propagatedElement; |
| 7997 toNode.propagatedType = node.propagatedType; | 7980 toNode.propagatedType = node.propagatedType; |
| 7998 toNode.staticElement = node.staticElement; | 7981 toNode.staticElement = node.staticElement; |
| 7999 toNode.staticType = node.staticType; | 7982 toNode.staticType = node.staticType; |
| 8000 return true; | 7983 return true; |
| 8001 } | 7984 } |
| 8002 return false; | 7985 return false; |
| 8003 } | 7986 } |
| 8004 | 7987 |
| 8005 bool visitFunctionTypeAlias(FunctionTypeAlias node) { | 7988 bool visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 8006 FunctionTypeAlias toNode = this._toNode as FunctionTypeAlias; | 7989 FunctionTypeAlias toNode = this._toNode as FunctionTypeAlias; |
| 8007 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.documentationComment, toNo
de.documentationComment), isEqualNodeLists(node.metadata, toNode.metadata)), isE
qualTokens(node.keyword, toNode.keyword)), isEqualNodes(node.returnType, toNode.
returnType)), isEqualNodes(node.name, toNode.name)), isEqualNodes(node.typeParam
eters, toNode.typeParameters)), isEqualNodes(node.parameters, toNode.parameters)
), isEqualTokens(node.semicolon, toNode.semicolon)); | 7990 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.documentationComment, toN
ode.documentationComment), _isEqualNodeLists(node.metadata, toNode.metadata)), _
isEqualTokens(node.keyword, toNode.keyword)), _isEqualNodes(node.returnType, toN
ode.returnType)), _isEqualNodes(node.name, toNode.name)), _isEqualNodes(node.typ
eParameters, toNode.typeParameters)), _isEqualNodes(node.parameters, toNode.para
meters)), _isEqualTokens(node.semicolon, toNode.semicolon)); |
| 8008 } | 7991 } |
| 8009 | 7992 |
| 8010 bool visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 7993 bool visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 8011 FunctionTypedFormalParameter toNode = this._toNode as FunctionTypedFormalPar
ameter; | 7994 FunctionTypedFormalParameter toNode = this._toNode as FunctionTypedFormalPar
ameter; |
| 8012 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualNodes(node.returnType, toNode.returnType)
), isEqualNodes(node.identifier, toNode.identifier)), isEqualNodes(node.paramete
rs, toNode.parameters)); | 7995 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualNodes(node.returnType, toNode.returnTy
pe)), _isEqualNodes(node.identifier, toNode.identifier)), _isEqualNodes(node.par
ameters, toNode.parameters)); |
| 8013 } | 7996 } |
| 8014 | 7997 |
| 8015 bool visitHideCombinator(HideCombinator node) { | 7998 bool visitHideCombinator(HideCombinator node) { |
| 8016 HideCombinator toNode = this._toNode as HideCombinator; | 7999 HideCombinator toNode = this._toNode as HideCombinator; |
| 8017 return javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualNo
deLists(node.hiddenNames, toNode.hiddenNames)); | 8000 return javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqual
NodeLists(node.hiddenNames, toNode.hiddenNames)); |
| 8018 } | 8001 } |
| 8019 | 8002 |
| 8020 bool visitIfStatement(IfStatement node) { | 8003 bool visitIfStatement(IfStatement node) { |
| 8021 IfStatement toNode = this._toNode as IfStatement; | 8004 IfStatement toNode = this._toNode as IfStatement; |
| 8022 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqualTokens(node.ifKeyword, toNode.ifKeyword), isEqualTok
ens(node.leftParenthesis, toNode.leftParenthesis)), isEqualNodes(node.condition,
toNode.condition)), isEqualTokens(node.rightParenthesis, toNode.rightParenthesi
s)), isEqualNodes(node.thenStatement, toNode.thenStatement)), isEqualTokens(node
.elseKeyword, toNode.elseKeyword)), isEqualNodes(node.elseStatement, toNode.else
Statement)); | 8005 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(_isEqualTokens(node.ifKeyword, toNode.ifKeyword), _isEqualT
okens(node.leftParenthesis, toNode.leftParenthesis)), _isEqualNodes(node.conditi
on, toNode.condition)), _isEqualTokens(node.rightParenthesis, toNode.rightParent
hesis)), _isEqualNodes(node.thenStatement, toNode.thenStatement)), _isEqualToken
s(node.elseKeyword, toNode.elseKeyword)), _isEqualNodes(node.elseStatement, toNo
de.elseStatement)); |
| 8023 } | 8006 } |
| 8024 | 8007 |
| 8025 bool visitImplementsClause(ImplementsClause node) { | 8008 bool visitImplementsClause(ImplementsClause node) { |
| 8026 ImplementsClause toNode = this._toNode as ImplementsClause; | 8009 ImplementsClause toNode = this._toNode as ImplementsClause; |
| 8027 return javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualNo
deLists(node.interfaces, toNode.interfaces)); | 8010 return javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqual
NodeLists(node.interfaces, toNode.interfaces)); |
| 8028 } | 8011 } |
| 8029 | 8012 |
| 8030 bool visitImportDirective(ImportDirective node) { | 8013 bool visitImportDirective(ImportDirective node) { |
| 8031 ImportDirective toNode = this._toNode as ImportDirective; | 8014 ImportDirective toNode = this._toNode as ImportDirective; |
| 8032 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.documentationComment, toNode.
documentationComment), isEqualNodeLists(node.metadata, toNode.metadata)), isEqua
lTokens(node.keyword, toNode.keyword)), isEqualNodes(node.uri, toNode.uri)), isE
qualTokens(node.asToken, toNode.asToken)), isEqualNodes(node.prefix, toNode.pref
ix)), isEqualNodeLists(node.combinators, toNode.combinators)), isEqualTokens(nod
e.semicolon, toNode.semicolon))) { | 8015 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.documentationComment, toNode
.documentationComment), _isEqualNodeLists(node.metadata, toNode.metadata)), _isE
qualTokens(node.keyword, toNode.keyword)), _isEqualNodes(node.uri, toNode.uri)),
_isEqualTokens(node.asToken, toNode.asToken)), _isEqualNodes(node.prefix, toNod
e.prefix)), _isEqualNodeLists(node.combinators, toNode.combinators)), _isEqualTo
kens(node.semicolon, toNode.semicolon))) { |
| 8033 toNode.element = node.element; | 8016 toNode.element = node.element; |
| 8034 return true; | 8017 return true; |
| 8035 } | 8018 } |
| 8036 return false; | 8019 return false; |
| 8037 } | 8020 } |
| 8038 | 8021 |
| 8039 bool visitIndexExpression(IndexExpression node) { | 8022 bool visitIndexExpression(IndexExpression node) { |
| 8040 IndexExpression toNode = this._toNode as IndexExpression; | 8023 IndexExpression toNode = this._toNode as IndexExpression; |
| 8041 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.target, t
oNode.target), isEqualTokens(node.leftBracket, toNode.leftBracket)), isEqualNode
s(node.index, toNode.index)), isEqualTokens(node.rightBracket, toNode.rightBrack
et))) { | 8024 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.target,
toNode.target), _isEqualTokens(node.leftBracket, toNode.leftBracket)), _isEqualN
odes(node.index, toNode.index)), _isEqualTokens(node.rightBracket, toNode.rightB
racket))) { |
| 8042 toNode.auxiliaryElements = node.auxiliaryElements; | 8025 toNode.auxiliaryElements = node.auxiliaryElements; |
| 8043 toNode.propagatedElement = node.propagatedElement; | 8026 toNode.propagatedElement = node.propagatedElement; |
| 8044 toNode.propagatedType = node.propagatedType; | 8027 toNode.propagatedType = node.propagatedType; |
| 8045 toNode.staticElement = node.staticElement; | 8028 toNode.staticElement = node.staticElement; |
| 8046 toNode.staticType = node.staticType; | 8029 toNode.staticType = node.staticType; |
| 8047 return true; | 8030 return true; |
| 8048 } | 8031 } |
| 8049 return false; | 8032 return false; |
| 8050 } | 8033 } |
| 8051 | 8034 |
| 8052 bool visitInstanceCreationExpression(InstanceCreationExpression node) { | 8035 bool visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 8053 InstanceCreationExpression toNode = this._toNode as InstanceCreationExpressi
on; | 8036 InstanceCreationExpression toNode = this._toNode as InstanceCreationExpressi
on; |
| 8054 if (javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword
), isEqualNodes(node.constructorName, toNode.constructorName)), isEqualNodes(nod
e.argumentList, toNode.argumentList))) { | 8037 if (javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keywor
d), _isEqualNodes(node.constructorName, toNode.constructorName)), _isEqualNodes(
node.argumentList, toNode.argumentList))) { |
| 8055 toNode.propagatedType = node.propagatedType; | 8038 toNode.propagatedType = node.propagatedType; |
| 8056 toNode.staticElement = node.staticElement; | 8039 toNode.staticElement = node.staticElement; |
| 8057 toNode.staticType = node.staticType; | 8040 toNode.staticType = node.staticType; |
| 8058 return true; | 8041 return true; |
| 8059 } | 8042 } |
| 8060 return false; | 8043 return false; |
| 8061 } | 8044 } |
| 8062 | 8045 |
| 8063 bool visitIntegerLiteral(IntegerLiteral node) { | 8046 bool visitIntegerLiteral(IntegerLiteral node) { |
| 8064 IntegerLiteral toNode = this._toNode as IntegerLiteral; | 8047 IntegerLiteral toNode = this._toNode as IntegerLiteral; |
| 8065 if (javaBooleanAnd(isEqualTokens(node.literal, toNode.literal), identical(no
de.value, toNode.value))) { | 8048 if (javaBooleanAnd(_isEqualTokens(node.literal, toNode.literal), identical(n
ode.value, toNode.value))) { |
| 8066 toNode.propagatedType = node.propagatedType; | 8049 toNode.propagatedType = node.propagatedType; |
| 8067 toNode.staticType = node.staticType; | 8050 toNode.staticType = node.staticType; |
| 8068 return true; | 8051 return true; |
| 8069 } | 8052 } |
| 8070 return false; | 8053 return false; |
| 8071 } | 8054 } |
| 8072 | 8055 |
| 8073 bool visitInterpolationExpression(InterpolationExpression node) { | 8056 bool visitInterpolationExpression(InterpolationExpression node) { |
| 8074 InterpolationExpression toNode = this._toNode as InterpolationExpression; | 8057 InterpolationExpression toNode = this._toNode as InterpolationExpression; |
| 8075 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.leftBracket, toNode.
leftBracket), isEqualNodes(node.expression, toNode.expression)), isEqualTokens(n
ode.rightBracket, toNode.rightBracket)); | 8058 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.leftBracket, toNode
.leftBracket), _isEqualNodes(node.expression, toNode.expression)), _isEqualToken
s(node.rightBracket, toNode.rightBracket)); |
| 8076 } | 8059 } |
| 8077 | 8060 |
| 8078 bool visitInterpolationString(InterpolationString node) { | 8061 bool visitInterpolationString(InterpolationString node) { |
| 8079 InterpolationString toNode = this._toNode as InterpolationString; | 8062 InterpolationString toNode = this._toNode as InterpolationString; |
| 8080 return javaBooleanAnd(isEqualTokens(node.contents, toNode.contents), node.va
lue == toNode.value); | 8063 return javaBooleanAnd(_isEqualTokens(node.contents, toNode.contents), node.v
alue == toNode.value); |
| 8081 } | 8064 } |
| 8082 | 8065 |
| 8083 bool visitIsExpression(IsExpression node) { | 8066 bool visitIsExpression(IsExpression node) { |
| 8084 IsExpression toNode = this._toNode as IsExpression; | 8067 IsExpression toNode = this._toNode as IsExpression; |
| 8085 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.expressio
n, toNode.expression), isEqualTokens(node.isOperator, toNode.isOperator)), isEqu
alTokens(node.notOperator, toNode.notOperator)), isEqualNodes(node.type, toNode.
type))) { | 8068 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.expressi
on, toNode.expression), _isEqualTokens(node.isOperator, toNode.isOperator)), _is
EqualTokens(node.notOperator, toNode.notOperator)), _isEqualNodes(node.type, toN
ode.type))) { |
| 8086 toNode.propagatedType = node.propagatedType; | 8069 toNode.propagatedType = node.propagatedType; |
| 8087 toNode.staticType = node.staticType; | 8070 toNode.staticType = node.staticType; |
| 8088 return true; | 8071 return true; |
| 8089 } | 8072 } |
| 8090 return false; | 8073 return false; |
| 8091 } | 8074 } |
| 8092 | 8075 |
| 8093 bool visitLabel(Label node) { | 8076 bool visitLabel(Label node) { |
| 8094 Label toNode = this._toNode as Label; | 8077 Label toNode = this._toNode as Label; |
| 8095 return javaBooleanAnd(isEqualNodes(node.label, toNode.label), isEqualTokens(
node.colon, toNode.colon)); | 8078 return javaBooleanAnd(_isEqualNodes(node.label, toNode.label), _isEqualToken
s(node.colon, toNode.colon)); |
| 8096 } | 8079 } |
| 8097 | 8080 |
| 8098 bool visitLabeledStatement(LabeledStatement node) { | 8081 bool visitLabeledStatement(LabeledStatement node) { |
| 8099 LabeledStatement toNode = this._toNode as LabeledStatement; | 8082 LabeledStatement toNode = this._toNode as LabeledStatement; |
| 8100 return javaBooleanAnd(isEqualNodeLists(node.labels, toNode.labels), isEqualN
odes(node.statement, toNode.statement)); | 8083 return javaBooleanAnd(_isEqualNodeLists(node.labels, toNode.labels), _isEqua
lNodes(node.statement, toNode.statement)); |
| 8101 } | 8084 } |
| 8102 | 8085 |
| 8103 bool visitLibraryDirective(LibraryDirective node) { | 8086 bool visitLibraryDirective(LibraryDirective node) { |
| 8104 LibraryDirective toNode = this._toNode as LibraryDirective; | 8087 LibraryDirective toNode = this._toNode as LibraryDirective; |
| 8105 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualTokens(node.libraryToken, toNode.libraryT
oken)), isEqualNodes(node.name, toNode.name)), isEqualTokens(node.semicolon, toN
ode.semicolon)); | 8088 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualTokens(node.libraryToken, toNode.libra
ryToken)), _isEqualNodes(node.name, toNode.name)), _isEqualTokens(node.semicolon
, toNode.semicolon)); |
| 8106 } | 8089 } |
| 8107 | 8090 |
| 8108 bool visitLibraryIdentifier(LibraryIdentifier node) { | 8091 bool visitLibraryIdentifier(LibraryIdentifier node) { |
| 8109 LibraryIdentifier toNode = this._toNode as LibraryIdentifier; | 8092 LibraryIdentifier toNode = this._toNode as LibraryIdentifier; |
| 8110 if (isEqualNodeLists(node.components, toNode.components)) { | 8093 if (_isEqualNodeLists(node.components, toNode.components)) { |
| 8111 toNode.propagatedType = node.propagatedType; | 8094 toNode.propagatedType = node.propagatedType; |
| 8112 toNode.staticType = node.staticType; | 8095 toNode.staticType = node.staticType; |
| 8113 return true; | 8096 return true; |
| 8114 } | 8097 } |
| 8115 return false; | 8098 return false; |
| 8116 } | 8099 } |
| 8117 | 8100 |
| 8118 bool visitListLiteral(ListLiteral node) { | 8101 bool visitListLiteral(ListLiteral node) { |
| 8119 ListLiteral toNode = this._toNode as ListLiteral; | 8102 ListLiteral toNode = this._toNode as ListLiteral; |
| 8120 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualToken
s(node.constKeyword, toNode.constKeyword), isEqualNodes(node.typeArguments, toNo
de.typeArguments)), isEqualTokens(node.leftBracket, toNode.leftBracket)), isEqua
lNodeLists(node.elements, toNode.elements)), isEqualTokens(node.rightBracket, to
Node.rightBracket))) { | 8103 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualToke
ns(node.constKeyword, toNode.constKeyword), _isEqualNodes(node.typeArguments, to
Node.typeArguments)), _isEqualTokens(node.leftBracket, toNode.leftBracket)), _is
EqualNodeLists(node.elements, toNode.elements)), _isEqualTokens(node.rightBracke
t, toNode.rightBracket))) { |
| 8121 toNode.propagatedType = node.propagatedType; | 8104 toNode.propagatedType = node.propagatedType; |
| 8122 toNode.staticType = node.staticType; | 8105 toNode.staticType = node.staticType; |
| 8123 return true; | 8106 return true; |
| 8124 } | 8107 } |
| 8125 return false; | 8108 return false; |
| 8126 } | 8109 } |
| 8127 | 8110 |
| 8128 bool visitMapLiteral(MapLiteral node) { | 8111 bool visitMapLiteral(MapLiteral node) { |
| 8129 MapLiteral toNode = this._toNode as MapLiteral; | 8112 MapLiteral toNode = this._toNode as MapLiteral; |
| 8130 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualToken
s(node.constKeyword, toNode.constKeyword), isEqualNodes(node.typeArguments, toNo
de.typeArguments)), isEqualTokens(node.leftBracket, toNode.leftBracket)), isEqua
lNodeLists(node.entries, toNode.entries)), isEqualTokens(node.rightBracket, toNo
de.rightBracket))) { | 8113 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualToke
ns(node.constKeyword, toNode.constKeyword), _isEqualNodes(node.typeArguments, to
Node.typeArguments)), _isEqualTokens(node.leftBracket, toNode.leftBracket)), _is
EqualNodeLists(node.entries, toNode.entries)), _isEqualTokens(node.rightBracket,
toNode.rightBracket))) { |
| 8131 toNode.propagatedType = node.propagatedType; | 8114 toNode.propagatedType = node.propagatedType; |
| 8132 toNode.staticType = node.staticType; | 8115 toNode.staticType = node.staticType; |
| 8133 return true; | 8116 return true; |
| 8134 } | 8117 } |
| 8135 return false; | 8118 return false; |
| 8136 } | 8119 } |
| 8137 | 8120 |
| 8138 bool visitMapLiteralEntry(MapLiteralEntry node) { | 8121 bool visitMapLiteralEntry(MapLiteralEntry node) { |
| 8139 MapLiteralEntry toNode = this._toNode as MapLiteralEntry; | 8122 MapLiteralEntry toNode = this._toNode as MapLiteralEntry; |
| 8140 return javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.key, toNode.key), isE
qualTokens(node.separator, toNode.separator)), isEqualNodes(node.value, toNode.v
alue)); | 8123 return javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.key, toNode.key), _i
sEqualTokens(node.separator, toNode.separator)), _isEqualNodes(node.value, toNod
e.value)); |
| 8141 } | 8124 } |
| 8142 | 8125 |
| 8143 bool visitMethodDeclaration(MethodDeclaration node) { | 8126 bool visitMethodDeclaration(MethodDeclaration node) { |
| 8144 MethodDeclaration toNode = this._toNode as MethodDeclaration; | 8127 MethodDeclaration toNode = this._toNode as MethodDeclaration; |
| 8145 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(n
ode.documentationComment, toNode.documentationComment), isEqualNodeLists(node.me
tadata, toNode.metadata)), isEqualTokens(node.externalKeyword, toNode.externalKe
yword)), isEqualTokens(node.modifierKeyword, toNode.modifierKeyword)), isEqualNo
des(node.returnType, toNode.returnType)), isEqualTokens(node.propertyKeyword, to
Node.propertyKeyword)), isEqualTokens(node.propertyKeyword, toNode.propertyKeywo
rd)), isEqualNodes(node.name, toNode.name)), isEqualNodes(node.parameters, toNod
e.parameters)), isEqualNodes(node.body, toNode.body)); | 8128 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(
node.documentationComment, toNode.documentationComment), _isEqualNodeLists(node.
metadata, toNode.metadata)), _isEqualTokens(node.externalKeyword, toNode.externa
lKeyword)), _isEqualTokens(node.modifierKeyword, toNode.modifierKeyword)), _isEq
ualNodes(node.returnType, toNode.returnType)), _isEqualTokens(node.propertyKeywo
rd, toNode.propertyKeyword)), _isEqualTokens(node.propertyKeyword, toNode.proper
tyKeyword)), _isEqualNodes(node.name, toNode.name)), _isEqualNodes(node.paramete
rs, toNode.parameters)), _isEqualNodes(node.body, toNode.body)); |
| 8146 } | 8129 } |
| 8147 | 8130 |
| 8148 bool visitMethodInvocation(MethodInvocation node) { | 8131 bool visitMethodInvocation(MethodInvocation node) { |
| 8149 MethodInvocation toNode = this._toNode as MethodInvocation; | 8132 MethodInvocation toNode = this._toNode as MethodInvocation; |
| 8150 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.target, t
oNode.target), isEqualTokens(node.period, toNode.period)), isEqualNodes(node.met
hodName, toNode.methodName)), isEqualNodes(node.argumentList, toNode.argumentLis
t))) { | 8133 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.target,
toNode.target), _isEqualTokens(node.period, toNode.period)), _isEqualNodes(node.
methodName, toNode.methodName)), _isEqualNodes(node.argumentList, toNode.argumen
tList))) { |
| 8151 toNode.propagatedType = node.propagatedType; | 8134 toNode.propagatedType = node.propagatedType; |
| 8152 toNode.staticType = node.staticType; | 8135 toNode.staticType = node.staticType; |
| 8153 return true; | 8136 return true; |
| 8154 } | 8137 } |
| 8155 return false; | 8138 return false; |
| 8156 } | 8139 } |
| 8157 | 8140 |
| 8158 bool visitNamedExpression(NamedExpression node) { | 8141 bool visitNamedExpression(NamedExpression node) { |
| 8159 NamedExpression toNode = this._toNode as NamedExpression; | 8142 NamedExpression toNode = this._toNode as NamedExpression; |
| 8160 if (javaBooleanAnd(isEqualNodes(node.name, toNode.name), isEqualNodes(node.e
xpression, toNode.expression))) { | 8143 if (javaBooleanAnd(_isEqualNodes(node.name, toNode.name), _isEqualNodes(node
.expression, toNode.expression))) { |
| 8161 toNode.propagatedType = node.propagatedType; | 8144 toNode.propagatedType = node.propagatedType; |
| 8162 toNode.staticType = node.staticType; | 8145 toNode.staticType = node.staticType; |
| 8163 return true; | 8146 return true; |
| 8164 } | 8147 } |
| 8165 return false; | 8148 return false; |
| 8166 } | 8149 } |
| 8167 | 8150 |
| 8168 bool visitNativeClause(NativeClause node) { | 8151 bool visitNativeClause(NativeClause node) { |
| 8169 NativeClause toNode = this._toNode as NativeClause; | 8152 NativeClause toNode = this._toNode as NativeClause; |
| 8170 return javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualNo
des(node.name, toNode.name)); | 8153 return javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqual
Nodes(node.name, toNode.name)); |
| 8171 } | 8154 } |
| 8172 | 8155 |
| 8173 bool visitNativeFunctionBody(NativeFunctionBody node) { | 8156 bool visitNativeFunctionBody(NativeFunctionBody node) { |
| 8174 NativeFunctionBody toNode = this._toNode as NativeFunctionBody; | 8157 NativeFunctionBody toNode = this._toNode as NativeFunctionBody; |
| 8175 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.nativeToken, toNode.
nativeToken), isEqualNodes(node.stringLiteral, toNode.stringLiteral)), isEqualTo
kens(node.semicolon, toNode.semicolon)); | 8158 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.nativeToken, toNode
.nativeToken), _isEqualNodes(node.stringLiteral, toNode.stringLiteral)), _isEqua
lTokens(node.semicolon, toNode.semicolon)); |
| 8176 } | 8159 } |
| 8177 | 8160 |
| 8178 bool visitNullLiteral(NullLiteral node) { | 8161 bool visitNullLiteral(NullLiteral node) { |
| 8179 NullLiteral toNode = this._toNode as NullLiteral; | 8162 NullLiteral toNode = this._toNode as NullLiteral; |
| 8180 if (isEqualTokens(node.literal, toNode.literal)) { | 8163 if (_isEqualTokens(node.literal, toNode.literal)) { |
| 8181 toNode.propagatedType = node.propagatedType; | 8164 toNode.propagatedType = node.propagatedType; |
| 8182 toNode.staticType = node.staticType; | 8165 toNode.staticType = node.staticType; |
| 8183 return true; | 8166 return true; |
| 8184 } | 8167 } |
| 8185 return false; | 8168 return false; |
| 8186 } | 8169 } |
| 8187 | 8170 |
| 8188 bool visitParenthesizedExpression(ParenthesizedExpression node) { | 8171 bool visitParenthesizedExpression(ParenthesizedExpression node) { |
| 8189 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression; | 8172 ParenthesizedExpression toNode = this._toNode as ParenthesizedExpression; |
| 8190 if (javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.leftParenthesis, toNode
.leftParenthesis), isEqualNodes(node.expression, toNode.expression)), isEqualTok
ens(node.rightParenthesis, toNode.rightParenthesis))) { | 8173 if (javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.leftParenthesis, toNod
e.leftParenthesis), _isEqualNodes(node.expression, toNode.expression)), _isEqual
Tokens(node.rightParenthesis, toNode.rightParenthesis))) { |
| 8191 toNode.propagatedType = node.propagatedType; | 8174 toNode.propagatedType = node.propagatedType; |
| 8192 toNode.staticType = node.staticType; | 8175 toNode.staticType = node.staticType; |
| 8193 return true; | 8176 return true; |
| 8194 } | 8177 } |
| 8195 return false; | 8178 return false; |
| 8196 } | 8179 } |
| 8197 | 8180 |
| 8198 bool visitPartDirective(PartDirective node) { | 8181 bool visitPartDirective(PartDirective node) { |
| 8199 PartDirective toNode = this._toNode as PartDirective; | 8182 PartDirective toNode = this._toNode as PartDirective; |
| 8200 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes
(node.documentationComment, toNode.documentationComment), isEqualNodeLists(node.
metadata, toNode.metadata)), isEqualTokens(node.partToken, toNode.partToken)), i
sEqualNodes(node.uri, toNode.uri)), isEqualTokens(node.semicolon, toNode.semicol
on))) { | 8183 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNode
s(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(nod
e.metadata, toNode.metadata)), _isEqualTokens(node.partToken, toNode.partToken))
, _isEqualNodes(node.uri, toNode.uri)), _isEqualTokens(node.semicolon, toNode.se
micolon))) { |
| 8201 toNode.element = node.element; | 8184 toNode.element = node.element; |
| 8202 return true; | 8185 return true; |
| 8203 } | 8186 } |
| 8204 return false; | 8187 return false; |
| 8205 } | 8188 } |
| 8206 | 8189 |
| 8207 bool visitPartOfDirective(PartOfDirective node) { | 8190 bool visitPartOfDirective(PartOfDirective node) { |
| 8208 PartOfDirective toNode = this._toNode as PartOfDirective; | 8191 PartOfDirective toNode = this._toNode as PartOfDirective; |
| 8209 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(isEqualNodes(node.documentationComment, toNode.documentationComment), isEqual
NodeLists(node.metadata, toNode.metadata)), isEqualTokens(node.partToken, toNode
.partToken)), isEqualTokens(node.ofToken, toNode.ofToken)), isEqualNodes(node.li
braryName, toNode.libraryName)), isEqualTokens(node.semicolon, toNode.semicolon)
)) { | 8192 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanA
nd(_isEqualNodes(node.documentationComment, toNode.documentationComment), _isEqu
alNodeLists(node.metadata, toNode.metadata)), _isEqualTokens(node.partToken, toN
ode.partToken)), _isEqualTokens(node.ofToken, toNode.ofToken)), _isEqualNodes(no
de.libraryName, toNode.libraryName)), _isEqualTokens(node.semicolon, toNode.semi
colon))) { |
| 8210 toNode.element = node.element; | 8193 toNode.element = node.element; |
| 8211 return true; | 8194 return true; |
| 8212 } | 8195 } |
| 8213 return false; | 8196 return false; |
| 8214 } | 8197 } |
| 8215 | 8198 |
| 8216 bool visitPostfixExpression(PostfixExpression node) { | 8199 bool visitPostfixExpression(PostfixExpression node) { |
| 8217 PostfixExpression toNode = this._toNode as PostfixExpression; | 8200 PostfixExpression toNode = this._toNode as PostfixExpression; |
| 8218 if (javaBooleanAnd(isEqualNodes(node.operand, toNode.operand), isEqualTokens
(node.operator, toNode.operator))) { | 8201 if (javaBooleanAnd(_isEqualNodes(node.operand, toNode.operand), _isEqualToke
ns(node.operator, toNode.operator))) { |
| 8219 toNode.propagatedElement = node.propagatedElement; | 8202 toNode.propagatedElement = node.propagatedElement; |
| 8220 toNode.propagatedType = node.propagatedType; | 8203 toNode.propagatedType = node.propagatedType; |
| 8221 toNode.staticElement = node.staticElement; | 8204 toNode.staticElement = node.staticElement; |
| 8222 toNode.staticType = node.staticType; | 8205 toNode.staticType = node.staticType; |
| 8223 return true; | 8206 return true; |
| 8224 } | 8207 } |
| 8225 return false; | 8208 return false; |
| 8226 } | 8209 } |
| 8227 | 8210 |
| 8228 bool visitPrefixedIdentifier(PrefixedIdentifier node) { | 8211 bool visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 8229 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; | 8212 PrefixedIdentifier toNode = this._toNode as PrefixedIdentifier; |
| 8230 if (javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.prefix, toNode.prefix),
isEqualTokens(node.period, toNode.period)), isEqualNodes(node.identifier, toNode
.identifier))) { | 8213 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.prefix, toNode.prefix),
_isEqualTokens(node.period, toNode.period)), _isEqualNodes(node.identifier, toN
ode.identifier))) { |
| 8231 toNode.propagatedType = node.propagatedType; | 8214 toNode.propagatedType = node.propagatedType; |
| 8232 toNode.staticType = node.staticType; | 8215 toNode.staticType = node.staticType; |
| 8233 return true; | 8216 return true; |
| 8234 } | 8217 } |
| 8235 return false; | 8218 return false; |
| 8236 } | 8219 } |
| 8237 | 8220 |
| 8238 bool visitPrefixExpression(PrefixExpression node) { | 8221 bool visitPrefixExpression(PrefixExpression node) { |
| 8239 PrefixExpression toNode = this._toNode as PrefixExpression; | 8222 PrefixExpression toNode = this._toNode as PrefixExpression; |
| 8240 if (javaBooleanAnd(isEqualTokens(node.operator, toNode.operator), isEqualNod
es(node.operand, toNode.operand))) { | 8223 if (javaBooleanAnd(_isEqualTokens(node.operator, toNode.operator), _isEqualN
odes(node.operand, toNode.operand))) { |
| 8241 toNode.propagatedElement = node.propagatedElement; | 8224 toNode.propagatedElement = node.propagatedElement; |
| 8242 toNode.propagatedType = node.propagatedType; | 8225 toNode.propagatedType = node.propagatedType; |
| 8243 toNode.staticElement = node.staticElement; | 8226 toNode.staticElement = node.staticElement; |
| 8244 toNode.staticType = node.staticType; | 8227 toNode.staticType = node.staticType; |
| 8245 return true; | 8228 return true; |
| 8246 } | 8229 } |
| 8247 return false; | 8230 return false; |
| 8248 } | 8231 } |
| 8249 | 8232 |
| 8250 bool visitPropertyAccess(PropertyAccess node) { | 8233 bool visitPropertyAccess(PropertyAccess node) { |
| 8251 PropertyAccess toNode = this._toNode as PropertyAccess; | 8234 PropertyAccess toNode = this._toNode as PropertyAccess; |
| 8252 if (javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.target, toNode.target),
isEqualTokens(node.operator, toNode.operator)), isEqualNodes(node.propertyName,
toNode.propertyName))) { | 8235 if (javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.target, toNode.target),
_isEqualTokens(node.operator, toNode.operator)), _isEqualNodes(node.propertyNam
e, toNode.propertyName))) { |
| 8253 toNode.propagatedType = node.propagatedType; | 8236 toNode.propagatedType = node.propagatedType; |
| 8254 toNode.staticType = node.staticType; | 8237 toNode.staticType = node.staticType; |
| 8255 return true; | 8238 return true; |
| 8256 } | 8239 } |
| 8257 return false; | 8240 return false; |
| 8258 } | 8241 } |
| 8259 | 8242 |
| 8260 bool visitRedirectingConstructorInvocation(RedirectingConstructorInvocation no
de) { | 8243 bool visitRedirectingConstructorInvocation(RedirectingConstructorInvocation no
de) { |
| 8261 RedirectingConstructorInvocation toNode = this._toNode as RedirectingConstru
ctorInvocation; | 8244 RedirectingConstructorInvocation toNode = this._toNode as RedirectingConstru
ctorInvocation; |
| 8262 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.keyword,
toNode.keyword), isEqualTokens(node.period, toNode.period)), isEqualNodes(node.
constructorName, toNode.constructorName)), isEqualNodes(node.argumentList, toNod
e.argumentList))) { | 8245 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.keyword
, toNode.keyword), _isEqualTokens(node.period, toNode.period)), _isEqualNodes(no
de.constructorName, toNode.constructorName)), _isEqualNodes(node.argumentList, t
oNode.argumentList))) { |
| 8263 toNode.staticElement = node.staticElement; | 8246 toNode.staticElement = node.staticElement; |
| 8264 return true; | 8247 return true; |
| 8265 } | 8248 } |
| 8266 return false; | 8249 return false; |
| 8267 } | 8250 } |
| 8268 | 8251 |
| 8269 bool visitRethrowExpression(RethrowExpression node) { | 8252 bool visitRethrowExpression(RethrowExpression node) { |
| 8270 RethrowExpression toNode = this._toNode as RethrowExpression; | 8253 RethrowExpression toNode = this._toNode as RethrowExpression; |
| 8271 if (isEqualTokens(node.keyword, toNode.keyword)) { | 8254 if (_isEqualTokens(node.keyword, toNode.keyword)) { |
| 8272 toNode.propagatedType = node.propagatedType; | 8255 toNode.propagatedType = node.propagatedType; |
| 8273 toNode.staticType = node.staticType; | 8256 toNode.staticType = node.staticType; |
| 8274 return true; | 8257 return true; |
| 8275 } | 8258 } |
| 8276 return false; | 8259 return false; |
| 8277 } | 8260 } |
| 8278 | 8261 |
| 8279 bool visitReturnStatement(ReturnStatement node) { | 8262 bool visitReturnStatement(ReturnStatement node) { |
| 8280 ReturnStatement toNode = this._toNode as ReturnStatement; | 8263 ReturnStatement toNode = this._toNode as ReturnStatement; |
| 8281 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyw
ord), isEqualNodes(node.expression, toNode.expression)), isEqualTokens(node.semi
colon, toNode.semicolon)); | 8264 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.keyword, toNode.key
word), _isEqualNodes(node.expression, toNode.expression)), _isEqualTokens(node.s
emicolon, toNode.semicolon)); |
| 8282 } | 8265 } |
| 8283 | 8266 |
| 8284 bool visitScriptTag(ScriptTag node) { | 8267 bool visitScriptTag(ScriptTag node) { |
| 8285 ScriptTag toNode = this._toNode as ScriptTag; | 8268 ScriptTag toNode = this._toNode as ScriptTag; |
| 8286 return isEqualTokens(node.scriptTag, toNode.scriptTag); | 8269 return _isEqualTokens(node.scriptTag, toNode.scriptTag); |
| 8287 } | 8270 } |
| 8288 | 8271 |
| 8289 bool visitShowCombinator(ShowCombinator node) { | 8272 bool visitShowCombinator(ShowCombinator node) { |
| 8290 ShowCombinator toNode = this._toNode as ShowCombinator; | 8273 ShowCombinator toNode = this._toNode as ShowCombinator; |
| 8291 return javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualNo
deLists(node.shownNames, toNode.shownNames)); | 8274 return javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqual
NodeLists(node.shownNames, toNode.shownNames)); |
| 8292 } | 8275 } |
| 8293 | 8276 |
| 8294 bool visitSimpleFormalParameter(SimpleFormalParameter node) { | 8277 bool visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 8295 SimpleFormalParameter toNode = this._toNode as SimpleFormalParameter; | 8278 SimpleFormalParameter toNode = this._toNode as SimpleFormalParameter; |
| 8296 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualTokens(node.keyword, toNode.keyword)), is
EqualNodes(node.type, toNode.type)), isEqualNodes(node.identifier, toNode.identi
fier)); | 8279 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualTokens(node.keyword, toNode.keyword)),
_isEqualNodes(node.type, toNode.type)), _isEqualNodes(node.identifier, toNode.i
dentifier)); |
| 8297 } | 8280 } |
| 8298 | 8281 |
| 8299 bool visitSimpleIdentifier(SimpleIdentifier node) { | 8282 bool visitSimpleIdentifier(SimpleIdentifier node) { |
| 8300 SimpleIdentifier toNode = this._toNode as SimpleIdentifier; | 8283 SimpleIdentifier toNode = this._toNode as SimpleIdentifier; |
| 8301 if (isEqualTokens(node.token, toNode.token)) { | 8284 if (_isEqualTokens(node.token, toNode.token)) { |
| 8302 toNode.staticElement = node.staticElement; | 8285 toNode.staticElement = node.staticElement; |
| 8303 toNode.staticType = node.staticType; | 8286 toNode.staticType = node.staticType; |
| 8304 toNode.propagatedElement = node.propagatedElement; | 8287 toNode.propagatedElement = node.propagatedElement; |
| 8305 toNode.propagatedType = node.propagatedType; | 8288 toNode.propagatedType = node.propagatedType; |
| 8306 toNode.auxiliaryElements = node.auxiliaryElements; | 8289 toNode.auxiliaryElements = node.auxiliaryElements; |
| 8307 return true; | 8290 return true; |
| 8308 } | 8291 } |
| 8309 return false; | 8292 return false; |
| 8310 } | 8293 } |
| 8311 | 8294 |
| 8312 bool visitSimpleStringLiteral(SimpleStringLiteral node) { | 8295 bool visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 8313 SimpleStringLiteral toNode = this._toNode as SimpleStringLiteral; | 8296 SimpleStringLiteral toNode = this._toNode as SimpleStringLiteral; |
| 8314 if (javaBooleanAnd(isEqualTokens(node.literal, toNode.literal), identical(no
de.value, toNode.value))) { | 8297 if (javaBooleanAnd(_isEqualTokens(node.literal, toNode.literal), identical(n
ode.value, toNode.value))) { |
| 8315 toNode.propagatedType = node.propagatedType; | 8298 toNode.propagatedType = node.propagatedType; |
| 8316 toNode.staticType = node.staticType; | 8299 toNode.staticType = node.staticType; |
| 8317 return true; | 8300 return true; |
| 8318 } | 8301 } |
| 8319 return false; | 8302 return false; |
| 8320 } | 8303 } |
| 8321 | 8304 |
| 8322 bool visitStringInterpolation(StringInterpolation node) { | 8305 bool visitStringInterpolation(StringInterpolation node) { |
| 8323 StringInterpolation toNode = this._toNode as StringInterpolation; | 8306 StringInterpolation toNode = this._toNode as StringInterpolation; |
| 8324 if (isEqualNodeLists(node.elements, toNode.elements)) { | 8307 if (_isEqualNodeLists(node.elements, toNode.elements)) { |
| 8325 toNode.propagatedType = node.propagatedType; | 8308 toNode.propagatedType = node.propagatedType; |
| 8326 toNode.staticType = node.staticType; | 8309 toNode.staticType = node.staticType; |
| 8327 return true; | 8310 return true; |
| 8328 } | 8311 } |
| 8329 return false; | 8312 return false; |
| 8330 } | 8313 } |
| 8331 | 8314 |
| 8332 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 8315 bool visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 8333 SuperConstructorInvocation toNode = this._toNode as SuperConstructorInvocati
on; | 8316 SuperConstructorInvocation toNode = this._toNode as SuperConstructorInvocati
on; |
| 8334 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.keyword,
toNode.keyword), isEqualTokens(node.period, toNode.period)), isEqualNodes(node.
constructorName, toNode.constructorName)), isEqualNodes(node.argumentList, toNod
e.argumentList))) { | 8317 if (javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.keyword
, toNode.keyword), _isEqualTokens(node.period, toNode.period)), _isEqualNodes(no
de.constructorName, toNode.constructorName)), _isEqualNodes(node.argumentList, t
oNode.argumentList))) { |
| 8335 toNode.staticElement = node.staticElement; | 8318 toNode.staticElement = node.staticElement; |
| 8336 return true; | 8319 return true; |
| 8337 } | 8320 } |
| 8338 return false; | 8321 return false; |
| 8339 } | 8322 } |
| 8340 | 8323 |
| 8341 bool visitSuperExpression(SuperExpression node) { | 8324 bool visitSuperExpression(SuperExpression node) { |
| 8342 SuperExpression toNode = this._toNode as SuperExpression; | 8325 SuperExpression toNode = this._toNode as SuperExpression; |
| 8343 if (isEqualTokens(node.keyword, toNode.keyword)) { | 8326 if (_isEqualTokens(node.keyword, toNode.keyword)) { |
| 8344 toNode.propagatedType = node.propagatedType; | 8327 toNode.propagatedType = node.propagatedType; |
| 8345 toNode.staticType = node.staticType; | 8328 toNode.staticType = node.staticType; |
| 8346 return true; | 8329 return true; |
| 8347 } | 8330 } |
| 8348 return false; | 8331 return false; |
| 8349 } | 8332 } |
| 8350 | 8333 |
| 8351 bool visitSwitchCase(SwitchCase node) { | 8334 bool visitSwitchCase(SwitchCase node) { |
| 8352 SwitchCase toNode = this._toNode as SwitchCase; | 8335 SwitchCase toNode = this._toNode as SwitchCase; |
| 8353 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
deLists(node.labels, toNode.labels), isEqualTokens(node.keyword, toNode.keyword)
), isEqualNodes(node.expression, toNode.expression)), isEqualTokens(node.colon,
toNode.colon)), isEqualNodeLists(node.statements, toNode.statements)); | 8336 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odeLists(node.labels, toNode.labels), _isEqualTokens(node.keyword, toNode.keywor
d)), _isEqualNodes(node.expression, toNode.expression)), _isEqualTokens(node.col
on, toNode.colon)), _isEqualNodeLists(node.statements, toNode.statements)); |
| 8354 } | 8337 } |
| 8355 | 8338 |
| 8356 bool visitSwitchDefault(SwitchDefault node) { | 8339 bool visitSwitchDefault(SwitchDefault node) { |
| 8357 SwitchDefault toNode = this._toNode as SwitchDefault; | 8340 SwitchDefault toNode = this._toNode as SwitchDefault; |
| 8358 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodeLists(node.la
bels, toNode.labels), isEqualTokens(node.keyword, toNode.keyword)), isEqualToken
s(node.colon, toNode.colon)), isEqualNodeLists(node.statements, toNode.statement
s)); | 8341 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodeLists(node.l
abels, toNode.labels), _isEqualTokens(node.keyword, toNode.keyword)), _isEqualTo
kens(node.colon, toNode.colon)), _isEqualNodeLists(node.statements, toNode.state
ments)); |
| 8359 } | 8342 } |
| 8360 | 8343 |
| 8361 bool visitSwitchStatement(SwitchStatement node) { | 8344 bool visitSwitchStatement(SwitchStatement node) { |
| 8362 SwitchStatement toNode = this._toNode as SwitchStatement; | 8345 SwitchStatement toNode = this._toNode as SwitchStatement; |
| 8363 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualTokens(
node.leftParenthesis, toNode.leftParenthesis)), isEqualNodes(node.expression, to
Node.expression)), isEqualTokens(node.rightParenthesis, toNode.rightParenthesis)
), isEqualTokens(node.leftBracket, toNode.leftBracket)), isEqualNodeLists(node.m
embers, toNode.members)), isEqualTokens(node.rightBracket, toNode.rightBracket))
; | 8346 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBoole
anAnd(javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqualToken
s(node.leftParenthesis, toNode.leftParenthesis)), _isEqualNodes(node.expression,
toNode.expression)), _isEqualTokens(node.rightParenthesis, toNode.rightParenthe
sis)), _isEqualTokens(node.leftBracket, toNode.leftBracket)), _isEqualNodeLists(
node.members, toNode.members)), _isEqualTokens(node.rightBracket, toNode.rightBr
acket)); |
| 8364 } | 8347 } |
| 8365 | 8348 |
| 8366 bool visitSymbolLiteral(SymbolLiteral node) { | 8349 bool visitSymbolLiteral(SymbolLiteral node) { |
| 8367 SymbolLiteral toNode = this._toNode as SymbolLiteral; | 8350 SymbolLiteral toNode = this._toNode as SymbolLiteral; |
| 8368 if (javaBooleanAnd(isEqualTokens(node.poundSign, toNode.poundSign), isEqualT
okenLists(node.components, toNode.components))) { | 8351 if (javaBooleanAnd(_isEqualTokens(node.poundSign, toNode.poundSign), _isEqua
lTokenLists(node.components, toNode.components))) { |
| 8369 toNode.propagatedType = node.propagatedType; | 8352 toNode.propagatedType = node.propagatedType; |
| 8370 toNode.staticType = node.staticType; | 8353 toNode.staticType = node.staticType; |
| 8371 return true; | 8354 return true; |
| 8372 } | 8355 } |
| 8373 return false; | 8356 return false; |
| 8374 } | 8357 } |
| 8375 | 8358 |
| 8376 bool visitThisExpression(ThisExpression node) { | 8359 bool visitThisExpression(ThisExpression node) { |
| 8377 ThisExpression toNode = this._toNode as ThisExpression; | 8360 ThisExpression toNode = this._toNode as ThisExpression; |
| 8378 if (isEqualTokens(node.keyword, toNode.keyword)) { | 8361 if (_isEqualTokens(node.keyword, toNode.keyword)) { |
| 8379 toNode.propagatedType = node.propagatedType; | 8362 toNode.propagatedType = node.propagatedType; |
| 8380 toNode.staticType = node.staticType; | 8363 toNode.staticType = node.staticType; |
| 8381 return true; | 8364 return true; |
| 8382 } | 8365 } |
| 8383 return false; | 8366 return false; |
| 8384 } | 8367 } |
| 8385 | 8368 |
| 8386 bool visitThrowExpression(ThrowExpression node) { | 8369 bool visitThrowExpression(ThrowExpression node) { |
| 8387 ThrowExpression toNode = this._toNode as ThrowExpression; | 8370 ThrowExpression toNode = this._toNode as ThrowExpression; |
| 8388 if (javaBooleanAnd(isEqualTokens(node.keyword, toNode.keyword), isEqualNodes
(node.expression, toNode.expression))) { | 8371 if (javaBooleanAnd(_isEqualTokens(node.keyword, toNode.keyword), _isEqualNod
es(node.expression, toNode.expression))) { |
| 8389 toNode.propagatedType = node.propagatedType; | 8372 toNode.propagatedType = node.propagatedType; |
| 8390 toNode.staticType = node.staticType; | 8373 toNode.staticType = node.staticType; |
| 8391 return true; | 8374 return true; |
| 8392 } | 8375 } |
| 8393 return false; | 8376 return false; |
| 8394 } | 8377 } |
| 8395 | 8378 |
| 8396 bool visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 8379 bool visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 8397 TopLevelVariableDeclaration toNode = this._toNode as TopLevelVariableDeclara
tion; | 8380 TopLevelVariableDeclaration toNode = this._toNode as TopLevelVariableDeclara
tion; |
| 8398 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNodes(node.docume
ntationComment, toNode.documentationComment), isEqualNodeLists(node.metadata, to
Node.metadata)), isEqualNodes(node.variables, toNode.variables)), isEqualTokens(
node.semicolon, toNode.semicolon)); | 8381 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualNodes(node.docum
entationComment, toNode.documentationComment), _isEqualNodeLists(node.metadata,
toNode.metadata)), _isEqualNodes(node.variables, toNode.variables)), _isEqualTok
ens(node.semicolon, toNode.semicolon)); |
| 8399 } | 8382 } |
| 8400 | 8383 |
| 8401 bool visitTryStatement(TryStatement node) { | 8384 bool visitTryStatement(TryStatement node) { |
| 8402 TryStatement toNode = this._toNode as TryStatement; | 8385 TryStatement toNode = this._toNode as TryStatement; |
| 8403 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTo
kens(node.tryKeyword, toNode.tryKeyword), isEqualNodes(node.body, toNode.body)),
isEqualNodeLists(node.catchClauses, toNode.catchClauses)), isEqualTokens(node.f
inallyKeyword, toNode.finallyKeyword)), isEqualNodes(node.finallyBlock, toNode.f
inallyBlock)); | 8386 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualT
okens(node.tryKeyword, toNode.tryKeyword), _isEqualNodes(node.body, toNode.body)
), _isEqualNodeLists(node.catchClauses, toNode.catchClauses)), _isEqualTokens(no
de.finallyKeyword, toNode.finallyKeyword)), _isEqualNodes(node.finallyBlock, toN
ode.finallyBlock)); |
| 8404 } | 8387 } |
| 8405 | 8388 |
| 8406 bool visitTypeArgumentList(TypeArgumentList node) { | 8389 bool visitTypeArgumentList(TypeArgumentList node) { |
| 8407 TypeArgumentList toNode = this._toNode as TypeArgumentList; | 8390 TypeArgumentList toNode = this._toNode as TypeArgumentList; |
| 8408 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.leftBracket, toNode.
leftBracket), isEqualNodeLists(node.arguments, toNode.arguments)), isEqualTokens
(node.rightBracket, toNode.rightBracket)); | 8391 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.leftBracket, toNode
.leftBracket), _isEqualNodeLists(node.arguments, toNode.arguments)), _isEqualTok
ens(node.rightBracket, toNode.rightBracket)); |
| 8409 } | 8392 } |
| 8410 | 8393 |
| 8411 bool visitTypeName(TypeName node) { | 8394 bool visitTypeName(TypeName node) { |
| 8412 TypeName toNode = this._toNode as TypeName; | 8395 TypeName toNode = this._toNode as TypeName; |
| 8413 if (javaBooleanAnd(isEqualNodes(node.name, toNode.name), isEqualNodes(node.t
ypeArguments, toNode.typeArguments))) { | 8396 if (javaBooleanAnd(_isEqualNodes(node.name, toNode.name), _isEqualNodes(node
.typeArguments, toNode.typeArguments))) { |
| 8414 toNode.type = node.type; | 8397 toNode.type = node.type; |
| 8415 return true; | 8398 return true; |
| 8416 } | 8399 } |
| 8417 return false; | 8400 return false; |
| 8418 } | 8401 } |
| 8419 | 8402 |
| 8420 bool visitTypeParameter(TypeParameter node) { | 8403 bool visitTypeParameter(TypeParameter node) { |
| 8421 TypeParameter toNode = this._toNode as TypeParameter; | 8404 TypeParameter toNode = this._toNode as TypeParameter; |
| 8422 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualNodes(node.name, toNode.name)), isEqualTo
kens(node.keyword, toNode.keyword)), isEqualNodes(node.bound, toNode.bound)); | 8405 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualNodes(node.name, toNode.name)), _isEqu
alTokens(node.keyword, toNode.keyword)), _isEqualNodes(node.bound, toNode.bound)
); |
| 8423 } | 8406 } |
| 8424 | 8407 |
| 8425 bool visitTypeParameterList(TypeParameterList node) { | 8408 bool visitTypeParameterList(TypeParameterList node) { |
| 8426 TypeParameterList toNode = this._toNode as TypeParameterList; | 8409 TypeParameterList toNode = this._toNode as TypeParameterList; |
| 8427 return javaBooleanAnd(javaBooleanAnd(isEqualTokens(node.leftBracket, toNode.
leftBracket), isEqualNodeLists(node.typeParameters, toNode.typeParameters)), isE
qualTokens(node.rightBracket, toNode.rightBracket)); | 8410 return javaBooleanAnd(javaBooleanAnd(_isEqualTokens(node.leftBracket, toNode
.leftBracket), _isEqualNodeLists(node.typeParameters, toNode.typeParameters)), _
isEqualTokens(node.rightBracket, toNode.rightBracket)); |
| 8428 } | 8411 } |
| 8429 | 8412 |
| 8430 bool visitVariableDeclaration(VariableDeclaration node) { | 8413 bool visitVariableDeclaration(VariableDeclaration node) { |
| 8431 VariableDeclaration toNode = this._toNode as VariableDeclaration; | 8414 VariableDeclaration toNode = this._toNode as VariableDeclaration; |
| 8432 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualNodes(node.name, toNode.name)), isEqualTo
kens(node.equals, toNode.equals)), isEqualNodes(node.initializer, toNode.initial
izer)); | 8415 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualNodes(node.name, toNode.name)), _isEqu
alTokens(node.equals, toNode.equals)), _isEqualNodes(node.initializer, toNode.in
itializer)); |
| 8433 } | 8416 } |
| 8434 | 8417 |
| 8435 bool visitVariableDeclarationList(VariableDeclarationList node) { | 8418 bool visitVariableDeclarationList(VariableDeclarationList node) { |
| 8436 VariableDeclarationList toNode = this._toNode as VariableDeclarationList; | 8419 VariableDeclarationList toNode = this._toNode as VariableDeclarationList; |
| 8437 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualNo
des(node.documentationComment, toNode.documentationComment), isEqualNodeLists(no
de.metadata, toNode.metadata)), isEqualTokens(node.keyword, toNode.keyword)), is
EqualNodes(node.type, toNode.type)), isEqualNodeLists(node.variables, toNode.var
iables)); | 8420 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualN
odes(node.documentationComment, toNode.documentationComment), _isEqualNodeLists(
node.metadata, toNode.metadata)), _isEqualTokens(node.keyword, toNode.keyword)),
_isEqualNodes(node.type, toNode.type)), _isEqualNodeLists(node.variables, toNod
e.variables)); |
| 8438 } | 8421 } |
| 8439 | 8422 |
| 8440 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 8423 bool visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 8441 VariableDeclarationStatement toNode = this._toNode as VariableDeclarationSta
tement; | 8424 VariableDeclarationStatement toNode = this._toNode as VariableDeclarationSta
tement; |
| 8442 return javaBooleanAnd(isEqualNodes(node.variables, toNode.variables), isEqua
lTokens(node.semicolon, toNode.semicolon)); | 8425 return javaBooleanAnd(_isEqualNodes(node.variables, toNode.variables), _isEq
ualTokens(node.semicolon, toNode.semicolon)); |
| 8443 } | 8426 } |
| 8444 | 8427 |
| 8445 bool visitWhileStatement(WhileStatement node) { | 8428 bool visitWhileStatement(WhileStatement node) { |
| 8446 WhileStatement toNode = this._toNode as WhileStatement; | 8429 WhileStatement toNode = this._toNode as WhileStatement; |
| 8447 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(isEqualTo
kens(node.keyword, toNode.keyword), isEqualTokens(node.leftParenthesis, toNode.l
eftParenthesis)), isEqualNodes(node.condition, toNode.condition)), isEqualTokens
(node.rightParenthesis, toNode.rightParenthesis)), isEqualNodes(node.body, toNod
e.body)); | 8430 return javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(javaBooleanAnd(_isEqualT
okens(node.keyword, toNode.keyword), _isEqualTokens(node.leftParenthesis, toNode
.leftParenthesis)), _isEqualNodes(node.condition, toNode.condition)), _isEqualTo
kens(node.rightParenthesis, toNode.rightParenthesis)), _isEqualNodes(node.body,
toNode.body)); |
| 8448 } | 8431 } |
| 8449 | 8432 |
| 8450 bool visitWithClause(WithClause node) { | 8433 bool visitWithClause(WithClause node) { |
| 8451 WithClause toNode = this._toNode as WithClause; | 8434 WithClause toNode = this._toNode as WithClause; |
| 8452 return javaBooleanAnd(isEqualTokens(node.withKeyword, toNode.withKeyword), i
sEqualNodeLists(node.mixinTypes, toNode.mixinTypes)); | 8435 return javaBooleanAnd(_isEqualTokens(node.withKeyword, toNode.withKeyword),
_isEqualNodeLists(node.mixinTypes, toNode.mixinTypes)); |
| 8453 } | 8436 } |
| 8454 | 8437 |
| 8455 /** | 8438 /** |
| 8456 * Return `true` if the given lists of AST nodes have the same size and corres
ponding | 8439 * Return `true` if the given lists of AST nodes have the same size and corres
ponding |
| 8457 * elements are equal. | 8440 * elements are equal. |
| 8458 * | 8441 * |
| 8459 * @param first the first node being compared | 8442 * @param first the first node being compared |
| 8460 * @param second the second node being compared | 8443 * @param second the second node being compared |
| 8461 * @return `true` if the given AST nodes have the same size and corresponding
elements are | 8444 * @return `true` if the given AST nodes have the same size and corresponding
elements are |
| 8462 * equal | 8445 * equal |
| 8463 */ | 8446 */ |
| 8464 bool isEqualNodeLists(NodeList first, NodeList second) { | 8447 bool _isEqualNodeLists(NodeList first, NodeList second) { |
| 8465 if (first == null) { | 8448 if (first == null) { |
| 8466 return second == null; | 8449 return second == null; |
| 8467 } else if (second == null) { | 8450 } else if (second == null) { |
| 8468 return false; | 8451 return false; |
| 8469 } | 8452 } |
| 8470 int size = first.length; | 8453 int size = first.length; |
| 8471 if (second.length != size) { | 8454 if (second.length != size) { |
| 8472 return false; | 8455 return false; |
| 8473 } | 8456 } |
| 8474 bool equal = true; | 8457 bool equal = true; |
| 8475 for (int i = 0; i < size; i++) { | 8458 for (int i = 0; i < size; i++) { |
| 8476 if (!isEqualNodes(first[i], second[i])) { | 8459 if (!_isEqualNodes(first[i], second[i])) { |
| 8477 equal = false; | 8460 equal = false; |
| 8478 } | 8461 } |
| 8479 } | 8462 } |
| 8480 return equal; | 8463 return equal; |
| 8481 } | 8464 } |
| 8482 | 8465 |
| 8483 /** | 8466 /** |
| 8484 * Return `true` if the given AST nodes have the same structure. As a side-eff
ect, if the | 8467 * Return `true` if the given AST nodes have the same structure. As a side-eff
ect, if the |
| 8485 * nodes do have the same structure, any resolution data from the first node w
ill be copied to the | 8468 * nodes do have the same structure, any resolution data from the first node w
ill be copied to the |
| 8486 * second node. | 8469 * second node. |
| 8487 * | 8470 * |
| 8488 * @param fromNode the node from which resolution information will be copied | 8471 * @param fromNode the node from which resolution information will be copied |
| 8489 * @param toNode the node to which resolution information will be copied | 8472 * @param toNode the node to which resolution information will be copied |
| 8490 * @return `true` if the given AST nodes have the same structure | 8473 * @return `true` if the given AST nodes have the same structure |
| 8491 */ | 8474 */ |
| 8492 bool isEqualNodes(AstNode fromNode, AstNode toNode) { | 8475 bool _isEqualNodes(AstNode fromNode, AstNode toNode) { |
| 8493 if (fromNode == null) { | 8476 if (fromNode == null) { |
| 8494 return toNode == null; | 8477 return toNode == null; |
| 8495 } else if (toNode == null) { | 8478 } else if (toNode == null) { |
| 8496 return false; | 8479 return false; |
| 8497 } else if (fromNode.runtimeType == toNode.runtimeType) { | 8480 } else if (fromNode.runtimeType == toNode.runtimeType) { |
| 8498 this._toNode = toNode; | 8481 this._toNode = toNode; |
| 8499 return fromNode.accept(this); | 8482 return fromNode.accept(this); |
| 8500 } | 8483 } |
| 8501 // | 8484 // |
| 8502 // Check for a simple transformation caused by entering a period. | 8485 // Check for a simple transformation caused by entering a period. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 8519 | 8502 |
| 8520 /** | 8503 /** |
| 8521 * Return `true` if the given arrays of tokens have the same length and corres
ponding | 8504 * Return `true` if the given arrays of tokens have the same length and corres
ponding |
| 8522 * elements are equal. | 8505 * elements are equal. |
| 8523 * | 8506 * |
| 8524 * @param first the first node being compared | 8507 * @param first the first node being compared |
| 8525 * @param second the second node being compared | 8508 * @param second the second node being compared |
| 8526 * @return `true` if the given arrays of tokens have the same length and corre
sponding | 8509 * @return `true` if the given arrays of tokens have the same length and corre
sponding |
| 8527 * elements are equal | 8510 * elements are equal |
| 8528 */ | 8511 */ |
| 8529 bool isEqualTokenLists(List<Token> first, List<Token> second) { | 8512 bool _isEqualTokenLists(List<Token> first, List<Token> second) { |
| 8530 int length = first.length; | 8513 int length = first.length; |
| 8531 if (second.length != length) { | 8514 if (second.length != length) { |
| 8532 return false; | 8515 return false; |
| 8533 } | 8516 } |
| 8534 for (int i = 0; i < length; i++) { | 8517 for (int i = 0; i < length; i++) { |
| 8535 if (!isEqualTokens(first[i], second[i])) { | 8518 if (!_isEqualTokens(first[i], second[i])) { |
| 8536 return false; | 8519 return false; |
| 8537 } | 8520 } |
| 8538 } | 8521 } |
| 8539 return true; | 8522 return true; |
| 8540 } | 8523 } |
| 8541 | 8524 |
| 8542 /** | 8525 /** |
| 8543 * Return `true` if the given tokens have the same structure. | 8526 * Return `true` if the given tokens have the same structure. |
| 8544 * | 8527 * |
| 8545 * @param first the first node being compared | 8528 * @param first the first node being compared |
| 8546 * @param second the second node being compared | 8529 * @param second the second node being compared |
| 8547 * @return `true` if the given tokens have the same structure | 8530 * @return `true` if the given tokens have the same structure |
| 8548 */ | 8531 */ |
| 8549 bool isEqualTokens(Token first, Token second) { | 8532 bool _isEqualTokens(Token first, Token second) { |
| 8550 if (first == null) { | 8533 if (first == null) { |
| 8551 return second == null; | 8534 return second == null; |
| 8552 } else if (second == null) { | 8535 } else if (second == null) { |
| 8553 return false; | 8536 return false; |
| 8554 } | 8537 } |
| 8555 return first.lexeme == second.lexeme; | 8538 return first.lexeme == second.lexeme; |
| 8556 } | 8539 } |
| 8557 } | 8540 } |
| 8558 | 8541 |
| 8559 /** | 8542 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 8576 * Initialize a newly created visitor to write source code representing the vi
sited nodes to the | 8559 * Initialize a newly created visitor to write source code representing the vi
sited nodes to the |
| 8577 * given writer. | 8560 * given writer. |
| 8578 * | 8561 * |
| 8579 * @param writer the writer to which the source is to be written | 8562 * @param writer the writer to which the source is to be written |
| 8580 */ | 8563 */ |
| 8581 ToFormattedSourceVisitor(PrintWriter writer) { | 8564 ToFormattedSourceVisitor(PrintWriter writer) { |
| 8582 this._writer = writer; | 8565 this._writer = writer; |
| 8583 } | 8566 } |
| 8584 | 8567 |
| 8585 Object visitAdjacentStrings(AdjacentStrings node) { | 8568 Object visitAdjacentStrings(AdjacentStrings node) { |
| 8586 visitNodeListWithSeparator(node.strings, " "); | 8569 _visitNodeListWithSeparator(node.strings, " "); |
| 8587 return null; | 8570 return null; |
| 8588 } | 8571 } |
| 8589 | 8572 |
| 8590 Object visitAnnotation(Annotation node) { | 8573 Object visitAnnotation(Annotation node) { |
| 8591 _writer.print('@'); | 8574 _writer.print('@'); |
| 8592 visitNode(node.name); | 8575 _visitNode(node.name); |
| 8593 visitNodeWithPrefix(".", node.constructorName); | 8576 _visitNodeWithPrefix(".", node.constructorName); |
| 8594 visitNode(node.arguments); | 8577 _visitNode(node.arguments); |
| 8595 return null; | 8578 return null; |
| 8596 } | 8579 } |
| 8597 | 8580 |
| 8598 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { | 8581 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { |
| 8599 _writer.print('?'); | 8582 _writer.print('?'); |
| 8600 visitNode(node.identifier); | 8583 _visitNode(node.identifier); |
| 8601 return null; | 8584 return null; |
| 8602 } | 8585 } |
| 8603 | 8586 |
| 8604 Object visitArgumentList(ArgumentList node) { | 8587 Object visitArgumentList(ArgumentList node) { |
| 8605 _writer.print('('); | 8588 _writer.print('('); |
| 8606 visitNodeListWithSeparator(node.arguments, ", "); | 8589 _visitNodeListWithSeparator(node.arguments, ", "); |
| 8607 _writer.print(')'); | 8590 _writer.print(')'); |
| 8608 return null; | 8591 return null; |
| 8609 } | 8592 } |
| 8610 | 8593 |
| 8611 Object visitAsExpression(AsExpression node) { | 8594 Object visitAsExpression(AsExpression node) { |
| 8612 visitNode(node.expression); | 8595 _visitNode(node.expression); |
| 8613 _writer.print(" as "); | 8596 _writer.print(" as "); |
| 8614 visitNode(node.type); | 8597 _visitNode(node.type); |
| 8615 return null; | 8598 return null; |
| 8616 } | 8599 } |
| 8617 | 8600 |
| 8618 Object visitAssertStatement(AssertStatement node) { | 8601 Object visitAssertStatement(AssertStatement node) { |
| 8619 _writer.print("assert("); | 8602 _writer.print("assert("); |
| 8620 visitNode(node.condition); | 8603 _visitNode(node.condition); |
| 8621 _writer.print(");"); | 8604 _writer.print(");"); |
| 8622 return null; | 8605 return null; |
| 8623 } | 8606 } |
| 8624 | 8607 |
| 8625 Object visitAssignmentExpression(AssignmentExpression node) { | 8608 Object visitAssignmentExpression(AssignmentExpression node) { |
| 8626 visitNode(node.leftHandSide); | 8609 _visitNode(node.leftHandSide); |
| 8627 _writer.print(' '); | 8610 _writer.print(' '); |
| 8628 _writer.print(node.operator.lexeme); | 8611 _writer.print(node.operator.lexeme); |
| 8629 _writer.print(' '); | 8612 _writer.print(' '); |
| 8630 visitNode(node.rightHandSide); | 8613 _visitNode(node.rightHandSide); |
| 8631 return null; | 8614 return null; |
| 8632 } | 8615 } |
| 8633 | 8616 |
| 8634 Object visitBinaryExpression(BinaryExpression node) { | 8617 Object visitBinaryExpression(BinaryExpression node) { |
| 8635 visitNode(node.leftOperand); | 8618 _visitNode(node.leftOperand); |
| 8636 _writer.print(' '); | 8619 _writer.print(' '); |
| 8637 _writer.print(node.operator.lexeme); | 8620 _writer.print(node.operator.lexeme); |
| 8638 _writer.print(' '); | 8621 _writer.print(' '); |
| 8639 visitNode(node.rightOperand); | 8622 _visitNode(node.rightOperand); |
| 8640 return null; | 8623 return null; |
| 8641 } | 8624 } |
| 8642 | 8625 |
| 8643 Object visitBlock(Block node) { | 8626 Object visitBlock(Block node) { |
| 8644 _writer.print('{'); | 8627 _writer.print('{'); |
| 8645 { | 8628 { |
| 8646 indentInc(); | 8629 _indentInc(); |
| 8647 visitNodeListWithSeparatorAndPrefix("\n", node.statements, "\n"); | 8630 _visitNodeListWithSeparatorAndPrefix("\n", node.statements, "\n"); |
| 8648 indentDec(); | 8631 _indentDec(); |
| 8649 } | 8632 } |
| 8650 nl2(); | 8633 _nl2(); |
| 8651 _writer.print('}'); | 8634 _writer.print('}'); |
| 8652 return null; | 8635 return null; |
| 8653 } | 8636 } |
| 8654 | 8637 |
| 8655 Object visitBlockFunctionBody(BlockFunctionBody node) { | 8638 Object visitBlockFunctionBody(BlockFunctionBody node) { |
| 8656 visitNode(node.block); | 8639 _visitNode(node.block); |
| 8657 return null; | 8640 return null; |
| 8658 } | 8641 } |
| 8659 | 8642 |
| 8660 Object visitBooleanLiteral(BooleanLiteral node) { | 8643 Object visitBooleanLiteral(BooleanLiteral node) { |
| 8661 _writer.print(node.literal.lexeme); | 8644 _writer.print(node.literal.lexeme); |
| 8662 return null; | 8645 return null; |
| 8663 } | 8646 } |
| 8664 | 8647 |
| 8665 Object visitBreakStatement(BreakStatement node) { | 8648 Object visitBreakStatement(BreakStatement node) { |
| 8666 _writer.print("break"); | 8649 _writer.print("break"); |
| 8667 visitNodeWithPrefix(" ", node.label); | 8650 _visitNodeWithPrefix(" ", node.label); |
| 8668 _writer.print(";"); | 8651 _writer.print(";"); |
| 8669 return null; | 8652 return null; |
| 8670 } | 8653 } |
| 8671 | 8654 |
| 8672 Object visitCascadeExpression(CascadeExpression node) { | 8655 Object visitCascadeExpression(CascadeExpression node) { |
| 8673 visitNode(node.target); | 8656 _visitNode(node.target); |
| 8674 visitNodeList(node.cascadeSections); | 8657 _visitNodeList(node.cascadeSections); |
| 8675 return null; | 8658 return null; |
| 8676 } | 8659 } |
| 8677 | 8660 |
| 8678 Object visitCatchClause(CatchClause node) { | 8661 Object visitCatchClause(CatchClause node) { |
| 8679 visitNodeWithPrefix("on ", node.exceptionType); | 8662 _visitNodeWithPrefix("on ", node.exceptionType); |
| 8680 if (node.catchKeyword != null) { | 8663 if (node.catchKeyword != null) { |
| 8681 if (node.exceptionType != null) { | 8664 if (node.exceptionType != null) { |
| 8682 _writer.print(' '); | 8665 _writer.print(' '); |
| 8683 } | 8666 } |
| 8684 _writer.print("catch ("); | 8667 _writer.print("catch ("); |
| 8685 visitNode(node.exceptionParameter); | 8668 _visitNode(node.exceptionParameter); |
| 8686 visitNodeWithPrefix(", ", node.stackTraceParameter); | 8669 _visitNodeWithPrefix(", ", node.stackTraceParameter); |
| 8687 _writer.print(") "); | 8670 _writer.print(") "); |
| 8688 } else { | 8671 } else { |
| 8689 _writer.print(" "); | 8672 _writer.print(" "); |
| 8690 } | 8673 } |
| 8691 visitNode(node.body); | 8674 _visitNode(node.body); |
| 8692 return null; | 8675 return null; |
| 8693 } | 8676 } |
| 8694 | 8677 |
| 8695 Object visitClassDeclaration(ClassDeclaration node) { | 8678 Object visitClassDeclaration(ClassDeclaration node) { |
| 8696 visitNode(node.documentationComment); | 8679 _visitNode(node.documentationComment); |
| 8697 visitTokenWithSuffix(node.abstractKeyword, " "); | 8680 _visitTokenWithSuffix(node.abstractKeyword, " "); |
| 8698 _writer.print("class "); | 8681 _writer.print("class "); |
| 8699 visitNode(node.name); | 8682 _visitNode(node.name); |
| 8700 visitNode(node.typeParameters); | 8683 _visitNode(node.typeParameters); |
| 8701 visitNodeWithPrefix(" ", node.extendsClause); | 8684 _visitNodeWithPrefix(" ", node.extendsClause); |
| 8702 visitNodeWithPrefix(" ", node.withClause); | 8685 _visitNodeWithPrefix(" ", node.withClause); |
| 8703 visitNodeWithPrefix(" ", node.implementsClause); | 8686 _visitNodeWithPrefix(" ", node.implementsClause); |
| 8704 _writer.print(" {"); | 8687 _writer.print(" {"); |
| 8705 { | 8688 { |
| 8706 indentInc(); | 8689 _indentInc(); |
| 8707 visitNodeListWithSeparatorAndPrefix("\n", node.members, "\n\n"); | 8690 _visitNodeListWithSeparatorAndPrefix("\n", node.members, "\n\n"); |
| 8708 indentDec(); | 8691 _indentDec(); |
| 8709 } | 8692 } |
| 8710 nl2(); | 8693 _nl2(); |
| 8711 _writer.print("}"); | 8694 _writer.print("}"); |
| 8712 return null; | 8695 return null; |
| 8713 } | 8696 } |
| 8714 | 8697 |
| 8715 Object visitClassTypeAlias(ClassTypeAlias node) { | 8698 Object visitClassTypeAlias(ClassTypeAlias node) { |
| 8716 _writer.print("typedef "); | 8699 _writer.print("typedef "); |
| 8717 visitNode(node.name); | 8700 _visitNode(node.name); |
| 8718 visitNode(node.typeParameters); | 8701 _visitNode(node.typeParameters); |
| 8719 _writer.print(" = "); | 8702 _writer.print(" = "); |
| 8720 if (node.abstractKeyword != null) { | 8703 if (node.abstractKeyword != null) { |
| 8721 _writer.print("abstract "); | 8704 _writer.print("abstract "); |
| 8722 } | 8705 } |
| 8723 visitNode(node.superclass); | 8706 _visitNode(node.superclass); |
| 8724 visitNodeWithPrefix(" ", node.withClause); | 8707 _visitNodeWithPrefix(" ", node.withClause); |
| 8725 visitNodeWithPrefix(" ", node.implementsClause); | 8708 _visitNodeWithPrefix(" ", node.implementsClause); |
| 8726 _writer.print(";"); | 8709 _writer.print(";"); |
| 8727 return null; | 8710 return null; |
| 8728 } | 8711 } |
| 8729 | 8712 |
| 8730 Object visitComment(Comment node) { | 8713 Object visitComment(Comment node) { |
| 8731 Token token = node.beginToken; | 8714 Token token = node.beginToken; |
| 8732 while (token != null) { | 8715 while (token != null) { |
| 8733 bool firstLine = true; | 8716 bool firstLine = true; |
| 8734 for (String line in StringUtils.split(token.lexeme, "\n")) { | 8717 for (String line in StringUtils.split(token.lexeme, "\n")) { |
| 8735 if (firstLine) { | 8718 if (firstLine) { |
| 8736 firstLine = false; | 8719 firstLine = false; |
| 8737 } else { | 8720 } else { |
| 8738 line = " ${line.trim()}"; | 8721 line = " ${line.trim()}"; |
| 8739 line = StringUtils.replace(line, "/*", "/ *"); | 8722 line = StringUtils.replace(line, "/*", "/ *"); |
| 8740 } | 8723 } |
| 8741 _writer.print(line); | 8724 _writer.print(line); |
| 8742 nl2(); | 8725 _nl2(); |
| 8743 } | 8726 } |
| 8744 if (identical(token, node.endToken)) { | 8727 if (identical(token, node.endToken)) { |
| 8745 break; | 8728 break; |
| 8746 } | 8729 } |
| 8747 } | 8730 } |
| 8748 return null; | 8731 return null; |
| 8749 } | 8732 } |
| 8750 | 8733 |
| 8751 Object visitCommentReference(CommentReference node) => null; | 8734 Object visitCommentReference(CommentReference node) => null; |
| 8752 | 8735 |
| 8753 Object visitCompilationUnit(CompilationUnit node) { | 8736 Object visitCompilationUnit(CompilationUnit node) { |
| 8754 ScriptTag scriptTag = node.scriptTag; | 8737 ScriptTag scriptTag = node.scriptTag; |
| 8755 NodeList<Directive> directives = node.directives; | 8738 NodeList<Directive> directives = node.directives; |
| 8756 visitNode(scriptTag); | 8739 _visitNode(scriptTag); |
| 8757 // directives | 8740 // directives |
| 8758 String prefix = scriptTag == null ? "" : " "; | 8741 String prefix = scriptTag == null ? "" : " "; |
| 8759 visitNodeListWithSeparatorAndPrefix(prefix, directives, "\n"); | 8742 _visitNodeListWithSeparatorAndPrefix(prefix, directives, "\n"); |
| 8760 nl(); | 8743 _nl(); |
| 8761 // declarations | 8744 // declarations |
| 8762 prefix = scriptTag == null && directives.isEmpty ? "" : "\n"; | 8745 prefix = scriptTag == null && directives.isEmpty ? "" : "\n"; |
| 8763 visitNodeListWithSeparatorAndPrefix(prefix, node.declarations, "\n\n"); | 8746 _visitNodeListWithSeparatorAndPrefix(prefix, node.declarations, "\n\n"); |
| 8764 return null; | 8747 return null; |
| 8765 } | 8748 } |
| 8766 | 8749 |
| 8767 Object visitConditionalExpression(ConditionalExpression node) { | 8750 Object visitConditionalExpression(ConditionalExpression node) { |
| 8768 visitNode(node.condition); | 8751 _visitNode(node.condition); |
| 8769 _writer.print(" ? "); | 8752 _writer.print(" ? "); |
| 8770 visitNode(node.thenExpression); | 8753 _visitNode(node.thenExpression); |
| 8771 _writer.print(" : "); | 8754 _writer.print(" : "); |
| 8772 visitNode(node.elseExpression); | 8755 _visitNode(node.elseExpression); |
| 8773 return null; | 8756 return null; |
| 8774 } | 8757 } |
| 8775 | 8758 |
| 8776 Object visitConstructorDeclaration(ConstructorDeclaration node) { | 8759 Object visitConstructorDeclaration(ConstructorDeclaration node) { |
| 8777 visitNode(node.documentationComment); | 8760 _visitNode(node.documentationComment); |
| 8778 visitTokenWithSuffix(node.externalKeyword, " "); | 8761 _visitTokenWithSuffix(node.externalKeyword, " "); |
| 8779 visitTokenWithSuffix(node.constKeyword, " "); | 8762 _visitTokenWithSuffix(node.constKeyword, " "); |
| 8780 visitTokenWithSuffix(node.factoryKeyword, " "); | 8763 _visitTokenWithSuffix(node.factoryKeyword, " "); |
| 8781 visitNode(node.returnType); | 8764 _visitNode(node.returnType); |
| 8782 visitNodeWithPrefix(".", node.name); | 8765 _visitNodeWithPrefix(".", node.name); |
| 8783 visitNode(node.parameters); | 8766 _visitNode(node.parameters); |
| 8784 visitNodeListWithSeparatorAndPrefix(" : ", node.initializers, ", "); | 8767 _visitNodeListWithSeparatorAndPrefix(" : ", node.initializers, ", "); |
| 8785 visitNodeWithPrefix(" = ", node.redirectedConstructor); | 8768 _visitNodeWithPrefix(" = ", node.redirectedConstructor); |
| 8786 if (node.body is! EmptyFunctionBody) { | 8769 if (node.body is! EmptyFunctionBody) { |
| 8787 _writer.print(' '); | 8770 _writer.print(' '); |
| 8788 } | 8771 } |
| 8789 visitNode(node.body); | 8772 _visitNode(node.body); |
| 8790 return null; | 8773 return null; |
| 8791 } | 8774 } |
| 8792 | 8775 |
| 8793 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { | 8776 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { |
| 8794 visitTokenWithSuffix(node.keyword, "."); | 8777 _visitTokenWithSuffix(node.keyword, "."); |
| 8795 visitNode(node.fieldName); | 8778 _visitNode(node.fieldName); |
| 8796 _writer.print(" = "); | 8779 _writer.print(" = "); |
| 8797 visitNode(node.expression); | 8780 _visitNode(node.expression); |
| 8798 return null; | 8781 return null; |
| 8799 } | 8782 } |
| 8800 | 8783 |
| 8801 Object visitConstructorName(ConstructorName node) { | 8784 Object visitConstructorName(ConstructorName node) { |
| 8802 visitNode(node.type); | 8785 _visitNode(node.type); |
| 8803 visitNodeWithPrefix(".", node.name); | 8786 _visitNodeWithPrefix(".", node.name); |
| 8804 return null; | 8787 return null; |
| 8805 } | 8788 } |
| 8806 | 8789 |
| 8807 Object visitContinueStatement(ContinueStatement node) { | 8790 Object visitContinueStatement(ContinueStatement node) { |
| 8808 _writer.print("continue"); | 8791 _writer.print("continue"); |
| 8809 visitNodeWithPrefix(" ", node.label); | 8792 _visitNodeWithPrefix(" ", node.label); |
| 8810 _writer.print(";"); | 8793 _writer.print(";"); |
| 8811 return null; | 8794 return null; |
| 8812 } | 8795 } |
| 8813 | 8796 |
| 8814 Object visitDeclaredIdentifier(DeclaredIdentifier node) { | 8797 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 8815 visitTokenWithSuffix(node.keyword, " "); | 8798 _visitTokenWithSuffix(node.keyword, " "); |
| 8816 visitNodeWithSuffix(node.type, " "); | 8799 _visitNodeWithSuffix(node.type, " "); |
| 8817 visitNode(node.identifier); | 8800 _visitNode(node.identifier); |
| 8818 return null; | 8801 return null; |
| 8819 } | 8802 } |
| 8820 | 8803 |
| 8821 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 8804 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 8822 visitNode(node.parameter); | 8805 _visitNode(node.parameter); |
| 8823 if (node.separator != null) { | 8806 if (node.separator != null) { |
| 8824 _writer.print(" "); | 8807 _writer.print(" "); |
| 8825 _writer.print(node.separator.lexeme); | 8808 _writer.print(node.separator.lexeme); |
| 8826 visitNodeWithPrefix(" ", node.defaultValue); | 8809 _visitNodeWithPrefix(" ", node.defaultValue); |
| 8827 } | 8810 } |
| 8828 return null; | 8811 return null; |
| 8829 } | 8812 } |
| 8830 | 8813 |
| 8831 Object visitDoStatement(DoStatement node) { | 8814 Object visitDoStatement(DoStatement node) { |
| 8832 _writer.print("do "); | 8815 _writer.print("do "); |
| 8833 visitNode(node.body); | 8816 _visitNode(node.body); |
| 8834 _writer.print(" while ("); | 8817 _writer.print(" while ("); |
| 8835 visitNode(node.condition); | 8818 _visitNode(node.condition); |
| 8836 _writer.print(");"); | 8819 _writer.print(");"); |
| 8837 return null; | 8820 return null; |
| 8838 } | 8821 } |
| 8839 | 8822 |
| 8840 Object visitDoubleLiteral(DoubleLiteral node) { | 8823 Object visitDoubleLiteral(DoubleLiteral node) { |
| 8841 _writer.print(node.literal.lexeme); | 8824 _writer.print(node.literal.lexeme); |
| 8842 return null; | 8825 return null; |
| 8843 } | 8826 } |
| 8844 | 8827 |
| 8845 Object visitEmptyFunctionBody(EmptyFunctionBody node) { | 8828 Object visitEmptyFunctionBody(EmptyFunctionBody node) { |
| 8846 _writer.print(';'); | 8829 _writer.print(';'); |
| 8847 return null; | 8830 return null; |
| 8848 } | 8831 } |
| 8849 | 8832 |
| 8850 Object visitEmptyStatement(EmptyStatement node) { | 8833 Object visitEmptyStatement(EmptyStatement node) { |
| 8851 _writer.print(';'); | 8834 _writer.print(';'); |
| 8852 return null; | 8835 return null; |
| 8853 } | 8836 } |
| 8854 | 8837 |
| 8855 Object visitExportDirective(ExportDirective node) { | 8838 Object visitExportDirective(ExportDirective node) { |
| 8856 _writer.print("export "); | 8839 _writer.print("export "); |
| 8857 visitNode(node.uri); | 8840 _visitNode(node.uri); |
| 8858 visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " "); | 8841 _visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " "); |
| 8859 _writer.print(';'); | 8842 _writer.print(';'); |
| 8860 return null; | 8843 return null; |
| 8861 } | 8844 } |
| 8862 | 8845 |
| 8863 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { | 8846 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { |
| 8864 _writer.print("=> "); | 8847 _writer.print("=> "); |
| 8865 visitNode(node.expression); | 8848 _visitNode(node.expression); |
| 8866 if (node.semicolon != null) { | 8849 if (node.semicolon != null) { |
| 8867 _writer.print(';'); | 8850 _writer.print(';'); |
| 8868 } | 8851 } |
| 8869 return null; | 8852 return null; |
| 8870 } | 8853 } |
| 8871 | 8854 |
| 8872 Object visitExpressionStatement(ExpressionStatement node) { | 8855 Object visitExpressionStatement(ExpressionStatement node) { |
| 8873 visitNode(node.expression); | 8856 _visitNode(node.expression); |
| 8874 _writer.print(';'); | 8857 _writer.print(';'); |
| 8875 return null; | 8858 return null; |
| 8876 } | 8859 } |
| 8877 | 8860 |
| 8878 Object visitExtendsClause(ExtendsClause node) { | 8861 Object visitExtendsClause(ExtendsClause node) { |
| 8879 _writer.print("extends "); | 8862 _writer.print("extends "); |
| 8880 visitNode(node.superclass); | 8863 _visitNode(node.superclass); |
| 8881 return null; | 8864 return null; |
| 8882 } | 8865 } |
| 8883 | 8866 |
| 8884 Object visitFieldDeclaration(FieldDeclaration node) { | 8867 Object visitFieldDeclaration(FieldDeclaration node) { |
| 8885 visitNode(node.documentationComment); | 8868 _visitNode(node.documentationComment); |
| 8886 visitTokenWithSuffix(node.staticKeyword, " "); | 8869 _visitTokenWithSuffix(node.staticKeyword, " "); |
| 8887 visitNode(node.fields); | 8870 _visitNode(node.fields); |
| 8888 _writer.print(";"); | 8871 _writer.print(";"); |
| 8889 return null; | 8872 return null; |
| 8890 } | 8873 } |
| 8891 | 8874 |
| 8892 Object visitFieldFormalParameter(FieldFormalParameter node) { | 8875 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 8893 visitTokenWithSuffix(node.keyword, " "); | 8876 _visitTokenWithSuffix(node.keyword, " "); |
| 8894 visitNodeWithSuffix(node.type, " "); | 8877 _visitNodeWithSuffix(node.type, " "); |
| 8895 _writer.print("this."); | 8878 _writer.print("this."); |
| 8896 visitNode(node.identifier); | 8879 _visitNode(node.identifier); |
| 8897 visitNode(node.parameters); | 8880 _visitNode(node.parameters); |
| 8898 return null; | 8881 return null; |
| 8899 } | 8882 } |
| 8900 | 8883 |
| 8901 Object visitForEachStatement(ForEachStatement node) { | 8884 Object visitForEachStatement(ForEachStatement node) { |
| 8902 DeclaredIdentifier loopVariable = node.loopVariable; | 8885 DeclaredIdentifier loopVariable = node.loopVariable; |
| 8903 _writer.print("for ("); | 8886 _writer.print("for ("); |
| 8904 if (loopVariable == null) { | 8887 if (loopVariable == null) { |
| 8905 visitNode(node.identifier); | 8888 _visitNode(node.identifier); |
| 8906 } else { | 8889 } else { |
| 8907 visitNode(loopVariable); | 8890 _visitNode(loopVariable); |
| 8908 } | 8891 } |
| 8909 _writer.print(" in "); | 8892 _writer.print(" in "); |
| 8910 visitNode(node.iterator); | 8893 _visitNode(node.iterator); |
| 8911 _writer.print(") "); | 8894 _writer.print(") "); |
| 8912 visitNode(node.body); | 8895 _visitNode(node.body); |
| 8913 return null; | 8896 return null; |
| 8914 } | 8897 } |
| 8915 | 8898 |
| 8916 Object visitFormalParameterList(FormalParameterList node) { | 8899 Object visitFormalParameterList(FormalParameterList node) { |
| 8917 String groupEnd = null; | 8900 String groupEnd = null; |
| 8918 _writer.print('('); | 8901 _writer.print('('); |
| 8919 NodeList<FormalParameter> parameters = node.parameters; | 8902 NodeList<FormalParameter> parameters = node.parameters; |
| 8920 int size = parameters.length; | 8903 int size = parameters.length; |
| 8921 for (int i = 0; i < size; i++) { | 8904 for (int i = 0; i < size; i++) { |
| 8922 FormalParameter parameter = parameters[i]; | 8905 FormalParameter parameter = parameters[i]; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8938 _writer.print(groupEnd); | 8921 _writer.print(groupEnd); |
| 8939 } | 8922 } |
| 8940 _writer.print(')'); | 8923 _writer.print(')'); |
| 8941 return null; | 8924 return null; |
| 8942 } | 8925 } |
| 8943 | 8926 |
| 8944 Object visitForStatement(ForStatement node) { | 8927 Object visitForStatement(ForStatement node) { |
| 8945 Expression initialization = node.initialization; | 8928 Expression initialization = node.initialization; |
| 8946 _writer.print("for ("); | 8929 _writer.print("for ("); |
| 8947 if (initialization != null) { | 8930 if (initialization != null) { |
| 8948 visitNode(initialization); | 8931 _visitNode(initialization); |
| 8949 } else { | 8932 } else { |
| 8950 visitNode(node.variables); | 8933 _visitNode(node.variables); |
| 8951 } | 8934 } |
| 8952 _writer.print(";"); | 8935 _writer.print(";"); |
| 8953 visitNodeWithPrefix(" ", node.condition); | 8936 _visitNodeWithPrefix(" ", node.condition); |
| 8954 _writer.print(";"); | 8937 _writer.print(";"); |
| 8955 visitNodeListWithSeparatorAndPrefix(" ", node.updaters, ", "); | 8938 _visitNodeListWithSeparatorAndPrefix(" ", node.updaters, ", "); |
| 8956 _writer.print(") "); | 8939 _writer.print(") "); |
| 8957 visitNode(node.body); | 8940 _visitNode(node.body); |
| 8958 return null; | 8941 return null; |
| 8959 } | 8942 } |
| 8960 | 8943 |
| 8961 Object visitFunctionDeclaration(FunctionDeclaration node) { | 8944 Object visitFunctionDeclaration(FunctionDeclaration node) { |
| 8962 visitNodeWithSuffix(node.returnType, " "); | 8945 _visitNodeWithSuffix(node.returnType, " "); |
| 8963 visitTokenWithSuffix(node.propertyKeyword, " "); | 8946 _visitTokenWithSuffix(node.propertyKeyword, " "); |
| 8964 visitNode(node.name); | 8947 _visitNode(node.name); |
| 8965 visitNode(node.functionExpression); | 8948 _visitNode(node.functionExpression); |
| 8966 return null; | 8949 return null; |
| 8967 } | 8950 } |
| 8968 | 8951 |
| 8969 Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { | 8952 Object visitFunctionDeclarationStatement(FunctionDeclarationStatement node) { |
| 8970 visitNode(node.functionDeclaration); | 8953 _visitNode(node.functionDeclaration); |
| 8971 _writer.print(';'); | 8954 _writer.print(';'); |
| 8972 return null; | 8955 return null; |
| 8973 } | 8956 } |
| 8974 | 8957 |
| 8975 Object visitFunctionExpression(FunctionExpression node) { | 8958 Object visitFunctionExpression(FunctionExpression node) { |
| 8976 visitNode(node.parameters); | 8959 _visitNode(node.parameters); |
| 8977 _writer.print(' '); | 8960 _writer.print(' '); |
| 8978 visitNode(node.body); | 8961 _visitNode(node.body); |
| 8979 return null; | 8962 return null; |
| 8980 } | 8963 } |
| 8981 | 8964 |
| 8982 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { | 8965 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { |
| 8983 visitNode(node.function); | 8966 _visitNode(node.function); |
| 8984 visitNode(node.argumentList); | 8967 _visitNode(node.argumentList); |
| 8985 return null; | 8968 return null; |
| 8986 } | 8969 } |
| 8987 | 8970 |
| 8988 Object visitFunctionTypeAlias(FunctionTypeAlias node) { | 8971 Object visitFunctionTypeAlias(FunctionTypeAlias node) { |
| 8989 _writer.print("typedef "); | 8972 _writer.print("typedef "); |
| 8990 visitNodeWithSuffix(node.returnType, " "); | 8973 _visitNodeWithSuffix(node.returnType, " "); |
| 8991 visitNode(node.name); | 8974 _visitNode(node.name); |
| 8992 visitNode(node.typeParameters); | 8975 _visitNode(node.typeParameters); |
| 8993 visitNode(node.parameters); | 8976 _visitNode(node.parameters); |
| 8994 _writer.print(";"); | 8977 _writer.print(";"); |
| 8995 return null; | 8978 return null; |
| 8996 } | 8979 } |
| 8997 | 8980 |
| 8998 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { | 8981 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { |
| 8999 visitNodeWithSuffix(node.returnType, " "); | 8982 _visitNodeWithSuffix(node.returnType, " "); |
| 9000 visitNode(node.identifier); | 8983 _visitNode(node.identifier); |
| 9001 visitNode(node.parameters); | 8984 _visitNode(node.parameters); |
| 9002 return null; | 8985 return null; |
| 9003 } | 8986 } |
| 9004 | 8987 |
| 9005 Object visitHideCombinator(HideCombinator node) { | 8988 Object visitHideCombinator(HideCombinator node) { |
| 9006 _writer.print("hide "); | 8989 _writer.print("hide "); |
| 9007 visitNodeListWithSeparator(node.hiddenNames, ", "); | 8990 _visitNodeListWithSeparator(node.hiddenNames, ", "); |
| 9008 return null; | 8991 return null; |
| 9009 } | 8992 } |
| 9010 | 8993 |
| 9011 Object visitIfStatement(IfStatement node) { | 8994 Object visitIfStatement(IfStatement node) { |
| 9012 _writer.print("if ("); | 8995 _writer.print("if ("); |
| 9013 visitNode(node.condition); | 8996 _visitNode(node.condition); |
| 9014 _writer.print(") "); | 8997 _writer.print(") "); |
| 9015 visitNode(node.thenStatement); | 8998 _visitNode(node.thenStatement); |
| 9016 visitNodeWithPrefix(" else ", node.elseStatement); | 8999 _visitNodeWithPrefix(" else ", node.elseStatement); |
| 9017 return null; | 9000 return null; |
| 9018 } | 9001 } |
| 9019 | 9002 |
| 9020 Object visitImplementsClause(ImplementsClause node) { | 9003 Object visitImplementsClause(ImplementsClause node) { |
| 9021 _writer.print("implements "); | 9004 _writer.print("implements "); |
| 9022 visitNodeListWithSeparator(node.interfaces, ", "); | 9005 _visitNodeListWithSeparator(node.interfaces, ", "); |
| 9023 return null; | 9006 return null; |
| 9024 } | 9007 } |
| 9025 | 9008 |
| 9026 Object visitImportDirective(ImportDirective node) { | 9009 Object visitImportDirective(ImportDirective node) { |
| 9027 _writer.print("import "); | 9010 _writer.print("import "); |
| 9028 visitNode(node.uri); | 9011 _visitNode(node.uri); |
| 9029 visitNodeWithPrefix(" as ", node.prefix); | 9012 _visitNodeWithPrefix(" as ", node.prefix); |
| 9030 visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " "); | 9013 _visitNodeListWithSeparatorAndPrefix(" ", node.combinators, " "); |
| 9031 _writer.print(';'); | 9014 _writer.print(';'); |
| 9032 return null; | 9015 return null; |
| 9033 } | 9016 } |
| 9034 | 9017 |
| 9035 Object visitIndexExpression(IndexExpression node) { | 9018 Object visitIndexExpression(IndexExpression node) { |
| 9036 if (node.isCascaded) { | 9019 if (node.isCascaded) { |
| 9037 _writer.print(".."); | 9020 _writer.print(".."); |
| 9038 } else { | 9021 } else { |
| 9039 visitNode(node.target); | 9022 _visitNode(node.target); |
| 9040 } | 9023 } |
| 9041 _writer.print('['); | 9024 _writer.print('['); |
| 9042 visitNode(node.index); | 9025 _visitNode(node.index); |
| 9043 _writer.print(']'); | 9026 _writer.print(']'); |
| 9044 return null; | 9027 return null; |
| 9045 } | 9028 } |
| 9046 | 9029 |
| 9047 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 9030 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 9048 visitTokenWithSuffix(node.keyword, " "); | 9031 _visitTokenWithSuffix(node.keyword, " "); |
| 9049 visitNode(node.constructorName); | 9032 _visitNode(node.constructorName); |
| 9050 visitNode(node.argumentList); | 9033 _visitNode(node.argumentList); |
| 9051 return null; | 9034 return null; |
| 9052 } | 9035 } |
| 9053 | 9036 |
| 9054 Object visitIntegerLiteral(IntegerLiteral node) { | 9037 Object visitIntegerLiteral(IntegerLiteral node) { |
| 9055 _writer.print(node.literal.lexeme); | 9038 _writer.print(node.literal.lexeme); |
| 9056 return null; | 9039 return null; |
| 9057 } | 9040 } |
| 9058 | 9041 |
| 9059 Object visitInterpolationExpression(InterpolationExpression node) { | 9042 Object visitInterpolationExpression(InterpolationExpression node) { |
| 9060 if (node.rightBracket != null) { | 9043 if (node.rightBracket != null) { |
| 9061 _writer.print("\${"); | 9044 _writer.print("\${"); |
| 9062 visitNode(node.expression); | 9045 _visitNode(node.expression); |
| 9063 _writer.print("}"); | 9046 _writer.print("}"); |
| 9064 } else { | 9047 } else { |
| 9065 _writer.print("\$"); | 9048 _writer.print("\$"); |
| 9066 visitNode(node.expression); | 9049 _visitNode(node.expression); |
| 9067 } | 9050 } |
| 9068 return null; | 9051 return null; |
| 9069 } | 9052 } |
| 9070 | 9053 |
| 9071 Object visitInterpolationString(InterpolationString node) { | 9054 Object visitInterpolationString(InterpolationString node) { |
| 9072 _writer.print(node.contents.lexeme); | 9055 _writer.print(node.contents.lexeme); |
| 9073 return null; | 9056 return null; |
| 9074 } | 9057 } |
| 9075 | 9058 |
| 9076 Object visitIsExpression(IsExpression node) { | 9059 Object visitIsExpression(IsExpression node) { |
| 9077 visitNode(node.expression); | 9060 _visitNode(node.expression); |
| 9078 if (node.notOperator == null) { | 9061 if (node.notOperator == null) { |
| 9079 _writer.print(" is "); | 9062 _writer.print(" is "); |
| 9080 } else { | 9063 } else { |
| 9081 _writer.print(" is! "); | 9064 _writer.print(" is! "); |
| 9082 } | 9065 } |
| 9083 visitNode(node.type); | 9066 _visitNode(node.type); |
| 9084 return null; | 9067 return null; |
| 9085 } | 9068 } |
| 9086 | 9069 |
| 9087 Object visitLabel(Label node) { | 9070 Object visitLabel(Label node) { |
| 9088 visitNode(node.label); | 9071 _visitNode(node.label); |
| 9089 _writer.print(":"); | 9072 _writer.print(":"); |
| 9090 return null; | 9073 return null; |
| 9091 } | 9074 } |
| 9092 | 9075 |
| 9093 Object visitLabeledStatement(LabeledStatement node) { | 9076 Object visitLabeledStatement(LabeledStatement node) { |
| 9094 visitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); | 9077 _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); |
| 9095 visitNode(node.statement); | 9078 _visitNode(node.statement); |
| 9096 return null; | 9079 return null; |
| 9097 } | 9080 } |
| 9098 | 9081 |
| 9099 Object visitLibraryDirective(LibraryDirective node) { | 9082 Object visitLibraryDirective(LibraryDirective node) { |
| 9100 _writer.print("library "); | 9083 _writer.print("library "); |
| 9101 visitNode(node.name); | 9084 _visitNode(node.name); |
| 9102 _writer.print(';'); | 9085 _writer.print(';'); |
| 9103 nl(); | 9086 _nl(); |
| 9104 return null; | 9087 return null; |
| 9105 } | 9088 } |
| 9106 | 9089 |
| 9107 Object visitLibraryIdentifier(LibraryIdentifier node) { | 9090 Object visitLibraryIdentifier(LibraryIdentifier node) { |
| 9108 _writer.print(node.name); | 9091 _writer.print(node.name); |
| 9109 return null; | 9092 return null; |
| 9110 } | 9093 } |
| 9111 | 9094 |
| 9112 Object visitListLiteral(ListLiteral node) { | 9095 Object visitListLiteral(ListLiteral node) { |
| 9113 if (node.constKeyword != null) { | 9096 if (node.constKeyword != null) { |
| 9114 _writer.print(node.constKeyword.lexeme); | 9097 _writer.print(node.constKeyword.lexeme); |
| 9115 _writer.print(' '); | 9098 _writer.print(' '); |
| 9116 } | 9099 } |
| 9117 visitNodeWithSuffix(node.typeArguments, " "); | 9100 _visitNodeWithSuffix(node.typeArguments, " "); |
| 9118 _writer.print("["); | 9101 _writer.print("["); |
| 9119 { | 9102 { |
| 9120 NodeList<Expression> elements = node.elements; | 9103 NodeList<Expression> elements = node.elements; |
| 9121 if (elements.length < 2 || elements.toString().length < 60) { | 9104 if (elements.length < 2 || elements.toString().length < 60) { |
| 9122 visitNodeListWithSeparator(elements, ", "); | 9105 _visitNodeListWithSeparator(elements, ", "); |
| 9123 } else { | 9106 } else { |
| 9124 String elementIndent = "${_indentString} "; | 9107 String elementIndent = "${_indentString} "; |
| 9125 _writer.print("\n"); | 9108 _writer.print("\n"); |
| 9126 _writer.print(elementIndent); | 9109 _writer.print(elementIndent); |
| 9127 visitNodeListWithSeparator(elements, ",\n${elementIndent}"); | 9110 _visitNodeListWithSeparator(elements, ",\n${elementIndent}"); |
| 9128 } | 9111 } |
| 9129 } | 9112 } |
| 9130 _writer.print("]"); | 9113 _writer.print("]"); |
| 9131 return null; | 9114 return null; |
| 9132 } | 9115 } |
| 9133 | 9116 |
| 9134 Object visitMapLiteral(MapLiteral node) { | 9117 Object visitMapLiteral(MapLiteral node) { |
| 9135 if (node.constKeyword != null) { | 9118 if (node.constKeyword != null) { |
| 9136 _writer.print(node.constKeyword.lexeme); | 9119 _writer.print(node.constKeyword.lexeme); |
| 9137 _writer.print(' '); | 9120 _writer.print(' '); |
| 9138 } | 9121 } |
| 9139 visitNodeWithSuffix(node.typeArguments, " "); | 9122 _visitNodeWithSuffix(node.typeArguments, " "); |
| 9140 _writer.print("{"); | 9123 _writer.print("{"); |
| 9141 visitNodeListWithSeparator(node.entries, ", "); | 9124 _visitNodeListWithSeparator(node.entries, ", "); |
| 9142 _writer.print("}"); | 9125 _writer.print("}"); |
| 9143 return null; | 9126 return null; |
| 9144 } | 9127 } |
| 9145 | 9128 |
| 9146 Object visitMapLiteralEntry(MapLiteralEntry node) { | 9129 Object visitMapLiteralEntry(MapLiteralEntry node) { |
| 9147 visitNode(node.key); | 9130 _visitNode(node.key); |
| 9148 _writer.print(" : "); | 9131 _writer.print(" : "); |
| 9149 visitNode(node.value); | 9132 _visitNode(node.value); |
| 9150 return null; | 9133 return null; |
| 9151 } | 9134 } |
| 9152 | 9135 |
| 9153 Object visitMethodDeclaration(MethodDeclaration node) { | 9136 Object visitMethodDeclaration(MethodDeclaration node) { |
| 9154 visitNode(node.documentationComment); | 9137 _visitNode(node.documentationComment); |
| 9155 visitTokenWithSuffix(node.externalKeyword, " "); | 9138 _visitTokenWithSuffix(node.externalKeyword, " "); |
| 9156 visitTokenWithSuffix(node.modifierKeyword, " "); | 9139 _visitTokenWithSuffix(node.modifierKeyword, " "); |
| 9157 visitNodeWithSuffix(node.returnType, " "); | 9140 _visitNodeWithSuffix(node.returnType, " "); |
| 9158 visitTokenWithSuffix(node.propertyKeyword, " "); | 9141 _visitTokenWithSuffix(node.propertyKeyword, " "); |
| 9159 visitTokenWithSuffix(node.operatorKeyword, " "); | 9142 _visitTokenWithSuffix(node.operatorKeyword, " "); |
| 9160 visitNode(node.name); | 9143 _visitNode(node.name); |
| 9161 if (!node.isGetter) { | 9144 if (!node.isGetter) { |
| 9162 visitNode(node.parameters); | 9145 _visitNode(node.parameters); |
| 9163 } | 9146 } |
| 9164 if (node.body is! EmptyFunctionBody) { | 9147 if (node.body is! EmptyFunctionBody) { |
| 9165 _writer.print(' '); | 9148 _writer.print(' '); |
| 9166 } | 9149 } |
| 9167 visitNode(node.body); | 9150 _visitNode(node.body); |
| 9168 return null; | 9151 return null; |
| 9169 } | 9152 } |
| 9170 | 9153 |
| 9171 Object visitMethodInvocation(MethodInvocation node) { | 9154 Object visitMethodInvocation(MethodInvocation node) { |
| 9172 if (node.isCascaded) { | 9155 if (node.isCascaded) { |
| 9173 _writer.print(".."); | 9156 _writer.print(".."); |
| 9174 } else { | 9157 } else { |
| 9175 visitNodeWithSuffix(node.target, "."); | 9158 _visitNodeWithSuffix(node.target, "."); |
| 9176 } | 9159 } |
| 9177 visitNode(node.methodName); | 9160 _visitNode(node.methodName); |
| 9178 visitNode(node.argumentList); | 9161 _visitNode(node.argumentList); |
| 9179 return null; | 9162 return null; |
| 9180 } | 9163 } |
| 9181 | 9164 |
| 9182 Object visitNamedExpression(NamedExpression node) { | 9165 Object visitNamedExpression(NamedExpression node) { |
| 9183 visitNode(node.name); | 9166 _visitNode(node.name); |
| 9184 visitNodeWithPrefix(" ", node.expression); | 9167 _visitNodeWithPrefix(" ", node.expression); |
| 9185 return null; | 9168 return null; |
| 9186 } | 9169 } |
| 9187 | 9170 |
| 9188 Object visitNativeClause(NativeClause node) { | 9171 Object visitNativeClause(NativeClause node) { |
| 9189 _writer.print("native "); | 9172 _writer.print("native "); |
| 9190 visitNode(node.name); | 9173 _visitNode(node.name); |
| 9191 return null; | 9174 return null; |
| 9192 } | 9175 } |
| 9193 | 9176 |
| 9194 Object visitNativeFunctionBody(NativeFunctionBody node) { | 9177 Object visitNativeFunctionBody(NativeFunctionBody node) { |
| 9195 _writer.print("native "); | 9178 _writer.print("native "); |
| 9196 visitNode(node.stringLiteral); | 9179 _visitNode(node.stringLiteral); |
| 9197 _writer.print(';'); | 9180 _writer.print(';'); |
| 9198 return null; | 9181 return null; |
| 9199 } | 9182 } |
| 9200 | 9183 |
| 9201 Object visitNullLiteral(NullLiteral node) { | 9184 Object visitNullLiteral(NullLiteral node) { |
| 9202 _writer.print("null"); | 9185 _writer.print("null"); |
| 9203 return null; | 9186 return null; |
| 9204 } | 9187 } |
| 9205 | 9188 |
| 9206 Object visitParenthesizedExpression(ParenthesizedExpression node) { | 9189 Object visitParenthesizedExpression(ParenthesizedExpression node) { |
| 9207 _writer.print('('); | 9190 _writer.print('('); |
| 9208 visitNode(node.expression); | 9191 _visitNode(node.expression); |
| 9209 _writer.print(')'); | 9192 _writer.print(')'); |
| 9210 return null; | 9193 return null; |
| 9211 } | 9194 } |
| 9212 | 9195 |
| 9213 Object visitPartDirective(PartDirective node) { | 9196 Object visitPartDirective(PartDirective node) { |
| 9214 _writer.print("part "); | 9197 _writer.print("part "); |
| 9215 visitNode(node.uri); | 9198 _visitNode(node.uri); |
| 9216 _writer.print(';'); | 9199 _writer.print(';'); |
| 9217 return null; | 9200 return null; |
| 9218 } | 9201 } |
| 9219 | 9202 |
| 9220 Object visitPartOfDirective(PartOfDirective node) { | 9203 Object visitPartOfDirective(PartOfDirective node) { |
| 9221 _writer.print("part of "); | 9204 _writer.print("part of "); |
| 9222 visitNode(node.libraryName); | 9205 _visitNode(node.libraryName); |
| 9223 _writer.print(';'); | 9206 _writer.print(';'); |
| 9224 return null; | 9207 return null; |
| 9225 } | 9208 } |
| 9226 | 9209 |
| 9227 Object visitPostfixExpression(PostfixExpression node) { | 9210 Object visitPostfixExpression(PostfixExpression node) { |
| 9228 visitNode(node.operand); | 9211 _visitNode(node.operand); |
| 9229 _writer.print(node.operator.lexeme); | 9212 _writer.print(node.operator.lexeme); |
| 9230 return null; | 9213 return null; |
| 9231 } | 9214 } |
| 9232 | 9215 |
| 9233 Object visitPrefixedIdentifier(PrefixedIdentifier node) { | 9216 Object visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 9234 visitNode(node.prefix); | 9217 _visitNode(node.prefix); |
| 9235 _writer.print('.'); | 9218 _writer.print('.'); |
| 9236 visitNode(node.identifier); | 9219 _visitNode(node.identifier); |
| 9237 return null; | 9220 return null; |
| 9238 } | 9221 } |
| 9239 | 9222 |
| 9240 Object visitPrefixExpression(PrefixExpression node) { | 9223 Object visitPrefixExpression(PrefixExpression node) { |
| 9241 _writer.print(node.operator.lexeme); | 9224 _writer.print(node.operator.lexeme); |
| 9242 visitNode(node.operand); | 9225 _visitNode(node.operand); |
| 9243 return null; | 9226 return null; |
| 9244 } | 9227 } |
| 9245 | 9228 |
| 9246 Object visitPropertyAccess(PropertyAccess node) { | 9229 Object visitPropertyAccess(PropertyAccess node) { |
| 9247 if (node.isCascaded) { | 9230 if (node.isCascaded) { |
| 9248 _writer.print(".."); | 9231 _writer.print(".."); |
| 9249 } else { | 9232 } else { |
| 9250 visitNodeWithSuffix(node.target, "."); | 9233 _visitNodeWithSuffix(node.target, "."); |
| 9251 } | 9234 } |
| 9252 visitNode(node.propertyName); | 9235 _visitNode(node.propertyName); |
| 9253 return null; | 9236 return null; |
| 9254 } | 9237 } |
| 9255 | 9238 |
| 9256 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { | 9239 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation
node) { |
| 9257 _writer.print("this"); | 9240 _writer.print("this"); |
| 9258 visitNodeWithPrefix(".", node.constructorName); | 9241 _visitNodeWithPrefix(".", node.constructorName); |
| 9259 visitNode(node.argumentList); | 9242 _visitNode(node.argumentList); |
| 9260 return null; | 9243 return null; |
| 9261 } | 9244 } |
| 9262 | 9245 |
| 9263 Object visitRethrowExpression(RethrowExpression node) { | 9246 Object visitRethrowExpression(RethrowExpression node) { |
| 9264 _writer.print("rethrow"); | 9247 _writer.print("rethrow"); |
| 9265 return null; | 9248 return null; |
| 9266 } | 9249 } |
| 9267 | 9250 |
| 9268 Object visitReturnStatement(ReturnStatement node) { | 9251 Object visitReturnStatement(ReturnStatement node) { |
| 9269 Expression expression = node.expression; | 9252 Expression expression = node.expression; |
| 9270 if (expression == null) { | 9253 if (expression == null) { |
| 9271 _writer.print("return;"); | 9254 _writer.print("return;"); |
| 9272 } else { | 9255 } else { |
| 9273 _writer.print("return "); | 9256 _writer.print("return "); |
| 9274 expression.accept(this); | 9257 expression.accept(this); |
| 9275 _writer.print(";"); | 9258 _writer.print(";"); |
| 9276 } | 9259 } |
| 9277 return null; | 9260 return null; |
| 9278 } | 9261 } |
| 9279 | 9262 |
| 9280 Object visitScriptTag(ScriptTag node) { | 9263 Object visitScriptTag(ScriptTag node) { |
| 9281 _writer.print(node.scriptTag.lexeme); | 9264 _writer.print(node.scriptTag.lexeme); |
| 9282 return null; | 9265 return null; |
| 9283 } | 9266 } |
| 9284 | 9267 |
| 9285 Object visitShowCombinator(ShowCombinator node) { | 9268 Object visitShowCombinator(ShowCombinator node) { |
| 9286 _writer.print("show "); | 9269 _writer.print("show "); |
| 9287 visitNodeListWithSeparator(node.shownNames, ", "); | 9270 _visitNodeListWithSeparator(node.shownNames, ", "); |
| 9288 return null; | 9271 return null; |
| 9289 } | 9272 } |
| 9290 | 9273 |
| 9291 Object visitSimpleFormalParameter(SimpleFormalParameter node) { | 9274 Object visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 9292 visitTokenWithSuffix(node.keyword, " "); | 9275 _visitTokenWithSuffix(node.keyword, " "); |
| 9293 visitNodeWithSuffix(node.type, " "); | 9276 _visitNodeWithSuffix(node.type, " "); |
| 9294 visitNode(node.identifier); | 9277 _visitNode(node.identifier); |
| 9295 return null; | 9278 return null; |
| 9296 } | 9279 } |
| 9297 | 9280 |
| 9298 Object visitSimpleIdentifier(SimpleIdentifier node) { | 9281 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 9299 _writer.print(node.token.lexeme); | 9282 _writer.print(node.token.lexeme); |
| 9300 return null; | 9283 return null; |
| 9301 } | 9284 } |
| 9302 | 9285 |
| 9303 Object visitSimpleStringLiteral(SimpleStringLiteral node) { | 9286 Object visitSimpleStringLiteral(SimpleStringLiteral node) { |
| 9304 _writer.print(node.literal.lexeme); | 9287 _writer.print(node.literal.lexeme); |
| 9305 return null; | 9288 return null; |
| 9306 } | 9289 } |
| 9307 | 9290 |
| 9308 Object visitStringInterpolation(StringInterpolation node) { | 9291 Object visitStringInterpolation(StringInterpolation node) { |
| 9309 visitNodeList(node.elements); | 9292 _visitNodeList(node.elements); |
| 9310 return null; | 9293 return null; |
| 9311 } | 9294 } |
| 9312 | 9295 |
| 9313 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 9296 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 9314 _writer.print("super"); | 9297 _writer.print("super"); |
| 9315 visitNodeWithPrefix(".", node.constructorName); | 9298 _visitNodeWithPrefix(".", node.constructorName); |
| 9316 visitNode(node.argumentList); | 9299 _visitNode(node.argumentList); |
| 9317 return null; | 9300 return null; |
| 9318 } | 9301 } |
| 9319 | 9302 |
| 9320 Object visitSuperExpression(SuperExpression node) { | 9303 Object visitSuperExpression(SuperExpression node) { |
| 9321 _writer.print("super"); | 9304 _writer.print("super"); |
| 9322 return null; | 9305 return null; |
| 9323 } | 9306 } |
| 9324 | 9307 |
| 9325 Object visitSwitchCase(SwitchCase node) { | 9308 Object visitSwitchCase(SwitchCase node) { |
| 9326 visitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); | 9309 _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); |
| 9327 _writer.print("case "); | 9310 _writer.print("case "); |
| 9328 visitNode(node.expression); | 9311 _visitNode(node.expression); |
| 9329 _writer.print(": "); | 9312 _writer.print(": "); |
| 9330 { | 9313 { |
| 9331 indentInc(); | 9314 _indentInc(); |
| 9332 visitNodeListWithSeparator(node.statements, "\n"); | 9315 _visitNodeListWithSeparator(node.statements, "\n"); |
| 9333 indentDec(); | 9316 _indentDec(); |
| 9334 } | 9317 } |
| 9335 return null; | 9318 return null; |
| 9336 } | 9319 } |
| 9337 | 9320 |
| 9338 Object visitSwitchDefault(SwitchDefault node) { | 9321 Object visitSwitchDefault(SwitchDefault node) { |
| 9339 visitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); | 9322 _visitNodeListWithSeparatorAndSuffix(node.labels, " ", " "); |
| 9340 _writer.print("default: "); | 9323 _writer.print("default: "); |
| 9341 { | 9324 { |
| 9342 indentInc(); | 9325 _indentInc(); |
| 9343 visitNodeListWithSeparator(node.statements, "\n"); | 9326 _visitNodeListWithSeparator(node.statements, "\n"); |
| 9344 indentDec(); | 9327 _indentDec(); |
| 9345 } | 9328 } |
| 9346 return null; | 9329 return null; |
| 9347 } | 9330 } |
| 9348 | 9331 |
| 9349 Object visitSwitchStatement(SwitchStatement node) { | 9332 Object visitSwitchStatement(SwitchStatement node) { |
| 9350 _writer.print("switch ("); | 9333 _writer.print("switch ("); |
| 9351 visitNode(node.expression); | 9334 _visitNode(node.expression); |
| 9352 _writer.print(") {"); | 9335 _writer.print(") {"); |
| 9353 { | 9336 { |
| 9354 indentInc(); | 9337 _indentInc(); |
| 9355 visitNodeListWithSeparator(node.members, "\n"); | 9338 _visitNodeListWithSeparator(node.members, "\n"); |
| 9356 indentDec(); | 9339 _indentDec(); |
| 9357 } | 9340 } |
| 9358 nl2(); | 9341 _nl2(); |
| 9359 _writer.print('}'); | 9342 _writer.print('}'); |
| 9360 return null; | 9343 return null; |
| 9361 } | 9344 } |
| 9362 | 9345 |
| 9363 Object visitSymbolLiteral(SymbolLiteral node) { | 9346 Object visitSymbolLiteral(SymbolLiteral node) { |
| 9364 _writer.print("#"); | 9347 _writer.print("#"); |
| 9365 visitTokenListWithSeparator(node.components, "."); | 9348 _visitTokenListWithSeparator(node.components, "."); |
| 9366 return null; | 9349 return null; |
| 9367 } | 9350 } |
| 9368 | 9351 |
| 9369 Object visitThisExpression(ThisExpression node) { | 9352 Object visitThisExpression(ThisExpression node) { |
| 9370 _writer.print("this"); | 9353 _writer.print("this"); |
| 9371 return null; | 9354 return null; |
| 9372 } | 9355 } |
| 9373 | 9356 |
| 9374 Object visitThrowExpression(ThrowExpression node) { | 9357 Object visitThrowExpression(ThrowExpression node) { |
| 9375 _writer.print("throw "); | 9358 _writer.print("throw "); |
| 9376 visitNode(node.expression); | 9359 _visitNode(node.expression); |
| 9377 return null; | 9360 return null; |
| 9378 } | 9361 } |
| 9379 | 9362 |
| 9380 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { | 9363 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
| 9381 visitNodeWithSuffix(node.variables, ";"); | 9364 _visitNodeWithSuffix(node.variables, ";"); |
| 9382 return null; | 9365 return null; |
| 9383 } | 9366 } |
| 9384 | 9367 |
| 9385 Object visitTryStatement(TryStatement node) { | 9368 Object visitTryStatement(TryStatement node) { |
| 9386 _writer.print("try "); | 9369 _writer.print("try "); |
| 9387 visitNode(node.body); | 9370 _visitNode(node.body); |
| 9388 visitNodeListWithSeparatorAndPrefix(" ", node.catchClauses, " "); | 9371 _visitNodeListWithSeparatorAndPrefix(" ", node.catchClauses, " "); |
| 9389 visitNodeWithPrefix(" finally ", node.finallyBlock); | 9372 _visitNodeWithPrefix(" finally ", node.finallyBlock); |
| 9390 return null; | 9373 return null; |
| 9391 } | 9374 } |
| 9392 | 9375 |
| 9393 Object visitTypeArgumentList(TypeArgumentList node) { | 9376 Object visitTypeArgumentList(TypeArgumentList node) { |
| 9394 _writer.print('<'); | 9377 _writer.print('<'); |
| 9395 visitNodeListWithSeparator(node.arguments, ", "); | 9378 _visitNodeListWithSeparator(node.arguments, ", "); |
| 9396 _writer.print('>'); | 9379 _writer.print('>'); |
| 9397 return null; | 9380 return null; |
| 9398 } | 9381 } |
| 9399 | 9382 |
| 9400 Object visitTypeName(TypeName node) { | 9383 Object visitTypeName(TypeName node) { |
| 9401 visitNode(node.name); | 9384 _visitNode(node.name); |
| 9402 visitNode(node.typeArguments); | 9385 _visitNode(node.typeArguments); |
| 9403 return null; | 9386 return null; |
| 9404 } | 9387 } |
| 9405 | 9388 |
| 9406 Object visitTypeParameter(TypeParameter node) { | 9389 Object visitTypeParameter(TypeParameter node) { |
| 9407 visitNode(node.name); | 9390 _visitNode(node.name); |
| 9408 visitNodeWithPrefix(" extends ", node.bound); | 9391 _visitNodeWithPrefix(" extends ", node.bound); |
| 9409 return null; | 9392 return null; |
| 9410 } | 9393 } |
| 9411 | 9394 |
| 9412 Object visitTypeParameterList(TypeParameterList node) { | 9395 Object visitTypeParameterList(TypeParameterList node) { |
| 9413 _writer.print('<'); | 9396 _writer.print('<'); |
| 9414 visitNodeListWithSeparator(node.typeParameters, ", "); | 9397 _visitNodeListWithSeparator(node.typeParameters, ", "); |
| 9415 _writer.print('>'); | 9398 _writer.print('>'); |
| 9416 return null; | 9399 return null; |
| 9417 } | 9400 } |
| 9418 | 9401 |
| 9419 Object visitVariableDeclaration(VariableDeclaration node) { | 9402 Object visitVariableDeclaration(VariableDeclaration node) { |
| 9420 visitNode(node.name); | 9403 _visitNode(node.name); |
| 9421 visitNodeWithPrefix(" = ", node.initializer); | 9404 _visitNodeWithPrefix(" = ", node.initializer); |
| 9422 return null; | 9405 return null; |
| 9423 } | 9406 } |
| 9424 | 9407 |
| 9425 Object visitVariableDeclarationList(VariableDeclarationList node) { | 9408 Object visitVariableDeclarationList(VariableDeclarationList node) { |
| 9426 visitTokenWithSuffix(node.keyword, " "); | 9409 _visitTokenWithSuffix(node.keyword, " "); |
| 9427 visitNodeWithSuffix(node.type, " "); | 9410 _visitNodeWithSuffix(node.type, " "); |
| 9428 visitNodeListWithSeparator(node.variables, ", "); | 9411 _visitNodeListWithSeparator(node.variables, ", "); |
| 9429 return null; | 9412 return null; |
| 9430 } | 9413 } |
| 9431 | 9414 |
| 9432 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 9415 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 9433 visitNode(node.variables); | 9416 _visitNode(node.variables); |
| 9434 _writer.print(";"); | 9417 _writer.print(";"); |
| 9435 return null; | 9418 return null; |
| 9436 } | 9419 } |
| 9437 | 9420 |
| 9438 Object visitWhileStatement(WhileStatement node) { | 9421 Object visitWhileStatement(WhileStatement node) { |
| 9439 _writer.print("while ("); | 9422 _writer.print("while ("); |
| 9440 visitNode(node.condition); | 9423 _visitNode(node.condition); |
| 9441 _writer.print(") "); | 9424 _writer.print(") "); |
| 9442 visitNode(node.body); | 9425 _visitNode(node.body); |
| 9443 return null; | 9426 return null; |
| 9444 } | 9427 } |
| 9445 | 9428 |
| 9446 Object visitWithClause(WithClause node) { | 9429 Object visitWithClause(WithClause node) { |
| 9447 _writer.print("with "); | 9430 _writer.print("with "); |
| 9448 visitNodeListWithSeparator(node.mixinTypes, ", "); | 9431 _visitNodeListWithSeparator(node.mixinTypes, ", "); |
| 9449 return null; | 9432 return null; |
| 9450 } | 9433 } |
| 9451 | 9434 |
| 9452 void indent() { | 9435 void _indent() { |
| 9453 _writer.print(_indentString); | 9436 _writer.print(_indentString); |
| 9454 } | 9437 } |
| 9455 | 9438 |
| 9456 void indentDec() { | 9439 void _indentDec() { |
| 9457 _indentLevel -= 2; | 9440 _indentLevel -= 2; |
| 9458 _indentString = StringUtils.repeat(" ", _indentLevel); | 9441 _indentString = StringUtils.repeat(" ", _indentLevel); |
| 9459 } | 9442 } |
| 9460 | 9443 |
| 9461 void indentInc() { | 9444 void _indentInc() { |
| 9462 _indentLevel += 2; | 9445 _indentLevel += 2; |
| 9463 _indentString = StringUtils.repeat(" ", _indentLevel); | 9446 _indentString = StringUtils.repeat(" ", _indentLevel); |
| 9464 } | 9447 } |
| 9465 | 9448 |
| 9466 void nl() { | 9449 void _nl() { |
| 9467 _writer.print("\n"); | 9450 _writer.print("\n"); |
| 9468 } | 9451 } |
| 9469 | 9452 |
| 9470 void nl2() { | 9453 void _nl2() { |
| 9471 nl(); | 9454 _nl(); |
| 9472 indent(); | 9455 _indent(); |
| 9473 } | 9456 } |
| 9474 | 9457 |
| 9475 void printLeadingComments(Statement statement) { | 9458 void _printLeadingComments(Statement statement) { |
| 9476 List<String> comments = statement.getProperty(COMMENTS_KEY) as List<String>; | 9459 List<String> comments = statement.getProperty(COMMENTS_KEY) as List<String>; |
| 9477 if (comments == null) { | 9460 if (comments == null) { |
| 9478 return; | 9461 return; |
| 9479 } | 9462 } |
| 9480 for (String comment in comments) { | 9463 for (String comment in comments) { |
| 9481 _writer.print(comment); | 9464 _writer.print(comment); |
| 9482 _writer.print("\n"); | 9465 _writer.print("\n"); |
| 9483 indent(); | 9466 _indent(); |
| 9484 } | 9467 } |
| 9485 } | 9468 } |
| 9486 | 9469 |
| 9487 /** | 9470 /** |
| 9488 * Safely visit the given node. | 9471 * Safely visit the given node. |
| 9489 * | 9472 * |
| 9490 * @param node the node to be visited | 9473 * @param node the node to be visited |
| 9491 */ | 9474 */ |
| 9492 void visitNode(AstNode node) { | 9475 void _visitNode(AstNode node) { |
| 9493 if (node != null) { | 9476 if (node != null) { |
| 9494 node.accept(this); | 9477 node.accept(this); |
| 9495 } | 9478 } |
| 9496 } | 9479 } |
| 9497 | 9480 |
| 9498 /** | 9481 /** |
| 9499 * Print a list of nodes without any separation. | 9482 * Print a list of nodes without any separation. |
| 9500 * | 9483 * |
| 9501 * @param nodes the nodes to be printed | 9484 * @param nodes the nodes to be printed |
| 9502 * @param separator the separator to be printed between adjacent nodes | 9485 * @param separator the separator to be printed between adjacent nodes |
| 9503 */ | 9486 */ |
| 9504 void visitNodeList(NodeList<AstNode> nodes) { | 9487 void _visitNodeList(NodeList<AstNode> nodes) { |
| 9505 visitNodeListWithSeparator(nodes, ""); | 9488 _visitNodeListWithSeparator(nodes, ""); |
| 9506 } | 9489 } |
| 9507 | 9490 |
| 9508 /** | 9491 /** |
| 9509 * Print a list of nodes, separated by the given separator. | 9492 * Print a list of nodes, separated by the given separator. |
| 9510 * | 9493 * |
| 9511 * @param nodes the nodes to be printed | 9494 * @param nodes the nodes to be printed |
| 9512 * @param separator the separator to be printed between adjacent nodes | 9495 * @param separator the separator to be printed between adjacent nodes |
| 9513 */ | 9496 */ |
| 9514 void visitNodeListWithSeparator(NodeList<AstNode> nodes, String separator) { | 9497 void _visitNodeListWithSeparator(NodeList<AstNode> nodes, String separator) { |
| 9515 visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, ""); | 9498 _visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, ""); |
| 9516 } | 9499 } |
| 9517 | 9500 |
| 9518 /** | 9501 /** |
| 9519 * Print a list of nodes, separated by the given separator. | 9502 * Print a list of nodes, separated by the given separator. |
| 9520 * | 9503 * |
| 9521 * @param prefix the prefix to be printed if the list is not empty | 9504 * @param prefix the prefix to be printed if the list is not empty |
| 9522 * @param nodes the nodes to be printed | 9505 * @param nodes the nodes to be printed |
| 9523 * @param separator the separator to be printed between adjacent nodes | 9506 * @param separator the separator to be printed between adjacent nodes |
| 9524 */ | 9507 */ |
| 9525 void visitNodeListWithSeparatorAndPrefix(String prefix, NodeList<AstNode> node
s, String separator) { | 9508 void _visitNodeListWithSeparatorAndPrefix(String prefix, NodeList<AstNode> nod
es, String separator) { |
| 9526 visitNodeListWithSeparatorPrefixAndSuffix(prefix, nodes, separator, ""); | 9509 _visitNodeListWithSeparatorPrefixAndSuffix(prefix, nodes, separator, ""); |
| 9527 } | 9510 } |
| 9528 | 9511 |
| 9529 /** | 9512 /** |
| 9530 * Print a list of nodes, separated by the given separator. | 9513 * Print a list of nodes, separated by the given separator. |
| 9531 * | 9514 * |
| 9532 * @param nodes the nodes to be printed | 9515 * @param nodes the nodes to be printed |
| 9533 * @param separator the separator to be printed between adjacent nodes | 9516 * @param separator the separator to be printed between adjacent nodes |
| 9534 * @param suffix the suffix to be printed if the list is not empty | 9517 * @param suffix the suffix to be printed if the list is not empty |
| 9535 */ | 9518 */ |
| 9536 void visitNodeListWithSeparatorAndSuffix(NodeList<AstNode> nodes, String separ
ator, String suffix) { | 9519 void _visitNodeListWithSeparatorAndSuffix(NodeList<AstNode> nodes, String sepa
rator, String suffix) { |
| 9537 visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, suffix); | 9520 _visitNodeListWithSeparatorPrefixAndSuffix("", nodes, separator, suffix); |
| 9538 } | 9521 } |
| 9539 | 9522 |
| 9540 /** | 9523 /** |
| 9541 * Print a list of nodes, separated by the given separator. | 9524 * Print a list of nodes, separated by the given separator. |
| 9542 * | 9525 * |
| 9543 * @param prefix the prefix to be printed if the list is not empty | 9526 * @param prefix the prefix to be printed if the list is not empty |
| 9544 * @param nodes the nodes to be printed | 9527 * @param nodes the nodes to be printed |
| 9545 * @param separator the separator to be printed between adjacent nodes | 9528 * @param separator the separator to be printed between adjacent nodes |
| 9546 * @param suffix the suffix to be printed if the list is not empty | 9529 * @param suffix the suffix to be printed if the list is not empty |
| 9547 */ | 9530 */ |
| 9548 void visitNodeListWithSeparatorPrefixAndSuffix(String prefix, NodeList<AstNode
> nodes, String separator, String suffix) { | 9531 void _visitNodeListWithSeparatorPrefixAndSuffix(String prefix, NodeList<AstNod
e> nodes, String separator, String suffix) { |
| 9549 if (nodes != null) { | 9532 if (nodes != null) { |
| 9550 int size = nodes.length; | 9533 int size = nodes.length; |
| 9551 if (size != 0) { | 9534 if (size != 0) { |
| 9552 // prefix | 9535 // prefix |
| 9553 _writer.print(prefix); | 9536 _writer.print(prefix); |
| 9554 if (prefix.endsWith("\n")) { | 9537 if (prefix.endsWith("\n")) { |
| 9555 indent(); | 9538 _indent(); |
| 9556 } | 9539 } |
| 9557 // nodes | 9540 // nodes |
| 9558 bool newLineSeparator = separator.endsWith("\n"); | 9541 bool newLineSeparator = separator.endsWith("\n"); |
| 9559 for (int i = 0; i < size; i++) { | 9542 for (int i = 0; i < size; i++) { |
| 9560 if (i > 0) { | 9543 if (i > 0) { |
| 9561 _writer.print(separator); | 9544 _writer.print(separator); |
| 9562 if (newLineSeparator) { | 9545 if (newLineSeparator) { |
| 9563 indent(); | 9546 _indent(); |
| 9564 } | 9547 } |
| 9565 } | 9548 } |
| 9566 AstNode node = nodes[i]; | 9549 AstNode node = nodes[i]; |
| 9567 if (node is Statement) { | 9550 if (node is Statement) { |
| 9568 printLeadingComments(node); | 9551 _printLeadingComments(node); |
| 9569 } | 9552 } |
| 9570 node.accept(this); | 9553 node.accept(this); |
| 9571 } | 9554 } |
| 9572 // suffix | 9555 // suffix |
| 9573 _writer.print(suffix); | 9556 _writer.print(suffix); |
| 9574 } | 9557 } |
| 9575 } | 9558 } |
| 9576 } | 9559 } |
| 9577 | 9560 |
| 9578 /** | 9561 /** |
| 9579 * Safely visit the given node, printing the prefix before the node if it is n
on-<code>null</code> | 9562 * Safely visit the given node, printing the prefix before the node if it is n
on-<code>null</code> |
| 9580 * . | 9563 * . |
| 9581 * | 9564 * |
| 9582 * @param prefix the prefix to be printed if there is a node to visit | 9565 * @param prefix the prefix to be printed if there is a node to visit |
| 9583 * @param node the node to be visited | 9566 * @param node the node to be visited |
| 9584 */ | 9567 */ |
| 9585 void visitNodeWithPrefix(String prefix, AstNode node) { | 9568 void _visitNodeWithPrefix(String prefix, AstNode node) { |
| 9586 if (node != null) { | 9569 if (node != null) { |
| 9587 _writer.print(prefix); | 9570 _writer.print(prefix); |
| 9588 node.accept(this); | 9571 node.accept(this); |
| 9589 } | 9572 } |
| 9590 } | 9573 } |
| 9591 | 9574 |
| 9592 /** | 9575 /** |
| 9593 * Safely visit the given node, printing the suffix after the node if it is no
n-<code>null</code>. | 9576 * Safely visit the given node, printing the suffix after the node if it is no
n-<code>null</code>. |
| 9594 * | 9577 * |
| 9595 * @param suffix the suffix to be printed if there is a node to visit | 9578 * @param suffix the suffix to be printed if there is a node to visit |
| 9596 * @param node the node to be visited | 9579 * @param node the node to be visited |
| 9597 */ | 9580 */ |
| 9598 void visitNodeWithSuffix(AstNode node, String suffix) { | 9581 void _visitNodeWithSuffix(AstNode node, String suffix) { |
| 9599 if (node != null) { | 9582 if (node != null) { |
| 9600 node.accept(this); | 9583 node.accept(this); |
| 9601 _writer.print(suffix); | 9584 _writer.print(suffix); |
| 9602 } | 9585 } |
| 9603 } | 9586 } |
| 9604 | 9587 |
| 9605 /** | 9588 /** |
| 9606 * Print a list of tokens, separated by the given separator. | 9589 * Print a list of tokens, separated by the given separator. |
| 9607 * | 9590 * |
| 9608 * @param tokens the tokens to be printed | 9591 * @param tokens the tokens to be printed |
| 9609 * @param separator the separator to be printed between adjacent tokens | 9592 * @param separator the separator to be printed between adjacent tokens |
| 9610 */ | 9593 */ |
| 9611 void visitTokenListWithSeparator(List<Token> tokens, String separator) { | 9594 void _visitTokenListWithSeparator(List<Token> tokens, String separator) { |
| 9612 int size = tokens.length; | 9595 int size = tokens.length; |
| 9613 for (int i = 0; i < size; i++) { | 9596 for (int i = 0; i < size; i++) { |
| 9614 if ("\n" == separator) { | 9597 if ("\n" == separator) { |
| 9615 _writer.print("\n"); | 9598 _writer.print("\n"); |
| 9616 indent(); | 9599 _indent(); |
| 9617 } else if (i > 0) { | 9600 } else if (i > 0) { |
| 9618 _writer.print(separator); | 9601 _writer.print(separator); |
| 9619 } | 9602 } |
| 9620 _writer.print(tokens[i].lexeme); | 9603 _writer.print(tokens[i].lexeme); |
| 9621 } | 9604 } |
| 9622 } | 9605 } |
| 9623 | 9606 |
| 9624 /** | 9607 /** |
| 9625 * Safely visit the given node, printing the suffix after the node if it is no
n-<code>null</code>. | 9608 * Safely visit the given node, printing the suffix after the node if it is no
n-<code>null</code>. |
| 9626 * | 9609 * |
| 9627 * @param suffix the suffix to be printed if there is a node to visit | 9610 * @param suffix the suffix to be printed if there is a node to visit |
| 9628 * @param node the node to be visited | 9611 * @param node the node to be visited |
| 9629 */ | 9612 */ |
| 9630 void visitTokenWithSuffix(Token token, String suffix) { | 9613 void _visitTokenWithSuffix(Token token, String suffix) { |
| 9631 if (token != null) { | 9614 if (token != null) { |
| 9632 _writer.print(token.lexeme); | 9615 _writer.print(token.lexeme); |
| 9633 _writer.print(suffix); | 9616 _writer.print(suffix); |
| 9634 } | 9617 } |
| 9635 } | 9618 } |
| 9636 } | 9619 } |
| 9620 Map<String, MethodTrampoline> methodTable_Parser = <String, MethodTrampoline> { |
| 9621 'parseCompilationUnit_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get.parseCompilationUnit(arg0)), |
| 9622 'parseExpression_1': new MethodTrampoline(1, (Parser target, arg0) => target.p
arseExpression(arg0)), |
| 9623 'parseStatement_1': new MethodTrampoline(1, (Parser target, arg0) => target.pa
rseStatement(arg0)), |
| 9624 'parseStatements_1': new MethodTrampoline(1, (Parser target, arg0) => target.p
arseStatements(arg0)), |
| 9625 'parseAnnotation_0': new MethodTrampoline(0, (Parser target) => target.parseAn
notation()), |
| 9626 'parseArgument_0': new MethodTrampoline(0, (Parser target) => target.parseArgu
ment()), |
| 9627 'parseArgumentList_0': new MethodTrampoline(0, (Parser target) => target.parse
ArgumentList()), |
| 9628 'parseBitwiseOrExpression_0': new MethodTrampoline(0, (Parser target) => targe
t.parseBitwiseOrExpression()), |
| 9629 'parseBlock_0': new MethodTrampoline(0, (Parser target) => target.parseBlock()
), |
| 9630 'parseClassMember_1': new MethodTrampoline(1, (Parser target, arg0) => target.
parseClassMember(arg0)), |
| 9631 'parseCompilationUnit_0': new MethodTrampoline(0, (Parser target) => target.pa
rseCompilationUnit2()), |
| 9632 'parseConditionalExpression_0': new MethodTrampoline(0, (Parser target) => tar
get.parseConditionalExpression()), |
| 9633 'parseConstructorName_0': new MethodTrampoline(0, (Parser target) => target.pa
rseConstructorName()), |
| 9634 'parseExpression_0': new MethodTrampoline(0, (Parser target) => target.parseEx
pression2()), |
| 9635 'parseExpressionWithoutCascade_0': new MethodTrampoline(0, (Parser target) =>
target.parseExpressionWithoutCascade()), |
| 9636 'parseExtendsClause_0': new MethodTrampoline(0, (Parser target) => target.pars
eExtendsClause()), |
| 9637 'parseFormalParameterList_0': new MethodTrampoline(0, (Parser target) => targe
t.parseFormalParameterList()), |
| 9638 'parseFunctionExpression_0': new MethodTrampoline(0, (Parser target) => target
.parseFunctionExpression()), |
| 9639 'parseImplementsClause_0': new MethodTrampoline(0, (Parser target) => target.p
arseImplementsClause()), |
| 9640 'parseLabel_0': new MethodTrampoline(0, (Parser target) => target.parseLabel()
), |
| 9641 'parseLibraryIdentifier_0': new MethodTrampoline(0, (Parser target) => target.
parseLibraryIdentifier()), |
| 9642 'parseLogicalOrExpression_0': new MethodTrampoline(0, (Parser target) => targe
t.parseLogicalOrExpression()), |
| 9643 'parseMapLiteralEntry_0': new MethodTrampoline(0, (Parser target) => target.pa
rseMapLiteralEntry()), |
| 9644 'parseNormalFormalParameter_0': new MethodTrampoline(0, (Parser target) => tar
get.parseNormalFormalParameter()), |
| 9645 'parsePrefixedIdentifier_0': new MethodTrampoline(0, (Parser target) => target
.parsePrefixedIdentifier()), |
| 9646 'parseReturnType_0': new MethodTrampoline(0, (Parser target) => target.parseRe
turnType()), |
| 9647 'parseSimpleIdentifier_0': new MethodTrampoline(0, (Parser target) => target.p
arseSimpleIdentifier()), |
| 9648 'parseStatement_0': new MethodTrampoline(0, (Parser target) => target.parseSta
tement2()), |
| 9649 'parseStringLiteral_0': new MethodTrampoline(0, (Parser target) => target.pars
eStringLiteral()), |
| 9650 'parseTypeArgumentList_0': new MethodTrampoline(0, (Parser target) => target.p
arseTypeArgumentList()), |
| 9651 'parseTypeName_0': new MethodTrampoline(0, (Parser target) => target.parseType
Name()), |
| 9652 'parseTypeParameter_0': new MethodTrampoline(0, (Parser target) => target.pars
eTypeParameter()), |
| 9653 'parseTypeParameterList_0': new MethodTrampoline(0, (Parser target) => target.
parseTypeParameterList()), |
| 9654 'parseWithClause_0': new MethodTrampoline(0, (Parser target) => target.parseWi
thClause()), |
| 9655 'advance_0': new MethodTrampoline(0, (Parser target) => target._advance()), |
| 9656 'appendScalarValue_5': new MethodTrampoline(5, (Parser target, arg0, arg1, arg
2, arg3, arg4) => target._appendScalarValue(arg0, arg1, arg2, arg3, arg4)), |
| 9657 'computeStringValue_3': new MethodTrampoline(3, (Parser target, arg0, arg1, ar
g2) => target._computeStringValue(arg0, arg1, arg2)), |
| 9658 'convertToFunctionDeclaration_1': new MethodTrampoline(1, (Parser target, arg0
) => target._convertToFunctionDeclaration(arg0)), |
| 9659 'couldBeStartOfCompilationUnitMember_0': new MethodTrampoline(0, (Parser targe
t) => target._couldBeStartOfCompilationUnitMember()), |
| 9660 'createSyntheticIdentifier_0': new MethodTrampoline(0, (Parser target) => targ
et._createSyntheticIdentifier()), |
| 9661 'createSyntheticKeyword_1': new MethodTrampoline(1, (Parser target, arg0) => t
arget._createSyntheticKeyword(arg0)), |
| 9662 'createSyntheticStringLiteral_0': new MethodTrampoline(0, (Parser target) => t
arget._createSyntheticStringLiteral()), |
| 9663 'createSyntheticToken_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._createSyntheticToken(arg0)), |
| 9664 'ensureAssignable_1': new MethodTrampoline(1, (Parser target, arg0) => target.
_ensureAssignable(arg0)), |
| 9665 'expect_1': new MethodTrampoline(1, (Parser target, arg0) => target._expect(ar
g0)), |
| 9666 'expectKeyword_1': new MethodTrampoline(1, (Parser target, arg0) => target._ex
pectKeyword(arg0)), |
| 9667 'expectSemicolon_0': new MethodTrampoline(0, (Parser target) => target._expect
Semicolon()), |
| 9668 'findRange_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => target._
findRange(arg0, arg1)), |
| 9669 'getCodeBlockRanges_1': new MethodTrampoline(1, (Parser target, arg0) => targe
t._getCodeBlockRanges(arg0)), |
| 9670 'getEndToken_1': new MethodTrampoline(1, (Parser target, arg0) => target._getE
ndToken(arg0)), |
| 9671 'injectToken_1': new MethodTrampoline(1, (Parser target, arg0) => target._inje
ctToken(arg0)), |
| 9672 'isFunctionDeclaration_0': new MethodTrampoline(0, (Parser target) => target._
isFunctionDeclaration()), |
| 9673 'isFunctionExpression_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._isFunctionExpression(arg0)), |
| 9674 'isHexDigit_1': new MethodTrampoline(1, (Parser target, arg0) => target._isHex
Digit(arg0)), |
| 9675 'isInitializedVariableDeclaration_0': new MethodTrampoline(0, (Parser target)
=> target._isInitializedVariableDeclaration()), |
| 9676 'isLinkText_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => target.
_isLinkText(arg0, arg1)), |
| 9677 'isOperator_1': new MethodTrampoline(1, (Parser target, arg0) => target._isOpe
rator(arg0)), |
| 9678 'isSwitchMember_0': new MethodTrampoline(0, (Parser target) => target._isSwitc
hMember()), |
| 9679 'isTypedIdentifier_1': new MethodTrampoline(1, (Parser target, arg0) => target
._isTypedIdentifier(arg0)), |
| 9680 'lexicallyFirst_1': new MethodTrampoline(1, (Parser target, arg0) => target._l
exicallyFirst(arg0)), |
| 9681 'lockErrorListener_0': new MethodTrampoline(0, (Parser target) => target._lock
ErrorListener()), |
| 9682 'matches_1': new MethodTrampoline(1, (Parser target, arg0) => target._matches(
arg0)), |
| 9683 'matchesIdentifier_0': new MethodTrampoline(0, (Parser target) => target._matc
hesIdentifier()), |
| 9684 'matchesKeyword_1': new MethodTrampoline(1, (Parser target, arg0) => target._m
atchesKeyword(arg0)), |
| 9685 'matchesString_1': new MethodTrampoline(1, (Parser target, arg0) => target._ma
tchesString(arg0)), |
| 9686 'optional_1': new MethodTrampoline(1, (Parser target, arg0) => target._optiona
l(arg0)), |
| 9687 'parseAdditiveExpression_0': new MethodTrampoline(0, (Parser target) => target
._parseAdditiveExpression()), |
| 9688 'parseArgumentDefinitionTest_0': new MethodTrampoline(0, (Parser target) => ta
rget._parseArgumentDefinitionTest()), |
| 9689 'parseAssertStatement_0': new MethodTrampoline(0, (Parser target) => target._p
arseAssertStatement()), |
| 9690 'parseAssignableExpression_1': new MethodTrampoline(1, (Parser target, arg0) =
> target._parseAssignableExpression(arg0)), |
| 9691 'parseAssignableSelector_2': new MethodTrampoline(2, (Parser target, arg0, arg
1) => target._parseAssignableSelector(arg0, arg1)), |
| 9692 'parseBitwiseAndExpression_0': new MethodTrampoline(0, (Parser target) => targ
et._parseBitwiseAndExpression()), |
| 9693 'parseBitwiseXorExpression_0': new MethodTrampoline(0, (Parser target) => targ
et._parseBitwiseXorExpression()), |
| 9694 'parseBreakStatement_0': new MethodTrampoline(0, (Parser target) => target._pa
rseBreakStatement()), |
| 9695 'parseCascadeSection_0': new MethodTrampoline(0, (Parser target) => target._pa
rseCascadeSection()), |
| 9696 'parseClassDeclaration_2': new MethodTrampoline(2, (Parser target, arg0, arg1)
=> target._parseClassDeclaration(arg0, arg1)), |
| 9697 'parseClassMembers_2': new MethodTrampoline(2, (Parser target, arg0, arg1) =>
target._parseClassMembers(arg0, arg1)), |
| 9698 'parseClassTypeAlias_3': new MethodTrampoline(3, (Parser target, arg0, arg1, a
rg2) => target._parseClassTypeAlias(arg0, arg1, arg2)), |
| 9699 'parseCombinators_0': new MethodTrampoline(0, (Parser target) => target._parse
Combinators()), |
| 9700 'parseCommentAndMetadata_0': new MethodTrampoline(0, (Parser target) => target
._parseCommentAndMetadata()), |
| 9701 'parseCommentReference_2': new MethodTrampoline(2, (Parser target, arg0, arg1)
=> target._parseCommentReference(arg0, arg1)), |
| 9702 'parseCommentReferences_1': new MethodTrampoline(1, (Parser target, arg0) => t
arget._parseCommentReferences(arg0)), |
| 9703 'parseCompilationUnitMember_1': new MethodTrampoline(1, (Parser target, arg0)
=> target._parseCompilationUnitMember(arg0)), |
| 9704 'parseConstExpression_0': new MethodTrampoline(0, (Parser target) => target._p
arseConstExpression()), |
| 9705 'parseConstructor_8': new MethodTrampoline(8, (Parser target, arg0, arg1, arg2
, arg3, arg4, arg5, arg6, arg7) => target._parseConstructor(arg0, arg1, arg2, ar
g3, arg4, arg5, arg6, arg7)), |
| 9706 'parseConstructorFieldInitializer_0': new MethodTrampoline(0, (Parser target)
=> target._parseConstructorFieldInitializer()), |
| 9707 'parseContinueStatement_0': new MethodTrampoline(0, (Parser target) => target.
_parseContinueStatement()), |
| 9708 'parseDirective_1': new MethodTrampoline(1, (Parser target, arg0) => target._p
arseDirective(arg0)), |
| 9709 'parseDocumentationComment_0': new MethodTrampoline(0, (Parser target) => targ
et._parseDocumentationComment()), |
| 9710 'parseDoStatement_0': new MethodTrampoline(0, (Parser target) => target._parse
DoStatement()), |
| 9711 'parseEmptyStatement_0': new MethodTrampoline(0, (Parser target) => target._pa
rseEmptyStatement()), |
| 9712 'parseEqualityExpression_0': new MethodTrampoline(0, (Parser target) => target
._parseEqualityExpression()), |
| 9713 'parseExportDirective_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._parseExportDirective(arg0)), |
| 9714 'parseExpressionList_0': new MethodTrampoline(0, (Parser target) => target._pa
rseExpressionList()), |
| 9715 'parseFinalConstVarOrType_1': new MethodTrampoline(1, (Parser target, arg0) =>
target._parseFinalConstVarOrType(arg0)), |
| 9716 'parseFormalParameter_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._parseFormalParameter(arg0)), |
| 9717 'parseForStatement_0': new MethodTrampoline(0, (Parser target) => target._pars
eForStatement()), |
| 9718 'parseFunctionBody_3': new MethodTrampoline(3, (Parser target, arg0, arg1, arg
2) => target._parseFunctionBody(arg0, arg1, arg2)), |
| 9719 'parseFunctionDeclaration_3': new MethodTrampoline(3, (Parser target, arg0, ar
g1, arg2) => target._parseFunctionDeclaration(arg0, arg1, arg2)), |
| 9720 'parseFunctionDeclarationStatement_0': new MethodTrampoline(0, (Parser target)
=> target._parseFunctionDeclarationStatement()), |
| 9721 'parseFunctionDeclarationStatementAfterReturnType_2': new MethodTrampoline(2,
(Parser target, arg0, arg1) => target._parseFunctionDeclarationStatementAfterRet
urnType(arg0, arg1)), |
| 9722 'parseFunctionTypeAlias_2': new MethodTrampoline(2, (Parser target, arg0, arg1
) => target._parseFunctionTypeAlias(arg0, arg1)), |
| 9723 'parseGetter_4': new MethodTrampoline(4, (Parser target, arg0, arg1, arg2, arg
3) => target._parseGetter(arg0, arg1, arg2, arg3)), |
| 9724 'parseIdentifierList_0': new MethodTrampoline(0, (Parser target) => target._pa
rseIdentifierList()), |
| 9725 'parseIfStatement_0': new MethodTrampoline(0, (Parser target) => target._parse
IfStatement()), |
| 9726 'parseImportDirective_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._parseImportDirective(arg0)), |
| 9727 'parseInitializedIdentifierList_4': new MethodTrampoline(4, (Parser target, ar
g0, arg1, arg2, arg3) => target._parseInitializedIdentifierList(arg0, arg1, arg2
, arg3)), |
| 9728 'parseInstanceCreationExpression_1': new MethodTrampoline(1, (Parser target, a
rg0) => target._parseInstanceCreationExpression(arg0)), |
| 9729 'parseLibraryDirective_1': new MethodTrampoline(1, (Parser target, arg0) => ta
rget._parseLibraryDirective(arg0)), |
| 9730 'parseLibraryName_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => t
arget._parseLibraryName(arg0, arg1)), |
| 9731 'parseListLiteral_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => t
arget._parseListLiteral(arg0, arg1)), |
| 9732 'parseListOrMapLiteral_1': new MethodTrampoline(1, (Parser target, arg0) => ta
rget._parseListOrMapLiteral(arg0)), |
| 9733 'parseLogicalAndExpression_0': new MethodTrampoline(0, (Parser target) => targ
et._parseLogicalAndExpression()), |
| 9734 'parseMapLiteral_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => ta
rget._parseMapLiteral(arg0, arg1)), |
| 9735 'parseMethodDeclarationAfterParameters_6': new MethodTrampoline(6, (Parser tar
get, arg0, arg1, arg2, arg3, arg4, arg5) => target._parseMethodDeclarationAfterP
arameters(arg0, arg1, arg2, arg3, arg4, arg5)), |
| 9736 'parseMethodDeclarationAfterReturnType_4': new MethodTrampoline(4, (Parser tar
get, arg0, arg1, arg2, arg3) => target._parseMethodDeclarationAfterReturnType(ar
g0, arg1, arg2, arg3)), |
| 9737 'parseModifiers_0': new MethodTrampoline(0, (Parser target) => target._parseMo
difiers()), |
| 9738 'parseMultiplicativeExpression_0': new MethodTrampoline(0, (Parser target) =>
target._parseMultiplicativeExpression()), |
| 9739 'parseNativeClause_0': new MethodTrampoline(0, (Parser target) => target._pars
eNativeClause()), |
| 9740 'parseNewExpression_0': new MethodTrampoline(0, (Parser target) => target._par
seNewExpression()), |
| 9741 'parseNonLabeledStatement_0': new MethodTrampoline(0, (Parser target) => targe
t._parseNonLabeledStatement()), |
| 9742 'parseOperator_3': new MethodTrampoline(3, (Parser target, arg0, arg1, arg2) =
> target._parseOperator(arg0, arg1, arg2)), |
| 9743 'parseOptionalReturnType_0': new MethodTrampoline(0, (Parser target) => target
._parseOptionalReturnType()), |
| 9744 'parsePartDirective_1': new MethodTrampoline(1, (Parser target, arg0) => targe
t._parsePartDirective(arg0)), |
| 9745 'parsePostfixExpression_0': new MethodTrampoline(0, (Parser target) => target.
_parsePostfixExpression()), |
| 9746 'parsePrimaryExpression_0': new MethodTrampoline(0, (Parser target) => target.
_parsePrimaryExpression()), |
| 9747 'parseRedirectingConstructorInvocation_0': new MethodTrampoline(0, (Parser tar
get) => target._parseRedirectingConstructorInvocation()), |
| 9748 'parseRelationalExpression_0': new MethodTrampoline(0, (Parser target) => targ
et._parseRelationalExpression()), |
| 9749 'parseRethrowExpression_0': new MethodTrampoline(0, (Parser target) => target.
_parseRethrowExpression()), |
| 9750 'parseReturnStatement_0': new MethodTrampoline(0, (Parser target) => target._p
arseReturnStatement()), |
| 9751 'parseSetter_4': new MethodTrampoline(4, (Parser target, arg0, arg1, arg2, arg
3) => target._parseSetter(arg0, arg1, arg2, arg3)), |
| 9752 'parseShiftExpression_0': new MethodTrampoline(0, (Parser target) => target._p
arseShiftExpression()), |
| 9753 'parseStatementList_0': new MethodTrampoline(0, (Parser target) => target._par
seStatementList()), |
| 9754 'parseStringInterpolation_1': new MethodTrampoline(1, (Parser target, arg0) =>
target._parseStringInterpolation(arg0)), |
| 9755 'parseSuperConstructorInvocation_0': new MethodTrampoline(0, (Parser target) =
> target._parseSuperConstructorInvocation()), |
| 9756 'parseSwitchStatement_0': new MethodTrampoline(0, (Parser target) => target._p
arseSwitchStatement()), |
| 9757 'parseSymbolLiteral_0': new MethodTrampoline(0, (Parser target) => target._par
seSymbolLiteral()), |
| 9758 'parseThrowExpression_0': new MethodTrampoline(0, (Parser target) => target._p
arseThrowExpression()), |
| 9759 'parseThrowExpressionWithoutCascade_0': new MethodTrampoline(0, (Parser target
) => target._parseThrowExpressionWithoutCascade()), |
| 9760 'parseTryStatement_0': new MethodTrampoline(0, (Parser target) => target._pars
eTryStatement()), |
| 9761 'parseTypeAlias_1': new MethodTrampoline(1, (Parser target, arg0) => target._p
arseTypeAlias(arg0)), |
| 9762 'parseUnaryExpression_0': new MethodTrampoline(0, (Parser target) => target._p
arseUnaryExpression()), |
| 9763 'parseVariableDeclaration_0': new MethodTrampoline(0, (Parser target) => targe
t._parseVariableDeclaration()), |
| 9764 'parseVariableDeclarationListAfterMetadata_1': new MethodTrampoline(1, (Parser
target, arg0) => target._parseVariableDeclarationListAfterMetadata(arg0)), |
| 9765 'parseVariableDeclarationListAfterType_3': new MethodTrampoline(3, (Parser tar
get, arg0, arg1, arg2) => target._parseVariableDeclarationListAfterType(arg0, ar
g1, arg2)), |
| 9766 'parseVariableDeclarationStatementAfterMetadata_1': new MethodTrampoline(1, (P
arser target, arg0) => target._parseVariableDeclarationStatementAfterMetadata(ar
g0)), |
| 9767 'parseVariableDeclarationStatementAfterType_3': new MethodTrampoline(3, (Parse
r target, arg0, arg1, arg2) => target._parseVariableDeclarationStatementAfterTyp
e(arg0, arg1, arg2)), |
| 9768 'parseWhileStatement_0': new MethodTrampoline(0, (Parser target) => target._pa
rseWhileStatement()), |
| 9769 'peek_0': new MethodTrampoline(0, (Parser target) => target._peek()), |
| 9770 'peekAt_1': new MethodTrampoline(1, (Parser target, arg0) => target._peekAt(ar
g0)), |
| 9771 'reportError_1': new MethodTrampoline(1, (Parser target, arg0) => target._repo
rtError(arg0)), |
| 9772 'reportErrorForCurrentToken_2': new MethodTrampoline(2, (Parser target, arg0,
arg1) => target._reportErrorForCurrentToken(arg0, arg1)), |
| 9773 'reportErrorForNode_3': new MethodTrampoline(3, (Parser target, arg0, arg1, ar
g2) => target._reportErrorForNode(arg0, arg1, arg2)), |
| 9774 'reportErrorForToken_3': new MethodTrampoline(3, (Parser target, arg0, arg1, a
rg2) => target._reportErrorForToken(arg0, arg1, arg2)), |
| 9775 'skipBlock_0': new MethodTrampoline(0, (Parser target) => target._skipBlock())
, |
| 9776 'skipFinalConstVarOrType_1': new MethodTrampoline(1, (Parser target, arg0) =>
target._skipFinalConstVarOrType(arg0)), |
| 9777 'skipFormalParameterList_1': new MethodTrampoline(1, (Parser target, arg0) =>
target._skipFormalParameterList(arg0)), |
| 9778 'skipPastMatchingToken_1': new MethodTrampoline(1, (Parser target, arg0) => ta
rget._skipPastMatchingToken(arg0)), |
| 9779 'skipPrefixedIdentifier_1': new MethodTrampoline(1, (Parser target, arg0) => t
arget._skipPrefixedIdentifier(arg0)), |
| 9780 'skipReturnType_1': new MethodTrampoline(1, (Parser target, arg0) => target._s
kipReturnType(arg0)), |
| 9781 'skipSimpleIdentifier_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._skipSimpleIdentifier(arg0)), |
| 9782 'skipStringInterpolation_1': new MethodTrampoline(1, (Parser target, arg0) =>
target._skipStringInterpolation(arg0)), |
| 9783 'skipStringLiteral_1': new MethodTrampoline(1, (Parser target, arg0) => target
._skipStringLiteral(arg0)), |
| 9784 'skipTypeArgumentList_1': new MethodTrampoline(1, (Parser target, arg0) => tar
get._skipTypeArgumentList(arg0)), |
| 9785 'skipTypeName_1': new MethodTrampoline(1, (Parser target, arg0) => target._ski
pTypeName(arg0)), |
| 9786 'skipTypeParameterList_1': new MethodTrampoline(1, (Parser target, arg0) => ta
rget._skipTypeParameterList(arg0)), |
| 9787 'tokenMatches_2': new MethodTrampoline(2, (Parser target, arg0, arg1) => targe
t._tokenMatches(arg0, arg1)), |
| 9788 'tokenMatchesIdentifier_1': new MethodTrampoline(1, (Parser target, arg0) => t
arget._tokenMatchesIdentifier(arg0)), |
| 9789 'tokenMatchesKeyword_2': new MethodTrampoline(2, (Parser target, arg0, arg1) =
> target._tokenMatchesKeyword(arg0, arg1)), |
| 9790 'translateCharacter_3': new MethodTrampoline(3, (Parser target, arg0, arg1, ar
g2) => target._translateCharacter(arg0, arg1, arg2)), |
| 9791 'unlockErrorListener_0': new MethodTrampoline(0, (Parser target) => target._un
lockErrorListener()), |
| 9792 'validateFormalParameterList_1': new MethodTrampoline(1, (Parser target, arg0)
=> target._validateFormalParameterList(arg0)), |
| 9793 'validateModifiersForClass_1': new MethodTrampoline(1, (Parser target, arg0) =
> target._validateModifiersForClass(arg0)), |
| 9794 'validateModifiersForConstructor_1': new MethodTrampoline(1, (Parser target, a
rg0) => target._validateModifiersForConstructor(arg0)), |
| 9795 'validateModifiersForField_1': new MethodTrampoline(1, (Parser target, arg0) =
> target._validateModifiersForField(arg0)), |
| 9796 'validateModifiersForFunctionDeclarationStatement_1': new MethodTrampoline(1,
(Parser target, arg0) => target._validateModifiersForFunctionDeclarationStatemen
t(arg0)), |
| 9797 'validateModifiersForGetterOrSetterOrMethod_1': new MethodTrampoline(1, (Parse
r target, arg0) => target._validateModifiersForGetterOrSetterOrMethod(arg0)), |
| 9798 'validateModifiersForOperator_1': new MethodTrampoline(1, (Parser target, arg0
) => target._validateModifiersForOperator(arg0)), |
| 9799 'validateModifiersForTopLevelDeclaration_1': new MethodTrampoline(1, (Parser t
arget, arg0) => target._validateModifiersForTopLevelDeclaration(arg0)), |
| 9800 'validateModifiersForTopLevelFunction_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target._validateModifiersForTopLevelFunction(arg0)), |
| 9801 'validateModifiersForTopLevelVariable_1': new MethodTrampoline(1, (Parser targ
et, arg0) => target._validateModifiersForTopLevelVariable(arg0)), |
| 9802 'validateModifiersForTypedef_1': new MethodTrampoline(1, (Parser target, arg0)
=> target._validateModifiersForTypedef(arg0)),}; |
| 9803 |
| 9804 |
| 9805 Object invokeParserMethodImpl(Parser parser, String methodName, List<Object> obj
ects, Token tokenStream) { |
| 9806 parser.currentToken = tokenStream; |
| 9807 MethodTrampoline method = methodTable_Parser['${methodName}_${objects.length}'
]; |
| 9808 return method.invoke(parser, objects); |
| 9809 } |
| 9810 |
| 9811 |
| 9812 /** |
| 9813 * Wrapper around [Function] which should be called with "target" and "arguments
". |
| 9814 */ |
| 9815 class MethodTrampoline { |
| 9816 int parameterCount; |
| 9817 Function trampoline; |
| 9818 MethodTrampoline(this.parameterCount, this.trampoline); |
| 9819 Object invoke(target, List arguments) { |
| 9820 if (arguments.length != parameterCount) { |
| 9821 throw new IllegalArgumentException("${arguments.length} != $parameterCount
"); |
| 9822 } |
| 9823 switch (parameterCount) { |
| 9824 case 0: |
| 9825 return trampoline(target); |
| 9826 case 1: |
| 9827 return trampoline(target, arguments[0]); |
| 9828 case 2: |
| 9829 return trampoline(target, arguments[0], arguments[1]); |
| 9830 case 3: |
| 9831 return trampoline(target, arguments[0], arguments[1], arguments[2]); |
| 9832 case 4: |
| 9833 return trampoline(target, arguments[0], arguments[1], arguments[2], argu
ments[3]); |
| 9834 default: |
| 9835 throw new IllegalArgumentException("Not implemented for > 4 arguments"); |
| 9836 } |
| 9837 } |
| 9838 } |
| OLD | NEW |