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

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

Issue 2644543005: Element model support for covariant (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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 /** 800 /**
801 * Serialize a [FieldFormalParameter], [FunctionTypedFormalParameter], or 801 * Serialize a [FieldFormalParameter], [FunctionTypedFormalParameter], or
802 * [SimpleFormalParameter] into an [UnlinkedParam]. 802 * [SimpleFormalParameter] into an [UnlinkedParam].
803 */ 803 */
804 UnlinkedParamBuilder serializeParameter(NormalFormalParameter node) { 804 UnlinkedParamBuilder serializeParameter(NormalFormalParameter node) {
805 UnlinkedParamBuilder b = new UnlinkedParamBuilder(); 805 UnlinkedParamBuilder b = new UnlinkedParamBuilder();
806 b.name = node.identifier.name; 806 b.name = node.identifier.name;
807 b.nameOffset = node.identifier.offset; 807 b.nameOffset = node.identifier.offset;
808 b.annotations = serializeAnnotations(node.metadata); 808 b.annotations = serializeAnnotations(node.metadata);
809 b.codeRange = serializeCodeRange(node); 809 b.codeRange = serializeCodeRange(node);
810 b.isExplicitlyCovariant = node.covariantKeyword != null;
810 if (_parametersMayInheritCovariance) { 811 if (_parametersMayInheritCovariance) {
811 b.inheritsCovariantSlot = assignSlot(); 812 b.inheritsCovariantSlot = assignSlot();
812 } 813 }
813 switch (node.kind) { 814 switch (node.kind) {
814 case ParameterKind.REQUIRED: 815 case ParameterKind.REQUIRED:
815 b.kind = UnlinkedParamKind.required; 816 b.kind = UnlinkedParamKind.required;
816 break; 817 break;
817 case ParameterKind.POSITIONAL: 818 case ParameterKind.POSITIONAL:
818 b.kind = UnlinkedParamKind.positional; 819 b.kind = UnlinkedParamKind.positional;
819 break; 820 break;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 * Serialize the given [variables] into [UnlinkedVariable]s, and store them 965 * Serialize the given [variables] into [UnlinkedVariable]s, and store them
965 * in [this.variables]. 966 * in [this.variables].
966 */ 967 */
967 void serializeVariables( 968 void serializeVariables(
968 AstNode scopeNode, 969 AstNode scopeNode,
969 VariableDeclarationList variables, 970 VariableDeclarationList variables,
970 bool isDeclaredStatic, 971 bool isDeclaredStatic,
971 Comment documentationComment, 972 Comment documentationComment,
972 NodeList<Annotation> annotations, 973 NodeList<Annotation> annotations,
973 bool isField) { 974 bool isField) {
975 bool isCovariant = isField
976 ? (variables.parent as FieldDeclaration).covariantKeyword != null
977 : false;
974 for (VariableDeclaration variable in variables.variables) { 978 for (VariableDeclaration variable in variables.variables) {
975 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(); 979 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder();
980 b.isConst = variables.isConst;
981 b.isCovariant = isCovariant;
976 b.isFinal = variables.isFinal; 982 b.isFinal = variables.isFinal;
977 b.isConst = variables.isConst;
978 b.isStatic = isDeclaredStatic; 983 b.isStatic = isDeclaredStatic;
979 b.name = variable.name.name; 984 b.name = variable.name.name;
980 b.nameOffset = variable.name.offset; 985 b.nameOffset = variable.name.offset;
981 b.type = serializeTypeName(variables.type); 986 b.type = serializeTypeName(variables.type);
982 b.documentationComment = serializeDocumentation(documentationComment); 987 b.documentationComment = serializeDocumentation(documentationComment);
983 b.annotations = serializeAnnotations(annotations); 988 b.annotations = serializeAnnotations(annotations);
984 b.codeRange = serializeCodeRange(variables.parent); 989 b.codeRange = serializeCodeRange(variables.parent);
985 bool serializeBodyExpr = variable.isConst || 990 bool serializeBodyExpr = variable.isConst ||
986 variable.isFinal && isField && !isDeclaredStatic || 991 variable.isFinal && isField && !isDeclaredStatic ||
987 variables.type == null; 992 variables.type == null;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 /** 1419 /**
1415 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. 1420 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s.
1416 */ 1421 */
1417 class _TypeParameterScope extends _Scope { 1422 class _TypeParameterScope extends _Scope {
1418 /** 1423 /**
1419 * Get the number of [_ScopedTypeParameter]s defined in this 1424 * Get the number of [_ScopedTypeParameter]s defined in this
1420 * [_TypeParameterScope]. 1425 * [_TypeParameterScope].
1421 */ 1426 */
1422 int get length => _definedNames.length; 1427 int get length => _definedNames.length;
1423 } 1428 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698