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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:convert'; | 6 import 'dart:convert'; |
7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 final bool isInExternalSummaries; | 109 final bool isInExternalSummaries; |
110 | 110 |
111 bool _exists; | 111 bool _exists; |
112 List<int> _contentBytes; | 112 List<int> _contentBytes; |
113 String _content; | 113 String _content; |
114 String _contentHash; | 114 String _contentHash; |
115 LineInfo _lineInfo; | 115 LineInfo _lineInfo; |
116 Set<String> _definedTopLevelNames; | 116 Set<String> _definedTopLevelNames; |
117 Set<String> _definedClassMemberNames; | 117 Set<String> _definedClassMemberNames; |
118 Set<String> _referencedNames; | 118 Set<String> _referencedNames; |
| 119 Set<String> _subtypedNames; |
119 UnlinkedUnit _unlinked; | 120 UnlinkedUnit _unlinked; |
120 List<int> _apiSignature; | 121 List<int> _apiSignature; |
121 | 122 |
122 List<FileState> _importedFiles; | 123 List<FileState> _importedFiles; |
123 List<FileState> _exportedFiles; | 124 List<FileState> _exportedFiles; |
124 List<FileState> _partedFiles; | 125 List<FileState> _partedFiles; |
125 List<NameFilter> _exportFilters; | 126 List<NameFilter> _exportFilters; |
126 | 127 |
127 Set<FileState> _directReferencedFiles = new Set<FileState>(); | 128 Set<FileState> _directReferencedFiles = new Set<FileState>(); |
128 Set<FileState> _transitiveFiles; | 129 Set<FileState> _transitiveFiles; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 * The list of files this library file references as parts. | 271 * The list of files this library file references as parts. |
271 */ | 272 */ |
272 List<FileState> get partedFiles => _partedFiles; | 273 List<FileState> get partedFiles => _partedFiles; |
273 | 274 |
274 /** | 275 /** |
275 * The external names referenced by the file. | 276 * The external names referenced by the file. |
276 */ | 277 */ |
277 Set<String> get referencedNames => _referencedNames; | 278 Set<String> get referencedNames => _referencedNames; |
278 | 279 |
279 /** | 280 /** |
| 281 * The names which are used in `extends`, `with` or `implements` clauses in |
| 282 * the file. Import prefixes and type arguments are not included. |
| 283 */ |
| 284 Set<String> get subtypedNames => _subtypedNames; |
| 285 |
| 286 /** |
280 * Return public top-level declarations declared in the file. The keys to the | 287 * Return public top-level declarations declared in the file. The keys to the |
281 * map are names of declarations. | 288 * map are names of declarations. |
282 */ | 289 */ |
283 Map<String, TopLevelDeclaration> get topLevelDeclarations { | 290 Map<String, TopLevelDeclaration> get topLevelDeclarations { |
284 if (_topLevelDeclarations == null) { | 291 if (_topLevelDeclarations == null) { |
285 _topLevelDeclarations = <String, TopLevelDeclaration>{}; | 292 _topLevelDeclarations = <String, TopLevelDeclaration>{}; |
286 | 293 |
287 void addDeclaration(TopLevelDeclarationKind kind, String name) { | 294 void addDeclaration(TopLevelDeclarationKind kind, String name) { |
288 if (!name.startsWith('_')) { | 295 if (!name.startsWith('_')) { |
289 _topLevelDeclarations[name] = new TopLevelDeclaration(kind, name); | 296 _topLevelDeclarations[name] = new TopLevelDeclaration(kind, name); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 } | 435 } |
429 | 436 |
430 // Prepare bytes of the unlinked bundle - existing or new. | 437 // Prepare bytes of the unlinked bundle - existing or new. |
431 List<int> bytes; | 438 List<int> bytes; |
432 { | 439 { |
433 bytes = _fsState._byteStore.get(unlinkedKey); | 440 bytes = _fsState._byteStore.get(unlinkedKey); |
434 if (bytes == null) { | 441 if (bytes == null) { |
435 CompilationUnit unit = parse(AnalysisErrorListener.NULL_LISTENER); | 442 CompilationUnit unit = parse(AnalysisErrorListener.NULL_LISTENER); |
436 _fsState._logger.run('Create unlinked for $path', () { | 443 _fsState._logger.run('Create unlinked for $path', () { |
437 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); | 444 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); |
| 445 DefinedNames definedNames = computeDefinedNames(unit); |
438 List<String> referencedNames = computeReferencedNames(unit).toList(); | 446 List<String> referencedNames = computeReferencedNames(unit).toList(); |
439 DefinedNames definedNames = computeDefinedNames(unit); | 447 List<String> subtypedNames = computeSubtypedNames(unit).toList(); |
440 bytes = new AnalysisDriverUnlinkedUnitBuilder( | 448 bytes = new AnalysisDriverUnlinkedUnitBuilder( |
441 unit: unlinkedUnit, | 449 unit: unlinkedUnit, |
442 definedTopLevelNames: definedNames.topLevelNames.toList(), | 450 definedTopLevelNames: definedNames.topLevelNames.toList(), |
443 definedClassMemberNames: | 451 definedClassMemberNames: |
444 definedNames.classMemberNames.toList(), | 452 definedNames.classMemberNames.toList(), |
445 referencedNames: referencedNames) | 453 referencedNames: referencedNames, |
| 454 subtypedNames: subtypedNames) |
446 .toBuffer(); | 455 .toBuffer(); |
447 _fsState._byteStore.put(unlinkedKey, bytes); | 456 _fsState._byteStore.put(unlinkedKey, bytes); |
448 }); | 457 }); |
449 } | 458 } |
450 } | 459 } |
451 | 460 |
452 // Read the unlinked bundle. | 461 // Read the unlinked bundle. |
453 var driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes); | 462 var driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes); |
454 _definedTopLevelNames = driverUnlinkedUnit.definedTopLevelNames.toSet(); | 463 _definedTopLevelNames = driverUnlinkedUnit.definedTopLevelNames.toSet(); |
455 _definedClassMemberNames = | 464 _definedClassMemberNames = |
456 driverUnlinkedUnit.definedClassMemberNames.toSet(); | 465 driverUnlinkedUnit.definedClassMemberNames.toSet(); |
457 _referencedNames = driverUnlinkedUnit.referencedNames.toSet(); | 466 _referencedNames = driverUnlinkedUnit.referencedNames.toSet(); |
| 467 _subtypedNames = driverUnlinkedUnit.subtypedNames.toSet(); |
458 _unlinked = driverUnlinkedUnit.unit; | 468 _unlinked = driverUnlinkedUnit.unit; |
459 _lineInfo = new LineInfo(_unlinked.lineStarts); | 469 _lineInfo = new LineInfo(_unlinked.lineStarts); |
460 _topLevelDeclarations = null; | 470 _topLevelDeclarations = null; |
461 | 471 |
462 // Prepare API signature. | 472 // Prepare API signature. |
463 List<int> newApiSignature = new Uint8List.fromList(_unlinked.apiSignature); | 473 List<int> newApiSignature = new Uint8List.fromList(_unlinked.apiSignature); |
464 bool apiSignatureChanged = _apiSignature != null && | 474 bool apiSignatureChanged = _apiSignature != null && |
465 !_equalByteLists(_apiSignature, newApiSignature); | 475 !_equalByteLists(_apiSignature, newApiSignature); |
466 _apiSignature = newApiSignature; | 476 _apiSignature = newApiSignature; |
467 | 477 |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 _FastaElementProxy operator [](fasta.Builder builder) => | 955 _FastaElementProxy operator [](fasta.Builder builder) => |
946 _elements.putIfAbsent(builder, () => new _FastaElementProxy()); | 956 _elements.putIfAbsent(builder, () => new _FastaElementProxy()); |
947 | 957 |
948 @override | 958 @override |
949 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 959 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
950 } | 960 } |
951 | 961 |
952 class _FastaInterfaceTypeProxy implements fasta.KernelInterfaceType { | 962 class _FastaInterfaceTypeProxy implements fasta.KernelInterfaceType { |
953 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 963 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
954 } | 964 } |
OLD | NEW |