Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/generated/engine.dart' hide AnalysisTask; | 11 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 12 import 'package:analyzer/src/generated/java_engine.dart'; | 12 import 'package:analyzer/src/generated/java_engine.dart'; |
| 13 import 'package:analyzer/src/generated/resolver.dart'; | |
| 13 import 'package:analyzer/src/task/inputs.dart'; | 14 import 'package:analyzer/src/task/inputs.dart'; |
| 14 import 'package:analyzer/src/task/manager.dart'; | 15 import 'package:analyzer/src/task/manager.dart'; |
| 15 import 'package:analyzer/task/model.dart'; | 16 import 'package:analyzer/task/model.dart'; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * An object that is used to cause analysis to be performed until all of the | 19 * An object that is used to cause analysis to be performed until all of the |
| 19 * required analysis information has been computed. | 20 * required analysis information has been computed. |
| 20 */ | 21 */ |
| 21 class AnalysisDriver { | 22 class AnalysisDriver { |
| 22 /** | 23 /** |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 } | 227 } |
| 227 } | 228 } |
| 228 | 229 |
| 229 /** | 230 /** |
| 230 * A place to define the behaviors that need to be added to | 231 * A place to define the behaviors that need to be added to |
| 231 * [InternalAnalysisContext]. | 232 * [InternalAnalysisContext]. |
| 232 */ | 233 */ |
| 233 abstract class ExtendedAnalysisContext implements InternalAnalysisContext { | 234 abstract class ExtendedAnalysisContext implements InternalAnalysisContext { |
| 234 List<AnalysisTarget> get explicitTargets; | 235 List<AnalysisTarget> get explicitTargets; |
| 235 List<AnalysisTarget> get priorityTargets; | 236 List<AnalysisTarget> get priorityTargets; |
| 237 void set typeProvider(TypeProvider typeProvider); | |
| 236 CacheEntry getCacheEntry(AnalysisTarget target); | 238 CacheEntry getCacheEntry(AnalysisTarget target); |
| 237 } | 239 } |
| 238 | 240 |
| 239 /** | 241 /** |
| 240 * A description of a single anaysis task that can be performed to advance | 242 * A description of a single anaysis task that can be performed to advance |
| 241 * analysis. | 243 * analysis. |
| 242 */ | 244 */ |
| 243 class WorkItem { | 245 class WorkItem { |
| 244 /** | 246 /** |
| 245 * The context in which the task will be performed. | 247 * The context in which the task will be performed. |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 274 * results that this task would have computed need to be marked as being in | 276 * results that this task would have computed need to be marked as being in |
| 275 * ERROR with this exception. | 277 * ERROR with this exception. |
| 276 */ | 278 */ |
| 277 CaughtException exception = null; | 279 CaughtException exception = null; |
| 278 | 280 |
| 279 /** | 281 /** |
| 280 * Initialize a newly created work item to compute the inputs for the task | 282 * Initialize a newly created work item to compute the inputs for the task |
| 281 * described by the given descriptor. | 283 * described by the given descriptor. |
| 282 */ | 284 */ |
| 283 WorkItem(this.context, this.target, this.descriptor) { | 285 WorkItem(this.context, this.target, this.descriptor) { |
| 286 AnalysisTarget actualTarget = identical( | |
| 287 target, AnalysisContextTarget.request) | |
| 288 ? new AnalysisContextTarget(context) | |
| 289 : target; | |
| 284 Map<String, TaskInput> inputDescriptors = | 290 Map<String, TaskInput> inputDescriptors = |
| 285 descriptor.createTaskInputs(target); | 291 descriptor.createTaskInputs(actualTarget); |
| 286 builder = new TopLevelTaskInputBuilder(inputDescriptors); | 292 builder = new TopLevelTaskInputBuilder(inputDescriptors); |
| 287 if (!builder.moveNext()) { | 293 if (!builder.moveNext()) { |
| 288 builder = null; | 294 builder = null; |
| 289 } | 295 } |
| 290 inputs = new HashMap<String, dynamic>(); | 296 inputs = new HashMap<String, dynamic>(); |
| 291 } | 297 } |
| 292 | 298 |
| 293 /** | 299 /** |
| 294 * Build the task represented by this work item. | 300 * Build the task represented by this work item. |
| 295 */ | 301 */ |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 319 WorkItem gatherInputs(TaskManager taskManager) { | 325 WorkItem gatherInputs(TaskManager taskManager) { |
| 320 while (builder != null) { | 326 while (builder != null) { |
| 321 // | 327 // |
| 322 // TODO(brianwilkerson) Capture information about which inputs were used | 328 // TODO(brianwilkerson) Capture information about which inputs were used |
| 323 // to compute the results. This information can later be used to compute | 329 // to compute the results. This information can later be used to compute |
| 324 // which results depend on a given result, and hence which results need to | 330 // which results depend on a given result, and hence which results need to |
| 325 // be invalidated when one result is invalidated. | 331 // be invalidated when one result is invalidated. |
| 326 // | 332 // |
| 327 AnalysisTarget inputTarget = builder.currentTarget; | 333 AnalysisTarget inputTarget = builder.currentTarget; |
| 328 ResultDescriptor inputResult = builder.currentResult; | 334 ResultDescriptor inputResult = builder.currentResult; |
| 329 CacheEntry inputEntry = context.getCacheEntry(inputTarget); | 335 CacheEntry inputEntry = context.getCacheEntry(inputTarget); |
|
Brian Wilkerson
2015/03/14 03:03:18
I was expecting some "magic" to happen here. Perha
| |
| 330 CacheState inputState = inputEntry.getState(inputResult); | 336 CacheState inputState = inputEntry.getState(inputResult); |
| 331 if (inputState == CacheState.ERROR) { | 337 if (inputState == CacheState.ERROR) { |
| 332 exception = inputEntry.exception; | 338 exception = inputEntry.exception; |
| 333 return null; | 339 return null; |
| 334 } else if (inputState == CacheState.IN_PROCESS) { | 340 } else if (inputState == CacheState.IN_PROCESS) { |
| 335 // | 341 // |
| 336 // TODO(brianwilkerson) Implement this case. | 342 // TODO(brianwilkerson) Implement this case. |
| 337 // | 343 // |
| 338 // One possibility would be to return a WorkItem that would perform a | 344 // One possibility would be to return a WorkItem that would perform a |
| 339 // no-op task in order to cause us to come back to this work item on the | 345 // no-op task in order to cause us to come back to this work item on the |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 currentItem = pendingItems.removeLast(); | 411 currentItem = pendingItems.removeLast(); |
| 406 WorkItem childItem = currentItem.gatherInputs(taskManager); | 412 WorkItem childItem = currentItem.gatherInputs(taskManager); |
| 407 while (childItem != null) { | 413 while (childItem != null) { |
| 408 pendingItems.add(currentItem); | 414 pendingItems.add(currentItem); |
| 409 currentItem = childItem; | 415 currentItem = childItem; |
| 410 childItem = currentItem.gatherInputs(taskManager); | 416 childItem = currentItem.gatherInputs(taskManager); |
| 411 } | 417 } |
| 412 return true; | 418 return true; |
| 413 } | 419 } |
| 414 } | 420 } |
| OLD | NEW |