| 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/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/src/generated/utilities_dart.dart'; | 10 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 */ | 186 */ |
| 187 List<UnlinkedExecutableBuilder> executables = <UnlinkedExecutableBuilder>[]; | 187 List<UnlinkedExecutableBuilder> executables = <UnlinkedExecutableBuilder>[]; |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * List of objects which should be written to [UnlinkedUnit.exports]. | 190 * List of objects which should be written to [UnlinkedUnit.exports]. |
| 191 */ | 191 */ |
| 192 final List<UnlinkedExportNonPublicBuilder> exports = | 192 final List<UnlinkedExportNonPublicBuilder> exports = |
| 193 <UnlinkedExportNonPublicBuilder>[]; | 193 <UnlinkedExportNonPublicBuilder>[]; |
| 194 | 194 |
| 195 /** | 195 /** |
| 196 * List of objects which should be written to |
| 197 * [UnlinkedExecutable.localLabels]. |
| 198 */ |
| 199 List<UnlinkedLabelBuilder> labels = <UnlinkedLabelBuilder>[]; |
| 200 |
| 201 /** |
| 196 * List of objects which should be written to [UnlinkedUnit.parts]. | 202 * List of objects which should be written to [UnlinkedUnit.parts]. |
| 197 */ | 203 */ |
| 198 final List<UnlinkedPartBuilder> parts = <UnlinkedPartBuilder>[]; | 204 final List<UnlinkedPartBuilder> parts = <UnlinkedPartBuilder>[]; |
| 199 | 205 |
| 200 /** | 206 /** |
| 201 * List of objects which should be written to [UnlinkedUnit.typedefs]. | 207 * List of objects which should be written to [UnlinkedUnit.typedefs]. |
| 202 */ | 208 */ |
| 203 final List<UnlinkedTypedefBuilder> typedefs = <UnlinkedTypedefBuilder>[]; | 209 final List<UnlinkedTypedefBuilder> typedefs = <UnlinkedTypedefBuilder>[]; |
| 204 | 210 |
| 205 /** | 211 /** |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 * when we process a synthetic variable initializer function. | 550 * when we process a synthetic variable initializer function. |
| 545 */ | 551 */ |
| 546 void serializeFunctionBody(UnlinkedExecutableBuilder b, AstNode body) { | 552 void serializeFunctionBody(UnlinkedExecutableBuilder b, AstNode body) { |
| 547 if (body is BlockFunctionBody || body is ExpressionFunctionBody) { | 553 if (body is BlockFunctionBody || body is ExpressionFunctionBody) { |
| 548 for (UnlinkedParamBuilder parameter in b.parameters) { | 554 for (UnlinkedParamBuilder parameter in b.parameters) { |
| 549 parameter.visibleOffset = body.offset; | 555 parameter.visibleOffset = body.offset; |
| 550 parameter.visibleLength = body.length; | 556 parameter.visibleLength = body.length; |
| 551 } | 557 } |
| 552 } | 558 } |
| 553 List<UnlinkedExecutableBuilder> oldExecutables = executables; | 559 List<UnlinkedExecutableBuilder> oldExecutables = executables; |
| 560 List<UnlinkedLabelBuilder> oldLabels = labels; |
| 554 List<UnlinkedVariableBuilder> oldVariables = variables; | 561 List<UnlinkedVariableBuilder> oldVariables = variables; |
| 555 executables = <UnlinkedExecutableBuilder>[]; | 562 executables = <UnlinkedExecutableBuilder>[]; |
| 563 labels = <UnlinkedLabelBuilder>[]; |
| 556 variables = <UnlinkedVariableBuilder>[]; | 564 variables = <UnlinkedVariableBuilder>[]; |
| 557 body.accept(this); | 565 body.accept(this); |
| 558 b.localFunctions = executables; | 566 b.localFunctions = executables; |
| 567 b.localLabels = labels; |
| 559 b.localVariables = variables; | 568 b.localVariables = variables; |
| 560 executables = oldExecutables; | 569 executables = oldExecutables; |
| 570 labels = oldLabels; |
| 561 variables = oldVariables; | 571 variables = oldVariables; |
| 562 } | 572 } |
| 563 | 573 |
| 564 /** | 574 /** |
| 565 * Serialize the return type and parameters of a function-typed formal | 575 * Serialize the return type and parameters of a function-typed formal |
| 566 * parameter and store them in [b]. | 576 * parameter and store them in [b]. |
| 567 */ | 577 */ |
| 568 void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b, | 578 void serializeFunctionTypedParameterDetails(UnlinkedParamBuilder b, |
| 569 TypeName returnType, FormalParameterList parameters) { | 579 TypeName returnType, FormalParameterList parameters) { |
| 570 EntityRefBuilder serializedReturnType = serializeTypeName(returnType); | 580 EntityRefBuilder serializedReturnType = serializeTypeName(returnType); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 b.prefixOffset = node.prefix.offset; | 1021 b.prefixOffset = node.prefix.offset; |
| 1012 } | 1022 } |
| 1013 b.isDeferred = node.deferredKeyword != null; | 1023 b.isDeferred = node.deferredKeyword != null; |
| 1014 b.uri = node.uri.stringValue; | 1024 b.uri = node.uri.stringValue; |
| 1015 b.uriOffset = node.uri.offset; | 1025 b.uriOffset = node.uri.offset; |
| 1016 b.uriEnd = node.uri.end; | 1026 b.uriEnd = node.uri.end; |
| 1017 unlinkedImports.add(b); | 1027 unlinkedImports.add(b); |
| 1018 } | 1028 } |
| 1019 | 1029 |
| 1020 @override | 1030 @override |
| 1031 void visitLabel(Label node) { |
| 1032 AstNode parent = node.parent; |
| 1033 labels.add(new UnlinkedLabelBuilder( |
| 1034 name: node.label.name, |
| 1035 nameOffset: node.offset, |
| 1036 isOnSwitchMember: parent is SwitchMember, |
| 1037 isOnSwitchStatement: |
| 1038 parent is LabeledStatement && parent.statement is SwitchStatement)); |
| 1039 } |
| 1040 |
| 1041 @override |
| 1021 void visitLibraryDirective(LibraryDirective node) { | 1042 void visitLibraryDirective(LibraryDirective node) { |
| 1022 libraryName = | 1043 libraryName = |
| 1023 node.name.components.map((SimpleIdentifier id) => id.name).join('.'); | 1044 node.name.components.map((SimpleIdentifier id) => id.name).join('.'); |
| 1024 libraryNameOffset = node.name.offset; | 1045 libraryNameOffset = node.name.offset; |
| 1025 libraryNameLength = node.name.length; | 1046 libraryNameLength = node.name.length; |
| 1026 libraryDocumentationComment = | 1047 libraryDocumentationComment = |
| 1027 serializeDocumentation(node.documentationComment); | 1048 serializeDocumentation(node.documentationComment); |
| 1028 libraryAnnotations = serializeAnnotations(node.metadata); | 1049 libraryAnnotations = serializeAnnotations(node.metadata); |
| 1029 } | 1050 } |
| 1030 | 1051 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 /** | 1120 /** |
| 1100 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 1121 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 1101 */ | 1122 */ |
| 1102 class _TypeParameterScope extends _Scope { | 1123 class _TypeParameterScope extends _Scope { |
| 1103 /** | 1124 /** |
| 1104 * Get the number of [_ScopedTypeParameter]s defined in this | 1125 * Get the number of [_ScopedTypeParameter]s defined in this |
| 1105 * [_TypeParameterScope]. | 1126 * [_TypeParameterScope]. |
| 1106 */ | 1127 */ |
| 1107 int get length => _definedNames.length; | 1128 int get length => _definedNames.length; |
| 1108 } | 1129 } |
| OLD | NEW |