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

Side by Side Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.parser; 5 library analyzer.src.generated.parser;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 4447 matching lines...) Expand 10 before | Expand all | Expand 10 after
4458 // A primary expression can start with an identifier. We resolve the 4458 // A primary expression can start with an identifier. We resolve the
4459 // ambiguity by determining whether the primary consists of anything other 4459 // ambiguity by determining whether the primary consists of anything other
4460 // than an identifier and/or is followed by an assignableSelector. 4460 // than an identifier and/or is followed by an assignableSelector.
4461 // 4461 //
4462 Expression expression = _parsePrimaryExpression(); 4462 Expression expression = _parsePrimaryExpression();
4463 bool isOptional = primaryAllowed || expression is SimpleIdentifier; 4463 bool isOptional = primaryAllowed || expression is SimpleIdentifier;
4464 while (true) { 4464 while (true) {
4465 while (_isLikelyArgumentList()) { 4465 while (_isLikelyArgumentList()) {
4466 TypeArgumentList typeArguments = _parseOptionalTypeArguments(); 4466 TypeArgumentList typeArguments = _parseOptionalTypeArguments();
4467 ArgumentList argumentList = parseArgumentList(); 4467 ArgumentList argumentList = parseArgumentList();
4468 if (expression is SimpleIdentifier) { 4468 Expression currentExpression = expression;
4469 expression = new MethodInvocation(null, null, 4469 if (currentExpression is SimpleIdentifier) {
4470 expression as SimpleIdentifier, typeArguments, argumentList);
4471 } else if (expression is PrefixedIdentifier) {
4472 PrefixedIdentifier identifier = expression as PrefixedIdentifier;
4473 expression = new MethodInvocation( 4470 expression = new MethodInvocation(
4474 identifier.prefix, 4471 null, null, currentExpression, typeArguments, argumentList);
4475 identifier.period, 4472 } else if (currentExpression is PrefixedIdentifier) {
4476 identifier.identifier, 4473 expression = new MethodInvocation(
4474 currentExpression.prefix,
4475 currentExpression.period,
4476 currentExpression.identifier,
4477 typeArguments, 4477 typeArguments,
4478 argumentList); 4478 argumentList);
4479 } else if (expression is PropertyAccess) { 4479 } else if (currentExpression is PropertyAccess) {
4480 PropertyAccess access = expression as PropertyAccess; 4480 expression = new MethodInvocation(
4481 expression = new MethodInvocation(access.target, access.operator, 4481 currentExpression.target,
4482 access.propertyName, typeArguments, argumentList); 4482 currentExpression.operator,
4483 currentExpression.propertyName,
4484 typeArguments,
4485 argumentList);
4483 } else { 4486 } else {
4484 expression = new FunctionExpressionInvocation( 4487 expression = new FunctionExpressionInvocation(
4485 expression, typeArguments, argumentList); 4488 expression, typeArguments, argumentList);
4486 } 4489 }
4487 if (!primaryAllowed) { 4490 if (!primaryAllowed) {
4488 isOptional = false; 4491 isOptional = false;
4489 } 4492 }
4490 } 4493 }
4491 Expression selectorExpression = _parseAssignableSelector( 4494 Expression selectorExpression = _parseAssignableSelector(
4492 expression, isOptional || (expression is PrefixedIdentifier)); 4495 expression, isOptional || (expression is PrefixedIdentifier));
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 assert(expression != null); 4697 assert(expression != null);
4695 bool progress = true; 4698 bool progress = true;
4696 while (progress) { 4699 while (progress) {
4697 progress = false; 4700 progress = false;
4698 Expression selector = _parseAssignableSelector(expression, true); 4701 Expression selector = _parseAssignableSelector(expression, true);
4699 if (!identical(selector, expression)) { 4702 if (!identical(selector, expression)) {
4700 expression = selector; 4703 expression = selector;
4701 progress = true; 4704 progress = true;
4702 while (_isLikelyArgumentList()) { 4705 while (_isLikelyArgumentList()) {
4703 TypeArgumentList typeArguments = _parseOptionalTypeArguments(); 4706 TypeArgumentList typeArguments = _parseOptionalTypeArguments();
4704 if (expression is PropertyAccess) { 4707 Expression currentExpression = expression;
4705 PropertyAccess propertyAccess = expression as PropertyAccess; 4708 ;
scheglov 2016/04/25 19:14:44 Remove this?
Brian Wilkerson 2016/04/25 19:24:20 Done
4709 if (currentExpression is PropertyAccess) {
4706 expression = new MethodInvocation( 4710 expression = new MethodInvocation(
4707 propertyAccess.target, 4711 currentExpression.target,
4708 propertyAccess.operator, 4712 currentExpression.operator,
4709 propertyAccess.propertyName, 4713 currentExpression.propertyName,
4710 typeArguments, 4714 typeArguments,
4711 parseArgumentList()); 4715 parseArgumentList());
4712 } else { 4716 } else {
4713 expression = new FunctionExpressionInvocation( 4717 expression = new FunctionExpressionInvocation(
4714 expression, typeArguments, parseArgumentList()); 4718 expression, typeArguments, parseArgumentList());
4715 } 4719 }
4716 } 4720 }
4717 } 4721 }
4718 } 4722 }
4719 if (_currentToken.type.isAssignmentOperator) { 4723 if (_currentToken.type.isAssignmentOperator) {
(...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after
7323 Expression operand = _parseAssignableExpression(true); 7327 Expression operand = _parseAssignableExpression(true);
7324 if (_matches(TokenType.OPEN_SQUARE_BRACKET) || 7328 if (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
7325 _matches(TokenType.PERIOD) || 7329 _matches(TokenType.PERIOD) ||
7326 _matches(TokenType.QUESTION_PERIOD) || 7330 _matches(TokenType.QUESTION_PERIOD) ||
7327 _matches(TokenType.OPEN_PAREN) || 7331 _matches(TokenType.OPEN_PAREN) ||
7328 (parseGenericMethods && _matches(TokenType.LT))) { 7332 (parseGenericMethods && _matches(TokenType.LT))) {
7329 do { 7333 do {
7330 if (_isLikelyArgumentList()) { 7334 if (_isLikelyArgumentList()) {
7331 TypeArgumentList typeArguments = _parseOptionalTypeArguments(); 7335 TypeArgumentList typeArguments = _parseOptionalTypeArguments();
7332 ArgumentList argumentList = parseArgumentList(); 7336 ArgumentList argumentList = parseArgumentList();
7333 if (operand is PropertyAccess) { 7337 Expression currentOperand = operand;
7334 PropertyAccess access = operand as PropertyAccess; 7338 if (currentOperand is PropertyAccess) {
7335 operand = new MethodInvocation(access.target, access.operator, 7339 operand = new MethodInvocation(
7336 access.propertyName, typeArguments, argumentList); 7340 currentOperand.target,
7341 currentOperand.operator,
7342 currentOperand.propertyName,
7343 typeArguments,
7344 argumentList);
7337 } else { 7345 } else {
7338 operand = new FunctionExpressionInvocation( 7346 operand = new FunctionExpressionInvocation(
7339 operand, typeArguments, argumentList); 7347 operand, typeArguments, argumentList);
7340 } 7348 }
7341 } else { 7349 } else {
7342 operand = _parseAssignableSelector(operand, true); 7350 operand = _parseAssignableSelector(operand, true);
7343 } 7351 }
7344 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) || 7352 } while (_matches(TokenType.OPEN_SQUARE_BRACKET) ||
7345 _matches(TokenType.PERIOD) || 7353 _matches(TokenType.PERIOD) ||
7346 _matches(TokenType.QUESTION_PERIOD) || 7354 _matches(TokenType.QUESTION_PERIOD) ||
(...skipping 2618 matching lines...) Expand 10 before | Expand all | Expand 10 after
9965 */ 9973 */
9966 const ParserErrorCode(String name, String message, [String correction]) 9974 const ParserErrorCode(String name, String message, [String correction])
9967 : super(name, message, correction); 9975 : super(name, message, correction);
9968 9976
9969 @override 9977 @override
9970 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; 9978 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR;
9971 9979
9972 @override 9980 @override
9973 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 9981 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
9974 } 9982 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/incremental_resolver.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698