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

Side by Side Diff: pkg/analyzer/lib/src/task/driver.dart

Issue 988883004: Add CacheEntry.setErrorState(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
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.task.driver; 5 library analyzer.src.task.driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/src/context/cache.dart'; 10 import 'package:analyzer/src/context/cache.dart';
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 /** 186 /**
187 * Perform the given work item. 187 * Perform the given work item.
188 */ 188 */
189 void performWorkItem(WorkItem item) { 189 void performWorkItem(WorkItem item) {
190 if (item.exception != null) { 190 if (item.exception != null) {
191 // Mark all of the results that the task would have computed as being in 191 // Mark all of the results that the task would have computed as being in
192 // ERROR with the exception recorded on the work item. 192 // ERROR with the exception recorded on the work item.
193 CacheEntry targetEntry = context.getCacheEntry(item.target); 193 CacheEntry targetEntry = context.getCacheEntry(item.target);
194 targetEntry.exception = item.exception; 194 targetEntry.setErrorState(item.descriptor.results, item.exception);
195 for (ResultDescriptor result in item.descriptor.results) {
196 targetEntry.setState(result, CacheState.ERROR);
197 }
198 return; 195 return;
199 } 196 }
200 // Otherwise, perform the task. 197 // Otherwise, perform the task.
201 AnalysisTask task = item.buildTask(); 198 AnalysisTask task = item.buildTask();
202 _onTaskStartedController.add(task); 199 _onTaskStartedController.add(task);
203 task.perform(); 200 task.perform();
204 CacheEntry entry = context.getCacheEntry(task.target); 201 CacheEntry entry = context.getCacheEntry(task.target);
205 if (task.caughtException == null) { 202 if (task.caughtException == null) {
206 Map<ResultDescriptor, dynamic> outputs = task.outputs; 203 Map<ResultDescriptor, dynamic> outputs = task.outputs;
207 for (ResultDescriptor result in task.descriptor.results) { 204 for (ResultDescriptor result in task.descriptor.results) {
208 // TODO(brianwilkerson) We could check here that a value was produced 205 // TODO(brianwilkerson) We could check here that a value was produced
209 // and throw an exception if not (unless we want to allow null values). 206 // and throw an exception if not (unless we want to allow null values).
210 entry.setValue(result, outputs[result]); 207 entry.setValue(result, outputs[result]);
211 } 208 }
212 } else { 209 } else {
213 entry.exception = task.caughtException; 210 entry.setErrorState(item.descriptor.results, task.caughtException);
214 for (ResultDescriptor result in task.descriptor.results) {
215 entry.setState(result, CacheState.ERROR);
216 }
217 } 211 }
218 _onTaskCompletedController.add(task); 212 _onTaskCompletedController.add(task);
219 } 213 }
220 214
221 /** 215 /**
222 * Reset the state of the driver in response to a change in the state of one 216 * Reset the state of the driver in response to a change in the state of one
223 * or more analysis targets. This will cause any analysis that was currently 217 * or more analysis targets. This will cause any analysis that was currently
224 * in process to be stopped and for analysis to resume based on the new state. 218 * in process to be stopped and for analysis to resume based on the new state.
225 */ 219 */
226 void reset() { 220 void reset() {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 currentItem = pendingItems.removeLast(); 401 currentItem = pendingItems.removeLast();
408 WorkItem childItem = currentItem.gatherInputs(taskManager); 402 WorkItem childItem = currentItem.gatherInputs(taskManager);
409 while (childItem != null) { 403 while (childItem != null) {
410 pendingItems.add(currentItem); 404 pendingItems.add(currentItem);
411 currentItem = childItem; 405 currentItem = childItem;
412 childItem = currentItem.gatherInputs(taskManager); 406 childItem = currentItem.gatherInputs(taskManager);
413 } 407 }
414 return true; 408 return true;
415 } 409 }
416 } 410 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698