Skip to content

Commit e648d63

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Revert "Compute unlinked API signatures without unlinked summaries."
This reverts commit eb96871. Exceptions like "Element not found in summary" still happen with 2.1.0-dev.7.1 internally, and I suspect that it is caused by discrepancies in API signatures and unlinked units. So, I think we should revert this change. We are not going to do one-phase link anymore, so this CL is not strongly required anymore. [email protected], [email protected] Change-Id: I213156942fa3257b1884b209dda0b1d0c731d9a8 Reviewed-on: https://dart-review.googlesource.com/c/81181 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 74792f4 commit e648d63

File tree

5 files changed

+40
-1053
lines changed

5 files changed

+40
-1053
lines changed

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import 'package:analyzer/src/dart/analysis/defined_names.dart';
1515
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
1616
import 'package:analyzer/src/dart/analysis/referenced_names.dart';
1717
import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
18-
import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart';
1918
import 'package:analyzer/src/dart/scanner/reader.dart';
2019
import 'package:analyzer/src/dart/scanner/scanner.dart';
2120
import 'package:analyzer/src/generated/engine.dart';
@@ -114,6 +113,7 @@ class FileState {
114113
Set<String> _definedClassMemberNames;
115114
Set<String> _definedTopLevelNames;
116115
Set<String> _referencedNames;
116+
String _unlinkedKey;
117117
AnalysisDriverUnlinkedUnit _driverUnlinkedUnit;
118118
UnlinkedUnit _unlinked;
119119
List<int> _apiSignature;
@@ -396,59 +396,48 @@ class FileState {
396396
_contentHash = rawFileState.contentHash;
397397
}
398398

399-
// Prepare keys of unlinked data.
400-
String apiSignatureKey;
401-
String unlinkedKey;
399+
// Prepare the unlinked bundle key.
402400
{
403401
var signature = new ApiSignature();
404402
signature.addUint32List(_fsState._unlinkedSalt);
405403
signature.addString(_contentHash);
406-
407-
var signatureHex = signature.toHex();
408-
apiSignatureKey = '$signatureHex.api_signature';
409-
unlinkedKey = '$signatureHex.unlinked';
404+
_unlinkedKey = '${signature.toHex()}.unlinked';
410405
}
411406

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(
430419
unit: unlinkedUnit,
431420
definedTopLevelNames: definedNames.topLevelNames.toList(),
432421
definedClassMemberNames:
433422
definedNames.classMemberNames.toList(),
434423
referencedNames: referencedNames,
435424
subtypedNames: subtypedNames)
436425
.toBuffer();
437-
_fsState._byteStore.put(unlinkedKey, unlinkedUnitBytes);
438-
}
439-
});
426+
_fsState._byteStore.put(_unlinkedKey, bytes);
427+
});
428+
}
440429
}
441430

442431
// Read the unlinked bundle.
443-
_driverUnlinkedUnit =
444-
new AnalysisDriverUnlinkedUnit.fromBuffer(unlinkedUnitBytes);
432+
_driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes);
445433
_unlinked = _driverUnlinkedUnit.unit;
446434
_lineInfo = new LineInfo(_unlinked.lineStarts);
447435

448436
// Prepare API signature.
437+
List<int> newApiSignature = new Uint8List.fromList(_unlinked.apiSignature);
449438
bool apiSignatureChanged = _apiSignature != null &&
450-
!_equalByteLists(_apiSignature, apiSignatureBytes);
451-
_apiSignature = apiSignatureBytes;
439+
!_equalByteLists(_apiSignature, newApiSignature);
440+
_apiSignature = newApiSignature;
452441

453442
// The API signature changed.
454443
// Flush transitive signatures of affected files.
@@ -695,6 +684,8 @@ class FileStateTestView {
695684
final FileState file;
696685

697686
FileStateTestView(this.file);
687+
688+
String get unlinkedKey => file._unlinkedKey;
698689
}
699690

700691
/**

pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart

Lines changed: 0 additions & 134 deletions
This file was deleted.

pkg/analyzer/test/src/dart/analysis/file_state_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,22 @@ class C {
698698
expect(file.apiSignature, signature);
699699
}
700700

701+
test_store_zeroLengthUnlinked() {
702+
String path = _p('/test.dart');
703+
provider.newFile(path, 'class A {}');
704+
705+
// Get the file, prepare unlinked.
706+
FileState file = fileSystemState.getFileForPath(path);
707+
expect(file.unlinked, isNotNull);
708+
709+
// Make the unlinked unit in the byte store zero-length, damaged.
710+
byteStore.put(file.test.unlinkedKey, <int>[]);
711+
712+
// Refresh should not fail, zero bytes in the store are ignored.
713+
file.refresh();
714+
expect(file.unlinked, isNotNull);
715+
}
716+
701717
test_subtypedNames() {
702718
String path = _p('/test.dart');
703719
provider.newFile(path, r'''

pkg/analyzer/test/src/dart/analysis/test_all.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import 'referenced_names_test.dart' as referenced_names;
2424
import 'search_test.dart' as search;
2525
import 'session_helper_test.dart' as session_helper;
2626
import 'session_test.dart' as session;
27-
import 'unlinked_api_signature_test.dart' as unlinked_api_signature;
2827
import 'uri_converter_test.dart' as uri_converter;
2928

3029
main() {
@@ -49,7 +48,6 @@ main() {
4948
search.main();
5049
session.main();
5150
session_helper.main();
52-
unlinked_api_signature.main();
5351
uri_converter.main();
5452
}, name: 'analysis');
5553
}

0 commit comments

Comments
 (0)