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

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

Issue 1121963002: Record dependencies and invalidate results. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge and fixes for review comments. 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 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 CacheEntry targetEntry = context.getCacheEntry(item.target); 203 CacheEntry targetEntry = context.getCacheEntry(item.target);
204 targetEntry.setErrorState(item.exception, item.descriptor.results); 204 targetEntry.setErrorState(item.exception, item.descriptor.results);
205 return null; 205 return null;
206 } 206 }
207 // Otherwise, perform the task. 207 // Otherwise, perform the task.
208 AnalysisTask task = item.buildTask(); 208 AnalysisTask task = item.buildTask();
209 _onTaskStartedController.add(task); 209 _onTaskStartedController.add(task);
210 task.perform(); 210 task.perform();
211 CacheEntry entry = context.getCacheEntry(task.target); 211 CacheEntry entry = context.getCacheEntry(task.target);
212 if (task.caughtException == null) { 212 if (task.caughtException == null) {
213 List<TargetedResult> dependedOn = item.inputTargetedResults.toList();
213 Map<ResultDescriptor, dynamic> outputs = task.outputs; 214 Map<ResultDescriptor, dynamic> outputs = task.outputs;
214 for (ResultDescriptor result in task.descriptor.results) { 215 for (ResultDescriptor result in task.descriptor.results) {
215 // TODO(brianwilkerson) We could check here that a value was produced 216 // TODO(brianwilkerson) We could check here that a value was produced
216 // and throw an exception if not (unless we want to allow null values). 217 // and throw an exception if not (unless we want to allow null values).
217 entry.setValue(result, outputs[result]); 218 entry.setValue(result, outputs[result], dependedOn);
218 } 219 }
219 } else { 220 } else {
220 entry.setErrorState(task.caughtException, item.descriptor.results); 221 entry.setErrorState(task.caughtException, item.descriptor.results);
221 } 222 }
222 _onTaskCompletedController.add(task); 223 _onTaskCompletedController.add(task);
223 return task; 224 return task;
224 } 225 }
225 226
226 /** 227 /**
227 * Reset the state of the driver in response to a change in the state of one 228 * Reset the state of the driver in response to a change in the state of one
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 final TaskDescriptor descriptor; 280 final TaskDescriptor descriptor;
280 281
281 /** 282 /**
282 * An iterator used to iterate over the descriptors of the inputs to the task, 283 * An iterator used to iterate over the descriptors of the inputs to the task,
283 * or `null` if all of the inputs have been collected and the task can be 284 * or `null` if all of the inputs have been collected and the task can be
284 * created. 285 * created.
285 */ 286 */
286 TaskInputBuilder builder; 287 TaskInputBuilder builder;
287 288
288 /** 289 /**
290 * The [TargetedResult]s outputs of this task depends on.
291 */
292 final HashSet<TargetedResult> inputTargetedResults =
293 new HashSet<TargetedResult>();
294
295 /**
289 * The inputs to the task that have been computed. 296 * The inputs to the task that have been computed.
290 */ 297 */
291 Map<String, dynamic> inputs; 298 Map<String, dynamic> inputs;
292 299
293 /** 300 /**
294 * The exception that was found while trying to populate the inputs. If this 301 * The exception that was found while trying to populate the inputs. If this
295 * field is non-`null`, then the task cannot be performed and all of the 302 * field is non-`null`, then the task cannot be performed and all of the
296 * results that this task would have computed need to be marked as being in 303 * results that this task would have computed need to be marked as being in
297 * ERROR with this exception. 304 * ERROR with this exception.
298 */ 305 */
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 * If all of the inputs have been gathered, return `null` to indicate that the 344 * If all of the inputs have been gathered, return `null` to indicate that the
338 * client should build and perform the task. A value of `null` will also be 345 * client should build and perform the task. A value of `null` will also be
339 * returned if some of the inputs cannot be computed and the task cannot be 346 * returned if some of the inputs cannot be computed and the task cannot be
340 * performed. Callers can differentiate between these cases by checking the 347 * performed. Callers can differentiate between these cases by checking the
341 * [exception] field. If the field is `null`, then the task can be performed; 348 * [exception] field. If the field is `null`, then the task can be performed;
342 * if the field is non-`null` then the task cannot be performed and all of the 349 * if the field is non-`null` then the task cannot be performed and all of the
343 * tasks' results should be marked as being in ERROR. 350 * tasks' results should be marked as being in ERROR.
344 */ 351 */
345 WorkItem gatherInputs(TaskManager taskManager) { 352 WorkItem gatherInputs(TaskManager taskManager) {
346 while (builder != null) { 353 while (builder != null) {
347 //
348 // TODO(brianwilkerson) Capture information about which inputs were used
349 // to compute the results. This information can later be used to compute
350 // which results depend on a given result, and hence which results need to
351 // be invalidated when one result is invalidated.
352 //
353 AnalysisTarget inputTarget = builder.currentTarget; 354 AnalysisTarget inputTarget = builder.currentTarget;
354 ResultDescriptor inputResult = builder.currentResult; 355 ResultDescriptor inputResult = builder.currentResult;
356 inputTargetedResults.add(new TargetedResult(inputTarget, inputResult));
355 CacheEntry inputEntry = context.getCacheEntry(inputTarget); 357 CacheEntry inputEntry = context.getCacheEntry(inputTarget);
356 CacheState inputState = inputEntry.getState(inputResult); 358 CacheState inputState = inputEntry.getState(inputResult);
357 if (inputState == CacheState.ERROR) { 359 if (inputState == CacheState.ERROR) {
358 exception = inputEntry.exception; 360 exception = inputEntry.exception;
359 return null; 361 return null;
360 } else if (inputState == CacheState.IN_PROCESS) { 362 } else if (inputState == CacheState.IN_PROCESS) {
361 // 363 //
362 // TODO(brianwilkerson) Implement this case. 364 // TODO(brianwilkerson) Implement this case.
363 // 365 //
364 // One possibility would be to return a WorkItem that would perform a 366 // One possibility would be to return a WorkItem that would perform a
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 TaskDescriptor descriptor = currentItem.descriptor; 461 TaskDescriptor descriptor = currentItem.descriptor;
460 AnalysisTarget target = currentItem.target; 462 AnalysisTarget target = currentItem.target;
461 for (WorkItem item in pendingItems) { 463 for (WorkItem item in pendingItems) {
462 if (item.descriptor == descriptor && item.target == target) { 464 if (item.descriptor == descriptor && item.target == target) {
463 return true; 465 return true;
464 } 466 }
465 } 467 }
466 return false; 468 return false;
467 } 469 }
468 } 470 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/context/abstract_context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698