| 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/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:analyzer/src/generated/scanner.dart'; | 9 import 'package:analyzer/src/generated/scanner.dart'; |
| 10 import 'package:analyzer/src/generated/utilities_dart.dart'; | 10 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 */ | 214 */ |
| 215 int libraryNameLength; | 215 int libraryNameLength; |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * If the library has a library directive, the documentation comment for it | 218 * If the library has a library directive, the documentation comment for it |
| 219 * (if any). Otherwise `null`. | 219 * (if any). Otherwise `null`. |
| 220 */ | 220 */ |
| 221 UnlinkedDocumentationCommentBuilder libraryDocumentationComment; | 221 UnlinkedDocumentationCommentBuilder libraryDocumentationComment; |
| 222 | 222 |
| 223 /** | 223 /** |
| 224 * The number of slot ids which have been assigned to this compilation unit. |
| 225 */ |
| 226 int numSlots = 0; |
| 227 |
| 228 /** |
| 229 * Create a slot id for storing a propagated or inferred type. |
| 230 */ |
| 231 int assignTypeSlot() => ++numSlots; |
| 232 |
| 233 /** |
| 224 * Build a [_Scope] object containing the names defined within the body of a | 234 * Build a [_Scope] object containing the names defined within the body of a |
| 225 * class declaration. | 235 * class declaration. |
| 226 */ | 236 */ |
| 227 _Scope buildClassMemberScope(NodeList<ClassMember> members) { | 237 _Scope buildClassMemberScope(NodeList<ClassMember> members) { |
| 228 _Scope scope = new _Scope(); | 238 _Scope scope = new _Scope(); |
| 229 for (ClassMember member in members) { | 239 for (ClassMember member in members) { |
| 230 // TODO(paulbery): consider replacing these if-tests with dynamic method | 240 // TODO(paulbery): consider replacing these if-tests with dynamic method |
| 231 // dispatch. | 241 // dispatch. |
| 232 if (member is MethodDeclaration) { | 242 if (member is MethodDeclaration) { |
| 233 if (member.isSetter || member.isOperator) { | 243 if (member.isSetter || member.isOperator) { |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 b.nameOffset = variable.name.offset; | 614 b.nameOffset = variable.name.offset; |
| 605 b.type = serializeTypeName(variables.type); | 615 b.type = serializeTypeName(variables.type); |
| 606 b.hasImplicitType = variables.type == null; | 616 b.hasImplicitType = variables.type == null; |
| 607 b.documentationComment = serializeDocumentation(documentationComment); | 617 b.documentationComment = serializeDocumentation(documentationComment); |
| 608 if (variable.isConst) { | 618 if (variable.isConst) { |
| 609 Expression initializer = variable.initializer; | 619 Expression initializer = variable.initializer; |
| 610 if (initializer != null) { | 620 if (initializer != null) { |
| 611 b.constExpr = serializeConstExpr(initializer); | 621 b.constExpr = serializeConstExpr(initializer); |
| 612 } | 622 } |
| 613 } | 623 } |
| 624 if (variable.initializer != null && |
| 625 (variables.isFinal || variables.isConst)) { |
| 626 b.propagatedTypeSlot = assignTypeSlot(); |
| 627 } |
| 614 this.variables.add(b); | 628 this.variables.add(b); |
| 615 } | 629 } |
| 616 } | 630 } |
| 617 | 631 |
| 618 @override | 632 @override |
| 619 void visitClassDeclaration(ClassDeclaration node) { | 633 void visitClassDeclaration(ClassDeclaration node) { |
| 620 currentClassDeclaration = node; | 634 currentClassDeclaration = node; |
| 621 TypeName superclass = | 635 TypeName superclass = |
| 622 node.extendsClause == null ? null : node.extendsClause.superclass; | 636 node.extendsClause == null ? null : node.extendsClause.superclass; |
| 623 serializeClass( | 637 serializeClass( |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 /** | 875 /** |
| 862 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 876 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 863 */ | 877 */ |
| 864 class _TypeParameterScope extends _Scope { | 878 class _TypeParameterScope extends _Scope { |
| 865 /** | 879 /** |
| 866 * Get the number of [_ScopedTypeParameter]s defined in this | 880 * Get the number of [_ScopedTypeParameter]s defined in this |
| 867 * [_TypeParameterScope]. | 881 * [_TypeParameterScope]. |
| 868 */ | 882 */ |
| 869 int get length => _definedNames.length; | 883 int get length => _definedNames.length; |
| 870 } | 884 } |
| OLD | NEW |