| Index: pkg/analyzer/lib/src/summary/summarize_ast.dart
|
| diff --git a/pkg/analyzer/lib/src/summary/summarize_ast.dart b/pkg/analyzer/lib/src/summary/summarize_ast.dart
|
| index c0b0df5a6232403cd6ab4f88fb36b70eeb40b371..5ab4159896fa47157cdf7427fc919770bc3e4e7e 100644
|
| --- a/pkg/analyzer/lib/src/summary/summarize_ast.dart
|
| +++ b/pkg/analyzer/lib/src/summary/summarize_ast.dart
|
| @@ -10,6 +10,7 @@ import 'package:analyzer/src/generated/scanner.dart';
|
| import 'package:analyzer/src/generated/utilities_dart.dart';
|
| import 'package:analyzer/src/summary/format.dart';
|
| import 'package:analyzer/src/summary/public_namespace_computer.dart';
|
| +import 'package:analyzer/src/summary/summarize_const_expr.dart';
|
|
|
| /**
|
| * Serialize all the declarations in [compilationUnit] to an unlinked summary.
|
| @@ -19,6 +20,21 @@ UnlinkedUnitBuilder serializeAstUnlinked(CompilationUnit compilationUnit) {
|
| }
|
|
|
| /**
|
| + * Instances of this class keep track of intermediate state during
|
| + * serialization of a single constant [Expression].
|
| + */
|
| +class _ConstExprSerializer extends AbstractConstExprSerializer {
|
| + UnlinkedTypeRefBuilder serializeIdentifier(Identifier identifier) {
|
| + throw new UnimplementedError('serializeIdentifier');
|
| + }
|
| +
|
| + @override
|
| + UnlinkedTypeRefBuilder serializeType(TypeName typeName) {
|
| + throw new UnimplementedError('serializeType');
|
| + }
|
| +}
|
| +
|
| +/**
|
| * An [_OtherScopedEntity] is a [_ScopedEntity] that does not refer to a type
|
| * parameter. Since we don't need to track any special information about these
|
| * types of scoped entities, it is a singleton class.
|
| @@ -341,6 +357,15 @@ class _SummarizeAstVisitor extends SimpleAstVisitor {
|
| }
|
|
|
| /**
|
| + * Serialize the given [expression], creating an [UnlinkedConstBuilder].
|
| + */
|
| + UnlinkedConstBuilder serializeConstExpr(Expression expression) {
|
| + _ConstExprSerializer serializer = new _ConstExprSerializer();
|
| + serializer.serialize(expression);
|
| + return serializer.toBuilder();
|
| + }
|
| +
|
| + /**
|
| * Serialize a [Comment] node into an [UnlinkedDocumentationComment] object.
|
| */
|
| UnlinkedDocumentationCommentBuilder serializeDocumentation(
|
| @@ -555,6 +580,12 @@ class _SummarizeAstVisitor extends SimpleAstVisitor {
|
| b.type = serializeTypeName(variables.type);
|
| b.hasImplicitType = variables.type == null;
|
| b.documentationComment = serializeDocumentation(documentationComment);
|
| + if (variable.isConst) {
|
| + Expression initializer = variable.initializer;
|
| + if (initializer != null) {
|
| + b.constExpr = serializeConstExpr(initializer);
|
| + }
|
| + }
|
| this.variables.add(b);
|
| }
|
| }
|
|
|