| 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; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 * into [UnlinkedUnit.references] for the name itself. | 291 * into [UnlinkedUnit.references] for the name itself. |
| 292 */ | 292 */ |
| 293 final Map<int, Map<String, int>> nameToReference = <int, Map<String, int>>{}; | 293 final Map<int, Map<String, int>> nameToReference = <int, Map<String, int>>{}; |
| 294 | 294 |
| 295 /** | 295 /** |
| 296 * True if the 'dart:core' library is been summarized. | 296 * True if the 'dart:core' library is been summarized. |
| 297 */ | 297 */ |
| 298 bool isCoreLibrary = false; | 298 bool isCoreLibrary = false; |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * True is a [PartOfDirective] was found, so the unit is a part. |
| 302 */ |
| 303 bool isPartOf = false; |
| 304 |
| 305 /** |
| 301 * If the library has a library directive, the library name derived from it. | 306 * If the library has a library directive, the library name derived from it. |
| 302 * Otherwise `null`. | 307 * Otherwise `null`. |
| 303 */ | 308 */ |
| 304 String libraryName; | 309 String libraryName; |
| 305 | 310 |
| 306 /** | 311 /** |
| 307 * If the library has a library directive, the offset of the library name. | 312 * If the library has a library directive, the offset of the library name. |
| 308 * Otherwise `null`. | 313 * Otherwise `null`. |
| 309 */ | 314 */ |
| 310 int libraryNameOffset; | 315 int libraryNameOffset; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 */ | 516 */ |
| 512 UnlinkedUnitBuilder serializeCompilationUnit( | 517 UnlinkedUnitBuilder serializeCompilationUnit( |
| 513 CompilationUnit compilationUnit) { | 518 CompilationUnit compilationUnit) { |
| 514 compilationUnit.directives.accept(this); | 519 compilationUnit.directives.accept(this); |
| 515 if (!hasCoreBeenImported) { | 520 if (!hasCoreBeenImported) { |
| 516 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); | 521 unlinkedImports.add(new UnlinkedImportBuilder(isImplicit: true)); |
| 517 } | 522 } |
| 518 compilationUnit.declarations.accept(this); | 523 compilationUnit.declarations.accept(this); |
| 519 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); | 524 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(); |
| 520 b.lineStarts = compilationUnit.lineInfo?.lineStarts; | 525 b.lineStarts = compilationUnit.lineInfo?.lineStarts; |
| 526 b.isPartOf = isPartOf; |
| 521 b.libraryName = libraryName; | 527 b.libraryName = libraryName; |
| 522 b.libraryNameOffset = libraryNameOffset; | 528 b.libraryNameOffset = libraryNameOffset; |
| 523 b.libraryNameLength = libraryNameLength; | 529 b.libraryNameLength = libraryNameLength; |
| 524 b.libraryDocumentationComment = libraryDocumentationComment; | 530 b.libraryDocumentationComment = libraryDocumentationComment; |
| 525 b.libraryAnnotations = libraryAnnotations; | 531 b.libraryAnnotations = libraryAnnotations; |
| 526 b.codeRange = serializeCodeRange(compilationUnit); | 532 b.codeRange = serializeCodeRange(compilationUnit); |
| 527 b.classes = classes; | 533 b.classes = classes; |
| 528 b.enums = enums; | 534 b.enums = enums; |
| 529 b.executables = executables; | 535 b.executables = executables; |
| 530 b.exports = exports; | 536 b.exports = exports; |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 void visitPartDirective(PartDirective node) { | 1344 void visitPartDirective(PartDirective node) { |
| 1339 parts.add(new UnlinkedPartBuilder( | 1345 parts.add(new UnlinkedPartBuilder( |
| 1340 uriOffset: node.uri.offset, | 1346 uriOffset: node.uri.offset, |
| 1341 uriEnd: node.uri.end, | 1347 uriEnd: node.uri.end, |
| 1342 annotations: serializeAnnotations(node.metadata))); | 1348 annotations: serializeAnnotations(node.metadata))); |
| 1343 } | 1349 } |
| 1344 | 1350 |
| 1345 @override | 1351 @override |
| 1346 void visitPartOfDirective(PartOfDirective node) { | 1352 void visitPartOfDirective(PartOfDirective node) { |
| 1347 isCoreLibrary = node.libraryName.name == 'dart.core'; | 1353 isCoreLibrary = node.libraryName.name == 'dart.core'; |
| 1354 isPartOf = true; |
| 1348 } | 1355 } |
| 1349 | 1356 |
| 1350 @override | 1357 @override |
| 1351 UnlinkedParamBuilder visitSimpleFormalParameter(SimpleFormalParameter node) { | 1358 UnlinkedParamBuilder visitSimpleFormalParameter(SimpleFormalParameter node) { |
| 1352 UnlinkedParamBuilder b = serializeParameter(node); | 1359 UnlinkedParamBuilder b = serializeParameter(node); |
| 1353 b.type = serializeTypeName(node.type); | 1360 b.type = serializeTypeName(node.type); |
| 1354 return b; | 1361 return b; |
| 1355 } | 1362 } |
| 1356 | 1363 |
| 1357 @override | 1364 @override |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 /** | 1398 /** |
| 1392 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. | 1399 * A [_TypeParameterScope] is a [_Scope] which defines [_ScopedTypeParameter]s. |
| 1393 */ | 1400 */ |
| 1394 class _TypeParameterScope extends _Scope { | 1401 class _TypeParameterScope extends _Scope { |
| 1395 /** | 1402 /** |
| 1396 * Get the number of [_ScopedTypeParameter]s defined in this | 1403 * Get the number of [_ScopedTypeParameter]s defined in this |
| 1397 * [_TypeParameterScope]. | 1404 * [_TypeParameterScope]. |
| 1398 */ | 1405 */ |
| 1399 int get length => _definedNames.length; | 1406 int get length => _definedNames.length; |
| 1400 } | 1407 } |
| OLD | NEW |