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.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
| 24 import 'package:analyzer/src/generated/visitors.dart'; | 24 import 'package:analyzer/src/generated/visitors.dart'; |
| 25 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 25 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
| 26 import 'package:analyzer/src/services/lint.dart'; | 26 import 'package:analyzer/src/services/lint.dart'; |
| 27 import 'package:analyzer/src/task/driver.dart'; | 27 import 'package:analyzer/src/task/driver.dart'; |
| 28 import 'package:analyzer/src/task/general.dart'; | 28 import 'package:analyzer/src/task/general.dart'; |
| 29 import 'package:analyzer/src/task/html.dart'; | 29 import 'package:analyzer/src/task/html.dart'; |
| 30 import 'package:analyzer/src/task/inputs.dart'; | 30 import 'package:analyzer/src/task/inputs.dart'; |
| 31 import 'package:analyzer/src/task/model.dart'; | 31 import 'package:analyzer/src/task/model.dart'; |
| 32 import 'package:analyzer/src/task/strong_mode.dart'; | 32 import 'package:analyzer/src/task/strong_mode.dart'; |
| 33 import 'package:analyzer/src/task/strong/checker.dart'; | |
| 34 import 'package:analyzer/src/task/strong/rules.dart'; | |
| 33 import 'package:analyzer/task/dart.dart'; | 35 import 'package:analyzer/task/dart.dart'; |
| 34 import 'package:analyzer/task/general.dart'; | 36 import 'package:analyzer/task/general.dart'; |
| 35 import 'package:analyzer/task/model.dart'; | 37 import 'package:analyzer/task/model.dart'; |
| 36 | 38 |
| 37 /** | 39 /** |
| 38 * The [ResultCachingPolicy] for ASTs. | 40 * The [ResultCachingPolicy] for ASTs. |
| 39 */ | 41 */ |
| 40 const ResultCachingPolicy AST_CACHING_POLICY = | 42 const ResultCachingPolicy AST_CACHING_POLICY = |
| 41 const SimpleResultCachingPolicy(8192, 8192); | 43 const SimpleResultCachingPolicy(8192, 8192); |
| 42 | 44 |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 * The resolved [CompilationUnit] associated with a compilation unit, with | 456 * The resolved [CompilationUnit] associated with a compilation unit, with |
| 455 * constants not yet resolved. | 457 * constants not yet resolved. |
| 456 * | 458 * |
| 457 * The result is only available for [LibrarySpecificUnit]s. | 459 * The result is only available for [LibrarySpecificUnit]s. |
| 458 */ | 460 */ |
| 459 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT9 = | 461 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT9 = |
| 460 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT9', null, | 462 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT9', null, |
| 461 cachingPolicy: AST_CACHING_POLICY); | 463 cachingPolicy: AST_CACHING_POLICY); |
| 462 | 464 |
| 463 /** | 465 /** |
| 466 * The resolved [CompilationUnit] associated with a compilation unit, with | |
| 467 * constants resolved. | |
| 468 * | |
| 469 * The result is only available for [LibrarySpecificUnit]s. | |
| 470 */ | |
| 471 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT10 = | |
| 472 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT10', null, | |
| 473 cachingPolicy: AST_CACHING_POLICY); | |
| 474 | |
| 475 /** | |
| 464 * The errors produced while scanning a compilation unit. | 476 * The errors produced while scanning a compilation unit. |
| 465 * | 477 * |
| 466 * The list will be empty if there were no errors, but will not be `null`. | 478 * The list will be empty if there were no errors, but will not be `null`. |
| 467 * | 479 * |
| 468 * The result is only available for [Source]s representing a compilation unit. | 480 * The result is only available for [Source]s representing a compilation unit. |
| 469 */ | 481 */ |
| 470 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = | 482 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = |
| 471 new ListResultDescriptor<AnalysisError>( | 483 new ListResultDescriptor<AnalysisError>( |
| 472 'SCAN_ERRORS', AnalysisError.NO_ERRORS); | 484 'SCAN_ERRORS', AnalysisError.NO_ERRORS); |
| 473 | 485 |
| 474 /** | 486 /** |
| 487 * The additional strong mode errors produced while scanning a compilation unit. | |
|
scheglov
2015/10/13 15:21:20
Probably not "scanning".
Leaf
2015/10/13 16:46:27
Done.
| |
| 488 * | |
| 489 * The list will be empty if there were no errors, but will not be `null`. | |
| 490 * | |
| 491 * The result is only available for [Source]s representing a compilation unit. | |
|
Brian Wilkerson
2015/10/13 14:21:19
"Source" --> "LibrarySpecificUnit"
Leaf
2015/10/13 16:46:27
Done.
| |
| 492 * | |
| 493 */ | |
| 494 final ListResultDescriptor<AnalysisError> STRONG_MODE_ERRORS = | |
| 495 new ListResultDescriptor<AnalysisError>( | |
| 496 'STRONG_MODE_ERRORS', AnalysisError.NO_ERRORS); | |
| 497 | |
| 498 /** | |
| 475 * The [TypeProvider] of the [AnalysisContext]. | 499 * The [TypeProvider] of the [AnalysisContext]. |
| 476 */ | 500 */ |
| 477 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = | 501 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = |
| 478 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); | 502 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); |
| 479 | 503 |
| 480 /** | 504 /** |
| 481 * The [UsedImportedElements] of a [LibrarySpecificUnit]. | 505 * The [UsedImportedElements] of a [LibrarySpecificUnit]. |
| 482 */ | 506 */ |
| 483 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS = | 507 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS = |
| 484 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null, | 508 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null, |
| (...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2102 * Create a [DartErrorsTask] based on the given [target] in the given | 2126 * Create a [DartErrorsTask] based on the given [target] in the given |
| 2103 * [context]. | 2127 * [context]. |
| 2104 */ | 2128 */ |
| 2105 static DartErrorsTask createTask( | 2129 static DartErrorsTask createTask( |
| 2106 AnalysisContext context, AnalysisTarget target) { | 2130 AnalysisContext context, AnalysisTarget target) { |
| 2107 return new DartErrorsTask(context, target); | 2131 return new DartErrorsTask(context, target); |
| 2108 } | 2132 } |
| 2109 } | 2133 } |
| 2110 | 2134 |
| 2111 /** | 2135 /** |
| 2112 * A task that builds [RESOLVED_UNIT] for a unit. | 2136 * A task that builds [RESOLVED_UNIT10] for a unit. |
| 2113 */ | 2137 */ |
| 2114 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { | 2138 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { |
| 2115 /** | 2139 /** |
| 2116 * The name of the [RESOLVED_UNIT9] input. | 2140 * The name of the [RESOLVED_UNIT9] input. |
| 2117 */ | 2141 */ |
| 2118 static const String UNIT_INPUT = 'UNIT_INPUT'; | 2142 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 2119 | 2143 |
| 2120 /** | 2144 /** |
| 2121 * The name of the [CONSTANT_VALUE] input. | 2145 * The name of the [CONSTANT_VALUE] input. |
| 2122 */ | 2146 */ |
| 2123 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; | 2147 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; |
| 2124 | 2148 |
| 2125 /** | 2149 /** |
| 2126 * The task descriptor describing this kind of task. | 2150 * The task descriptor describing this kind of task. |
| 2127 */ | 2151 */ |
| 2128 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2152 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2129 'EvaluateUnitConstantsTask', | 2153 'EvaluateUnitConstantsTask', |
| 2130 createTask, | 2154 createTask, |
| 2131 buildInputs, | 2155 buildInputs, |
| 2132 <ResultDescriptor>[RESOLVED_UNIT]); | 2156 <ResultDescriptor>[RESOLVED_UNIT10]); |
| 2133 | 2157 |
| 2134 EvaluateUnitConstantsTask(AnalysisContext context, LibrarySpecificUnit target) | 2158 EvaluateUnitConstantsTask(AnalysisContext context, LibrarySpecificUnit target) |
| 2135 : super(context, target); | 2159 : super(context, target); |
| 2136 | 2160 |
| 2137 @override | 2161 @override |
| 2138 TaskDescriptor get descriptor => DESCRIPTOR; | 2162 TaskDescriptor get descriptor => DESCRIPTOR; |
| 2139 | 2163 |
| 2140 @override | 2164 @override |
| 2141 void internalPerform() { | 2165 void internalPerform() { |
| 2142 // No actual work needs to be performed; the task manager will ensure that | 2166 // No actual work needs to be performed; the task manager will ensure that |
| 2143 // all constants are evaluated before this method is called. | 2167 // all constants are evaluated before this method is called. |
| 2144 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 2168 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 2145 outputs[RESOLVED_UNIT] = unit; | 2169 outputs[RESOLVED_UNIT10] = unit; |
| 2146 } | 2170 } |
| 2147 | 2171 |
| 2148 /** | 2172 /** |
| 2149 * Return a map from the names of the inputs of this kind of task to the task | 2173 * Return a map from the names of the inputs of this kind of task to the task |
| 2150 * input descriptors describing those inputs for a task with the | 2174 * input descriptors describing those inputs for a task with the |
| 2151 * given [target]. | 2175 * given [target]. |
| 2152 */ | 2176 */ |
| 2153 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 2177 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 2154 LibrarySpecificUnit unit = target; | 2178 LibrarySpecificUnit unit = target; |
| 2155 return <String, TaskInput>{ | 2179 return <String, TaskInput>{ |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2528 AnalysisContext context, AnalysisTarget target) { | 2552 AnalysisContext context, AnalysisTarget target) { |
| 2529 return new GenerateHintsTask(context, target); | 2553 return new GenerateHintsTask(context, target); |
| 2530 } | 2554 } |
| 2531 } | 2555 } |
| 2532 | 2556 |
| 2533 /** | 2557 /** |
| 2534 * A task that generates [LINTS] for a unit. | 2558 * A task that generates [LINTS] for a unit. |
| 2535 */ | 2559 */ |
| 2536 class GenerateLintsTask extends SourceBasedAnalysisTask { | 2560 class GenerateLintsTask extends SourceBasedAnalysisTask { |
| 2537 /** | 2561 /** |
| 2538 * The name of the [RESOLVED_UNIT8] input. | 2562 * The name of the [RESOLVED_UNIT] input. |
| 2539 */ | 2563 */ |
| 2540 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; | 2564 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; |
| 2541 | 2565 |
| 2542 /** | 2566 /** |
| 2543 * The task descriptor describing this kind of task. | 2567 * The task descriptor describing this kind of task. |
| 2544 */ | 2568 */ |
| 2545 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 2569 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 2546 'GenerateLintsTask', createTask, buildInputs, <ResultDescriptor>[LINTS]); | 2570 'GenerateLintsTask', createTask, buildInputs, <ResultDescriptor>[LINTS]); |
| 2547 | 2571 |
| 2548 GenerateLintsTask(InternalAnalysisContext context, AnalysisTarget target) | 2572 GenerateLintsTask(InternalAnalysisContext context, AnalysisTarget target) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 2567 // | 2591 // |
| 2568 // Prepare inputs. | 2592 // Prepare inputs. |
| 2569 // | 2593 // |
| 2570 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT); | 2594 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT); |
| 2571 | 2595 |
| 2572 // | 2596 // |
| 2573 // Generate lints. | 2597 // Generate lints. |
| 2574 // | 2598 // |
| 2575 List<Linter> linters = lintRegistry[context] ?? []; | 2599 List<Linter> linters = lintRegistry[context] ?? []; |
| 2576 linters.forEach((l) => l.reporter = errorReporter); | 2600 linters.forEach((l) => l.reporter = errorReporter); |
| 2577 Iterable<AstVisitor> visitors = | 2601 Iterable<AstVisitor> visitors = linters.map((l) => l.getVisitor()).toList(); |
|
Jennifer Messerly
2015/10/13 15:23:52
it didn't look like you actually changed this besi
| |
| 2578 linters.map((l) => l.getVisitor()).toList(); | |
| 2579 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); | 2602 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); |
| 2580 | 2603 |
| 2581 // | 2604 // |
| 2582 // Record outputs. | 2605 // Record outputs. |
| 2583 // | 2606 // |
| 2584 outputs[LINTS] = errorListener.errors; | 2607 outputs[LINTS] = errorListener.errors; |
| 2585 } | 2608 } |
| 2586 | 2609 |
| 2587 /** | 2610 /** |
| 2588 * Return a map from the names of the inputs of this kind of task to the task | 2611 * Return a map from the names of the inputs of this kind of task to the task |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3117 * The name of the [HINTS] input. | 3140 * The name of the [HINTS] input. |
| 3118 */ | 3141 */ |
| 3119 static const String HINTS_INPUT = 'HINTS'; | 3142 static const String HINTS_INPUT = 'HINTS'; |
| 3120 | 3143 |
| 3121 /** | 3144 /** |
| 3122 * The name of the [LINTS] input. | 3145 * The name of the [LINTS] input. |
| 3123 */ | 3146 */ |
| 3124 static const String LINTS_INPUT = 'LINTS'; | 3147 static const String LINTS_INPUT = 'LINTS'; |
| 3125 | 3148 |
| 3126 /** | 3149 /** |
| 3150 * The name of the [STRONG_MODE_ERRORS] input. | |
| 3151 */ | |
| 3152 static const String STRONG_MODE_ERRORS_INPUT = 'STRONG_MODE_ERRORS'; | |
| 3153 | |
| 3154 /** | |
| 3127 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. | 3155 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. |
| 3128 */ | 3156 */ |
| 3129 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = | 3157 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = |
| 3130 'RESOLVE_TYPE_NAMES_ERRORS'; | 3158 'RESOLVE_TYPE_NAMES_ERRORS'; |
| 3131 | 3159 |
| 3132 /** | 3160 /** |
| 3133 * The name of the [RESOLVE_UNIT_ERRORS] input. | 3161 * The name of the [RESOLVE_UNIT_ERRORS] input. |
| 3134 */ | 3162 */ |
| 3135 static const String RESOLVE_UNIT_ERRORS_INPUT = 'RESOLVE_UNIT_ERRORS'; | 3163 static const String RESOLVE_UNIT_ERRORS_INPUT = 'RESOLVE_UNIT_ERRORS'; |
| 3136 | 3164 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 3165 // | 3193 // |
| 3166 // Prepare inputs. | 3194 // Prepare inputs. |
| 3167 // | 3195 // |
| 3168 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; | 3196 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; |
| 3169 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); | 3197 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); |
| 3170 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); | 3198 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); |
| 3171 errorLists.add(getRequiredInput(HINTS_INPUT)); | 3199 errorLists.add(getRequiredInput(HINTS_INPUT)); |
| 3172 errorLists.add(getRequiredInput(LINTS_INPUT)); | 3200 errorLists.add(getRequiredInput(LINTS_INPUT)); |
| 3173 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); | 3201 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); |
| 3174 errorLists.add(getRequiredInput(RESOLVE_UNIT_ERRORS_INPUT)); | 3202 errorLists.add(getRequiredInput(RESOLVE_UNIT_ERRORS_INPUT)); |
| 3203 errorLists.add(getRequiredInput(STRONG_MODE_ERRORS_INPUT)); | |
| 3175 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); | 3204 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); |
| 3176 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); | 3205 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); |
| 3177 // | 3206 // |
| 3178 // Record outputs. | 3207 // Record outputs. |
| 3179 // | 3208 // |
| 3180 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); | 3209 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); |
| 3181 } | 3210 } |
| 3182 | 3211 |
| 3183 /** | 3212 /** |
| 3184 * Return a map from the names of the inputs of this kind of task to the task | 3213 * Return a map from the names of the inputs of this kind of task to the task |
| 3185 * input descriptors describing those inputs for a task with the | 3214 * input descriptors describing those inputs for a task with the |
| 3186 * given [unit]. | 3215 * given [unit]. |
| 3187 */ | 3216 */ |
| 3188 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 3217 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { |
| 3189 LibrarySpecificUnit unit = target; | 3218 LibrarySpecificUnit unit = target; |
| 3190 Map<String, TaskInput> inputs = <String, TaskInput>{ | 3219 Map<String, TaskInput> inputs = <String, TaskInput>{ |
| 3191 HINTS_INPUT: HINTS.of(unit), | 3220 HINTS_INPUT: HINTS.of(unit), |
| 3192 LINTS_INPUT: LINTS.of(unit), | 3221 LINTS_INPUT: LINTS.of(unit), |
| 3193 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), | 3222 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), |
| 3194 RESOLVE_UNIT_ERRORS_INPUT: RESOLVE_UNIT_ERRORS.of(unit), | 3223 RESOLVE_UNIT_ERRORS_INPUT: RESOLVE_UNIT_ERRORS.of(unit), |
| 3224 STRONG_MODE_ERRORS_INPUT: STRONG_MODE_ERRORS.of(unit), | |
| 3195 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), | 3225 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), |
| 3196 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) | 3226 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) |
| 3197 }; | 3227 }; |
| 3198 Source source = unit.source; | 3228 Source source = unit.source; |
| 3199 if (unit.library == source) { | 3229 if (unit.library == source) { |
| 3200 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = | 3230 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = |
| 3201 BUILD_DIRECTIVES_ERRORS.of(source); | 3231 BUILD_DIRECTIVES_ERRORS.of(source); |
| 3202 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); | 3232 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); |
| 3203 } else { | 3233 } else { |
| 3204 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = | 3234 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4145 /** | 4175 /** |
| 4146 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 4176 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 4147 */ | 4177 */ |
| 4148 static ScanDartTask createTask( | 4178 static ScanDartTask createTask( |
| 4149 AnalysisContext context, AnalysisTarget target) { | 4179 AnalysisContext context, AnalysisTarget target) { |
| 4150 return new ScanDartTask(context, target); | 4180 return new ScanDartTask(context, target); |
| 4151 } | 4181 } |
| 4152 } | 4182 } |
| 4153 | 4183 |
| 4154 /** | 4184 /** |
| 4185 * A task that builds [STRONG_MODE_ERRORS] for a unit. Also builds | |
| 4186 * [RESOLVED_UNIT] for a unit. | |
| 4187 */ | |
| 4188 class StrongModeVerifyUnitTask extends SourceBasedAnalysisTask { | |
| 4189 /** | |
| 4190 * The name of the [RESOLVED_UNIT10] input. | |
| 4191 */ | |
| 4192 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
| 4193 | |
| 4194 /** | |
| 4195 * The name of the [TYPE_PROVIDER] input. | |
| 4196 */ | |
| 4197 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | |
| 4198 | |
| 4199 /** | |
| 4200 * The task descriptor describing this kind of task. | |
| 4201 */ | |
| 4202 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 4203 'StrongModeVerifyUnitTask', | |
| 4204 createTask, | |
| 4205 buildInputs, | |
| 4206 <ResultDescriptor>[STRONG_MODE_ERRORS, RESOLVED_UNIT]); | |
| 4207 | |
| 4208 StrongModeVerifyUnitTask( | |
| 4209 InternalAnalysisContext context, AnalysisTarget target) | |
| 4210 : super(context, target); | |
| 4211 | |
| 4212 @override | |
| 4213 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 4214 | |
| 4215 @override | |
| 4216 void internalPerform() { | |
| 4217 RecordingErrorListener errorListener = new RecordingErrorListener(); | |
| 4218 // | |
| 4219 // Prepare inputs. | |
| 4220 // | |
| 4221 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | |
| 4222 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
| 4223 if (context.analysisOptions.strongMode) { | |
| 4224 unit.accept(new CodeChecker(new TypeRules(typeProvider), errorListener)); | |
| 4225 } | |
| 4226 | |
| 4227 // | |
| 4228 // Record outputs. | |
| 4229 // | |
| 4230 outputs[STRONG_MODE_ERRORS] = removeDuplicateErrors(errorListener.errors); | |
| 4231 outputs[RESOLVED_UNIT] = unit; | |
| 4232 } | |
| 4233 | |
| 4234 /** | |
| 4235 * Return a map from the names of the inputs of this kind of task to the task | |
| 4236 * input descriptors describing those inputs for a task with the | |
| 4237 * given [target]. | |
| 4238 */ | |
| 4239 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 4240 LibrarySpecificUnit unit = target; | |
| 4241 return <String, TaskInput>{ | |
| 4242 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE | |
| 4243 .of(unit.library) | |
| 4244 .toMapOf(UNITS) | |
| 4245 .toFlattenList((Source library, Source unit) => | |
| 4246 RESOLVED_UNIT10.of(new LibrarySpecificUnit(library, unit))), | |
| 4247 UNIT_INPUT: RESOLVED_UNIT10.of(unit), | |
| 4248 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) | |
| 4249 }; | |
| 4250 } | |
| 4251 | |
| 4252 /** | |
| 4253 * Create a [StrongModeVerifyUnitTask] based on the given [target] in | |
| 4254 * the given [context]. | |
| 4255 */ | |
| 4256 static StrongModeVerifyUnitTask createTask( | |
| 4257 AnalysisContext context, AnalysisTarget target) { | |
| 4258 return new StrongModeVerifyUnitTask(context, target); | |
| 4259 } | |
| 4260 } | |
| 4261 | |
| 4262 /** | |
| 4155 * A task that builds [VERIFY_ERRORS] for a unit. | 4263 * A task that builds [VERIFY_ERRORS] for a unit. |
| 4156 */ | 4264 */ |
| 4157 class VerifyUnitTask extends SourceBasedAnalysisTask { | 4265 class VerifyUnitTask extends SourceBasedAnalysisTask { |
| 4158 /** | 4266 /** |
| 4159 * The name of the [RESOLVED_UNIT] input. | 4267 * The name of the [RESOLVED_UNIT] input. |
| 4160 */ | 4268 */ |
| 4161 static const String UNIT_INPUT = 'UNIT_INPUT'; | 4269 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 4162 | 4270 |
| 4163 /** | 4271 /** |
| 4164 * The name of the [TYPE_PROVIDER] input. | 4272 * The name of the [TYPE_PROVIDER] input. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4207 // | 4315 // |
| 4208 // Use the ErrorVerifier to compute errors. | 4316 // Use the ErrorVerifier to compute errors. |
| 4209 // | 4317 // |
| 4210 ErrorVerifier errorVerifier = new ErrorVerifier( | 4318 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 4211 errorReporter, | 4319 errorReporter, |
| 4212 libraryElement, | 4320 libraryElement, |
| 4213 typeProvider, | 4321 typeProvider, |
| 4214 new InheritanceManager(libraryElement), | 4322 new InheritanceManager(libraryElement), |
| 4215 context.analysisOptions.enableSuperMixins); | 4323 context.analysisOptions.enableSuperMixins); |
| 4216 unit.accept(errorVerifier); | 4324 unit.accept(errorVerifier); |
| 4325 | |
| 4217 // | 4326 // |
| 4218 // Record outputs. | 4327 // Record outputs. |
| 4219 // | 4328 // |
| 4220 outputs[VERIFY_ERRORS] = removeDuplicateErrors(errorListener.errors); | 4329 outputs[VERIFY_ERRORS] = removeDuplicateErrors(errorListener.errors); |
| 4221 } | 4330 } |
| 4222 | 4331 |
| 4223 /** | 4332 /** |
| 4224 * Check each directive in the given [unit] to see if the referenced source | 4333 * Check each directive in the given [unit] to see if the referenced source |
| 4225 * exists and report an error if it does not. | 4334 * exists and report an error if it does not. |
| 4226 */ | 4335 */ |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4398 | 4507 |
| 4399 @override | 4508 @override |
| 4400 bool moveNext() { | 4509 bool moveNext() { |
| 4401 if (_newSources.isEmpty) { | 4510 if (_newSources.isEmpty) { |
| 4402 return false; | 4511 return false; |
| 4403 } | 4512 } |
| 4404 currentTarget = _newSources.removeLast(); | 4513 currentTarget = _newSources.removeLast(); |
| 4405 return true; | 4514 return true; |
| 4406 } | 4515 } |
| 4407 } | 4516 } |
| OLD | NEW |