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

Unified Diff: packages/analyzer/lib/src/task/general.dart

Issue 2990843002: Removed fixed dependencies (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 | « packages/analyzer/lib/src/task/driver.dart ('k') | packages/analyzer/lib/src/task/html.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/analyzer/lib/src/task/general.dart
diff --git a/packages/analyzer/lib/src/task/general.dart b/packages/analyzer/lib/src/task/general.dart
index 72f80fde5520670f3e84aefe28a43880c135945f..064fd200c59f264df84e71df02603e24f21ec76f 100644
--- a/packages/analyzer/lib/src/task/general.dart
+++ b/packages/analyzer/lib/src/task/general.dart
@@ -4,7 +4,8 @@
library analyzer.src.task.general;
-import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
+import 'package:analyzer/src/context/cache.dart';
+import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/task/general.dart';
import 'package:analyzer/task/model.dart';
@@ -33,13 +34,36 @@ class GetContentTask extends SourceBasedAnalysisTask {
@override
internalPerform() {
Source source = getRequiredSource();
+ String content;
+ int modificationTime;
try {
TimestampedData<String> data = context.getContents(source);
- outputs[CONTENT] = data.data;
- outputs[MODIFICATION_TIME] = data.modificationTime;
+ content = data.data;
+ modificationTime = data.modificationTime;
} catch (exception) {
- outputs[CONTENT] = '';
- outputs[MODIFICATION_TIME] = -1;
+ content = '';
+ modificationTime = -1;
+ }
+ _validateModificationTime(source, modificationTime);
+ outputs[CONTENT] = content;
+ outputs[MODIFICATION_TIME] = modificationTime;
+ }
+
+ /**
+ * Validate that the [target] cache entry has the same modification time
+ * as the given. Otherwise throw a new [ModificationTimeMismatchError] and
+ * instruct to invalidate targets content.
+ */
+ void _validateModificationTime(Source source, int modificationTime) {
+ AnalysisContext context = this.context;
+ if (context is InternalAnalysisContext) {
+ CacheEntry entry = context.getCacheEntry(target);
+ if (entry != null && entry.modificationTime != modificationTime) {
+ entry.modificationTime = modificationTime;
+ entry.setState(CONTENT, CacheState.INVALID);
+ entry.setState(MODIFICATION_TIME, CacheState.INVALID);
+ throw new ModificationTimeMismatchError(source);
+ }
}
}
« no previous file with comments | « packages/analyzer/lib/src/task/driver.dart ('k') | packages/analyzer/lib/src/task/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698