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

Unified Diff: pkg/analyzer/lib/src/task/dart_work_manager.dart

Issue 1136543006: Prioritize scheduling analysis for priority sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/task/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart_work_manager.dart
diff --git a/pkg/analyzer/lib/src/task/dart_work_manager.dart b/pkg/analyzer/lib/src/task/dart_work_manager.dart
index db062d0f11b7b410c45b559d9631d05ab8ebd77a..500422fe09f0df74264306d922c395e6de230bc8 100644
--- a/pkg/analyzer/lib/src/task/dart_work_manager.dart
+++ b/pkg/analyzer/lib/src/task/dart_work_manager.dart
@@ -44,6 +44,11 @@ class DartWorkManager implements WorkManager {
DartWorkManager(this.context);
/**
+ * Returns the correctly typed result of `context.analysisCache`.
+ */
+ AnalysisCache get analysisCache => context.analysisCache;
+
+ /**
* Specifies that the client want the given [result] of the given [target]
* to be computed with priority.
*/
@@ -69,7 +74,7 @@ class DartWorkManager implements WorkManager {
// Some of the libraries might have been invalidated, reschedule them.
{
MapIterator<AnalysisTarget, CacheEntry> iterator =
- (context.analysisCache as AnalysisCache).iterator();
+ analysisCache.iterator();
while (iterator.moveNext()) {
AnalysisTarget target = iterator.key;
if (_isDartSource(target)) {
@@ -84,6 +89,32 @@ class DartWorkManager implements WorkManager {
}
@override
+ void applyPriorityTargets(List<AnalysisTarget> targets) {
+ // Unschedule the old targets.
+ List<TargetedResult> resultsToUnschedule = <TargetedResult>[];
+ for (TargetedResult result in priorityResultQueue) {
+ if (result.result == LIBRARY_ERRORS_READY) {
+ resultsToUnschedule.add(result);
+ }
+ }
+ priorityResultQueue.removeAll(resultsToUnschedule);
+ // Schedule new targets.
+ for (AnalysisTarget target in targets) {
+ if (_isDartSource(target)) {
+ SourceKind sourceKind = analysisCache.getValue(target, SOURCE_KIND);
+ if (sourceKind == SourceKind.LIBRARY) {
+ addPriorityResult(target, LIBRARY_ERRORS_READY);
+ } else if (sourceKind == SourceKind.PART) {
+ List<Source> libraries = context.getLibrariesContaining(target);
+ for (Source library in libraries) {
+ addPriorityResult(library, LIBRARY_ERRORS_READY);
+ }
+ }
+ }
+ }
+ }
+
+ @override
TargetedResult getNextResult() {
// Try to find a priority result to compute.
while (priorityResultQueue.isNotEmpty) {
@@ -157,8 +188,7 @@ class DartWorkManager implements WorkManager {
* computing, i.e. it is not in the valid and not in the error state.
*/
bool _needsComputing(AnalysisTarget target, ResultDescriptor result) {
- AnalysisCache cache = context.analysisCache;
- CacheState state = cache.getState(target, result);
+ CacheState state = analysisCache.getState(target, result);
return state != CacheState.VALID && state != CacheState.ERROR;
}
}
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/task/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698