| 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.task.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2224 changedNames.contains(name) || | 2224 changedNames.contains(name) || |
| 2225 removedNames.contains(name); | 2225 removedNames.contains(name); |
| 2226 } | 2226 } |
| 2227 | 2227 |
| 2228 bool nameChanged(String name) { | 2228 bool nameChanged(String name) { |
| 2229 return changedNames.add(name); | 2229 return changedNames.add(name); |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 @override | 2232 @override |
| 2233 DeltaResult validate(InternalAnalysisContext context, AnalysisTarget target, | 2233 DeltaResult validate(InternalAnalysisContext context, AnalysisTarget target, |
| 2234 ResultDescriptor descriptor) { | 2234 ResultDescriptor descriptor, CacheState state, Object value) { |
| 2235 if (hasDirectiveChange) { | 2235 if (hasDirectiveChange) { |
| 2236 return DeltaResult.INVALIDATE; | 2236 return DeltaResult.INVALIDATE; |
| 2237 } | 2237 } |
| 2238 // Prepare target source. | 2238 // Prepare target source. |
| 2239 Source targetSource = null; | 2239 Source targetSource = null; |
| 2240 if (target is Source) { | 2240 if (target is Source) { |
| 2241 targetSource = target; | 2241 targetSource = target; |
| 2242 } | 2242 } |
| 2243 if (target is LibrarySpecificUnit) { | 2243 if (target is LibrarySpecificUnit) { |
| 2244 targetSource = target.library; | 2244 targetSource = target.library; |
| 2245 } | 2245 } |
| 2246 if (target is Element) { | 2246 if (target is Element) { |
| 2247 targetSource = target.source; | 2247 targetSource = target.source; |
| 2248 } | 2248 } |
| 2249 // Keep results that are updated incrementally. | 2249 // Keep results that are updated incrementally. |
| 2250 // If we want to analyze only some references to the source being changed, | 2250 // If we want to analyze only some references to the source being changed, |
| 2251 // we need to keep the same instances of CompilationUnitElement and | 2251 // we need to keep the same instances of CompilationUnitElement and |
| 2252 // LibraryElement. | 2252 // LibraryElement. |
| 2253 if (targetSource == source) { | 2253 if (targetSource == source) { |
| 2254 if (ParseDartTask.DESCRIPTOR.results.contains(descriptor)) { | 2254 if (ParseDartTask.DESCRIPTOR.results.contains(descriptor)) { |
| 2255 return DeltaResult.KEEP_CONTINUE; | 2255 return DeltaResult.KEEP_CONTINUE; |
| 2256 } | 2256 } |
| 2257 if (BuildCompilationUnitElementTask.DESCRIPTOR.results | 2257 if (BuildCompilationUnitElementTask.DESCRIPTOR.results |
| 2258 .contains(descriptor)) { | 2258 .contains(descriptor)) { |
| 2259 return DeltaResult.KEEP_CONTINUE; | 2259 return DeltaResult.KEEP_CONTINUE; |
| 2260 } | 2260 } |
| 2261 if (BuildLibraryElementTask.DESCRIPTOR.results.contains(descriptor)) { | 2261 if (BuildLibraryElementTask.DESCRIPTOR.results.contains(descriptor)) { |
| 2262 // Invalidate cached results. |
| 2263 if (value is LibraryElementImpl) { |
| 2264 value.exportNamespace = null; |
| 2265 } |
| 2262 return DeltaResult.KEEP_CONTINUE; | 2266 return DeltaResult.KEEP_CONTINUE; |
| 2263 } | 2267 } |
| 2264 return DeltaResult.INVALIDATE; | 2268 return DeltaResult.INVALIDATE; |
| 2265 } | 2269 } |
| 2266 // Use the target library dependency information to decide whether | 2270 // Use the target library dependency information to decide whether |
| 2267 // the delta affects the library. | 2271 // the delta affects the library. |
| 2268 if (targetSource != null) { | 2272 if (targetSource != null) { |
| 2269 List<Source> librarySources = | 2273 List<Source> librarySources = |
| 2270 context.getLibrariesContaining(targetSource); | 2274 context.getLibrariesContaining(targetSource); |
| 2271 for (Source librarySource in librarySources) { | 2275 for (Source librarySource in librarySources) { |
| (...skipping 3078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5350 | 5354 |
| 5351 @override | 5355 @override |
| 5352 bool moveNext() { | 5356 bool moveNext() { |
| 5353 if (_newSources.isEmpty) { | 5357 if (_newSources.isEmpty) { |
| 5354 return false; | 5358 return false; |
| 5355 } | 5359 } |
| 5356 currentTarget = _newSources.removeLast(); | 5360 currentTarget = _newSources.removeLast(); |
| 5357 return true; | 5361 return true; |
| 5358 } | 5362 } |
| 5359 } | 5363 } |
| OLD | NEW |