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

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

Issue 1181603004: Add AnalysisContext.onResultComputed(). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rename ResultComputedEvent -> ComputedResult. Created 5 years, 6 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
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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';
11 import 'package:analyzer/src/context/context.dart' show ResultComputedEvent;
12 import 'package:analyzer/src/generated/engine.dart' 11 import 'package:analyzer/src/generated/engine.dart'
13 hide AnalysisTask, AnalysisContextImpl; 12 hide AnalysisTask, AnalysisContextImpl;
14 import 'package:analyzer/src/generated/java_engine.dart'; 13 import 'package:analyzer/src/generated/java_engine.dart';
15 import 'package:analyzer/src/generated/resolver.dart'; 14 import 'package:analyzer/src/generated/resolver.dart';
16 import 'package:analyzer/src/generated/utilities_general.dart'; 15 import 'package:analyzer/src/generated/utilities_general.dart';
17 import 'package:analyzer/src/task/inputs.dart'; 16 import 'package:analyzer/src/task/inputs.dart';
18 import 'package:analyzer/src/task/manager.dart'; 17 import 'package:analyzer/src/task/manager.dart';
19 import 'package:analyzer/task/model.dart'; 18 import 'package:analyzer/task/model.dart';
20 19
21 final PerformanceTag workOrderMoveNextPerfTag = 20 final PerformanceTag workOrderMoveNextPerfTag =
(...skipping 14 matching lines...) Expand all
36 * compute. 35 * compute.
37 */ 36 */
38 final List<WorkManager> workManagers; 37 final List<WorkManager> workManagers;
39 38
40 /** 39 /**
41 * The context in which analysis is to be performed. 40 * The context in which analysis is to be performed.
42 */ 41 */
43 final InternalAnalysisContext context; 42 final InternalAnalysisContext context;
44 43
45 /** 44 /**
46 * The map of [ResultComputedEvent] controllers. 45 * The map of [ComputedResult] controllers.
47 */ 46 */
48 final Map<ResultDescriptor, StreamController<ResultComputedEvent>> resultCompu tedControllers = 47 final Map<ResultDescriptor, StreamController<ComputedResult>> resultComputedCo ntrollers =
49 <ResultDescriptor, StreamController<ResultComputedEvent>>{}; 48 <ResultDescriptor, StreamController<ComputedResult>>{};
50 49
51 /** 50 /**
52 * The work order that was previously computed but that has not yet been 51 * The work order that was previously computed but that has not yet been
53 * completed. 52 * completed.
54 */ 53 */
55 WorkOrder currentWorkOrder; 54 WorkOrder currentWorkOrder;
56 55
57 /** 56 /**
58 * Indicates whether any tasks are currently being performed (or building 57 * Indicates whether any tasks are currently being performed (or building
59 * their inputs). In debug builds, we use this to ensure that tasks don't 58 * their inputs). In debug builds, we use this to ensure that tasks don't
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 189 }
191 } 190 }
192 } 191 }
193 return null; 192 return null;
194 } 193 }
195 194
196 /** 195 /**
197 * Return the stream that is notified when a new value for the given 196 * Return the stream that is notified when a new value for the given
198 * [descriptor] is computed. 197 * [descriptor] is computed.
199 */ 198 */
200 Stream<ResultComputedEvent> onResultComputed(ResultDescriptor descriptor) { 199 Stream<ComputedResult> onResultComputed(ResultDescriptor descriptor) {
201 return resultComputedControllers.putIfAbsent(descriptor, () => 200 return resultComputedControllers.putIfAbsent(descriptor, () =>
202 new StreamController<ResultComputedEvent>.broadcast(sync: true)).stream; 201 new StreamController<ComputedResult>.broadcast(sync: true)).stream;
203 } 202 }
204 203
205 /** 204 /**
206 * Perform the next analysis task, and return `true` if there is more work to 205 * Perform the next analysis task, and return `true` if there is more work to
207 * be done in order to compute all of the required analysis information. 206 * be done in order to compute all of the required analysis information.
208 */ 207 */
209 bool performAnalysisTask() { 208 bool performAnalysisTask() {
210 // 209 //
211 // TODO(brianwilkerson) This implementaiton does not allow us to prioritize 210 // TODO(brianwilkerson) This implementaiton does not allow us to prioritize
212 // work across contexts. What we need is a way for an external client to ask 211 // work across contexts. What we need is a way for an external client to ask
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 CacheEntry entry = context.getCacheEntry(target); 262 CacheEntry entry = context.getCacheEntry(target);
264 if (task.caughtException == null) { 263 if (task.caughtException == null) {
265 List<TargetedResult> dependedOn = item.inputTargetedResults.toList(); 264 List<TargetedResult> dependedOn = item.inputTargetedResults.toList();
266 Map<ResultDescriptor, dynamic> outputs = task.outputs; 265 Map<ResultDescriptor, dynamic> outputs = task.outputs;
267 for (ResultDescriptor result in task.descriptor.results) { 266 for (ResultDescriptor result in task.descriptor.results) {
268 // TODO(brianwilkerson) We could check here that a value was produced 267 // TODO(brianwilkerson) We could check here that a value was produced
269 // and throw an exception if not (unless we want to allow null values). 268 // and throw an exception if not (unless we want to allow null values).
270 entry.setValue(result, outputs[result], dependedOn); 269 entry.setValue(result, outputs[result], dependedOn);
271 } 270 }
272 outputs.forEach((ResultDescriptor descriptor, value) { 271 outputs.forEach((ResultDescriptor descriptor, value) {
273 StreamController<ResultComputedEvent> controller = 272 StreamController<ComputedResult> controller =
274 resultComputedControllers[descriptor]; 273 resultComputedControllers[descriptor];
275 if (controller != null) { 274 if (controller != null) {
276 ResultComputedEvent event = 275 ComputedResult event =
277 new ResultComputedEvent(context, descriptor, target, value); 276 new ComputedResult(context, descriptor, target, value);
278 controller.add(event); 277 controller.add(event);
279 } 278 }
280 }); 279 });
281 for (WorkManager manager in workManagers) { 280 for (WorkManager manager in workManagers) {
282 manager.resultsComputed(target, outputs); 281 manager.resultsComputed(target, outputs);
283 } 282 }
284 } else { 283 } else {
285 entry.setErrorState(task.caughtException, item.descriptor.results); 284 entry.setErrorState(task.caughtException, item.descriptor.results);
286 } 285 }
287 _onTaskCompletedController.add(task); 286 _onTaskCompletedController.add(task);
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 final TaskManager taskManager; 808 final TaskManager taskManager;
810 809
811 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode) 810 _WorkOrderDependencyWalker(this.taskManager, WorkItem startingNode)
812 : super(startingNode); 811 : super(startingNode);
813 812
814 @override 813 @override
815 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) { 814 WorkItem getNextInput(WorkItem node, List<WorkItem> skipInputs) {
816 return node.gatherInputs(taskManager, skipInputs); 815 return node.gatherInputs(taskManager, skipInputs);
817 } 816 }
818 } 817 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698