| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 'Unexpected identifier type: ${identifier.runtimeType}'); | 55 'Unexpected identifier type: ${identifier.runtimeType}'); |
| 56 } | 56 } |
| 57 return b; | 57 return b; |
| 58 } | 58 } |
| 59 | 59 |
| 60 @override | 60 @override |
| 61 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { | 61 EntityRefBuilder serializePropertyAccess(PropertyAccess access) { |
| 62 Expression target = access.target; | 62 Expression target = access.target; |
| 63 if (target is Identifier) { | 63 if (target is Identifier) { |
| 64 EntityRefBuilder targetRef = serializeIdentifier(target); | 64 EntityRefBuilder targetRef = serializeIdentifier(target); |
| 65 return new EntityRefBuilder( | 65 return new EntityRefBuilder(reference: visitor.serializeReference( |
| 66 reference: visitor.serializeReference( | 66 targetRef.reference, access.propertyName.name)); |
| 67 targetRef.reference, access.propertyName.name)); | |
| 68 } else { | 67 } else { |
| 69 // TODO(scheglov) should we handle other targets in malformed constants? | 68 // TODO(scheglov) should we handle other targets in malformed constants? |
| 70 throw new StateError('Unexpected target type: ${target.runtimeType}'); | 69 throw new StateError('Unexpected target type: ${target.runtimeType}'); |
| 71 } | 70 } |
| 72 } | 71 } |
| 73 | 72 |
| 74 @override | 73 @override |
| 75 EntityRefBuilder serializeType(TypeName node) { | 74 EntityRefBuilder serializeType(TypeName node) { |
| 76 return visitor.serializeTypeName(node); | 75 return visitor.serializeTypeName(node); |
| 77 } | 76 } |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 b.isFactory = node.factoryKeyword != null; | 688 b.isFactory = node.factoryKeyword != null; |
| 690 b.isConst = node.constKeyword != null; | 689 b.isConst = node.constKeyword != null; |
| 691 b.isExternal = node.externalKeyword != null; | 690 b.isExternal = node.externalKeyword != null; |
| 692 b.documentationComment = serializeDocumentation(node.documentationComment); | 691 b.documentationComment = serializeDocumentation(node.documentationComment); |
| 693 executables.add(b); | 692 executables.add(b); |
| 694 } | 693 } |
| 695 | 694 |
| 696 @override | 695 @override |
| 697 UnlinkedParamBuilder visitDefaultFormalParameter( | 696 UnlinkedParamBuilder visitDefaultFormalParameter( |
| 698 DefaultFormalParameter node) { | 697 DefaultFormalParameter node) { |
| 699 return node.parameter.accept(this); | 698 UnlinkedParamBuilder b = node.parameter.accept(this); |
| 699 if (node.defaultValue != null) { |
| 700 b.defaultValue = serializeConstExpr(node.defaultValue); |
| 701 } |
| 702 return b; |
| 700 } | 703 } |
| 701 | 704 |
| 702 @override | 705 @override |
| 703 void visitEnumDeclaration(EnumDeclaration node) { | 706 void visitEnumDeclaration(EnumDeclaration node) { |
| 704 UnlinkedEnumBuilder b = new UnlinkedEnumBuilder(); | 707 UnlinkedEnumBuilder b = new UnlinkedEnumBuilder(); |
| 705 b.name = node.name.name; | 708 b.name = node.name.name; |
| 706 b.nameOffset = node.name.offset; | 709 b.nameOffset = node.name.offset; |
| 707 b.values = node.constants | 710 b.values = node.constants |
| 708 .map((EnumConstantDeclaration value) => new UnlinkedEnumValueBuilder( | 711 .map((EnumConstantDeclaration value) => new UnlinkedEnumValueBuilder( |
| 709 name: value.name.name, nameOffset: value.name.offset)) | 712 name: value.name.name, nameOffset: value.name.offset)) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 /** | 880 /** |
| 878 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 881 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 879 */ | 882 */ |
| 880 class _TypeParameterScope extends _Scope { | 883 class _TypeParameterScope extends _Scope { |
| 881 /** | 884 /** |
| 882 * Get the number of [_ScopedTypeParameter]s defined in this | 885 * Get the number of [_ScopedTypeParameter]s defined in this |
| 883 * [_TypeParameterScope]. | 886 * [_TypeParameterScope]. |
| 884 */ | 887 */ |
| 885 int get length => _definedNames.length; | 888 int get length => _definedNames.length; |
| 886 } | 889 } |
| OLD | NEW |