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

Side by Side Diff: pkg/analyzer/lib/src/context/context.dart

Issue 2209493003: Don't report removed sources as changed in CacheConsistencyValidatorImpl. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 2061
2062 CacheConsistencyValidatorImpl(this.context); 2062 CacheConsistencyValidatorImpl(this.context);
2063 2063
2064 @override 2064 @override
2065 List<Source> getSourcesToComputeModificationTimes() { 2065 List<Source> getSourcesToComputeModificationTimes() {
2066 return context._privatePartition.sources.toList(); 2066 return context._privatePartition.sources.toList();
2067 } 2067 }
2068 2068
2069 @override 2069 @override
2070 bool sourceModificationTimesComputed(List<Source> sources, List<int> times) { 2070 bool sourceModificationTimesComputed(List<Source> sources, List<int> times) {
2071 int consistencyCheckStart = JavaSystem.nanoTime(); 2071 Stopwatch timer = new Stopwatch()..start();
2072 HashSet<Source> changedSources = new HashSet<Source>(); 2072 HashSet<Source> changedSources = new HashSet<Source>();
2073 HashSet<Source> missingSources = new HashSet<Source>(); 2073 HashSet<Source> removedSources = new HashSet<Source>();
2074 for (int i = 0; i < sources.length; i++) { 2074 for (int i = 0; i < sources.length; i++) {
2075 Source source = sources[i]; 2075 Source source = sources[i];
2076 // When a source is in the content cache, 2076 // When a source is in the content cache,
2077 // its modification time in the file system does not matter. 2077 // its modification time in the file system does not matter.
2078 if (context._contentCache.getModificationStamp(source) != null) { 2078 if (context._contentCache.getModificationStamp(source) != null) {
2079 continue; 2079 continue;
2080 } 2080 }
2081 // When we were not able to compute the modification time in the 2081 // When we were not able to compute the modification time in the
2082 // file system, there is nothing to compare with, so skip the source. 2082 // file system, there is nothing to compare with, so skip the source.
2083 int sourceTime = times[i]; 2083 int sourceTime = times[i];
2084 if (sourceTime == null) { 2084 if (sourceTime == null) {
2085 continue; 2085 continue;
2086 } 2086 }
2087 // Compare with the modification time in the cache entry. 2087 // Compare with the modification time in the cache entry.
2088 CacheEntry entry = context._privatePartition.get(source); 2088 CacheEntry entry = context._privatePartition.get(source);
2089 if (entry != null) { 2089 if (entry != null) {
2090 if (sourceTime != entry.modificationTime) { 2090 if (entry.modificationTime != sourceTime) {
2091 changedSources.add(source);
2092 PerformanceStatistics
2093 .cacheConsistencyValidationStatistics.numOfModified++;
2094 }
2095 if (entry.exception != null) {
2096 if (sourceTime == -1) { 2091 if (sourceTime == -1) {
2097 missingSources.add(source); 2092 removedSources.add(source);
2098 PerformanceStatistics 2093 PerformanceStatistics
2099 .cacheConsistencyValidationStatistics.numOfModified++; 2094 .cacheConsistencyValidationStatistics.numOfRemoved++;
2095 } else {
2096 changedSources.add(source);
2097 PerformanceStatistics
2098 .cacheConsistencyValidationStatistics.numOfChanged++;
2100 } 2099 }
2101 } 2100 }
2102 } 2101 }
2103 } 2102 }
2104 for (Source source in changedSources) { 2103 for (Source source in changedSources) {
2105 context._sourceChanged(source); 2104 context._sourceChanged(source);
2106 } 2105 }
2107 int removalCount = 0; 2106 for (Source source in removedSources) {
2108 for (Source source in missingSources) { 2107 context._sourceRemoved(source);
2109 if (context.getLibrariesContaining(source).isEmpty &&
2110 context.getLibrariesDependingOn(source).isEmpty) {
2111 context._removeFromCache(source);
2112 removalCount++;
2113 }
2114 } 2108 }
2115 int consistencyCheckEnd = JavaSystem.nanoTime(); 2109 if (changedSources.length > 0 || removedSources.length > 0) {
2116 if (changedSources.length > 0 || missingSources.length > 0) {
2117 StringBuffer buffer = new StringBuffer(); 2110 StringBuffer buffer = new StringBuffer();
2118 buffer.write("Consistency check took "); 2111 buffer.write("Consistency check took ");
2119 buffer.write((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); 2112 buffer.write(timer.elapsedMilliseconds);
2120 buffer.writeln(" ms and found"); 2113 buffer.writeln(" ms and found");
2121 buffer.write(" "); 2114 buffer.write(" ");
2122 buffer.write(changedSources.length); 2115 buffer.write(changedSources.length);
2123 buffer.writeln(" inconsistent entries"); 2116 buffer.writeln(" changed sources");
2124 buffer.write(" "); 2117 buffer.write(" ");
2125 buffer.write(missingSources.length); 2118 buffer.write(removedSources.length);
2126 buffer.write(" missing sources ("); 2119 buffer.write(" removed sources.");
2127 buffer.write(removalCount);
2128 buffer.writeln(" removed");
2129 for (Source source in missingSources) {
2130 buffer.write(" ");
2131 buffer.writeln(source.fullName);
2132 }
2133 context._logInformation(buffer.toString()); 2120 context._logInformation(buffer.toString());
2134 } 2121 }
2135 return changedSources.length > 0; 2122 return changedSources.isNotEmpty || removedSources.isNotEmpty;
2136 } 2123 }
2137 } 2124 }
2138 2125
2139 /** 2126 /**
2140 * An object that manages the partitions that can be shared between analysis 2127 * An object that manages the partitions that can be shared between analysis
2141 * contexts. 2128 * contexts.
2142 */ 2129 */
2143 class PartitionManager { 2130 class PartitionManager {
2144 /** 2131 /**
2145 * A table mapping SDK's to the partitions used for those SDK's. 2132 * A table mapping SDK's to the partitions used for those SDK's.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 } 2288 }
2302 DartSdk sdk = factory.dartSdk; 2289 DartSdk sdk = factory.dartSdk;
2303 if (sdk == null) { 2290 if (sdk == null) {
2304 throw new IllegalArgumentException( 2291 throw new IllegalArgumentException(
2305 "The source factory for an SDK analysis context must have a DartUriRes olver"); 2292 "The source factory for an SDK analysis context must have a DartUriRes olver");
2306 } 2293 }
2307 return new AnalysisCache( 2294 return new AnalysisCache(
2308 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); 2295 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
2309 } 2296 }
2310 } 2297 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/cache.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698