Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_ast.dart

Issue 2622303006: Reapply "Add support for generic function type syntax, part 1" (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 /** 560 /**
561 * Serialize the given [declaredIdentifier] into [UnlinkedVariable], and 561 * Serialize the given [declaredIdentifier] into [UnlinkedVariable], and
562 * store it in [variables]. 562 * store it in [variables].
563 */ 563 */
564 void serializeDeclaredIdentifier( 564 void serializeDeclaredIdentifier(
565 AstNode scopeNode, 565 AstNode scopeNode,
566 Comment documentationComment, 566 Comment documentationComment,
567 NodeList<Annotation> annotations, 567 NodeList<Annotation> annotations,
568 bool isFinal, 568 bool isFinal,
569 bool isConst, 569 bool isConst,
570 TypeName type, 570 TypeAnnotation type,
571 bool assignPropagatedTypeSlot, 571 bool assignPropagatedTypeSlot,
572 SimpleIdentifier declaredIdentifier) { 572 SimpleIdentifier declaredIdentifier) {
573 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(); 573 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder();
574 b.isFinal = isFinal; 574 b.isFinal = isFinal;
575 b.isConst = isConst; 575 b.isConst = isConst;
576 b.name = declaredIdentifier.name; 576 b.name = declaredIdentifier.name;
577 b.nameOffset = declaredIdentifier.offset; 577 b.nameOffset = declaredIdentifier.offset;
578 b.type = serializeTypeName(type); 578 b.type = serializeTypeName(type);
579 b.documentationComment = serializeDocumentation(documentationComment); 579 b.documentationComment = serializeDocumentation(documentationComment);
580 b.annotations = serializeAnnotations(annotations); 580 b.annotations = serializeAnnotations(annotations);
(...skipping 27 matching lines...) Expand all
608 * 608 *
609 * If [serializeBodyExpr] is `true`, then the function definition is stored 609 * If [serializeBodyExpr] is `true`, then the function definition is stored
610 * in [UnlinkedExecutableBuilder.bodyExpr]. 610 * in [UnlinkedExecutableBuilder.bodyExpr].
611 */ 611 */
612 UnlinkedExecutableBuilder serializeExecutable( 612 UnlinkedExecutableBuilder serializeExecutable(
613 AstNode node, 613 AstNode node,
614 String name, 614 String name,
615 int nameOffset, 615 int nameOffset,
616 bool isGetter, 616 bool isGetter,
617 bool isSetter, 617 bool isSetter,
618 TypeName returnType, 618 TypeAnnotation returnType,
619 FormalParameterList formalParameters, 619 FormalParameterList formalParameters,
620 FunctionBody body, 620 FunctionBody body,
621 bool isTopLevel, 621 bool isTopLevel,
622 bool isDeclaredStatic, 622 bool isDeclaredStatic,
623 Comment documentationComment, 623 Comment documentationComment,
624 NodeList<Annotation> annotations, 624 NodeList<Annotation> annotations,
625 TypeParameterList typeParameters, 625 TypeParameterList typeParameters,
626 bool isExternal, 626 bool isExternal,
627 bool serializeBodyExpr, 627 bool serializeBodyExpr,
628 bool serializeBody) { 628 bool serializeBody) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 _localClosureIndexMap = oldLocalClosureIndexMap; 757 _localClosureIndexMap = oldLocalClosureIndexMap;
758 _serializeClosureBodyExprs = oldSerializeClosureBodyExprs; 758 _serializeClosureBodyExprs = oldSerializeClosureBodyExprs;
759 return localClosureIndexMap; 759 return localClosureIndexMap;
760 } 760 }
761 761
762 /** 762 /**
763 * Serialize the return type and parameters of a function-typed formal 763 * Serialize the return type and parameters of a function-typed formal
764 * parameter and store them in [b]. 764 * parameter and store them in [b].
765 */ 765 */
766 void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b, 766 void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b,
767 TypeName returnType, FormalParameterList parameters) { 767 TypeAnnotation returnType, FormalParameterList parameters) {
768 EntityRefBuilder serializedReturnType = serializeTypeName(returnType); 768 EntityRefBuilder serializedReturnType = serializeTypeName(returnType);
769 if (serializedReturnType != null) { 769 if (serializedReturnType != null) {
770 b.type = serializedReturnType; 770 b.type = serializedReturnType;
771 } 771 }
772 bool oldMayInheritCovariance = _parametersMayInheritCovariance; 772 bool oldMayInheritCovariance = _parametersMayInheritCovariance;
773 _parametersMayInheritCovariance = false; 773 _parametersMayInheritCovariance = false;
774 b.parameters = parameters.parameters 774 b.parameters = parameters.parameters
775 .map((FormalParameter p) => p.accept(this) as UnlinkedParamBuilder) 775 .map((FormalParameter p) => p.accept(this) as UnlinkedParamBuilder)
776 .toList(); 776 .toList();
777 _parametersMayInheritCovariance = oldMayInheritCovariance; 777 _parametersMayInheritCovariance = oldMayInheritCovariance;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return b; 926 return b;
927 } 927 }
928 } 928 }
929 929
930 /** 930 /**
931 * Serialize a type name (which might be defined in a nested scope, at top 931 * Serialize a type name (which might be defined in a nested scope, at top
932 * level within this library, or at top level within an imported library) to 932 * level within this library, or at top level within an imported library) to
933 * a [EntityRef]. Note that this method does the right thing if the 933 * a [EntityRef]. Note that this method does the right thing if the
934 * name doesn't refer to an entity other than a type (e.g. a class member). 934 * name doesn't refer to an entity other than a type (e.g. a class member).
935 */ 935 */
936 EntityRefBuilder serializeTypeName(TypeName node) { 936 EntityRefBuilder serializeTypeName(TypeAnnotation node) {
937 return serializeType(node?.name, node?.typeArguments); 937 if (node is TypeName) {
938 return serializeType(node?.name, node?.typeArguments);
939 } else if (node != null) {
940 throw new ArgumentError('Cannot serialize a ${node.runtimeType}');
941 }
942 return null;
938 } 943 }
939 944
940 /** 945 /**
941 * Serialize the given [typeParameters] into a list of [UnlinkedTypeParam]s, 946 * Serialize the given [typeParameters] into a list of [UnlinkedTypeParam]s,
942 * and also store them in [typeParameterScope]. 947 * and also store them in [typeParameterScope].
943 */ 948 */
944 List<UnlinkedTypeParamBuilder> serializeTypeParameters( 949 List<UnlinkedTypeParamBuilder> serializeTypeParameters(
945 TypeParameterList typeParameters, 950 TypeParameterList typeParameters,
946 _TypeParameterScope typeParameterScope) { 951 _TypeParameterScope typeParameterScope) {
947 if (typeParameters != null) { 952 if (typeParameters != null) {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 return b; 1395 return b;
1391 } 1396 }
1392 1397
1393 @override 1398 @override
1394 void visitVariableDeclarationStatement(VariableDeclarationStatement node) { 1399 void visitVariableDeclarationStatement(VariableDeclarationStatement node) {
1395 serializeVariables( 1400 serializeVariables(
1396 enclosingBlock, node.variables, false, null, null, false); 1401 enclosingBlock, node.variables, false, null, null, false);
1397 } 1402 }
1398 1403
1399 /** 1404 /**
1400 * Helper method to determine if a given [typeName] refers to `dynamic`.
1401 */
1402 static bool isDynamic(TypeName typeName) {
1403 Identifier name = typeName.name;
1404 return name is SimpleIdentifier && name.name == 'dynamic';
1405 }
1406
1407 /**
1408 * Compute the API signature of the unit and record it. 1405 * Compute the API signature of the unit and record it.
1409 */ 1406 */
1410 static void _computeApiSignature(UnlinkedUnitBuilder b) { 1407 static void _computeApiSignature(UnlinkedUnitBuilder b) {
1411 ApiSignature apiSignature = new ApiSignature(); 1408 ApiSignature apiSignature = new ApiSignature();
1412 b.collectApiSignature(apiSignature); 1409 b.collectApiSignature(apiSignature);
1413 b.apiSignature = apiSignature.toByteList(); 1410 b.apiSignature = apiSignature.toByteList();
1414 } 1411 }
1415 } 1412 }
1416 1413
1417 /** 1414 /**
1418 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1415 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1419 */ 1416 */
1420 class _TypeParameterScope extends _Scope { 1417 class _TypeParameterScope extends _Scope {
1421 /** 1418 /**
1422 * Get the number of [_ScopedTypeParameter]s defined in this 1419 * Get the number of [_ScopedTypeParameter]s defined in this
1423 * [_TypeParameterScope]. 1420 * [_TypeParameterScope].
1424 */ 1421 */
1425 int get length => _definedNames.length; 1422 int get length => _definedNames.length;
1426 } 1423 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | pkg/analyzer/lib/src/summary/summarize_const_expr.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698