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

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

Issue 1776023002: Add AnalysisContext.onResultInvalidated(descriptor). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update Analysis Server. Created 4 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
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 26 matching lines...) Expand all
37 * compute. 37 * compute.
38 */ 38 */
39 final List<WorkManager> workManagers; 39 final List<WorkManager> workManagers;
40 40
41 /** 41 /**
42 * The context in which analysis is to be performed. 42 * The context in which analysis is to be performed.
43 */ 43 */
44 final InternalAnalysisContext context; 44 final InternalAnalysisContext context;
45 45
46 /** 46 /**
47 * The map of [ComputedResult] controllers. 47 * The map of [ResultChangedEvent] controllers.
48 */ 48 */
49 final Map<ResultDescriptor, StreamController<ComputedResult>> 49 final Map<ResultDescriptor, StreamController<ResultChangedEvent>>
50 resultComputedControllers = 50 resultComputedControllers =
51 <ResultDescriptor, StreamController<ComputedResult>>{}; 51 <ResultDescriptor, StreamController<ResultChangedEvent>>{};
52 52
53 /** 53 /**
54 * The work order that was previously computed but that has not yet been 54 * The work order that was previously computed but that has not yet been
55 * completed. 55 * completed.
56 */ 56 */
57 WorkOrder currentWorkOrder; 57 WorkOrder currentWorkOrder;
58 58
59 /** 59 /**
60 * Indicates whether any tasks are currently being performed (or building 60 * Indicates whether any tasks are currently being performed (or building
61 * their inputs). In debug builds, we use this to ensure that tasks don't 61 * their inputs). In debug builds, we use this to ensure that tasks don't
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 } 202 }
203 } 203 }
204 return null; 204 return null;
205 } 205 }
206 206
207 /** 207 /**
208 * Return the stream that is notified when a new value for the given 208 * Return the stream that is notified when a new value for the given
209 * [descriptor] is computed. 209 * [descriptor] is computed.
210 */ 210 */
211 Stream<ComputedResult> onResultComputed(ResultDescriptor descriptor) { 211 Stream<ResultChangedEvent> onResultComputed(ResultDescriptor descriptor) {
212 return resultComputedControllers 212 return resultComputedControllers.putIfAbsent(descriptor, () {
213 .putIfAbsent(descriptor, 213 return new StreamController<ResultChangedEvent>.broadcast(sync: true);
214 () => new StreamController<ComputedResult>.broadcast(sync: true)) 214 }).stream;
215 .stream;
216 } 215 }
217 216
218 /** 217 /**
219 * Perform the next analysis task, and return `true` if there is more work to 218 * Perform the next analysis task, and return `true` if there is more work to
220 * be done in order to compute all of the required analysis information. 219 * be done in order to compute all of the required analysis information.
221 */ 220 */
222 bool performAnalysisTask() { 221 bool performAnalysisTask() {
223 // 222 //
224 // TODO(brianwilkerson) This implementaiton does not allow us to prioritize 223 // TODO(brianwilkerson) This implementaiton does not allow us to prioritize
225 // work across contexts. What we need is a way for an external client to ask 224 // work across contexts. What we need is a way for an external client to ask
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 CacheEntry entry = context.getCacheEntry(target); 276 CacheEntry entry = context.getCacheEntry(target);
278 if (task.caughtException == null) { 277 if (task.caughtException == null) {
279 List<TargetedResult> dependedOn = item.inputTargetedResults.toList(); 278 List<TargetedResult> dependedOn = item.inputTargetedResults.toList();
280 Map<ResultDescriptor, dynamic> outputs = task.outputs; 279 Map<ResultDescriptor, dynamic> outputs = task.outputs;
281 for (ResultDescriptor result in task.descriptor.results) { 280 for (ResultDescriptor result in task.descriptor.results) {
282 // TODO(brianwilkerson) We could check here that a value was produced 281 // TODO(brianwilkerson) We could check here that a value was produced
283 // and throw an exception if not (unless we want to allow null values) . 282 // and throw an exception if not (unless we want to allow null values) .
284 entry.setValue(result, outputs[result], dependedOn); 283 entry.setValue(result, outputs[result], dependedOn);
285 } 284 }
286 outputs.forEach((ResultDescriptor descriptor, value) { 285 outputs.forEach((ResultDescriptor descriptor, value) {
287 StreamController<ComputedResult> controller = 286 StreamController<ResultChangedEvent> controller =
288 resultComputedControllers[descriptor]; 287 resultComputedControllers[descriptor];
289 if (controller != null) { 288 if (controller != null) {
290 ComputedResult event = 289 ResultChangedEvent event = new ResultChangedEvent(
291 new ComputedResult(context, descriptor, target, value); 290 context, target, descriptor, value, true);
292 controller.add(event); 291 controller.add(event);
293 } 292 }
294 }); 293 });
295 for (WorkManager manager in workManagers) { 294 for (WorkManager manager in workManagers) {
296 manager.resultsComputed(target, outputs); 295 manager.resultsComputed(target, outputs);
297 } 296 }
298 } else { 297 } else {
299 entry.setErrorState(task.caughtException, item.descriptor.results); 298 entry.setErrorState(task.caughtException, item.descriptor.results);
300 } 299 }
301 }); 300 });
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 final TaskManager taskManager; 831 final TaskManager taskManager;
833 832
834 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) 833 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode)
835 : super(startingNode); 834 : super(startingNode);
836 835
837 @override 836 @override
838 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { 837 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) {
839 return node.gatherInputs(taskManager, skipInputs); 838 return node.gatherInputs(taskManager, skipInputs);
840 } 839 }
841 } 840 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698