| 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_ast; | 5 library serialization.summarize_ast; |
| 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/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart' show DartType; | 10 import 'package:analyzer/dart/element/type.dart' show DartType; |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 b.nameOffset = nameOffset; | 634 b.nameOffset = nameOffset; |
| 635 b.typeParameters = | 635 b.typeParameters = |
| 636 serializeTypeParameters(typeParameters, typeParameterScope); | 636 serializeTypeParameters(typeParameters, typeParameterScope); |
| 637 if (!isTopLevel) { | 637 if (!isTopLevel) { |
| 638 b.isStatic = isDeclaredStatic; | 638 b.isStatic = isDeclaredStatic; |
| 639 } | 639 } |
| 640 b.returnType = serializeTypeName(returnType); | 640 b.returnType = serializeTypeName(returnType); |
| 641 bool isSemanticallyStatic = isTopLevel || isDeclaredStatic; | 641 bool isSemanticallyStatic = isTopLevel || isDeclaredStatic; |
| 642 if (formalParameters != null) { | 642 if (formalParameters != null) { |
| 643 b.parameters = formalParameters.parameters | 643 b.parameters = formalParameters.parameters |
| 644 .map((FormalParameter p) => p.accept(this)) | 644 .map((FormalParameter p) => p.accept(this) as UnlinkedParamBuilder) |
| 645 .toList(); | 645 .toList(); |
| 646 if (!isSemanticallyStatic) { | 646 if (!isSemanticallyStatic) { |
| 647 for (int i = 0; i < formalParameters.parameters.length; i++) { | 647 for (int i = 0; i < formalParameters.parameters.length; i++) { |
| 648 if (!b.parameters[i].isFunctionTyped && | 648 if (!b.parameters[i].isFunctionTyped && |
| 649 b.parameters[i].type == null) { | 649 b.parameters[i].type == null) { |
| 650 b.parameters[i].inferredTypeSlot = assignSlot(); | 650 b.parameters[i].inferredTypeSlot = assignSlot(); |
| 651 } | 651 } |
| 652 } | 652 } |
| 653 } | 653 } |
| 654 } | 654 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 * Serialize the return type and parameters of a function-typed formal | 744 * Serialize the return type and parameters of a function-typed formal |
| 745 * parameter and store them in [b]. | 745 * parameter and store them in [b]. |
| 746 */ | 746 */ |
| 747 void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b, | 747 void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b, |
| 748 TypeName returnType, FormalParameterList parameters) { | 748 TypeName returnType, FormalParameterList parameters) { |
| 749 EntityRefBuilder serializedReturnType = serializeTypeName(returnType); | 749 EntityRefBuilder serializedReturnType = serializeTypeName(returnType); |
| 750 if (serializedReturnType != null) { | 750 if (serializedReturnType != null) { |
| 751 b.type = serializedReturnType; | 751 b.type = serializedReturnType; |
| 752 } | 752 } |
| 753 b.parameters = parameters.parameters | 753 b.parameters = parameters.parameters |
| 754 .map((FormalParameter p) => p.accept(this)) | 754 .map((FormalParameter p) => p.accept(this) as UnlinkedParamBuilder) |
| 755 .toList(); | 755 .toList(); |
| 756 } | 756 } |
| 757 | 757 |
| 758 /** | 758 /** |
| 759 * If the given [expression] is not `null`, serialize it as an | 759 * If the given [expression] is not `null`, serialize it as an |
| 760 * [UnlinkedExecutableBuilder], otherwise return `null`. | 760 * [UnlinkedExecutableBuilder], otherwise return `null`. |
| 761 * | 761 * |
| 762 * If [serializeBodyExpr] is `true`, then the initializer expression is stored | 762 * If [serializeBodyExpr] is `true`, then the initializer expression is stored |
| 763 * in [UnlinkedExecutableBuilder.bodyExpr]. | 763 * in [UnlinkedExecutableBuilder.bodyExpr]. |
| 764 */ | 764 */ |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 UnlinkedExecutableBuilder b = new UnlinkedExecutableBuilder(); | 1035 UnlinkedExecutableBuilder b = new UnlinkedExecutableBuilder(); |
| 1036 if (node.name != null) { | 1036 if (node.name != null) { |
| 1037 b.name = node.name.name; | 1037 b.name = node.name.name; |
| 1038 b.nameOffset = node.name.offset; | 1038 b.nameOffset = node.name.offset; |
| 1039 b.periodOffset = node.period.offset; | 1039 b.periodOffset = node.period.offset; |
| 1040 b.nameEnd = node.name.end; | 1040 b.nameEnd = node.name.end; |
| 1041 } else { | 1041 } else { |
| 1042 b.nameOffset = node.returnType.offset; | 1042 b.nameOffset = node.returnType.offset; |
| 1043 } | 1043 } |
| 1044 b.parameters = node.parameters.parameters | 1044 b.parameters = node.parameters.parameters |
| 1045 .map((FormalParameter p) => p.accept(this)) | 1045 .map((FormalParameter p) => p.accept(this) as UnlinkedParamBuilder) |
| 1046 .toList(); | 1046 .toList(); |
| 1047 b.kind = UnlinkedExecutableKind.constructor; | 1047 b.kind = UnlinkedExecutableKind.constructor; |
| 1048 if (node.factoryKeyword != null) { | 1048 if (node.factoryKeyword != null) { |
| 1049 b.isFactory = true; | 1049 b.isFactory = true; |
| 1050 if (node.redirectedConstructor != null) { | 1050 if (node.redirectedConstructor != null) { |
| 1051 b.isRedirectedConstructor = true; | 1051 b.isRedirectedConstructor = true; |
| 1052 TypeName typeName = node.redirectedConstructor.type; | 1052 TypeName typeName = node.redirectedConstructor.type; |
| 1053 // Closures can't appear inside factory constructor redirections, so we | 1053 // Closures can't appear inside factory constructor redirections, so we |
| 1054 // don't need a localClosureIndexMap. | 1054 // don't need a localClosureIndexMap. |
| 1055 Map<int, int> localClosureIndexMap = null; | 1055 Map<int, int> localClosureIndexMap = null; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 UnlinkedTypedefBuilder b = new UnlinkedTypedefBuilder(); | 1228 UnlinkedTypedefBuilder b = new UnlinkedTypedefBuilder(); |
| 1229 b.name = node.name.name; | 1229 b.name = node.name.name; |
| 1230 b.nameOffset = node.name.offset; | 1230 b.nameOffset = node.name.offset; |
| 1231 b.typeParameters = | 1231 b.typeParameters = |
| 1232 serializeTypeParameters(node.typeParameters, typeParameterScope); | 1232 serializeTypeParameters(node.typeParameters, typeParameterScope); |
| 1233 EntityRefBuilder serializedReturnType = serializeTypeName(node.returnType); | 1233 EntityRefBuilder serializedReturnType = serializeTypeName(node.returnType); |
| 1234 if (serializedReturnType != null) { | 1234 if (serializedReturnType != null) { |
| 1235 b.returnType = serializedReturnType; | 1235 b.returnType = serializedReturnType; |
| 1236 } | 1236 } |
| 1237 b.parameters = node.parameters.parameters | 1237 b.parameters = node.parameters.parameters |
| 1238 .map((FormalParameter p) => p.accept(this)) | 1238 .map((FormalParameter p) => p.accept(this) as UnlinkedParamBuilder) |
| 1239 .toList(); | 1239 .toList(); |
| 1240 b.documentationComment = serializeDocumentation(node.documentationComment); | 1240 b.documentationComment = serializeDocumentation(node.documentationComment); |
| 1241 b.annotations = serializeAnnotations(node.metadata); | 1241 b.annotations = serializeAnnotations(node.metadata); |
| 1242 b.codeRange = serializeCodeRange(node); | 1242 b.codeRange = serializeCodeRange(node); |
| 1243 typedefs.add(b); | 1243 typedefs.add(b); |
| 1244 scopes.removeLast(); | 1244 scopes.removeLast(); |
| 1245 assert(scopes.length == oldScopesLength); | 1245 assert(scopes.length == oldScopesLength); |
| 1246 } | 1246 } |
| 1247 | 1247 |
| 1248 @override | 1248 @override |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 /** | 1376 /** |
| 1377 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 1377 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 1378 */ | 1378 */ |
| 1379 class _TypeParameterScope extends _Scope { | 1379 class _TypeParameterScope extends _Scope { |
| 1380 /** | 1380 /** |
| 1381 * Get the number of [_ScopedTypeParameter]s defined in this | 1381 * Get the number of [_ScopedTypeParameter]s defined in this |
| 1382 * [_TypeParameterScope]. | 1382 * [_TypeParameterScope]. |
| 1383 */ | 1383 */ |
| 1384 int get length => _definedNames.length; | 1384 int get length => _definedNames.length; |
| 1385 } | 1385 } |
| OLD | NEW |