@@ -15,7 +15,6 @@ import 'package:analyzer/src/dart/analysis/defined_names.dart';
15
15
import 'package:analyzer/src/dart/analysis/performance_logger.dart' ;
16
16
import 'package:analyzer/src/dart/analysis/referenced_names.dart' ;
17
17
import 'package:analyzer/src/dart/analysis/top_level_declaration.dart' ;
18
- import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart' ;
19
18
import 'package:analyzer/src/dart/scanner/reader.dart' ;
20
19
import 'package:analyzer/src/dart/scanner/scanner.dart' ;
21
20
import 'package:analyzer/src/generated/engine.dart' ;
@@ -114,6 +113,7 @@ class FileState {
114
113
Set <String > _definedClassMemberNames;
115
114
Set <String > _definedTopLevelNames;
116
115
Set <String > _referencedNames;
116
+ String _unlinkedKey;
117
117
AnalysisDriverUnlinkedUnit _driverUnlinkedUnit;
118
118
UnlinkedUnit _unlinked;
119
119
List <int > _apiSignature;
@@ -396,59 +396,48 @@ class FileState {
396
396
_contentHash = rawFileState.contentHash;
397
397
}
398
398
399
- // Prepare keys of unlinked data.
400
- String apiSignatureKey;
401
- String unlinkedKey;
399
+ // Prepare the unlinked bundle key.
402
400
{
403
401
var signature = new ApiSignature ();
404
402
signature.addUint32List (_fsState._unlinkedSalt);
405
403
signature.addString (_contentHash);
406
-
407
- var signatureHex = signature.toHex ();
408
- apiSignatureKey = '$signatureHex .api_signature' ;
409
- unlinkedKey = '$signatureHex .unlinked' ;
404
+ _unlinkedKey = '${signature .toHex ()}.unlinked' ;
410
405
}
411
406
412
- // Try to get bytes of unlinked data.
413
- var apiSignatureBytes = _fsState._byteStore.get (apiSignatureKey);
414
- var unlinkedUnitBytes = _fsState._byteStore.get (unlinkedKey);
415
-
416
- // Compute unlinked data that we are missing.
417
- if (apiSignatureBytes == null || unlinkedUnitBytes == null ) {
418
- CompilationUnit unit = parse (AnalysisErrorListener .NULL_LISTENER );
419
- _fsState._logger.run ('Create unlinked for $path ' , () {
420
- if (apiSignatureBytes == null ) {
421
- apiSignatureBytes = computeUnlinkedApiSignature (unit);
422
- _fsState._byteStore.put (apiSignatureKey, apiSignatureBytes);
423
- }
424
- if (unlinkedUnitBytes == null ) {
425
- var unlinkedUnit = serializeAstUnlinked (unit);
426
- var definedNames = computeDefinedNames (unit);
427
- var referencedNames = computeReferencedNames (unit).toList ();
428
- var subtypedNames = computeSubtypedNames (unit).toList ();
429
- unlinkedUnitBytes = new AnalysisDriverUnlinkedUnitBuilder (
407
+ // Prepare bytes of the unlinked bundle - existing or new.
408
+ List <int > bytes;
409
+ {
410
+ bytes = _fsState._byteStore.get (_unlinkedKey);
411
+ if (bytes == null || bytes.isEmpty) {
412
+ CompilationUnit unit = parse ();
413
+ _fsState._logger.run ('Create unlinked for $path ' , () {
414
+ UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked (unit);
415
+ DefinedNames definedNames = computeDefinedNames (unit);
416
+ List <String > referencedNames = computeReferencedNames (unit).toList ();
417
+ List <String > subtypedNames = computeSubtypedNames (unit).toList ();
418
+ bytes = new AnalysisDriverUnlinkedUnitBuilder (
430
419
unit: unlinkedUnit,
431
420
definedTopLevelNames: definedNames.topLevelNames.toList (),
432
421
definedClassMemberNames:
433
422
definedNames.classMemberNames.toList (),
434
423
referencedNames: referencedNames,
435
424
subtypedNames: subtypedNames)
436
425
.toBuffer ();
437
- _fsState._byteStore.put (unlinkedKey, unlinkedUnitBytes );
438
- }
439
- });
426
+ _fsState._byteStore.put (_unlinkedKey, bytes );
427
+ });
428
+ }
440
429
}
441
430
442
431
// Read the unlinked bundle.
443
- _driverUnlinkedUnit =
444
- new AnalysisDriverUnlinkedUnit .fromBuffer (unlinkedUnitBytes);
432
+ _driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit .fromBuffer (bytes);
445
433
_unlinked = _driverUnlinkedUnit.unit;
446
434
_lineInfo = new LineInfo (_unlinked.lineStarts);
447
435
448
436
// Prepare API signature.
437
+ List <int > newApiSignature = new Uint8List .fromList (_unlinked.apiSignature);
449
438
bool apiSignatureChanged = _apiSignature != null &&
450
- ! _equalByteLists (_apiSignature, apiSignatureBytes );
451
- _apiSignature = apiSignatureBytes ;
439
+ ! _equalByteLists (_apiSignature, newApiSignature );
440
+ _apiSignature = newApiSignature ;
452
441
453
442
// The API signature changed.
454
443
// Flush transitive signatures of affected files.
@@ -695,6 +684,8 @@ class FileStateTestView {
695
684
final FileState file;
696
685
697
686
FileStateTestView (this .file);
687
+
688
+ String get unlinkedKey => file._unlinkedKey;
698
689
}
699
690
700
691
/**
0 commit comments