Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1646)

Unified Diff: pkg/analyzer/lib/src/dart/analysis/file_state.dart

Issue 2987303002: Fix for truncated unlinked summaries in ByteStore. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/file_state.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/file_state.dart b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
index 5db2c9281afeab51a9001d97e1bc0d8ee28d5617..342bbaa988474d9da977bfe2e880a8e38ea3aad7 100644
--- a/pkg/analyzer/lib/src/dart/analysis/file_state.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/file_state.dart
@@ -116,6 +116,7 @@ class FileState {
Set<String> _definedClassMemberNames;
Set<String> _referencedNames;
Set<String> _subtypedNames;
+ String _unlinkedKey;
UnlinkedUnit _unlinked;
List<int> _apiSignature;
@@ -282,6 +283,9 @@ class FileState {
*/
Set<String> get subtypedNames => _subtypedNames;
+ @visibleForTesting
+ FileStateTestView get test => new FileStateTestView(this);
+
/**
* Return public top-level declarations declared in the file. The keys to the
* map are names of declarations.
@@ -424,20 +428,19 @@ class FileState {
}
// Prepare the unlinked bundle key.
- String unlinkedKey;
{
ApiSignature signature = new ApiSignature();
signature.addUint32List(_fsState._salt);
signature.addInt(contentBytes.length);
signature.addString(_contentHash);
- unlinkedKey = '${signature.toHex()}.unlinked';
+ _unlinkedKey = '${signature.toHex()}.unlinked';
}
// Prepare bytes of the unlinked bundle - existing or new.
List<int> bytes;
{
- bytes = _fsState._byteStore.get(unlinkedKey);
- if (bytes == null) {
+ bytes = _fsState._byteStore.get(_unlinkedKey);
+ if (bytes == null || bytes.isEmpty) {
CompilationUnit unit = parse(AnalysisErrorListener.NULL_LISTENER);
_fsState._logger.run('Create unlinked for $path', () {
UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit);
@@ -452,7 +455,7 @@ class FileState {
referencedNames: referencedNames,
subtypedNames: subtypedNames)
.toBuffer();
- _fsState._byteStore.put(unlinkedKey, bytes);
+ _fsState._byteStore.put(_unlinkedKey, bytes);
});
}
}
@@ -641,6 +644,15 @@ class FileState {
}
}
+@visibleForTesting
+class FileStateTestView {
+ final FileState file;
+
+ FileStateTestView(this.file);
+
+ String get unlinkedKey => file._unlinkedKey;
+}
+
/**
* Information about known file system state.
*/
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/file_state_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698