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

Unified Diff: pkg/analyzer/lib/src/generated/engine.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/generated/engine.dart
diff --git a/pkg/analyzer/lib/src/generated/engine.dart b/pkg/analyzer/lib/src/generated/engine.dart
index b8cf515cef685a79bd00a15f997bd6dbbb30e7eb..f82681ca9f57702ea46d288054692b8b91f41a95 100644
--- a/pkg/analyzer/lib/src/generated/engine.dart
+++ b/pkg/analyzer/lib/src/generated/engine.dart
@@ -1212,6 +1212,27 @@ class AnalysisContextImpl implements InternalAnalysisContext {
}
@override
+ bool validateSourceCacheConsistency(Source source) {
+ SourceEntry 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
List<Source> get launchableServerLibrarySources {
// TODO(brianwilkerson) This needs to filter out libraries that reference
// dart:html, either directly or indirectly.
@@ -2269,9 +2290,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
AnalysisTask task = PerformanceStatistics.nextTask
.makeCurrentWhile(() => nextAnalysisTask);
int getEnd = JavaSystem.currentTimeMillis();
- if (task == null && _validateCacheConsistency()) {
- task = nextAnalysisTask;
- }
if (task == null) {
_validateLastIncrementalResolutionResult();
if (_performAnalysisTaskStopwatch != null) {
@@ -4026,13 +4044,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
false;
/**
- * Log the given debugging [message].
- */
- void _logInformation(String message) {
- AnalysisEngine.instance.logger.logInformation(message);
- }
-
- /**
* Notify all of the analysis listeners that a task is about to be performed.
*/
void _notifyAboutToPerformTask(String taskDescription) {
@@ -4731,65 +4742,6 @@ class AnalysisContextImpl implements InternalAnalysisContext {
});
}
- /**
- * 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();
- List<Source> changedSources = new List<Source>();
- List<Source> missingSources = new List<Source>();
- MapIterator<Source, SourceEntry> iterator = _cache.iterator();
- while (iterator.moveNext()) {
- Source source = iterator.key;
- SourceEntry sourceEntry = iterator.value;
- int sourceTime = getModificationStamp(source);
- if (sourceTime != sourceEntry.modificationTime) {
- changedSources.add(source);
- }
- if (sourceEntry.exception != null) {
- if (!exists(source)) {
- missingSources.add(source);
- }
- }
- }
- int count = changedSources.length;
- for (int i = 0; i < count; i++) {
- _sourceChanged(changedSources[i]);
- }
- 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;
- }
-
void _validateLastIncrementalResolutionResult() {
if (incrementalResolutionValidation_lastUnitSource == null ||
incrementalResolutionValidation_lastLibrarySource == null ||
@@ -9192,6 +9144,14 @@ abstract class InternalAnalysisContext implements AnalysisContext {
void set typeProvider(TypeProvider typeProvider);
/**
+ * Check whether the cache entry for the given [source] is valid, i.e. the
+ * entry modification time matches the modification time of the [source].
+ * If not, the entry is marked as invalid so that the source will be
+ * re-analyzed, and `true` is returned.
+ */
+ bool validateSourceCacheConsistency(Source source);
+
+ /**
* A factory to override how [TypeResolverVisitor] is created.
*/
TypeResolverVisitorFactory get typeResolverVisitorFactory;

Powered by Google App Engine
This is Rietveld 408576698