| 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/dart/element/type.dart' show DartType; | 10 import 'package:analyzer/dart/element/type.dart' show DartType; |
| 11 import 'package:analyzer/src/generated/utilities_dart.dart'; | 11 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 12 import 'package:analyzer/src/summary/format.dart'; | 12 import 'package:analyzer/src/summary/format.dart'; |
| 13 import 'package:analyzer/src/summary/idl.dart'; | 13 import 'package:analyzer/src/summary/idl.dart'; |
| 14 import 'package:analyzer/src/summary/public_namespace_computer.dart'; | 14 import 'package:analyzer/src/summary/public_namespace_computer.dart'; |
| 15 import 'package:analyzer/src/summary/summarize_const_expr.dart'; | 15 import 'package:analyzer/src/summary/summarize_const_expr.dart'; |
| 16 | 16 |
| 17 /** | 17 /** |
| 18 * Serialize all the declarations in [compilationUnit] to an unlinked summary. | 18 * Serialize all the declarations in [compilationUnit] to an unlinked summary. |
| 19 */ | 19 */ |
| 20 UnlinkedUnitBuilder serializeAstUnlinked(CompilationUnit compilationUnit) { | 20 UnlinkedUnitBuilder serializeAstUnlinked( |
| 21 return new _SummarizeAstVisitor().serializeCompilationUnit(compilationUnit); | 21 CompilationUnit compilationUnit, List<int> lineStarts) { |
| 22 return new _SummarizeAstVisitor() |
| 23 .serializeCompilationUnit(compilationUnit, lineStarts); |
| 22 } | 24 } |
| 23 | 25 |
| 24 /** | 26 /** |
| 25 * Instances of this class keep track of intermediate state during | 27 * Instances of this class keep track of intermediate state during |
| 26 * serialization of a single constant [Expression]. | 28 * serialization of a single constant [Expression]. |
| 27 */ | 29 */ |
| 28 class _ConstExprSerializer extends AbstractConstExprSerializer { | 30 class _ConstExprSerializer extends AbstractConstExprSerializer { |
| 29 final _SummarizeAstVisitor visitor; | 31 final _SummarizeAstVisitor visitor; |
| 30 | 32 |
| 31 /** | 33 /** |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 throw new StateError( | 499 throw new StateError( |
| 498 'Unexpected combinator type: ${combinator.runtimeType}'); | 500 'Unexpected combinator type: ${combinator.runtimeType}'); |
| 499 } | 501 } |
| 500 return b; | 502 return b; |
| 501 } | 503 } |
| 502 | 504 |
| 503 /** | 505 /** |
| 504 * Main entry point for serializing an AST. | 506 * Main entry point for serializing an AST. |
| 505 */ | 507 */ |
| 506 UnlinkedUnitBuilder serializeCompilationUnit( | 508 UnlinkedUnitBuilder serializeCompilationUnit( |
| 507 CompilationUnit compilationUnit) { | 509 CompilationUnit compilationUnit, List<int> lineStarts) { |
| 508 compilationUnit.directives.accept(this); | 510 compilationUnit.directives.accept(this); |
| 509 if (!hasCoreBeenImported) { | 511 if (!hasCoreBeenImported) { |
| 510 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); | 512 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); |
| 511 } | 513 } |
| 512 compilationUnit.declarations.accept(this); | 514 compilationUnit.declarations.accept(this); |
| 513 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); | 515 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); |
| 516 b.lineStarts = lineStarts; |
| 514 b.libraryName = libraryName; | 517 b.libraryName = libraryName; |
| 515 b.libraryNameOffset = libraryNameOffset; | 518 b.libraryNameOffset = libraryNameOffset; |
| 516 b.libraryNameLength = libraryNameLength; | 519 b.libraryNameLength = libraryNameLength; |
| 517 b.libraryDocumentationComment = libraryDocumentationComment; | 520 b.libraryDocumentationComment = libraryDocumentationComment; |
| 518 b.libraryAnnotations = libraryAnnotations; | 521 b.libraryAnnotations = libraryAnnotations; |
| 519 b.codeRange = serializeCodeRange(compilationUnit); | 522 b.codeRange = serializeCodeRange(compilationUnit); |
| 520 b.classes = classes; | 523 b.classes = classes; |
| 521 b.enums = enums; | 524 b.enums = enums; |
| 522 b.executables = executables; | 525 b.executables = executables; |
| 523 b.exports = exports; | 526 b.exports = exports; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 /** | 1379 /** |
| 1377 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 1380 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 1378 */ | 1381 */ |
| 1379 class _TypeParameterScope extends _Scope { | 1382 class _TypeParameterScope extends _Scope { |
| 1380 /** | 1383 /** |
| 1381 * Get the number of [_ScopedTypeParameter]s defined in this | 1384 * Get the number of [_ScopedTypeParameter]s defined in this |
| 1382 * [_TypeParameterScope]. | 1385 * [_TypeParameterScope]. |
| 1383 */ | 1386 */ |
| 1384 int get length => _definedNames.length; | 1387 int get length => _definedNames.length; |
| 1385 } | 1388 } |
| OLD | NEW |