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

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

Issue 2155013002: Always update 'modificationTime' in _sourceChanged(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/context/context_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 858fd0636a60235d799a0f331834c973c7a6e256..a9e5bc58604210d01ba373017720b295e10b8622 100644
--- a/pkg/analyzer/lib/src/context/context.dart
+++ b/pkg/analyzer/lib/src/context/context.dart
@@ -1825,21 +1825,25 @@ class AnalysisContextImpl implements InternalAnalysisContext {
// (For example, in getLibrariesContaining.)
entry.setState(CONTENT, CacheState.FLUSHED);
- if (oldContents != null) {
- // Fast path if the content is the same as it was last time.
- try {
- TimestampedData<String> fileContents = getContents(source);
- if (fileContents.data == oldContents) {
- int time = fileContents.modificationTime;
- for (CacheEntry entry in _entriesFor(source)) {
- entry.modificationTime = time;
- }
- return;
- }
- } catch (e) {
- entry.modificationTime = -1;
+ // Prepare the new contents.
+ TimestampedData<String> fileContents;
+ try {
+ fileContents = getContents(source);
+ } catch (e) {}
+
+ // Update 'modificationTime' - we are going to update the entry.
+ {
+ int time = fileContents?.modificationTime ?? -1;
+ for (CacheEntry entry in _entriesFor(source)) {
+ entry.modificationTime = time;
}
}
+
+ // Fast path if the contents is the same as it was last time.
+ if (oldContents != null && fileContents?.data == oldContents) {
+ return;
+ }
+
// We need to invalidate the cache.
{
if (analysisOptions.finerGrainedInvalidation &&
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698