| 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 library analyzer.src.generated.resolver; | 5 library analyzer.src.generated.resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 bool _checkAllTypeChecks(IsExpression node) { | 384 bool _checkAllTypeChecks(IsExpression node) { |
| 385 Expression expression = node.expression; | 385 Expression expression = node.expression; |
| 386 TypeAnnotation typeName = node.type; | 386 TypeAnnotation typeName = node.type; |
| 387 DartType lhsType = expression.staticType; | 387 DartType lhsType = expression.staticType; |
| 388 DartType rhsType = typeName.type; | 388 DartType rhsType = typeName.type; |
| 389 if (lhsType == null || rhsType == null) { | 389 if (lhsType == null || rhsType == null) { |
| 390 return false; | 390 return false; |
| 391 } | 391 } |
| 392 String rhsNameStr = typeName is TypeName ? typeName.name.name : null; | 392 String rhsNameStr = typeName is TypeName ? typeName.name.name : null; |
| 393 // if x is dynamic | 393 // if x is dynamic |
| 394 if (rhsType.isDynamic && rhsNameStr == Keyword.DYNAMIC.syntax) { | 394 if (rhsType.isDynamic && rhsNameStr == Keyword.DYNAMIC.lexeme) { |
| 395 if (node.notOperator == null) { | 395 if (node.notOperator == null) { |
| 396 // the is case | 396 // the is case |
| 397 _errorReporter.reportErrorForNode( | 397 _errorReporter.reportErrorForNode( |
| 398 HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node); | 398 HintCode.UNNECESSARY_TYPE_CHECK_TRUE, node); |
| 399 } else { | 399 } else { |
| 400 // the is not case | 400 // the is not case |
| 401 _errorReporter.reportErrorForNode( | 401 _errorReporter.reportErrorForNode( |
| 402 HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node); | 402 HintCode.UNNECESSARY_TYPE_CHECK_FALSE, node); |
| 403 } | 403 } |
| 404 return true; | 404 return true; |
| (...skipping 8206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8611 SimpleIdentifier prefix = typeName.prefix; | 8611 SimpleIdentifier prefix = typeName.prefix; |
| 8612 prefix.staticElement = nameScope.lookup(prefix, definingLibrary); | 8612 prefix.staticElement = nameScope.lookup(prefix, definingLibrary); |
| 8613 } | 8613 } |
| 8614 } | 8614 } |
| 8615 | 8615 |
| 8616 /** | 8616 /** |
| 8617 * Return `true` if the name of the given [typeName] is an built-in identifier
. | 8617 * Return `true` if the name of the given [typeName] is an built-in identifier
. |
| 8618 */ | 8618 */ |
| 8619 static bool _isBuiltInIdentifier(TypeName typeName) { | 8619 static bool _isBuiltInIdentifier(TypeName typeName) { |
| 8620 Token token = typeName.name.beginToken; | 8620 Token token = typeName.name.beginToken; |
| 8621 return token.type == TokenType.KEYWORD; | 8621 return token.type.isKeyword; |
| 8622 } | 8622 } |
| 8623 | 8623 |
| 8624 /** | 8624 /** |
| 8625 * @return `true` if given [typeName] is used as a type annotation. | 8625 * @return `true` if given [typeName] is used as a type annotation. |
| 8626 */ | 8626 */ |
| 8627 static bool _isTypeAnnotation(TypeName typeName) { | 8627 static bool _isTypeAnnotation(TypeName typeName) { |
| 8628 AstNode parent = typeName.parent; | 8628 AstNode parent = typeName.parent; |
| 8629 if (parent is VariableDeclarationList) { | 8629 if (parent is VariableDeclarationList) { |
| 8630 return identical(parent.type, typeName); | 8630 return identical(parent.type, typeName); |
| 8631 } else if (parent is FieldFormalParameter) { | 8631 } else if (parent is FieldFormalParameter) { |
| (...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10340 ClassElement element = type.element; | 10340 ClassElement element = type.element; |
| 10341 if (element != null && element.isEnum) { | 10341 if (element != null && element.isEnum) { |
| 10342 errorReporter.reportErrorForNode(enumTypeError, typeName); | 10342 errorReporter.reportErrorForNode(enumTypeError, typeName); |
| 10343 return null; | 10343 return null; |
| 10344 } | 10344 } |
| 10345 return type; | 10345 return type; |
| 10346 } | 10346 } |
| 10347 // If the type is not an InterfaceType, then visitTypeName() sets the type | 10347 // If the type is not an InterfaceType, then visitTypeName() sets the type |
| 10348 // to be a DynamicTypeImpl | 10348 // to be a DynamicTypeImpl |
| 10349 Identifier name = typeName.name; | 10349 Identifier name = typeName.name; |
| 10350 if (name.name == Keyword.DYNAMIC.syntax) { | 10350 if (name.name == Keyword.DYNAMIC.lexeme) { |
| 10351 errorReporter.reportErrorForNode(dynamicTypeError, name, [name.name]); | 10351 errorReporter.reportErrorForNode(dynamicTypeError, name, [name.name]); |
| 10352 } else if (!nameScope.shouldIgnoreUndefined(name)) { | 10352 } else if (!nameScope.shouldIgnoreUndefined(name)) { |
| 10353 errorReporter.reportErrorForNode(nonTypeError, name, [name.name]); | 10353 errorReporter.reportErrorForNode(nonTypeError, name, [name.name]); |
| 10354 } | 10354 } |
| 10355 return null; | 10355 return null; |
| 10356 } | 10356 } |
| 10357 | 10357 |
| 10358 /** | 10358 /** |
| 10359 * Resolve the types in the given list of type names. | 10359 * Resolve the types in the given list of type names. |
| 10360 * | 10360 * |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10938 return null; | 10938 return null; |
| 10939 } | 10939 } |
| 10940 if (identical(node.staticElement, variable)) { | 10940 if (identical(node.staticElement, variable)) { |
| 10941 if (node.inSetterContext()) { | 10941 if (node.inSetterContext()) { |
| 10942 result = true; | 10942 result = true; |
| 10943 } | 10943 } |
| 10944 } | 10944 } |
| 10945 return null; | 10945 return null; |
| 10946 } | 10946 } |
| 10947 } | 10947 } |
| OLD | NEW |