| 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.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' as math; | 8 import 'dart:math' as math; |
| 9 | 9 |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| 11 import 'package:analyzer/src/generated/ast.dart'; | 11 import 'package:analyzer/src/generated/ast.dart'; |
| 12 import 'package:analyzer/src/generated/constant.dart'; | 12 import 'package:analyzer/src/generated/constant.dart'; |
| 13 import 'package:analyzer/src/generated/element.dart'; | 13 import 'package:analyzer/src/generated/element.dart'; |
| 14 import 'package:analyzer/src/generated/engine.dart' | 14 import 'package:analyzer/src/generated/engine.dart' |
| 15 hide AnalysisCache, AnalysisTask; | 15 hide AnalysisCache, AnalysisTask; |
| 16 import 'package:analyzer/src/generated/error.dart'; | 16 import 'package:analyzer/src/generated/error.dart'; |
| 17 import 'package:analyzer/src/generated/error_verifier.dart'; | 17 import 'package:analyzer/src/generated/error_verifier.dart'; |
| 18 import 'package:analyzer/src/generated/java_engine.dart'; | 18 import 'package:analyzer/src/generated/java_engine.dart'; |
| 19 import 'package:analyzer/src/generated/parser.dart'; | 19 import 'package:analyzer/src/generated/parser.dart'; |
| 20 import 'package:analyzer/src/generated/resolver.dart'; | 20 import 'package:analyzer/src/generated/resolver.dart'; |
| 21 import 'package:analyzer/src/generated/scanner.dart'; | 21 import 'package:analyzer/src/generated/scanner.dart'; |
| 22 import 'package:analyzer/src/generated/sdk.dart'; | 22 import 'package:analyzer/src/generated/sdk.dart'; |
| 23 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 24 import 'package:analyzer/src/task/driver.dart'; | 24 import 'package:analyzer/src/task/driver.dart'; |
| 25 import 'package:analyzer/src/task/general.dart'; | 25 import 'package:analyzer/src/task/general.dart'; |
| 26 import 'package:analyzer/src/task/inputs.dart'; |
| 26 import 'package:analyzer/src/task/model.dart'; | 27 import 'package:analyzer/src/task/model.dart'; |
| 27 import 'package:analyzer/task/dart.dart'; | 28 import 'package:analyzer/task/dart.dart'; |
| 28 import 'package:analyzer/task/general.dart'; | 29 import 'package:analyzer/task/general.dart'; |
| 29 import 'package:analyzer/task/model.dart'; | 30 import 'package:analyzer/task/model.dart'; |
| 30 | 31 |
| 31 /** | 32 /** |
| 32 * The [ResultCachingPolicy] for ASTs. | 33 * The [ResultCachingPolicy] for ASTs. |
| 33 */ | 34 */ |
| 34 const ResultCachingPolicy AST_CACHING_POLICY = | 35 const ResultCachingPolicy AST_CACHING_POLICY = |
| 35 const SimpleResultCachingPolicy(8192, 8192); | 36 const SimpleResultCachingPolicy(8192, 8192); |
| (...skipping 2508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2544 */ | 2545 */ |
| 2545 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = | 2546 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = |
| 2546 'RESOLVE_TYPE_NAMES_ERRORS'; | 2547 'RESOLVE_TYPE_NAMES_ERRORS'; |
| 2547 | 2548 |
| 2548 /** | 2549 /** |
| 2549 * The name of the [VERIFY_ERRORS] input. | 2550 * The name of the [VERIFY_ERRORS] input. |
| 2550 */ | 2551 */ |
| 2551 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; | 2552 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS'; |
| 2552 | 2553 |
| 2553 /** | 2554 /** |
| 2555 * The name of the [CONSTRUCTORS_ERRORS] input. |
| 2556 */ |
| 2557 static const String CONSTRUCTORS_ERRORS_INPUT = 'CONSTRUCTORS_ERRORS'; |
| 2558 |
| 2559 /** |
| 2554 * The task descriptor describing this kind of task. | 2560 * The task descriptor describing this kind of task. |
| 2555 */ | 2561 */ |
| 2556 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2562 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2557 'LibraryUnitErrorsTask', createTask, buildInputs, | 2563 'LibraryUnitErrorsTask', createTask, buildInputs, |
| 2558 <ResultDescriptor>[LIBRARY_UNIT_ERRORS]); | 2564 <ResultDescriptor>[LIBRARY_UNIT_ERRORS]); |
| 2559 | 2565 |
| 2560 LibraryUnitErrorsTask(InternalAnalysisContext context, AnalysisTarget target) | 2566 LibraryUnitErrorsTask(InternalAnalysisContext context, AnalysisTarget target) |
| 2561 : super(context, target); | 2567 : super(context, target); |
| 2562 | 2568 |
| 2563 @override | 2569 @override |
| 2564 TaskDescriptor get descriptor => DESCRIPTOR; | 2570 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2565 | 2571 |
| 2566 @override | 2572 @override |
| 2567 void internalPerform() { | 2573 void internalPerform() { |
| 2568 // | 2574 // |
| 2569 // Prepare inputs. | 2575 // Prepare inputs. |
| 2570 // | 2576 // |
| 2571 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; | 2577 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; |
| 2572 errorLists.add(getRequiredInput(BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT)); | 2578 errorLists.add(getRequiredInput(BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT)); |
| 2579 errorLists.addAll(getRequiredInput(CONSTRUCTORS_ERRORS_INPUT)); |
| 2573 errorLists.add(getRequiredInput(HINTS_INPUT)); | 2580 errorLists.add(getRequiredInput(HINTS_INPUT)); |
| 2574 errorLists.add(getRequiredInput(RESOLVE_REFERENCES_ERRORS_INPUT)); | 2581 errorLists.add(getRequiredInput(RESOLVE_REFERENCES_ERRORS_INPUT)); |
| 2575 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); | 2582 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); |
| 2576 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); | 2583 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); |
| 2577 // | 2584 // |
| 2578 // Record outputs. | 2585 // Record outputs. |
| 2579 // | 2586 // |
| 2580 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); | 2587 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); |
| 2581 } | 2588 } |
| 2582 | 2589 |
| 2583 /** | 2590 /** |
| 2584 * Return a map from the names of the inputs of this kind of task to the task | 2591 * Return a map from the names of the inputs of this kind of task to the task |
| 2585 * input descriptors describing those inputs for a task with the | 2592 * input descriptors describing those inputs for a task with the |
| 2586 * given [unit]. | 2593 * given [unit]. |
| 2587 */ | 2594 */ |
| 2588 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit unit) { | 2595 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit unit) { |
| 2589 return <String, TaskInput>{ | 2596 return <String, TaskInput>{ |
| 2590 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT: | 2597 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT: |
| 2591 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit), | 2598 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit), |
| 2599 CONSTRUCTORS_ERRORS_INPUT: COMPILATION_UNIT_ELEMENT |
| 2600 .of(unit) |
| 2601 .mappedToList((CompilationUnitElement element) => element.types) |
| 2602 .toListOf(CONSTRUCTORS_ERRORS), |
| 2592 HINTS_INPUT: HINTS.of(unit), | 2603 HINTS_INPUT: HINTS.of(unit), |
| 2593 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit), | 2604 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit), |
| 2594 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), | 2605 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), |
| 2595 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) | 2606 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) |
| 2596 }; | 2607 }; |
| 2597 } | 2608 } |
| 2598 | 2609 |
| 2599 /** | 2610 /** |
| 2600 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given | 2611 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given |
| 2601 * [context]. | 2612 * [context]. |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3314 static VerifyUnitTask createTask( | 3325 static VerifyUnitTask createTask( |
| 3315 AnalysisContext context, AnalysisTarget target) { | 3326 AnalysisContext context, AnalysisTarget target) { |
| 3316 return new VerifyUnitTask(context, target); | 3327 return new VerifyUnitTask(context, target); |
| 3317 } | 3328 } |
| 3318 } | 3329 } |
| 3319 | 3330 |
| 3320 /** | 3331 /** |
| 3321 * A [TaskInput] whose value is a list of library sources exported directly | 3332 * A [TaskInput] whose value is a list of library sources exported directly |
| 3322 * or indirectly by the target [Source]. | 3333 * or indirectly by the target [Source]. |
| 3323 */ | 3334 */ |
| 3324 class _ExportSourceClosureTaskInput implements TaskInput<List<Source>> { | 3335 class _ExportSourceClosureTaskInput extends TaskInputImpl<List<Source>> { |
| 3325 final Source target; | 3336 final Source target; |
| 3326 | 3337 |
| 3327 _ExportSourceClosureTaskInput(this.target); | 3338 _ExportSourceClosureTaskInput(this.target); |
| 3328 | 3339 |
| 3329 @override | 3340 @override |
| 3330 TaskInputBuilder<List<Source>> createBuilder() => | 3341 TaskInputBuilder<List<Source>> createBuilder() => |
| 3331 new _SourceClosureTaskInputBuilder(target, _SourceClosureKind.EXPORT); | 3342 new _SourceClosureTaskInputBuilder(target, _SourceClosureKind.EXPORT); |
| 3332 } | 3343 } |
| 3333 | 3344 |
| 3334 /** | 3345 /** |
| 3335 * A [TaskInput] whose value is a list of library sources imported or exported, | 3346 * A [TaskInput] whose value is a list of library sources imported or exported, |
| 3336 * directly or indirectly by the target [Source]. | 3347 * directly or indirectly by the target [Source]. |
| 3337 */ | 3348 */ |
| 3338 class _ImportExportSourceClosureTaskInput implements TaskInput<List<Source>> { | 3349 class _ImportExportSourceClosureTaskInput extends TaskInputImpl<List<Source>> { |
| 3339 final Source target; | 3350 final Source target; |
| 3340 | 3351 |
| 3341 _ImportExportSourceClosureTaskInput(this.target); | 3352 _ImportExportSourceClosureTaskInput(this.target); |
| 3342 | 3353 |
| 3343 @override | 3354 @override |
| 3344 TaskInputBuilder<List<Source>> createBuilder() => | 3355 TaskInputBuilder<List<Source>> createBuilder() => |
| 3345 new _SourceClosureTaskInputBuilder( | 3356 new _SourceClosureTaskInputBuilder( |
| 3346 target, _SourceClosureKind.IMPORT_EXPORT); | 3357 target, _SourceClosureKind.IMPORT_EXPORT); |
| 3347 } | 3358 } |
| 3348 | 3359 |
| 3349 /** | 3360 /** |
| 3350 * A [TaskInput] whose value is a list of library sources imported directly | 3361 * A [TaskInput] whose value is a list of library sources imported directly |
| 3351 * or indirectly by the target [Source]. | 3362 * or indirectly by the target [Source]. |
| 3352 */ | 3363 */ |
| 3353 class _ImportSourceClosureTaskInput implements TaskInput<List<Source>> { | 3364 class _ImportSourceClosureTaskInput extends TaskInputImpl<List<Source>> { |
| 3354 final Source target; | 3365 final Source target; |
| 3355 | 3366 |
| 3356 _ImportSourceClosureTaskInput(this.target); | 3367 _ImportSourceClosureTaskInput(this.target); |
| 3357 | 3368 |
| 3358 @override | 3369 @override |
| 3359 TaskInputBuilder<List<Source>> createBuilder() => | 3370 TaskInputBuilder<List<Source>> createBuilder() => |
| 3360 new _SourceClosureTaskInputBuilder(target, _SourceClosureKind.IMPORT); | 3371 new _SourceClosureTaskInputBuilder(target, _SourceClosureKind.IMPORT); |
| 3361 } | 3372 } |
| 3362 | 3373 |
| 3363 /** | 3374 /** |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3417 @override | 3428 @override |
| 3418 bool moveNext() { | 3429 bool moveNext() { |
| 3419 if (_newSources.isEmpty) { | 3430 if (_newSources.isEmpty) { |
| 3420 return false; | 3431 return false; |
| 3421 } | 3432 } |
| 3422 currentTarget = _newSources.first; | 3433 currentTarget = _newSources.first; |
| 3423 _newSources.remove(currentTarget); | 3434 _newSources.remove(currentTarget); |
| 3424 return true; | 3435 return true; |
| 3425 } | 3436 } |
| 3426 } | 3437 } |
| OLD | NEW |