| 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 engine.resolver; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import "dart:math" as math; | 7 import "dart:math" as math; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/generated/utilities_collection.dart'; | 10 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| (...skipping 3283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3294 List<TopLevelVariableElement> _topLevelVariables; | 3294 List<TopLevelVariableElement> _topLevelVariables; |
| 3295 | 3295 |
| 3296 List<ClassElement> _types; | 3296 List<ClassElement> _types; |
| 3297 | 3297 |
| 3298 List<FunctionTypeAliasElement> _typeAliases; | 3298 List<FunctionTypeAliasElement> _typeAliases; |
| 3299 | 3299 |
| 3300 List<TypeParameterElement> _typeParameters; | 3300 List<TypeParameterElement> _typeParameters; |
| 3301 | 3301 |
| 3302 List<PropertyAccessorElement> get accessors { | 3302 List<PropertyAccessorElement> get accessors { |
| 3303 if (_accessors == null) { | 3303 if (_accessors == null) { |
| 3304 return PropertyAccessorElementImpl.EMPTY_ARRAY; | 3304 return PropertyAccessorElement.EMPTY_LIST; |
| 3305 } | 3305 } |
| 3306 List<PropertyAccessorElement> result = _accessors; | 3306 List<PropertyAccessorElement> result = _accessors; |
| 3307 _accessors = null; | 3307 _accessors = null; |
| 3308 return result; | 3308 return result; |
| 3309 } | 3309 } |
| 3310 | 3310 |
| 3311 List<ConstructorElement> get constructors { | 3311 List<ConstructorElement> get constructors { |
| 3312 if (_constructors == null) { | 3312 if (_constructors == null) { |
| 3313 return ConstructorElementImpl.EMPTY_ARRAY; | 3313 return ConstructorElement.EMPTY_LIST; |
| 3314 } | 3314 } |
| 3315 List<ConstructorElement> result = _constructors; | 3315 List<ConstructorElement> result = _constructors; |
| 3316 _constructors = null; | 3316 _constructors = null; |
| 3317 return result; | 3317 return result; |
| 3318 } | 3318 } |
| 3319 | 3319 |
| 3320 List<ClassElement> get enums { | 3320 List<ClassElement> get enums { |
| 3321 if (_enums == null) { | 3321 if (_enums == null) { |
| 3322 return ClassElementImpl.EMPTY_ARRAY; | 3322 return ClassElement.EMPTY_LIST; |
| 3323 } | 3323 } |
| 3324 List<ClassElement> result = _enums; | 3324 List<ClassElement> result = _enums; |
| 3325 _enums = null; | 3325 _enums = null; |
| 3326 return result; | 3326 return result; |
| 3327 } | 3327 } |
| 3328 | 3328 |
| 3329 List<FieldElement> get fields { | 3329 List<FieldElement> get fields { |
| 3330 if (_fields == null) { | 3330 if (_fields == null) { |
| 3331 return FieldElementImpl.EMPTY_ARRAY; | 3331 return FieldElement.EMPTY_LIST; |
| 3332 } | 3332 } |
| 3333 List<FieldElement> result = _fields; | 3333 List<FieldElement> result = _fields; |
| 3334 _fields = null; | 3334 _fields = null; |
| 3335 return result; | 3335 return result; |
| 3336 } | 3336 } |
| 3337 | 3337 |
| 3338 List<FieldElement> get fieldsWithoutFlushing { | 3338 List<FieldElement> get fieldsWithoutFlushing { |
| 3339 if (_fields == null) { | 3339 if (_fields == null) { |
| 3340 return FieldElementImpl.EMPTY_ARRAY; | 3340 return FieldElement.EMPTY_LIST; |
| 3341 } | 3341 } |
| 3342 List<FieldElement> result = _fields; | 3342 List<FieldElement> result = _fields; |
| 3343 return result; | 3343 return result; |
| 3344 } | 3344 } |
| 3345 | 3345 |
| 3346 List<FunctionElement> get functions { | 3346 List<FunctionElement> get functions { |
| 3347 if (_functions == null) { | 3347 if (_functions == null) { |
| 3348 return FunctionElementImpl.EMPTY_ARRAY; | 3348 return FunctionElement.EMPTY_LIST; |
| 3349 } | 3349 } |
| 3350 List<FunctionElement> result = _functions; | 3350 List<FunctionElement> result = _functions; |
| 3351 _functions = null; | 3351 _functions = null; |
| 3352 return result; | 3352 return result; |
| 3353 } | 3353 } |
| 3354 | 3354 |
| 3355 List<LabelElement> get labels { | 3355 List<LabelElement> get labels { |
| 3356 if (_labels == null) { | 3356 if (_labels == null) { |
| 3357 return LabelElementImpl.EMPTY_ARRAY; | 3357 return LabelElement.EMPTY_LIST; |
| 3358 } | 3358 } |
| 3359 List<LabelElement> result = _labels; | 3359 List<LabelElement> result = _labels; |
| 3360 _labels = null; | 3360 _labels = null; |
| 3361 return result; | 3361 return result; |
| 3362 } | 3362 } |
| 3363 | 3363 |
| 3364 List<LocalVariableElement> get localVariables { | 3364 List<LocalVariableElement> get localVariables { |
| 3365 if (_localVariables == null) { | 3365 if (_localVariables == null) { |
| 3366 return LocalVariableElementImpl.EMPTY_ARRAY; | 3366 return LocalVariableElement.EMPTY_LIST; |
| 3367 } | 3367 } |
| 3368 List<LocalVariableElement> result = _localVariables; | 3368 List<LocalVariableElement> result = _localVariables; |
| 3369 _localVariables = null; | 3369 _localVariables = null; |
| 3370 return result; | 3370 return result; |
| 3371 } | 3371 } |
| 3372 | 3372 |
| 3373 List<MethodElement> get methods { | 3373 List<MethodElement> get methods { |
| 3374 if (_methods == null) { | 3374 if (_methods == null) { |
| 3375 return MethodElementImpl.EMPTY_ARRAY; | 3375 return MethodElement.EMPTY_LIST; |
| 3376 } | 3376 } |
| 3377 List<MethodElement> result = _methods; | 3377 List<MethodElement> result = _methods; |
| 3378 _methods = null; | 3378 _methods = null; |
| 3379 return result; | 3379 return result; |
| 3380 } | 3380 } |
| 3381 | 3381 |
| 3382 List<ParameterElement> get parameters { | 3382 List<ParameterElement> get parameters { |
| 3383 if (_parameters == null) { | 3383 if (_parameters == null) { |
| 3384 return ParameterElementImpl.EMPTY_ARRAY; | 3384 return ParameterElement.EMPTY_LIST; |
| 3385 } | 3385 } |
| 3386 List<ParameterElement> result = _parameters; | 3386 List<ParameterElement> result = _parameters; |
| 3387 _parameters = null; | 3387 _parameters = null; |
| 3388 return result; | 3388 return result; |
| 3389 } | 3389 } |
| 3390 | 3390 |
| 3391 List<TopLevelVariableElement> get topLevelVariables { | 3391 List<TopLevelVariableElement> get topLevelVariables { |
| 3392 if (_topLevelVariables == null) { | 3392 if (_topLevelVariables == null) { |
| 3393 return TopLevelVariableElementImpl.EMPTY_ARRAY; | 3393 return TopLevelVariableElement.EMPTY_LIST; |
| 3394 } | 3394 } |
| 3395 List<TopLevelVariableElement> result = _topLevelVariables; | 3395 List<TopLevelVariableElement> result = _topLevelVariables; |
| 3396 _topLevelVariables = null; | 3396 _topLevelVariables = null; |
| 3397 return result; | 3397 return result; |
| 3398 } | 3398 } |
| 3399 | 3399 |
| 3400 List<FunctionTypeAliasElement> get typeAliases { | 3400 List<FunctionTypeAliasElement> get typeAliases { |
| 3401 if (_typeAliases == null) { | 3401 if (_typeAliases == null) { |
| 3402 return FunctionTypeAliasElementImpl.EMPTY_ARRAY; | 3402 return FunctionTypeAliasElement.EMPTY_LIST; |
| 3403 } | 3403 } |
| 3404 List<FunctionTypeAliasElement> result = _typeAliases; | 3404 List<FunctionTypeAliasElement> result = _typeAliases; |
| 3405 _typeAliases = null; | 3405 _typeAliases = null; |
| 3406 return result; | 3406 return result; |
| 3407 } | 3407 } |
| 3408 | 3408 |
| 3409 List<TypeParameterElement> get typeParameters { | 3409 List<TypeParameterElement> get typeParameters { |
| 3410 if (_typeParameters == null) { | 3410 if (_typeParameters == null) { |
| 3411 return TypeParameterElementImpl.EMPTY_ARRAY; | 3411 return TypeParameterElement.EMPTY_LIST; |
| 3412 } | 3412 } |
| 3413 List<TypeParameterElement> result = _typeParameters; | 3413 List<TypeParameterElement> result = _typeParameters; |
| 3414 _typeParameters = null; | 3414 _typeParameters = null; |
| 3415 return result; | 3415 return result; |
| 3416 } | 3416 } |
| 3417 | 3417 |
| 3418 List<ClassElement> get types { | 3418 List<ClassElement> get types { |
| 3419 if (_types == null) { | 3419 if (_types == null) { |
| 3420 return ClassElementImpl.EMPTY_ARRAY; | 3420 return ClassElement.EMPTY_LIST; |
| 3421 } | 3421 } |
| 3422 List<ClassElement> result = _types; | 3422 List<ClassElement> result = _types; |
| 3423 _types = null; | 3423 _types = null; |
| 3424 return result; | 3424 return result; |
| 3425 } | 3425 } |
| 3426 | 3426 |
| 3427 void addAccessor(PropertyAccessorElement element) { | 3427 void addAccessor(PropertyAccessorElement element) { |
| 3428 if (_accessors == null) { | 3428 if (_accessors == null) { |
| 3429 _accessors = new List<PropertyAccessorElement>(); | 3429 _accessors = new List<PropertyAccessorElement>(); |
| 3430 } | 3430 } |
| (...skipping 11087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14518 * | 14518 * |
| 14519 * @param type the type whole type arguments are to be returned | 14519 * @param type the type whole type arguments are to be returned |
| 14520 * @return the type arguments associated with the given type | 14520 * @return the type arguments associated with the given type |
| 14521 */ | 14521 */ |
| 14522 List<DartType> _getTypeArguments(DartType type) { | 14522 List<DartType> _getTypeArguments(DartType type) { |
| 14523 if (type is InterfaceType) { | 14523 if (type is InterfaceType) { |
| 14524 return type.typeArguments; | 14524 return type.typeArguments; |
| 14525 } else if (type is FunctionType) { | 14525 } else if (type is FunctionType) { |
| 14526 return type.typeArguments; | 14526 return type.typeArguments; |
| 14527 } | 14527 } |
| 14528 return TypeImpl.EMPTY_ARRAY; | 14528 return DartType.EMPTY_LIST; |
| 14529 } | 14529 } |
| 14530 | 14530 |
| 14531 /** | 14531 /** |
| 14532 * Returns the simple identifier of the given (may be qualified) type name. | 14532 * Returns the simple identifier of the given (may be qualified) type name. |
| 14533 * | 14533 * |
| 14534 * @param typeName the (may be qualified) qualified type name | 14534 * @param typeName the (may be qualified) qualified type name |
| 14535 * @return the simple identifier of the given (may be qualified) type name. | 14535 * @return the simple identifier of the given (may be qualified) type name. |
| 14536 */ | 14536 */ |
| 14537 SimpleIdentifier _getTypeSimpleIdentifier(Identifier typeName) { | 14537 SimpleIdentifier _getTypeSimpleIdentifier(Identifier typeName) { |
| 14538 if (typeName is SimpleIdentifier) { | 14538 if (typeName is SimpleIdentifier) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14810 FunctionTypeAliasElement alias = | 14810 FunctionTypeAliasElement alias = |
| 14811 element.getAncestor((element) => element is FunctionTypeAliasElement); | 14811 element.getAncestor((element) => element is FunctionTypeAliasElement); |
| 14812 while (alias != null && alias.isSynthetic) { | 14812 while (alias != null && alias.isSynthetic) { |
| 14813 alias = | 14813 alias = |
| 14814 alias.getAncestor((element) => element is FunctionTypeAliasElement); | 14814 alias.getAncestor((element) => element is FunctionTypeAliasElement); |
| 14815 } | 14815 } |
| 14816 if (alias != null) { | 14816 if (alias != null) { |
| 14817 aliasElement.typeParameters = alias.typeParameters; | 14817 aliasElement.typeParameters = alias.typeParameters; |
| 14818 type.typeArguments = alias.type.typeArguments; | 14818 type.typeArguments = alias.type.typeArguments; |
| 14819 } else { | 14819 } else { |
| 14820 type.typeArguments = TypeImpl.EMPTY_ARRAY; | 14820 type.typeArguments = DartType.EMPTY_LIST; |
| 14821 } | 14821 } |
| 14822 } | 14822 } |
| 14823 element.type = type; | 14823 element.type = type; |
| 14824 } | 14824 } |
| 14825 | 14825 |
| 14826 /** | 14826 /** |
| 14827 * @return `true` if the name of the given [TypeName] is an built-in identifie
r. | 14827 * @return `true` if the name of the given [TypeName] is an built-in identifie
r. |
| 14828 */ | 14828 */ |
| 14829 static bool _isBuiltInIdentifier(TypeName node) { | 14829 static bool _isBuiltInIdentifier(TypeName node) { |
| 14830 sc.Token token = node.name.beginToken; | 14830 sc.Token token = node.name.beginToken; |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15411 nonFields.add(node); | 15411 nonFields.add(node); |
| 15412 return null; | 15412 return null; |
| 15413 } | 15413 } |
| 15414 | 15414 |
| 15415 @override | 15415 @override |
| 15416 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 15416 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
| 15417 | 15417 |
| 15418 @override | 15418 @override |
| 15419 Object visitWithClause(WithClause node) => null; | 15419 Object visitWithClause(WithClause node) => null; |
| 15420 } | 15420 } |
| OLD | NEW |