| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.context.context; | 5 library analyzer.src.context.context; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2051 } | 2051 } |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 class CacheConsistencyValidatorImpl implements CacheConsistencyValidator { | 2054 class CacheConsistencyValidatorImpl implements CacheConsistencyValidator { |
| 2055 final AnalysisContextImpl context; | 2055 final AnalysisContextImpl context; |
| 2056 | 2056 |
| 2057 CacheConsistencyValidatorImpl(this.context); | 2057 CacheConsistencyValidatorImpl(this.context); |
| 2058 | 2058 |
| 2059 @override | 2059 @override |
| 2060 List<Source> getSourcesToComputeModificationTimes() { | 2060 List<Source> getSourcesToComputeModificationTimes() { |
| 2061 List<Source> sources = <Source>[]; | 2061 return context._privatePartition.sources.toList(); |
| 2062 for (Source source in context._privatePartition.sources) { | |
| 2063 if (context._contentCache.getModificationStamp(source) == null) { | |
| 2064 sources.add(source); | |
| 2065 } | |
| 2066 } | |
| 2067 return sources; | |
| 2068 } | 2062 } |
| 2069 | 2063 |
| 2070 @override | 2064 @override |
| 2071 bool sourceModificationTimesComputed(List<Source> sources, List<int> times) { | 2065 bool sourceModificationTimesComputed(List<Source> sources, List<int> times) { |
| 2072 int consistencyCheckStart = JavaSystem.nanoTime(); | 2066 int consistencyCheckStart = JavaSystem.nanoTime(); |
| 2073 HashSet<Source> changedSources = new HashSet<Source>(); | 2067 HashSet<Source> changedSources = new HashSet<Source>(); |
| 2074 HashSet<Source> missingSources = new HashSet<Source>(); | 2068 HashSet<Source> missingSources = new HashSet<Source>(); |
| 2075 for (int i = 0; i < sources.length; i++) { | 2069 for (int i = 0; i < sources.length; i++) { |
| 2076 Source source = sources[i]; | 2070 Source source = sources[i]; |
| 2071 // When a source is in the content cache, |
| 2072 // its modification time in the file system does not matter. |
| 2073 if (context._contentCache.getModificationStamp(source) != null) { |
| 2074 continue; |
| 2075 } |
| 2076 // When we were not able to compute the modification time in the |
| 2077 // file system, there is nothing to compare with, so skip the source. |
| 2077 int sourceTime = times[i]; | 2078 int sourceTime = times[i]; |
| 2078 if (sourceTime != null) { | 2079 if (sourceTime == null) { |
| 2079 CacheEntry entry = context._privatePartition.get(source); | 2080 continue; |
| 2080 if (entry != null) { | 2081 } |
| 2081 if (sourceTime != entry.modificationTime) { | 2082 // Compare with the modification time in the cache entry. |
| 2082 changedSources.add(source); | 2083 CacheEntry entry = context._privatePartition.get(source); |
| 2084 if (entry != null) { |
| 2085 if (sourceTime != entry.modificationTime) { |
| 2086 changedSources.add(source); |
| 2087 PerformanceStatistics |
| 2088 .cacheConsistencyValidationStatistics.numOfModified++; |
| 2089 } |
| 2090 if (entry.exception != null) { |
| 2091 if (sourceTime == -1) { |
| 2092 missingSources.add(source); |
| 2083 PerformanceStatistics | 2093 PerformanceStatistics |
| 2084 .cacheConsistencyValidationStatistics.numOfModified++; | 2094 .cacheConsistencyValidationStatistics.numOfModified++; |
| 2085 } | 2095 } |
| 2086 if (entry.exception != null) { | |
| 2087 if (sourceTime == -1) { | |
| 2088 missingSources.add(source); | |
| 2089 PerformanceStatistics | |
| 2090 .cacheConsistencyValidationStatistics.numOfModified++; | |
| 2091 } | |
| 2092 } | |
| 2093 } | 2096 } |
| 2094 } | 2097 } |
| 2095 } | 2098 } |
| 2096 for (Source source in changedSources) { | 2099 for (Source source in changedSources) { |
| 2097 context._sourceChanged(source); | 2100 context._sourceChanged(source); |
| 2098 } | 2101 } |
| 2099 int removalCount = 0; | 2102 int removalCount = 0; |
| 2100 for (Source source in missingSources) { | 2103 for (Source source in missingSources) { |
| 2101 if (context.getLibrariesContaining(source).isEmpty && | 2104 if (context.getLibrariesContaining(source).isEmpty && |
| 2102 context.getLibrariesDependingOn(source).isEmpty) { | 2105 context.getLibrariesDependingOn(source).isEmpty) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 } | 2296 } |
| 2294 DartSdk sdk = factory.dartSdk; | 2297 DartSdk sdk = factory.dartSdk; |
| 2295 if (sdk == null) { | 2298 if (sdk == null) { |
| 2296 throw new IllegalArgumentException( | 2299 throw new IllegalArgumentException( |
| 2297 "The source factory for an SDK analysis context must have a DartUriRes
olver"); | 2300 "The source factory for an SDK analysis context must have a DartUriRes
olver"); |
| 2298 } | 2301 } |
| 2299 return new AnalysisCache( | 2302 return new AnalysisCache( |
| 2300 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 2303 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 2301 } | 2304 } |
| 2302 } | 2305 } |
| OLD | NEW |