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 8443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8454 return null; | 8454 return null; |
8455 } | 8455 } |
8456 | 8456 |
8457 /** | 8457 /** |
8458 * Return the type represented by the given type [annotation]. | 8458 * Return the type represented by the given type [annotation]. |
8459 */ | 8459 */ |
8460 DartType _getType(TypeAnnotation annotation) { | 8460 DartType _getType(TypeAnnotation annotation) { |
8461 DartType type = annotation.type; | 8461 DartType type = annotation.type; |
8462 if (type == null) { | 8462 if (type == null) { |
8463 return undefinedType; | 8463 return undefinedType; |
8464 } else if (type is FunctionType) { | |
8465 Element element = type.element; | |
8466 if (annotation is TypeName && element is GenericTypeAliasElement) { | |
8467 List<TypeParameterElement> parameterElements = element.typeParameters; | |
8468 FunctionType functionType = element.function.type; | |
8469 if (parameterElements.isNotEmpty) { | |
8470 List<DartType> parameterTypes = | |
8471 TypeParameterTypeImpl.getTypes(parameterElements); | |
8472 int parameterCount = parameterTypes.length; | |
8473 TypeArgumentList argumentList = annotation.typeArguments; | |
8474 List<DartType> typeArguments; | |
8475 if (argumentList == null) { | |
8476 typeArguments = | |
8477 new List<DartType>.filled(parameterCount, dynamicType); | |
8478 } else { | |
8479 List<TypeAnnotation> arguments = argumentList.arguments; | |
8480 int argumentCount = arguments.length; | |
8481 if (argumentCount == parameterCount) { | |
8482 typeArguments = new List<DartType>(parameterCount); | |
8483 for (int i = 0; i < parameterCount; i++) { | |
8484 typeArguments[i] = _getType(arguments[i]) ?? dynamicType; | |
scheglov
2017/04/05 00:11:56
Is this recursion?
It seems that _getType() does n
Brian Wilkerson
2017/04/05 13:23:23
Yes, but it's guaranteed to terminate because it's
| |
8485 } | |
8486 } else { | |
8487 typeArguments = | |
8488 new List<DartType>.filled(parameterCount, dynamicType); | |
scheglov
2017/04/05 00:11:56
Could be a bit simpler with typeArguments ??= ...f
Brian Wilkerson
2017/04/05 13:23:23
Done
| |
8489 } | |
8490 } | |
8491 functionType = | |
8492 functionType.substitute2(typeArguments, parameterTypes); | |
8493 } | |
8494 return functionType; | |
8495 } | |
8464 } | 8496 } |
8465 return type; | 8497 return type; |
8466 } | 8498 } |
8467 | 8499 |
8468 /** | 8500 /** |
8469 * Returns the simple identifier of the given (may be qualified) type name. | 8501 * Returns the simple identifier of the given (may be qualified) type name. |
8470 * | 8502 * |
8471 * @param typeName the (may be qualified) qualified type name | 8503 * @param typeName the (may be qualified) qualified type name |
8472 * @return the simple identifier of the given (may be qualified) type name. | 8504 * @return the simple identifier of the given (may be qualified) type name. |
8473 */ | 8505 */ |
(...skipping 2422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10896 return null; | 10928 return null; |
10897 } | 10929 } |
10898 if (identical(node.staticElement, variable)) { | 10930 if (identical(node.staticElement, variable)) { |
10899 if (node.inSetterContext()) { | 10931 if (node.inSetterContext()) { |
10900 result = true; | 10932 result = true; |
10901 } | 10933 } |
10902 } | 10934 } |
10903 return null; | 10935 return null; |
10904 } | 10936 } |
10905 } | 10937 } |
OLD | NEW |