| 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_work_manager; | 5 library analyzer.src.task.dart_work_manager; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart' | 10 import 'package:analyzer/src/generated/engine.dart' |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * A table mapping part sources to the library sources that include them. | 78 * A table mapping part sources to the library sources that include them. |
| 79 */ | 79 */ |
| 80 final HashMap<Source, List<Source>> partLibrariesMap = | 80 final HashMap<Source, List<Source>> partLibrariesMap = |
| 81 new HashMap<Source, List<Source>>(); | 81 new HashMap<Source, List<Source>>(); |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * Initialize a newly created manager. | 84 * Initialize a newly created manager. |
| 85 */ | 85 */ |
| 86 DartWorkManager(this.context); | 86 DartWorkManager(this.context) { |
| 87 analysisCache.onResultInvalidated.listen((InvalidatedResult event) { |
| 88 if (event.descriptor == LIBRARY_ERRORS_READY) { |
| 89 CacheEntry entry = event.entry; |
| 90 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY) { |
| 91 librarySourceQueue.add(entry.target); |
| 92 } |
| 93 } |
| 94 }); |
| 95 } |
| 87 | 96 |
| 88 /** | 97 /** |
| 89 * Returns the correctly typed result of `context.analysisCache`. | 98 * Returns the correctly typed result of `context.analysisCache`. |
| 90 */ | 99 */ |
| 91 AnalysisCache get analysisCache => context.analysisCache; | 100 AnalysisCache get analysisCache => context.analysisCache; |
| 92 | 101 |
| 93 /** | 102 /** |
| 94 * The partition that contains analysis results that are not shared with other | 103 * The partition that contains analysis results that are not shared with other |
| 95 * contexts. | 104 * contexts. |
| 96 */ | 105 */ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 121 librarySourceQueue.removeAll(changedSources); | 130 librarySourceQueue.removeAll(changedSources); |
| 122 librarySourceQueue.removeAll(removedSources); | 131 librarySourceQueue.removeAll(removedSources); |
| 123 // parts in libraries | 132 // parts in libraries |
| 124 for (Source changedSource in changedSources) { | 133 for (Source changedSource in changedSources) { |
| 125 _onLibrarySourceChangedOrRemoved(changedSource); | 134 _onLibrarySourceChangedOrRemoved(changedSource); |
| 126 } | 135 } |
| 127 for (Source removedSource in removedSources) { | 136 for (Source removedSource in removedSources) { |
| 128 partLibrariesMap.remove(removedSource); | 137 partLibrariesMap.remove(removedSource); |
| 129 _onLibrarySourceChangedOrRemoved(removedSource); | 138 _onLibrarySourceChangedOrRemoved(removedSource); |
| 130 } | 139 } |
| 131 // Some of the libraries might have been invalidated, reschedule them. | |
| 132 { | |
| 133 MapIterator<AnalysisTarget, CacheEntry> iterator = | |
| 134 analysisCache.iterator(); | |
| 135 while (iterator.moveNext()) { | |
| 136 AnalysisTarget target = iterator.key; | |
| 137 if (_isDartSource(target)) { | |
| 138 CacheEntry entry = iterator.value; | |
| 139 if (entry.getValue(SOURCE_KIND) == SourceKind.LIBRARY && | |
| 140 entry.getValue(LIBRARY_ERRORS_READY) != true) { | |
| 141 librarySourceQueue.add(target); | |
| 142 } | |
| 143 } | |
| 144 } | |
| 145 } | |
| 146 } | 140 } |
| 147 | 141 |
| 148 @override | 142 @override |
| 149 void applyPriorityTargets(List<AnalysisTarget> targets) { | 143 void applyPriorityTargets(List<AnalysisTarget> targets) { |
| 150 // Unschedule the old targets. | 144 // Unschedule the old targets. |
| 151 List<TargetedResult> resultsToUnschedule = <TargetedResult>[]; | 145 List<TargetedResult> resultsToUnschedule = <TargetedResult>[]; |
| 152 for (TargetedResult result in priorityResultQueue) { | 146 for (TargetedResult result in priorityResultQueue) { |
| 153 if (result.result == LIBRARY_ERRORS_READY) { | 147 if (result.result == LIBRARY_ERRORS_READY) { |
| 154 resultsToUnschedule.add(result); | 148 resultsToUnschedule.add(result); |
| 155 } | 149 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 } | 438 } |
| 445 } | 439 } |
| 446 | 440 |
| 447 bool _shouldErrorsBeComputed(Source source) => | 441 bool _shouldErrorsBeComputed(Source source) => |
| 448 context.shouldErrorsBeAnalyzed(source, null); | 442 context.shouldErrorsBeAnalyzed(source, null); |
| 449 | 443 |
| 450 static bool _isDartSource(AnalysisTarget target) { | 444 static bool _isDartSource(AnalysisTarget target) { |
| 451 return target is Source && AnalysisEngine.isDartFileName(target.fullName); | 445 return target is Source && AnalysisEngine.isDartFileName(target.fullName); |
| 452 } | 446 } |
| 453 } | 447 } |
| OLD | NEW |