| 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(TypeAnnotation type) { | 181 EntityRefBuilder serializeTypeName(TypeName type) { |
| 182 if (type is TypeName) { | 182 return serializeType(type?.type, type?.name, type?.typeArguments); |
| 183 return serializeType(type?.type, type?.name, type?.typeArguments); | |
| 184 } | |
| 185 throw new ArgumentError( | |
| 186 'Cannot serialize an instance of ${type.runtimeType}'); | |
| 187 } | 183 } |
| 188 | 184 |
| 189 /** | 185 /** |
| 190 * Return the [UnlinkedExprBuilder] that corresponds to the state of this | 186 * Return the [UnlinkedExprBuilder] that corresponds to the state of this |
| 191 * serializer. | 187 * serializer. |
| 192 */ | 188 */ |
| 193 UnlinkedExprBuilder toBuilder() { | 189 UnlinkedExprBuilder toBuilder() { |
| 194 return new UnlinkedExprBuilder( | 190 return new UnlinkedExprBuilder( |
| 195 isValidConst: isValidConst, | 191 isValidConst: isValidConst, |
| 196 operations: operations, | 192 operations: operations, |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 operations.add(UnlinkedExprOperation.concatenate); | 642 operations.add(UnlinkedExprOperation.concatenate); |
| 647 ints.add(interpolation.elements.length); | 643 ints.add(interpolation.elements.length); |
| 648 } | 644 } |
| 649 } | 645 } |
| 650 | 646 |
| 651 void _serializeTypeArguments(TypeArgumentList typeArguments) { | 647 void _serializeTypeArguments(TypeArgumentList typeArguments) { |
| 652 if (typeArguments == null) { | 648 if (typeArguments == null) { |
| 653 ints.add(0); | 649 ints.add(0); |
| 654 } else { | 650 } else { |
| 655 ints.add(typeArguments.arguments.length); | 651 ints.add(typeArguments.arguments.length); |
| 656 for (TypeAnnotation type in typeArguments.arguments) { | 652 for (TypeName typeName in typeArguments.arguments) { |
| 657 references.add(serializeTypeName(type)); | 653 references.add(serializeTypeName(typeName)); |
| 658 } | 654 } |
| 659 } | 655 } |
| 660 } | 656 } |
| 661 } | 657 } |
| OLD | NEW |