| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 serialization.summarize_const_expr; | 5 library serialization.summarize_const_expr; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart' show DartType; | 9 import 'package:analyzer/dart/element/type.dart' show DartType; |
| 10 import 'package:analyzer/src/summary/format.dart'; | 10 import 'package:analyzer/src/summary/format.dart'; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 * [name] and [arguments]. It is expected that [type] corresponds to the | 171 * [name] and [arguments]. It is expected that [type] corresponds to the |
| 172 * given [name] and [arguments]. The parameter [type] might be `null` if the | 172 * given [name] and [arguments]. The parameter [type] might be `null` if the |
| 173 * type is not resolved. | 173 * type is not resolved. |
| 174 */ | 174 */ |
| 175 EntityRefBuilder serializeType( | 175 EntityRefBuilder serializeType( |
| 176 DartType type, Identifier name, TypeArgumentList arguments); | 176 DartType type, Identifier name, TypeArgumentList arguments); |
| 177 | 177 |
| 178 /** | 178 /** |
| 179 * Return [EntityRefBuilder] that corresponds to the given [type]. | 179 * Return [EntityRefBuilder] that corresponds to the given [type]. |
| 180 */ | 180 */ |
| 181 EntityRefBuilder serializeTypeName(TypeName type) { | 181 EntityRefBuilder serializeTypeName(TypeAnnotation type) { |
| 182 return serializeType(type?.type, type?.name, type?.typeArguments); | 182 if (type is TypeName) { |
| 183 return serializeType(type?.type, type?.name, type?.typeArguments); |
| 184 } |
| 185 throw new ArgumentError( |
| 186 'Cannot serialize an instance of ${type.runtimeType}'); |
| 183 } | 187 } |
| 184 | 188 |
| 185 /** | 189 /** |
| 186 * Return the [UnlinkedExprBuilder] that corresponds to the state of this | 190 * Return the [UnlinkedExprBuilder] that corresponds to the state of this |
| 187 * serializer. | 191 * serializer. |
| 188 */ | 192 */ |
| 189 UnlinkedExprBuilder toBuilder() { | 193 UnlinkedExprBuilder toBuilder() { |
| 190 return new UnlinkedExprBuilder( | 194 return new UnlinkedExprBuilder( |
| 191 isValidConst: isValidConst, | 195 isValidConst: isValidConst, |
| 192 operations: operations, | 196 operations: operations, |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 operations.add(UnlinkedExprOperation.concatenate); | 646 operations.add(UnlinkedExprOperation.concatenate); |
| 643 ints.add(interpolation.elements.length); | 647 ints.add(interpolation.elements.length); |
| 644 } | 648 } |
| 645 } | 649 } |
| 646 | 650 |
| 647 void _serializeTypeArguments(TypeArgumentList typeArguments) { | 651 void _serializeTypeArguments(TypeArgumentList typeArguments) { |
| 648 if (typeArguments == null) { | 652 if (typeArguments == null) { |
| 649 ints.add(0); | 653 ints.add(0); |
| 650 } else { | 654 } else { |
| 651 ints.add(typeArguments.arguments.length); | 655 ints.add(typeArguments.arguments.length); |
| 652 for (TypeName typeName in typeArguments.arguments) { | 656 for (TypeAnnotation type in typeArguments.arguments) { |
| 653 references.add(serializeTypeName(typeName)); | 657 references.add(serializeTypeName(type)); |
| 654 } | 658 } |
| 655 } | 659 } |
| 656 } | 660 } |
| 657 } | 661 } |
| OLD | NEW |