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

Unified Diff: pkg/analyzer/lib/src/context/context.dart

Issue 1195183002: Move cache consistency validation into Analysis Server. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
Index: pkg/analyzer/lib/src/context/context.dart
diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart
index 616c3ff6e0b675daa3e184d5a3213204fdca2363..c6613b03b0a619e965007a11ea06dfa67818d557 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -1051,9 +1051,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
return PerformanceStatistics.performAnaysis.makeCurrentWhile(() {
_evaluatePendingFutures();
bool done = !driver.performAnalysisTask();
- if (done) {
- done = !_validateCacheConsistency();
- }
List<ChangeNotice> notices = _getChangeNotices(done);
if (notices != null) {
int noticeCount = notices.length;
@@ -1187,6 +1184,27 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
@override
+ bool validateSourceCacheConsistency(Source source) {
+ CacheEntry entry = _cache.get(source);
+ if (entry != null) {
+ int sourceTime = getModificationStamp(source);
+ if (sourceTime != entry.modificationTime) {
+ _sourceChanged(source);
+ return true;
+ }
+ if (entry.exception != null) {
+ if (!exists(source)) {
+ if (getLibrariesContaining(source).isEmpty &&
+ getLibrariesDependingOn(source).isEmpty) {
+ _cache.remove(source);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @override
void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
DataDescriptor rowDesc, CacheState state)) {
// TODO(brianwilkerson) Figure out where this is used and either remove it
@@ -1583,13 +1601,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
/**
- * Log the given debugging [message].
- */
- void _logInformation(String message) {
- AnalysisEngine.instance.logger.logInformation(message);
- }
-
- /**
* Notify all of the analysis listeners that the errors associated with the
* given [source] has been updated to the given [errors].
*/
@@ -1770,62 +1781,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
return true;
});
}
-
- /**
- * Check the cache for any invalid entries (entries whose modification time
- * does not match the modification time of the source associated with the
- * entry). Invalid entries will be marked as invalid so that the source will
- * be re-analyzed. Return `true` if at least one entry was invalid.
- */
- bool _validateCacheConsistency() {
- int consistencyCheckStart = JavaSystem.nanoTime();
- HashSet<Source> changedSources = new HashSet<Source>();
- HashSet<Source> missingSources = new HashSet<Source>();
- for (Source source in _cache.sources) {
- CacheEntry entry = _cache.get(source);
- int sourceTime = getModificationStamp(source);
- if (sourceTime != entry.modificationTime) {
- changedSources.add(source);
- }
- if (entry.exception != null) {
- if (!exists(source)) {
- missingSources.add(source);
- }
- }
- }
- for (Source source in changedSources) {
- _sourceChanged(source);
- }
- int removalCount = 0;
- for (Source source in missingSources) {
- if (getLibrariesContaining(source).isEmpty &&
- getLibrariesDependingOn(source).isEmpty) {
- _cache.remove(source);
- removalCount++;
- }
- }
- int consistencyCheckEnd = JavaSystem.nanoTime();
- if (changedSources.length > 0 || missingSources.length > 0) {
- StringBuffer buffer = new StringBuffer();
- buffer.write("Consistency check took ");
- buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0);
- buffer.writeln(" ms and found");
- buffer.write(" ");
- buffer.write(changedSources.length);
- buffer.writeln(" inconsistent entries");
- buffer.write(" ");
- buffer.write(missingSources.length);
- buffer.write(" missing sources (");
- buffer.write(removalCount);
- buffer.writeln(" removed");
- for (Source source in missingSources) {
- buffer.write(" ");
- buffer.writeln(source.fullName);
- }
- _logInformation(buffer.toString());
- }
- return changedSources.length > 0;
- }
}
/**

Powered by Google App Engine
This is Rietveld 408576698