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

Side by Side Diff: packages/analyzer/lib/src/task/dart.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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.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 11 matching lines...) Expand all
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/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/checker.dart';
33 import 'package:analyzer/src/task/strong/rules.dart';
32 import 'package:analyzer/src/task/strong_mode.dart'; 34 import 'package:analyzer/src/task/strong_mode.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);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 /** 155 /**
154 * The sources representing the combined import/export closure of a library. 156 * The sources representing the combined import/export closure of a library.
155 * The [Source]s include only library sources, not their units. 157 * The [Source]s include only library sources, not their units.
156 * 158 *
157 * The result is only available for [Source]s representing a library. 159 * The result is only available for [Source]s representing a library.
158 */ 160 */
159 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE = 161 final ListResultDescriptor<Source> IMPORT_EXPORT_SOURCE_CLOSURE =
160 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null); 162 new ListResultDescriptor<Source>('IMPORT_EXPORT_SOURCE_CLOSURE', null);
161 163
162 /** 164 /**
163 * A list of the [LibraryElement]s that make up the strongly connected
164 * component in the import/export graph in which the target resides.
165 *
166 * Only non-empty in strongMode
167 *
168 * The result is only available for [LibrarySpecificUnit]s.
169 */
170 final ListResultDescriptor<LibraryElement> LIBRARY_CYCLE =
171 new ListResultDescriptor<LibraryElement>('LIBRARY_CYCLE', null);
172
173 /**
174 * A list of the [CompilationUnitElement]s (including all parts) that make up
175 * the strongly connected component in the import/export graph in which the
176 * target resides.
177 *
178 * Only non-empty in strongMode
179 *
180 * The result is only available for [LibrarySpecificUnit]s.
181 */
182 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_UNITS =
183 new ListResultDescriptor<CompilationUnitElement>(
184 'LIBRARY_CYCLE_UNITS', null);
185
186 /**
187 * A list of the [CompilationUnitElement]s that comprise all of the parts and
188 * libraries in the direct import/export dependencies of the library cycle
189 * of the target, with the intra-component dependencies excluded.
190 *
191 * Only non-empty in strongMode
192 *
193 * The result is only available for [LibrarySpecificUnit]s.
194 */
195 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_DEPENDENCIES =
196 new ListResultDescriptor<CompilationUnitElement>(
197 'LIBRARY_CYCLE_DEPENDENCIES', null);
198
199 /**
200 * A list of the [VariableElement]s whose type should be inferred that another 165 * A list of the [VariableElement]s whose type should be inferred that another
201 * inferable static variable (the target) depends on. 166 * inferable static variable (the target) depends on.
202 * 167 *
203 * The result is only available for [VariableElement]s, and only when strong 168 * The result is only available for [VariableElement]s, and only when strong
204 * mode is enabled. 169 * mode is enabled.
205 */ 170 */
206 final ListResultDescriptor< 171 final ListResultDescriptor<
207 VariableElement> INFERABLE_STATIC_VARIABLE_DEPENDENCIES = 172 VariableElement> INFERABLE_STATIC_VARIABLE_DEPENDENCIES =
208 new ListResultDescriptor<VariableElement>( 173 new ListResultDescriptor<VariableElement>(
209 'INFERABLE_STATIC_VARIABLE_DEPENDENCIES', null); 174 'INFERABLE_STATIC_VARIABLE_DEPENDENCIES', null);
(...skipping 15 matching lines...) Expand all
225 * inferred. 190 * inferred.
226 * 191 *
227 * The result is only available for [VariableElement]s, and only when strong 192 * The result is only available for [VariableElement]s, and only when strong
228 * mode is enabled. 193 * mode is enabled.
229 */ 194 */
230 final ResultDescriptor<VariableElement> INFERRED_STATIC_VARIABLE = 195 final ResultDescriptor<VariableElement> INFERRED_STATIC_VARIABLE =
231 new ResultDescriptor<VariableElement>('INFERRED_STATIC_VARIABLE', null, 196 new ResultDescriptor<VariableElement>('INFERRED_STATIC_VARIABLE', null,
232 cachingPolicy: ELEMENT_CACHING_POLICY); 197 cachingPolicy: ELEMENT_CACHING_POLICY);
233 198
234 /** 199 /**
200 * A list of the [LibraryElement]s that make up the strongly connected
201 * component in the import/export graph in which the target resides.
202 *
203 * Only non-empty in strongMode.
204 *
205 * The result is only available for [LibrarySpecificUnit]s.
206 */
207 final ListResultDescriptor<LibraryElement> LIBRARY_CYCLE =
208 new ListResultDescriptor<LibraryElement>('LIBRARY_CYCLE', null);
209
210 /**
211 * A list of the [CompilationUnitElement]s that comprise all of the parts and
212 * libraries in the direct import/export dependencies of the library cycle
213 * of the target, with the intra-component dependencies excluded.
214 *
215 * Only non-empty in strongMode.
216 *
217 * The result is only available for [LibrarySpecificUnit]s.
218 */
219 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_DEPENDENCIES =
220 new ListResultDescriptor<CompilationUnitElement>(
221 'LIBRARY_CYCLE_DEPENDENCIES', null);
222
223 /**
224 * A list of the [CompilationUnitElement]s (including all parts) that make up
225 * the strongly connected component in the import/export graph in which the
226 * target resides.
227 *
228 * Only non-empty in strongMode.
229 *
230 * The result is only available for [LibrarySpecificUnit]s.
231 */
232 final ListResultDescriptor<CompilationUnitElement> LIBRARY_CYCLE_UNITS =
233 new ListResultDescriptor<CompilationUnitElement>(
234 'LIBRARY_CYCLE_UNITS', null);
235
236 /**
235 * The partial [LibraryElement] associated with a library. 237 * The partial [LibraryElement] associated with a library.
236 * 238 *
237 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each 239 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each
238 * other. Directives 'library', 'part' and 'part of' are resolved. 240 * other. Directives 'library', 'part' and 'part of' are resolved.
239 * 241 *
240 * The result is only available for [Source]s representing a library. 242 * The result is only available for [Source]s representing a library.
241 */ 243 */
242 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 = 244 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 =
243 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT1', null, 245 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT1', null,
244 cachingPolicy: ELEMENT_CACHING_POLICY); 246 cachingPolicy: ELEMENT_CACHING_POLICY);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 336
335 /** 337 /**
336 * The names (resolved and not) referenced by a unit. 338 * The names (resolved and not) referenced by a unit.
337 * 339 *
338 * The result is only available for [Source]s representing a compilation unit. 340 * The result is only available for [Source]s representing a compilation unit.
339 */ 341 */
340 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES = 342 final ResultDescriptor<ReferencedNames> REFERENCED_NAMES =
341 new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null); 343 new ResultDescriptor<ReferencedNames>('REFERENCED_NAMES', null);
342 344
343 /** 345 /**
346 * The errors produced while resolving type names.
347 *
348 * The list will be empty if there were no errors, but will not be `null`.
349 *
350 * The result is only available for [LibrarySpecificUnit]s.
351 */
352 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS =
353 new ListResultDescriptor<AnalysisError>(
354 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS);
355
356 /**
344 * The errors produced while resolving a full compilation unit. 357 * The errors produced while resolving a full compilation unit.
345 * 358 *
346 * The list will be empty if there were no errors, but will not be `null`. 359 * The list will be empty if there were no errors, but will not be `null`.
347 * 360 *
348 * The result is only available for [LibrarySpecificUnit]s. 361 * The result is only available for [LibrarySpecificUnit]s.
349 */ 362 */
350 final ListResultDescriptor<AnalysisError> RESOLVE_UNIT_ERRORS = 363 final ListResultDescriptor<AnalysisError> RESOLVE_UNIT_ERRORS =
351 new ListResultDescriptor<AnalysisError>( 364 new ListResultDescriptor<AnalysisError>(
352 'RESOLVE_UNIT_ERRORS', AnalysisError.NO_ERRORS); 365 'RESOLVE_UNIT_ERRORS', AnalysisError.NO_ERRORS);
353 366
354 /** 367 /**
355 * The errors produced while resolving type names. 368 * The partially resolved [CompilationUnit] associated with a compilation unit.
356 * 369 *
357 * The list will be empty if there were no errors, but will not be `null`. 370 * Tasks that use this value as an input can assume that the [SimpleIdentifier]s
371 * at all declaration sites have been bound to the element defined by the
372 * declaration, except for the constants defined in an 'enum' declaration.
358 * 373 *
359 * The result is only available for [LibrarySpecificUnit]s. 374 * The result is only available for [LibrarySpecificUnit]s.
360 */ 375 */
361 final ListResultDescriptor<AnalysisError> RESOLVE_TYPE_NAMES_ERRORS =
362 new ListResultDescriptor<AnalysisError>(
363 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS);
364
365 /**
366 * The partially resolved [CompilationUnit] associated with a unit.
367 *
368 * All declarations bound to the element defined by the declaration.
369 *
370 * The result is only available for [LibrarySpecificUnit]s.
371 */
372 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = 376 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 =
373 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null, 377 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null,
374 cachingPolicy: AST_CACHING_POLICY); 378 cachingPolicy: AST_CACHING_POLICY);
375 379
376 /** 380 /**
377 * The partially resolved [CompilationUnit] associated with a unit. 381 * The resolved [CompilationUnit] associated with a compilation unit, with
378 * 382 * constants resolved.
379 * All the enum member elements are built.
380 * 383 *
381 * The result is only available for [LibrarySpecificUnit]s. 384 * The result is only available for [LibrarySpecificUnit]s.
382 */ 385 */
386 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT10 =
387 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT10', null,
388 cachingPolicy: AST_CACHING_POLICY);
389
390 /**
391 * The partially resolved [CompilationUnit] associated with a compilation unit.
392 *
393 * Tasks that use this value as an input can assume that the [SimpleIdentifier]s
394 * at all declaration sites have been bound to the element defined by the
395 * declaration, including the constants defined in an 'enum' declaration.
396 *
397 * The result is only available for [LibrarySpecificUnit]s.
398 */
383 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 = 399 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 =
384 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null, 400 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null,
385 cachingPolicy: AST_CACHING_POLICY); 401 cachingPolicy: AST_CACHING_POLICY);
386 402
387 /** 403 /**
388 * The partially resolved [CompilationUnit] associated with a unit. 404 * The partially resolved [CompilationUnit] associated with a compilation unit.
389 * 405 *
390 * [RESOLVED_UNIT2] with resolved type names. 406 * In addition to what is true of a [RESOLVED_UNIT2], tasks that use this value
407 * as an input can assume that the types associated with declarations have been
408 * resolved. This includes the types of superclasses, mixins, interfaces,
409 * fields, return types, parameters, and local variables.
391 * 410 *
392 * The result is only available for [LibrarySpecificUnit]s. 411 * The result is only available for [LibrarySpecificUnit]s.
393 */ 412 */
394 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = 413 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 =
395 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null, 414 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null,
396 cachingPolicy: AST_CACHING_POLICY); 415 cachingPolicy: AST_CACHING_POLICY);
397 416
398 /** 417 /**
399 * The partially resolved [CompilationUnit] associated with a unit. 418 * The partially resolved [CompilationUnit] associated with a compilation unit.
400 * 419 *
401 * [RESOLVED_UNIT3] plus resolved local variables and formal parameters. 420 * In addition to what is true of a [RESOLVED_UNIT3], tasks that use this value
421 * as an input can assume that references to local variables and formal
422 * parameters have been resolved.
402 * 423 *
403 * The result is only available for [LibrarySpecificUnit]s. 424 * The result is only available for [LibrarySpecificUnit]s.
404 */ 425 */
405 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = 426 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 =
406 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null, 427 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null,
407 cachingPolicy: AST_CACHING_POLICY); 428 cachingPolicy: AST_CACHING_POLICY);
408 429
409 /** 430 /**
410 * The resolved [CompilationUnit] associated with a compilation unit in which 431 * The partially resolved [CompilationUnit] associated with a compilation unit.
411 * elements and types have been initially resolved outside of method bodies in 432 *
412 * addition to everything that is true of a [RESOLVED_UNIT4]. 433 * In addition to what is true of a [RESOLVED_UNIT4], tasks that use this value
434 * as an input can assume that elements and types associated with expressions
435 * outside of method bodies (essentially initializers) have been initially
436 * resolved.
413 * 437 *
414 * The result is only available for [LibrarySpecificUnit]s. 438 * The result is only available for [LibrarySpecificUnit]s.
415 */ 439 */
416 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 = 440 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 =
417 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null, 441 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null,
418 cachingPolicy: AST_CACHING_POLICY); 442 cachingPolicy: AST_CACHING_POLICY);
419 443
420 /** 444 /**
421 * The resolved [CompilationUnit] associated with a compilation unit in which 445 * The partially resolved [CompilationUnit] associated with a compilation unit.
422 * the types of static variables have been inferred in addition to everything 446 *
423 * that is true of a [RESOLVED_UNIT5]. 447 * In addition to what is true of a [RESOLVED_UNIT5], tasks that use this value
448 * as an input can assume that the types of static variables have been inferred.
424 * 449 *
425 * The result is only available for [LibrarySpecificUnit]s. 450 * The result is only available for [LibrarySpecificUnit]s.
426 */ 451 */
427 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = 452 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 =
428 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null, 453 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null,
429 cachingPolicy: AST_CACHING_POLICY); 454 cachingPolicy: AST_CACHING_POLICY);
430 455
431 /** 456 /**
432 * The resolved [CompilationUnit] associated with a compilation unit in which 457 * The partially resolved [CompilationUnit] associated with a compilation unit.
433 * the right hand sides of instance variables have been re-resolved in addition 458 *
434 * to everything that is true of a [RESOLVED_UNIT6]. 459 * In addition to what is true of a [RESOLVED_UNIT6], tasks that use this value
460 * as an input can assume that the initializers of instance variables have been
461 * re-resolved.
435 * 462 *
436 * The result is only available for [LibrarySpecificUnit]s. 463 * The result is only available for [LibrarySpecificUnit]s.
437 */ 464 */
438 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 = 465 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT7 =
439 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null, 466 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT7', null,
440 cachingPolicy: AST_CACHING_POLICY); 467 cachingPolicy: AST_CACHING_POLICY);
441 468
442 /** 469 /**
443 * The resolved [CompilationUnit] associated with a compilation unit in which 470 * The resolved [CompilationUnit] associated with a compilation unit in which
444 * the types of class members have been inferred in addition to everything that 471 * the types of class members have been inferred in addition to everything that
(...skipping 20 matching lines...) Expand all
465 * 492 *
466 * The list will be empty if there were no errors, but will not be `null`. 493 * The list will be empty if there were no errors, but will not be `null`.
467 * 494 *
468 * The result is only available for [Source]s representing a compilation unit. 495 * The result is only available for [Source]s representing a compilation unit.
469 */ 496 */
470 final ListResultDescriptor<AnalysisError> SCAN_ERRORS = 497 final ListResultDescriptor<AnalysisError> SCAN_ERRORS =
471 new ListResultDescriptor<AnalysisError>( 498 new ListResultDescriptor<AnalysisError>(
472 'SCAN_ERRORS', AnalysisError.NO_ERRORS); 499 'SCAN_ERRORS', AnalysisError.NO_ERRORS);
473 500
474 /** 501 /**
502 * The additional strong mode errors produced while verifying a
503 * compilation unit.
504 *
505 * The list will be empty if there were no errors, but will not be `null`.
506 *
507 * The result is only available for [LibrarySpecificUnits]s representing a
508 * compilation unit.
509 *
510 */
511 final ListResultDescriptor<AnalysisError> STRONG_MODE_ERRORS =
512 new ListResultDescriptor<AnalysisError>(
513 'STRONG_MODE_ERRORS', AnalysisError.NO_ERRORS);
514
515 /**
475 * The [TypeProvider] of the [AnalysisContext]. 516 * The [TypeProvider] of the [AnalysisContext].
476 */ 517 */
477 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = 518 final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
478 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); 519 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null);
479 520
480 /** 521 /**
481 * The [UsedImportedElements] of a [LibrarySpecificUnit]. 522 * The [UsedImportedElements] of a [LibrarySpecificUnit].
482 */ 523 */
483 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS = 524 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS =
484 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null, 525 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null,
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 * Create a [DartErrorsTask] based on the given [target] in the given 2143 * Create a [DartErrorsTask] based on the given [target] in the given
2103 * [context]. 2144 * [context].
2104 */ 2145 */
2105 static DartErrorsTask createTask( 2146 static DartErrorsTask createTask(
2106 AnalysisContext context, AnalysisTarget target) { 2147 AnalysisContext context, AnalysisTarget target) {
2107 return new DartErrorsTask(context, target); 2148 return new DartErrorsTask(context, target);
2108 } 2149 }
2109 } 2150 }
2110 2151
2111 /** 2152 /**
2112 * A task that builds [RESOLVED_UNIT] for a unit. 2153 * A task that builds [RESOLVED_UNIT10] for a unit.
2113 */ 2154 */
2114 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask { 2155 class EvaluateUnitConstantsTask extends SourceBasedAnalysisTask {
2115 /** 2156 /**
2116 * The name of the [RESOLVED_UNIT9] input. 2157 * The name of the [RESOLVED_UNIT9] input.
2117 */ 2158 */
2118 static const String UNIT_INPUT = 'UNIT_INPUT'; 2159 static const String UNIT_INPUT = 'UNIT_INPUT';
2119 2160
2120 /** 2161 /**
2121 * The name of the [CONSTANT_VALUE] input. 2162 * The name of the [CONSTANT_VALUE] input.
2122 */ 2163 */
2123 static const String CONSTANT_VALUES = 'CONSTANT_VALUES'; 2164 static const String CONSTANT_VALUES = 'CONSTANT_VALUES';
2124 2165
2125 /** 2166 /**
2126 * The task descriptor describing this kind of task. 2167 * The task descriptor describing this kind of task.
2127 */ 2168 */
2128 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2169 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2129 'EvaluateUnitConstantsTask', 2170 'EvaluateUnitConstantsTask',
2130 createTask, 2171 createTask,
2131 buildInputs, 2172 buildInputs,
2132 <ResultDescriptor>[RESOLVED_UNIT]); 2173 <ResultDescriptor>[RESOLVED_UNIT10]);
2133 2174
2134 EvaluateUnitConstantsTask(AnalysisContext context, LibrarySpecificUnit target) 2175 EvaluateUnitConstantsTask(AnalysisContext context, LibrarySpecificUnit target)
2135 : super(context, target); 2176 : super(context, target);
2136 2177
2137 @override 2178 @override
2138 TaskDescriptor get descriptor => DESCRIPTOR; 2179 TaskDescriptor get descriptor => DESCRIPTOR;
2139 2180
2140 @override 2181 @override
2141 void internalPerform() { 2182 void internalPerform() {
2142 // No actual work needs to be performed; the task manager will ensure that 2183 // No actual work needs to be performed; the task manager will ensure that
2143 // all constants are evaluated before this method is called. 2184 // all constants are evaluated before this method is called.
2144 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 2185 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
2145 outputs[RESOLVED_UNIT] = unit; 2186 outputs[RESOLVED_UNIT10] = unit;
2146 } 2187 }
2147 2188
2148 /** 2189 /**
2149 * Return a map from the names of the inputs of this kind of task to the task 2190 * 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 2191 * input descriptors describing those inputs for a task with the
2151 * given [target]. 2192 * given [target].
2152 */ 2193 */
2153 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 2194 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
2154 LibrarySpecificUnit unit = target; 2195 LibrarySpecificUnit unit = target;
2155 return <String, TaskInput>{ 2196 return <String, TaskInput>{
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 AnalysisContext context, AnalysisTarget target) { 2569 AnalysisContext context, AnalysisTarget target) {
2529 return new GenerateHintsTask(context, target); 2570 return new GenerateHintsTask(context, target);
2530 } 2571 }
2531 } 2572 }
2532 2573
2533 /** 2574 /**
2534 * A task that generates [LINTS] for a unit. 2575 * A task that generates [LINTS] for a unit.
2535 */ 2576 */
2536 class GenerateLintsTask extends SourceBasedAnalysisTask { 2577 class GenerateLintsTask extends SourceBasedAnalysisTask {
2537 /** 2578 /**
2538 * The name of the [RESOLVED_UNIT8] input. 2579 * The name of the [RESOLVED_UNIT] input.
2539 */ 2580 */
2540 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT'; 2581 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT';
2541 2582
2542 /** 2583 /**
2543 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input.
2544 */
2545 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS';
2546
2547 /**
2548 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input.
2549 */
2550 static const String USED_IMPORTED_ELEMENTS_INPUT = 'USED_IMPORTED_ELEMENTS';
2551
2552 /**
2553 * The name of the [TYPE_PROVIDER] input.
2554 */
2555 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
2556
2557 /**
2558 * The task descriptor describing this kind of task. 2584 * The task descriptor describing this kind of task.
2559 */ 2585 */
2560 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2586 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2561 'GenerateLintsTask', createTask, buildInputs, <ResultDescriptor>[LINTS]); 2587 'GenerateLintsTask', createTask, buildInputs, <ResultDescriptor>[LINTS]);
2562 2588
2563 GenerateLintsTask(InternalAnalysisContext context, AnalysisTarget target) 2589 GenerateLintsTask(InternalAnalysisContext context, AnalysisTarget target)
2564 : super(context, target); 2590 : super(context, target);
2565 2591
2566 @override 2592 @override
2567 TaskDescriptor get descriptor => DESCRIPTOR; 2593 TaskDescriptor get descriptor => DESCRIPTOR;
(...skipping 12 matching lines...) Expand all
2580 Source source = getRequiredSource(); 2606 Source source = getRequiredSource();
2581 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 2607 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
2582 // 2608 //
2583 // Prepare inputs. 2609 // Prepare inputs.
2584 // 2610 //
2585 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT); 2611 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT);
2586 2612
2587 // 2613 //
2588 // Generate lints. 2614 // Generate lints.
2589 // 2615 //
2590 LintGenerator.LINTERS.forEach((l) => l.reporter = errorReporter); 2616 List<Linter> linters = getLints(context);
2591 Iterable<AstVisitor> visitors = 2617 linters.forEach((l) => l.reporter = errorReporter);
2592 LintGenerator.LINTERS.map((l) => l.getVisitor()).toList(); 2618 Iterable<AstVisitor> visitors = linters.map((l) => l.getVisitor()).toList();
2593 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null))); 2619 unit.accept(new DelegatingAstVisitor(visitors.where((v) => v != null)));
2594 2620
2595 // 2621 //
2596 // Record outputs. 2622 // Record outputs.
2597 // 2623 //
2598 outputs[LINTS] = errorListener.errors; 2624 outputs[LINTS] = errorListener.errors;
2599 } 2625 }
2600 2626
2601 /** 2627 /**
2602 * Return a map from the names of the inputs of this kind of task to the task 2628 * Return a map from the names of the inputs of this kind of task to the task
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2703 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in 2729 * Create a [InferInstanceMembersInUnitTask] based on the given [target] in
2704 * the given [context]. 2730 * the given [context].
2705 */ 2731 */
2706 static InferInstanceMembersInUnitTask createTask( 2732 static InferInstanceMembersInUnitTask createTask(
2707 AnalysisContext context, AnalysisTarget target) { 2733 AnalysisContext context, AnalysisTarget target) {
2708 return new InferInstanceMembersInUnitTask(context, target); 2734 return new InferInstanceMembersInUnitTask(context, target);
2709 } 2735 }
2710 } 2736 }
2711 2737
2712 /** 2738 /**
2713 * A task that ensures that all of the inferrable instance members in a
2714 * compilation unit have had their right hand sides re-resolved
2715 */
2716 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask {
2717 /**
2718 * The name of the [LIBRARY_ELEMENT5] input.
2719 */
2720 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
2721
2722 /**
2723 * The name of the [TYPE_PROVIDER] input.
2724 */
2725 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
2726
2727 /**
2728 * The name of the input whose value is the [RESOLVED_UNIT6] for the
2729 * compilation unit.
2730 */
2731 static const String UNIT_INPUT = 'UNIT_INPUT';
2732
2733 /**
2734 * The task descriptor describing this kind of task.
2735 */
2736 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2737 'ResolveInstanceFieldsInUnitTask',
2738 createTask,
2739 buildInputs,
2740 <ResultDescriptor>[RESOLVED_UNIT7]);
2741
2742 /**
2743 * Initialize a newly created task to build a library element for the given
2744 * [unit] in the given [context].
2745 */
2746 ResolveInstanceFieldsInUnitTask(
2747 InternalAnalysisContext context, LibrarySpecificUnit unit)
2748 : super(context, unit);
2749
2750 @override
2751 TaskDescriptor get descriptor => DESCRIPTOR;
2752
2753 @override
2754 void internalPerform() {
2755 //
2756 // Prepare inputs.
2757 //
2758 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
2759 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
2760 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
2761
2762 CompilationUnitElement unitElement = unit.element;
2763 if (context.analysisOptions.strongMode) {
2764 //
2765 // Resolve references.
2766 //
2767 // TODO(leafp): This code only needs to re-resolve the right hand sides of
2768 // instance fields. We could do incremental resolution on each field
2769 // only using the incremental resolver. However, this caused a massive
2770 // performance degredation on the large_class_declaration_test.dart test.
2771 // I would hypothesize that incremental resolution of field is linear in
2772 // the size of the enclosing class, and hence incrementally resolving each
2773 // field was quadratic. We may wish to revisit this if we can resolve
2774 // this performance issue.
2775 InheritanceManager inheritanceManager =
2776 new InheritanceManager(libraryElement);
2777 PartialResolverVisitor visitor = new PartialResolverVisitor(
2778 libraryElement,
2779 unitElement.source,
2780 typeProvider,
2781 AnalysisErrorListener.NULL_LISTENER,
2782 inheritanceManager: inheritanceManager);
2783 unit.accept(visitor);
2784 }
2785 //
2786 // Record outputs.
2787 //
2788 outputs[RESOLVED_UNIT7] = unit;
2789 }
2790
2791 /**
2792 * Return a map from the names of the inputs of this kind of task to the task
2793 * input descriptors describing those inputs for a task with the given
2794 * [libSource].
2795 */
2796 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
2797 LibrarySpecificUnit unit = target;
2798 return <String, TaskInput>{
2799 UNIT_INPUT: RESOLVED_UNIT6.of(unit),
2800 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library),
2801 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
2802 // In strong mode, add additional dependencies to enforce inference
2803 // ordering.
2804
2805 // Require that static variable inference be complete for all units in
2806 // the current library cycle.
2807 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList(
2808 (CompilationUnitElementImpl unit) => RESOLVED_UNIT6
2809 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))),
2810 // Require that full inference be complete for all dependencies of the
2811 // current library cycle.
2812 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList(
2813 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8
2814 .of(new LibrarySpecificUnit(unit.librarySource, unit.source)))
2815 };
2816 }
2817
2818 /**
2819 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in
2820 * the given [context].
2821 */
2822 static ResolveInstanceFieldsInUnitTask createTask(
2823 AnalysisContext context, AnalysisTarget target) {
2824 return new ResolveInstanceFieldsInUnitTask(context, target);
2825 }
2826 }
2827
2828 /**
2829 * An abstract class that defines utility methods that are useful for tasks 2739 * An abstract class that defines utility methods that are useful for tasks
2830 * operating on static variables. 2740 * operating on static variables.
2831 */ 2741 */
2832 abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask { 2742 abstract class InferStaticVariableTask extends ConstantEvaluationAnalysisTask {
2833 InferStaticVariableTask( 2743 InferStaticVariableTask(
2834 InternalAnalysisContext context, VariableElement variable) 2744 InternalAnalysisContext context, VariableElement variable)
2835 : super(context, variable); 2745 : super(context, variable);
2836 2746
2837 /** 2747 /**
2838 * Return the declaration of the target within the given compilation [unit]. 2748 * Return the declaration of the target within the given compilation [unit].
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 * The name of the [HINTS] input. 3041 * The name of the [HINTS] input.
3132 */ 3042 */
3133 static const String HINTS_INPUT = 'HINTS'; 3043 static const String HINTS_INPUT = 'HINTS';
3134 3044
3135 /** 3045 /**
3136 * The name of the [LINTS] input. 3046 * The name of the [LINTS] input.
3137 */ 3047 */
3138 static const String LINTS_INPUT = 'LINTS'; 3048 static const String LINTS_INPUT = 'LINTS';
3139 3049
3140 /** 3050 /**
3051 * The name of the [STRONG_MODE_ERRORS] input.
3052 */
3053 static const String STRONG_MODE_ERRORS_INPUT = 'STRONG_MODE_ERRORS';
3054
3055 /**
3141 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input. 3056 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input.
3142 */ 3057 */
3143 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT = 3058 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT =
3144 'RESOLVE_TYPE_NAMES_ERRORS'; 3059 'RESOLVE_TYPE_NAMES_ERRORS';
3145 3060
3146 /** 3061 /**
3147 * The name of the [RESOLVE_UNIT_ERRORS] input. 3062 * The name of the [RESOLVE_UNIT_ERRORS] input.
3148 */ 3063 */
3149 static const String RESOLVE_UNIT_ERRORS_INPUT = 'RESOLVE_UNIT_ERRORS'; 3064 static const String RESOLVE_UNIT_ERRORS_INPUT = 'RESOLVE_UNIT_ERRORS';
3150 3065
(...skipping 28 matching lines...) Expand all
3179 // 3094 //
3180 // Prepare inputs. 3095 // Prepare inputs.
3181 // 3096 //
3182 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[]; 3097 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[];
3183 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT)); 3098 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT));
3184 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT)); 3099 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT));
3185 errorLists.add(getRequiredInput(HINTS_INPUT)); 3100 errorLists.add(getRequiredInput(HINTS_INPUT));
3186 errorLists.add(getRequiredInput(LINTS_INPUT)); 3101 errorLists.add(getRequiredInput(LINTS_INPUT));
3187 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT)); 3102 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT));
3188 errorLists.add(getRequiredInput(RESOLVE_UNIT_ERRORS_INPUT)); 3103 errorLists.add(getRequiredInput(RESOLVE_UNIT_ERRORS_INPUT));
3104 errorLists.add(getRequiredInput(STRONG_MODE_ERRORS_INPUT));
3189 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT)); 3105 errorLists.add(getRequiredInput(VARIABLE_REFERENCE_ERRORS_INPUT));
3190 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT)); 3106 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT));
3191 // 3107 //
3192 // Record outputs. 3108 // Record outputs.
3193 // 3109 //
3194 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists); 3110 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists);
3195 } 3111 }
3196 3112
3197 /** 3113 /**
3198 * Return a map from the names of the inputs of this kind of task to the task 3114 * Return a map from the names of the inputs of this kind of task to the task
3199 * input descriptors describing those inputs for a task with the 3115 * input descriptors describing those inputs for a task with the
3200 * given [unit]. 3116 * given [unit].
3201 */ 3117 */
3202 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 3118 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
3203 LibrarySpecificUnit unit = target; 3119 LibrarySpecificUnit unit = target;
3204 Map<String, TaskInput> inputs = <String, TaskInput>{ 3120 Map<String, TaskInput> inputs = <String, TaskInput>{
3205 HINTS_INPUT: HINTS.of(unit), 3121 HINTS_INPUT: HINTS.of(unit),
3206 LINTS_INPUT: LINTS.of(unit), 3122 LINTS_INPUT: LINTS.of(unit),
3207 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit), 3123 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit),
3208 RESOLVE_UNIT_ERRORS_INPUT: RESOLVE_UNIT_ERRORS.of(unit), 3124 RESOLVE_UNIT_ERRORS_INPUT: RESOLVE_UNIT_ERRORS.of(unit),
3125 STRONG_MODE_ERRORS_INPUT: STRONG_MODE_ERRORS.of(unit),
3209 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit), 3126 VARIABLE_REFERENCE_ERRORS_INPUT: VARIABLE_REFERENCE_ERRORS.of(unit),
3210 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit) 3127 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit)
3211 }; 3128 };
3212 Source source = unit.source; 3129 Source source = unit.source;
3213 if (unit.library == source) { 3130 if (unit.library == source) {
3214 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = 3131 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] =
3215 BUILD_DIRECTIVES_ERRORS.of(source); 3132 BUILD_DIRECTIVES_ERRORS.of(source);
3216 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source); 3133 inputs[BUILD_LIBRARY_ERRORS_INPUT] = BUILD_LIBRARY_ERRORS.of(source);
3217 } else { 3134 } else {
3218 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] = 3135 inputs[BUILD_DIRECTIVES_ERRORS_INPUT] =
3219 new ConstantTaskInput(AnalysisError.NO_ERRORS); 3136 new ConstantTaskInput(AnalysisError.NO_ERRORS);
3220 inputs[BUILD_LIBRARY_ERRORS_INPUT] = 3137 inputs[BUILD_LIBRARY_ERRORS_INPUT] =
3221 new ConstantTaskInput(AnalysisError.NO_ERRORS); 3138 new ConstantTaskInput(AnalysisError.NO_ERRORS);
3222 } 3139 }
3223 return inputs; 3140 return inputs;
3224 } 3141 }
3225 3142
3226 /** 3143 /**
3227 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given 3144 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given
3228 * [context]. 3145 * [context].
3229 */ 3146 */
3230 static LibraryUnitErrorsTask createTask( 3147 static LibraryUnitErrorsTask createTask(
3231 AnalysisContext context, AnalysisTarget target) { 3148 AnalysisContext context, AnalysisTarget target) {
3232 return new LibraryUnitErrorsTask(context, target); 3149 return new LibraryUnitErrorsTask(context, target);
3233 } 3150 }
3234 } 3151 }
3235 3152
3236 /** 3153 /**
3237 * A task that parses the content of a Dart file, producing an AST structure. 3154 * A task that parses the content of a Dart file, producing an AST structure,
3155 * any lexical errors found in the process, the kind of the file (library or
3156 * part), and several lists based on the AST.
3238 */ 3157 */
3239 class ParseDartTask extends SourceBasedAnalysisTask { 3158 class ParseDartTask extends SourceBasedAnalysisTask {
3240 /** 3159 /**
3241 * The name of the input whose value is the line information produced for the 3160 * The name of the input whose value is the line information produced for the
3242 * file. 3161 * file.
3243 */ 3162 */
3244 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; 3163 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME';
3245 3164
3246 /** 3165 /**
3247 * The name of the input whose value is the modification time of the file. 3166 * The name of the input whose value is the modification time of the file.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3458 3377
3459 @override 3378 @override
3460 void internalPerform() { 3379 void internalPerform() {
3461 // 3380 //
3462 // Prepare inputs. 3381 // Prepare inputs.
3463 // 3382 //
3464 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); 3383 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
3465 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 3384 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
3466 CompilationUnitElement unitElement = unit.element; 3385 CompilationUnitElement unitElement = unit.element;
3467 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); 3386 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
3387 //
3388 // Resolve references and record outputs.
3389 //
3468 if (context.analysisOptions.strongMode) { 3390 if (context.analysisOptions.strongMode) {
3469 //
3470 // Resolve references.
3471 //
3472 InheritanceManager inheritanceManager = 3391 InheritanceManager inheritanceManager =
3473 new InheritanceManager(libraryElement); 3392 new InheritanceManager(libraryElement);
3474 PartialResolverVisitor visitor = new PartialResolverVisitor( 3393 PartialResolverVisitor visitor = new PartialResolverVisitor(
3475 libraryElement, 3394 libraryElement,
3476 unitElement.source, 3395 unitElement.source,
3477 typeProvider, 3396 typeProvider,
3478 AnalysisErrorListener.NULL_LISTENER, 3397 AnalysisErrorListener.NULL_LISTENER,
3479 inheritanceManager: inheritanceManager); 3398 inheritanceManager: inheritanceManager);
3480 unit.accept(visitor); 3399 unit.accept(visitor);
3481 // 3400
3482 // Record outputs.
3483 //
3484 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.variablesAndFields; 3401 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = visitor.variablesAndFields;
3485 } else { 3402 } else {
3486 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = []; 3403 outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT] = [];
3487 } 3404 }
3488 outputs[RESOLVED_UNIT5] = unit; 3405 outputs[RESOLVED_UNIT5] = unit;
3489 } 3406 }
3490 3407
3491 /** 3408 /**
3492 * Return a map from the names of the inputs of this kind of task to the task 3409 * Return a map from the names of the inputs of this kind of task to the task
3493 * input descriptors describing those inputs for a task with the 3410 * input descriptors describing those inputs for a task with the
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 String name = node.name; 3571 String name = node.name;
3655 names.names.add(name); 3572 names.names.add(name);
3656 if (dependsOn != null && bodyLevel == 0) { 3573 if (dependsOn != null && bodyLevel == 0) {
3657 dependsOn.add(name); 3574 dependsOn.add(name);
3658 } 3575 }
3659 } 3576 }
3660 } 3577 }
3661 } 3578 }
3662 3579
3663 /** 3580 /**
3664 * A task that resolves the bodies of top-level functions, constructors, and 3581 * A task that ensures that all of the inferrable instance members in a
3665 * methods within a single compilation unit. 3582 * compilation unit have had their right hand sides re-resolved
3666 */ 3583 */
3667 class ResolveUnitTask extends SourceBasedAnalysisTask { 3584 class ResolveInstanceFieldsInUnitTask extends SourceBasedAnalysisTask {
3668 /** 3585 /**
3669 * The name of the input whose value is the defining [LIBRARY_ELEMENT5]. 3586 * The name of the [LIBRARY_ELEMENT5] input.
3670 */ 3587 */
3671 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; 3588 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
3672 3589
3673 /** 3590 /**
3674 * The name of the [TYPE_PROVIDER] input. 3591 * The name of the [TYPE_PROVIDER] input.
3675 */ 3592 */
3676 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; 3593 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
3677 3594
3678 /** 3595 /**
3679 * The name of the [RESOLVED_UNIT8] input. 3596 * The name of the input whose value is the [RESOLVED_UNIT6] for the
3597 * compilation unit.
3680 */ 3598 */
3681 static const String UNIT_INPUT = 'UNIT_INPUT'; 3599 static const String UNIT_INPUT = 'UNIT_INPUT';
3682 3600
3601 /**
3602 * The task descriptor describing this kind of task.
3603 */
3683 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 3604 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
3684 'ResolveUnitTask', 3605 'ResolveInstanceFieldsInUnitTask',
3685 createTask, 3606 createTask,
3686 buildInputs, 3607 buildInputs,
3687 <ResultDescriptor>[RESOLVE_UNIT_ERRORS, RESOLVED_UNIT9]); 3608 <ResultDescriptor>[RESOLVED_UNIT7]);
3688 3609
3689 ResolveUnitTask( 3610 /**
3690 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit) 3611 * Initialize a newly created task to build a library element for the given
3691 : super(context, compilationUnit); 3612 * [unit] in the given [context].
3613 */
3614 ResolveInstanceFieldsInUnitTask(
3615 InternalAnalysisContext context, LibrarySpecificUnit unit)
3616 : super(context, unit);
3692 3617
3693 @override 3618 @override
3694 TaskDescriptor get descriptor => DESCRIPTOR; 3619 TaskDescriptor get descriptor => DESCRIPTOR;
3695 3620
3696 @override 3621 @override
3697 void internalPerform() { 3622 void internalPerform() {
3698 // 3623 //
3699 // Prepare inputs. 3624 // Prepare inputs.
3700 // 3625 //
3701 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); 3626 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
3702 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 3627 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
3703 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); 3628 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
3704 // 3629
3705 // Resolve everything
3706 //
3707 CompilationUnitElement unitElement = unit.element; 3630 CompilationUnitElement unitElement = unit.element;
3708 RecordingErrorListener errorListener = new RecordingErrorListener(); 3631 if (context.analysisOptions.strongMode) {
3709 ResolverVisitor visitor = new ResolverVisitor( 3632 //
3710 libraryElement, unitElement.source, typeProvider, errorListener); 3633 // Resolve references.
3711 unit.accept(visitor); 3634 //
3635 // TODO(leafp): This code only needs to re-resolve the right hand sides of
3636 // instance fields. We could do incremental resolution on each field
3637 // only using the incremental resolver. However, this caused a massive
3638 // performance degredation on the large_class_declaration_test.dart test.
3639 // I would hypothesize that incremental resolution of field is linear in
3640 // the size of the enclosing class, and hence incrementally resolving each
3641 // field was quadratic. We may wish to revisit this if we can resolve
3642 // this performance issue.
3643 InheritanceManager inheritanceManager =
3644 new InheritanceManager(libraryElement);
3645 PartialResolverVisitor visitor = new PartialResolverVisitor(
3646 libraryElement,
3647 unitElement.source,
3648 typeProvider,
3649 AnalysisErrorListener.NULL_LISTENER,
3650 inheritanceManager: inheritanceManager);
3651 unit.accept(visitor);
3652 }
3712 // 3653 //
3713 // Record outputs. 3654 // Record outputs.
3714 // 3655 //
3715 outputs[RESOLVE_UNIT_ERRORS] = errorListener.errors; 3656 outputs[RESOLVED_UNIT7] = unit;
3716 outputs[RESOLVED_UNIT9] = unit;
3717 } 3657 }
3718 3658
3719 /** 3659 /**
3720 * Return a map from the names of the inputs of this kind of task to the task 3660 * Return a map from the names of the inputs of this kind of task to the task
3721 * input descriptors describing those inputs for a task with the given 3661 * input descriptors describing those inputs for a task with the given
3722 * [target]. 3662 * [libSource].
3723 */ 3663 */
3724 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 3664 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
3725 LibrarySpecificUnit unit = target; 3665 LibrarySpecificUnit unit = target;
3726 return <String, TaskInput>{ 3666 return <String, TaskInput>{
3667 UNIT_INPUT: RESOLVED_UNIT6.of(unit),
3727 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library), 3668 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library),
3728 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 3669 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
3729 UNIT_INPUT: RESOLVED_UNIT8.of(unit),
3730 // In strong mode, add additional dependencies to enforce inference 3670 // In strong mode, add additional dependencies to enforce inference
3731 // ordering. 3671 // ordering.
3732 3672
3733 // Require that inference be complete for all units in the 3673 // Require that static variable inference be complete for all units in
3674 // the current library cycle.
3675 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList(
3676 (CompilationUnitElementImpl unit) => RESOLVED_UNIT6
3677 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))),
3678 // Require that full inference be complete for all dependencies of the
3734 // current library cycle. 3679 // current library cycle.
3735 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList( 3680 'orderLibraryCycles': LIBRARY_CYCLE_DEPENDENCIES.of(unit).toList(
3736 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8 3681 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8
3737 .of(new LibrarySpecificUnit(unit.librarySource, unit.source))) 3682 .of(new LibrarySpecificUnit(unit.librarySource, unit.source)))
3738 }; 3683 };
3739 } 3684 }
3740 3685
3741 /** 3686 /**
3742 * Create a [ResolveUnitTask] based on the given [target] in 3687 * Create a [ResolveInstanceFieldsInUnitTask] based on the given [target] in
3743 * the given [context]. 3688 * the given [context].
3744 */ 3689 */
3745 static ResolveUnitTask createTask( 3690 static ResolveInstanceFieldsInUnitTask createTask(
3746 AnalysisContext context, AnalysisTarget target) { 3691 AnalysisContext context, AnalysisTarget target) {
3747 return new ResolveUnitTask(context, target); 3692 return new ResolveInstanceFieldsInUnitTask(context, target);
3748 } 3693 }
3749 } 3694 }
3750 3695
3751 /** 3696 /**
3752 * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo r every 3697 * A task that finishes resolution by requesting [RESOLVED_UNIT_NO_CONSTANTS] fo r every
3753 * unit in the libraries closure and produces [LIBRARY_ELEMENT]. 3698 * unit in the libraries closure and produces [LIBRARY_ELEMENT].
3754 */ 3699 */
3755 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask { 3700 class ResolveLibraryReferencesTask extends SourceBasedAnalysisTask {
3756 /** 3701 /**
3757 * The name of the [LIBRARY_ELEMENT5] input. 3702 * The name of the [LIBRARY_ELEMENT5] input.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in 3822 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in
3878 * the given [context]. 3823 * the given [context].
3879 */ 3824 */
3880 static ResolveLibraryTypeNamesTask createTask( 3825 static ResolveLibraryTypeNamesTask createTask(
3881 AnalysisContext context, AnalysisTarget target) { 3826 AnalysisContext context, AnalysisTarget target) {
3882 return new ResolveLibraryTypeNamesTask(context, target); 3827 return new ResolveLibraryTypeNamesTask(context, target);
3883 } 3828 }
3884 } 3829 }
3885 3830
3886 /** 3831 /**
3832 * A task that resolves the bodies of top-level functions, constructors, and
3833 * methods within a single compilation unit.
3834 */
3835 class ResolveUnitTask extends SourceBasedAnalysisTask {
3836 /**
3837 * The name of the input whose value is the defining [LIBRARY_ELEMENT5].
3838 */
3839 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
3840
3841 /**
3842 * The name of the [TYPE_PROVIDER] input.
3843 */
3844 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
3845
3846 /**
3847 * The name of the [RESOLVED_UNIT8] input.
3848 */
3849 static const String UNIT_INPUT = 'UNIT_INPUT';
3850
3851 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
3852 'ResolveUnitTask',
3853 createTask,
3854 buildInputs,
3855 <ResultDescriptor>[RESOLVE_UNIT_ERRORS, RESOLVED_UNIT9]);
3856
3857 ResolveUnitTask(
3858 InternalAnalysisContext context, LibrarySpecificUnit compilationUnit)
3859 : super(context, compilationUnit);
3860
3861 @override
3862 TaskDescriptor get descriptor => DESCRIPTOR;
3863
3864 @override
3865 void internalPerform() {
3866 //
3867 // Prepare inputs.
3868 //
3869 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
3870 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
3871 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
3872 //
3873 // Resolve everything.
3874 //
3875 CompilationUnitElement unitElement = unit.element;
3876 RecordingErrorListener errorListener = new RecordingErrorListener();
3877 ResolverVisitor visitor = new ResolverVisitor(
3878 libraryElement, unitElement.source, typeProvider, errorListener);
3879 unit.accept(visitor);
3880 //
3881 // Record outputs.
3882 //
3883 outputs[RESOLVE_UNIT_ERRORS] = errorListener.errors;
3884 outputs[RESOLVED_UNIT9] = unit;
3885 }
3886
3887 /**
3888 * Return a map from the names of the inputs of this kind of task to the task
3889 * input descriptors describing those inputs for a task with the given
3890 * [target].
3891 */
3892 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
3893 LibrarySpecificUnit unit = target;
3894 return <String, TaskInput>{
3895 LIBRARY_INPUT: LIBRARY_ELEMENT5.of(unit.library),
3896 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
3897 UNIT_INPUT: RESOLVED_UNIT8.of(unit),
3898 // In strong mode, add additional dependencies to enforce inference
3899 // ordering.
3900
3901 // Require that inference be complete for all units in the
3902 // current library cycle.
3903 'orderLibraryCycleTasks': LIBRARY_CYCLE_UNITS.of(unit).toList(
3904 (CompilationUnitElementImpl unit) => RESOLVED_UNIT8
3905 .of(new LibrarySpecificUnit(unit.librarySource, unit.source)))
3906 };
3907 }
3908
3909 /**
3910 * Create a [ResolveUnitTask] based on the given [target] in
3911 * the given [context].
3912 */
3913 static ResolveUnitTask createTask(
3914 AnalysisContext context, AnalysisTarget target) {
3915 return new ResolveUnitTask(context, target);
3916 }
3917 }
3918
3919 /**
3887 * A task that builds [RESOLVED_UNIT3] for a unit. 3920 * A task that builds [RESOLVED_UNIT3] for a unit.
3888 */ 3921 */
3889 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { 3922 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask {
3890 /** 3923 /**
3891 * The name of the input whose value is the defining [LIBRARY_ELEMENT4]. 3924 * The name of the input whose value is the defining [LIBRARY_ELEMENT4].
3892 */ 3925 */
3893 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; 3926 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
3894 3927
3895 /** 3928 /**
3896 * The name of the [RESOLVED_UNIT2] input. 3929 * The name of the [RESOLVED_UNIT2] input.
(...skipping 16 matching lines...) Expand all
3913 3946
3914 ResolveUnitTypeNamesTask( 3947 ResolveUnitTypeNamesTask(
3915 InternalAnalysisContext context, AnalysisTarget target) 3948 InternalAnalysisContext context, AnalysisTarget target)
3916 : super(context, target); 3949 : super(context, target);
3917 3950
3918 @override 3951 @override
3919 TaskDescriptor get descriptor => DESCRIPTOR; 3952 TaskDescriptor get descriptor => DESCRIPTOR;
3920 3953
3921 @override 3954 @override
3922 void internalPerform() { 3955 void internalPerform() {
3923 RecordingErrorListener errorListener = new RecordingErrorListener();
3924 // 3956 //
3925 // Prepare inputs. 3957 // Prepare inputs.
3926 // 3958 //
3927 LibraryElement library = getRequiredInput(LIBRARY_INPUT); 3959 LibraryElement library = getRequiredInput(LIBRARY_INPUT);
3928 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 3960 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
3929 CompilationUnitElement unitElement = unit.element; 3961 CompilationUnitElement unitElement = unit.element;
3930 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); 3962 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
3931 // 3963 //
3932 // Resolve TypeName nodes. 3964 // Resolve TypeName nodes.
3933 // 3965 //
3966 RecordingErrorListener errorListener = new RecordingErrorListener();
3934 TypeResolverVisitor visitor = new TypeResolverVisitor( 3967 TypeResolverVisitor visitor = new TypeResolverVisitor(
3935 library, unitElement.source, typeProvider, errorListener); 3968 library, unitElement.source, typeProvider, errorListener);
3936 unit.accept(visitor); 3969 unit.accept(visitor);
3937 // 3970 //
3938 // Record outputs. 3971 // Record outputs.
3939 // 3972 //
3940 outputs[RESOLVE_TYPE_NAMES_ERRORS] = 3973 outputs[RESOLVE_TYPE_NAMES_ERRORS] =
3941 removeDuplicateErrors(errorListener.errors); 3974 removeDuplicateErrors(errorListener.errors);
3942 outputs[RESOLVED_UNIT3] = unit; 3975 outputs[RESOLVED_UNIT3] = unit;
3943 } 3976 }
3944 3977
3945 /** 3978 /**
3946 * Return a map from the names of the inputs of this kind of task to the task 3979 * Return a map from the names of the inputs of this kind of task to the task
3947 * input descriptors describing those inputs for a task with the 3980 * input descriptors describing those inputs for a task with the
3948 * given [target]. 3981 * given [target].
3949 */ 3982 */
3950 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { 3983 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
3984 // TODO(brianwilkerson) This task updates the element model to have type
3985 // information and updates the class hierarchy. It should produce a new
3986 // version of the element model in order to record those changes.
3951 LibrarySpecificUnit unit = target; 3987 LibrarySpecificUnit unit = target;
3952 return <String, TaskInput>{ 3988 return <String, TaskInput>{
3953 'importsExportNamespace': 3989 'importsExportNamespace':
3954 IMPORTED_LIBRARIES.of(unit.library).toMapOf(LIBRARY_ELEMENT4), 3990 IMPORTED_LIBRARIES.of(unit.library).toMapOf(LIBRARY_ELEMENT4),
3955 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(unit.library), 3991 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(unit.library),
3956 UNIT_INPUT: RESOLVED_UNIT2.of(unit), 3992 UNIT_INPUT: RESOLVED_UNIT2.of(unit),
3957 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request) 3993 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
3958 }; 3994 };
3959 } 3995 }
3960 3996
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3998 4034
3999 ResolveVariableReferencesTask( 4035 ResolveVariableReferencesTask(
4000 InternalAnalysisContext context, AnalysisTarget target) 4036 InternalAnalysisContext context, AnalysisTarget target)
4001 : super(context, target); 4037 : super(context, target);
4002 4038
4003 @override 4039 @override
4004 TaskDescriptor get descriptor => DESCRIPTOR; 4040 TaskDescriptor get descriptor => DESCRIPTOR;
4005 4041
4006 @override 4042 @override
4007 void internalPerform() { 4043 void internalPerform() {
4008 RecordingErrorListener errorListener = new RecordingErrorListener();
4009 // 4044 //
4010 // Prepare inputs. 4045 // Prepare inputs.
4011 // 4046 //
4012 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); 4047 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
4013 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 4048 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
4014 CompilationUnitElement unitElement = unit.element; 4049 CompilationUnitElement unitElement = unit.element;
4050 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
4015 // 4051 //
4016 // Resolve local variables. 4052 // Resolve local variables.
4017 // 4053 //
4018 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); 4054 RecordingErrorListener errorListener = new RecordingErrorListener();
4019 Scope nameScope = new LibraryScope(libraryElement, errorListener); 4055 Scope nameScope = new LibraryScope(libraryElement, errorListener);
4020 AstVisitor visitor = new VariableResolverVisitor( 4056 VariableResolverVisitor visitor = new VariableResolverVisitor(
4021 libraryElement, unitElement.source, typeProvider, errorListener, 4057 libraryElement, unitElement.source, typeProvider, errorListener,
4022 nameScope: nameScope); 4058 nameScope: nameScope);
4023 unit.accept(visitor); 4059 unit.accept(visitor);
4024 // 4060 //
4025 // Record outputs. 4061 // Record outputs.
4026 // 4062 //
4027 outputs[RESOLVED_UNIT4] = unit; 4063 outputs[RESOLVED_UNIT4] = unit;
4028 outputs[VARIABLE_REFERENCE_ERRORS] = 4064 outputs[VARIABLE_REFERENCE_ERRORS] =
4029 removeDuplicateErrors(errorListener.errors); 4065 removeDuplicateErrors(errorListener.errors);
4030 } 4066 }
(...skipping 16 matching lines...) Expand all
4047 * Create a [ResolveVariableReferencesTask] based on the given [target] in 4083 * Create a [ResolveVariableReferencesTask] based on the given [target] in
4048 * the given [context]. 4084 * the given [context].
4049 */ 4085 */
4050 static ResolveVariableReferencesTask createTask( 4086 static ResolveVariableReferencesTask createTask(
4051 AnalysisContext context, AnalysisTarget target) { 4087 AnalysisContext context, AnalysisTarget target) {
4052 return new ResolveVariableReferencesTask(context, target); 4088 return new ResolveVariableReferencesTask(context, target);
4053 } 4089 }
4054 } 4090 }
4055 4091
4056 /** 4092 /**
4057 * A task that scans the content of a file, producing a set of Dart tokens. 4093 * A task that scans the content of a Dart file, producing a stream of Dart
4094 * tokens, line information, and any lexical errors encountered in the process.
4058 */ 4095 */
4059 class ScanDartTask extends SourceBasedAnalysisTask { 4096 class ScanDartTask extends SourceBasedAnalysisTask {
4060 /** 4097 /**
4061 * The name of the input whose value is the content of the file. 4098 * The name of the input whose value is the content of the file.
4062 */ 4099 */
4063 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; 4100 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME';
4064 4101
4065 /** 4102 /**
4066 * The task descriptor describing this kind of task. 4103 * The task descriptor describing this kind of task.
4067 */ 4104 */
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4159 /** 4196 /**
4160 * Create a [ScanDartTask] based on the given [target] in the given [context]. 4197 * Create a [ScanDartTask] based on the given [target] in the given [context].
4161 */ 4198 */
4162 static ScanDartTask createTask( 4199 static ScanDartTask createTask(
4163 AnalysisContext context, AnalysisTarget target) { 4200 AnalysisContext context, AnalysisTarget target) {
4164 return new ScanDartTask(context, target); 4201 return new ScanDartTask(context, target);
4165 } 4202 }
4166 } 4203 }
4167 4204
4168 /** 4205 /**
4206 * A task that builds [STRONG_MODE_ERRORS] for a unit. Also builds
4207 * [RESOLVED_UNIT] for a unit.
4208 */
4209 class StrongModeVerifyUnitTask extends SourceBasedAnalysisTask {
4210 /**
4211 * The name of the [RESOLVED_UNIT10] input.
4212 */
4213 static const String UNIT_INPUT = 'UNIT_INPUT';
4214
4215 /**
4216 * The name of the [TYPE_PROVIDER] input.
4217 */
4218 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
4219
4220 /**
4221 * The task descriptor describing this kind of task.
4222 */
4223 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
4224 'StrongModeVerifyUnitTask',
4225 createTask,
4226 buildInputs,
4227 <ResultDescriptor>[STRONG_MODE_ERRORS, RESOLVED_UNIT]);
4228
4229 StrongModeVerifyUnitTask(
4230 InternalAnalysisContext context, AnalysisTarget target)
4231 : super(context, target);
4232
4233 @override
4234 TaskDescriptor get descriptor => DESCRIPTOR;
4235
4236 @override
4237 void internalPerform() {
4238 RecordingErrorListener errorListener = new RecordingErrorListener();
4239 //
4240 // Prepare inputs.
4241 //
4242 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
4243 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
4244 if (context.analysisOptions.strongMode) {
4245 unit.accept(new CodeChecker(new TypeRules(typeProvider), errorListener));
4246 }
4247
4248 //
4249 // Record outputs.
4250 //
4251 outputs[STRONG_MODE_ERRORS] = removeDuplicateErrors(errorListener.errors);
4252 outputs[RESOLVED_UNIT] = unit;
4253 }
4254
4255 /**
4256 * Return a map from the names of the inputs of this kind of task to the task
4257 * input descriptors describing those inputs for a task with the
4258 * given [target].
4259 */
4260 static Map<String, TaskInput> buildInputs(AnalysisTarget target) {
4261 LibrarySpecificUnit unit = target;
4262 return <String, TaskInput>{
4263 'resolvedUnits': IMPORT_EXPORT_SOURCE_CLOSURE
4264 .of(unit.library)
4265 .toMapOf(UNITS)
4266 .toFlattenList((Source library, Source unit) =>
4267 RESOLVED_UNIT10.of(new LibrarySpecificUnit(library, unit))),
4268 UNIT_INPUT: RESOLVED_UNIT10.of(unit),
4269 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
4270 };
4271 }
4272
4273 /**
4274 * Create a [StrongModeVerifyUnitTask] based on the given [target] in
4275 * the given [context].
4276 */
4277 static StrongModeVerifyUnitTask createTask(
4278 AnalysisContext context, AnalysisTarget target) {
4279 return new StrongModeVerifyUnitTask(context, target);
4280 }
4281 }
4282
4283 /**
4169 * A task that builds [VERIFY_ERRORS] for a unit. 4284 * A task that builds [VERIFY_ERRORS] for a unit.
4170 */ 4285 */
4171 class VerifyUnitTask extends SourceBasedAnalysisTask { 4286 class VerifyUnitTask extends SourceBasedAnalysisTask {
4172 /** 4287 /**
4173 * The name of the [RESOLVED_UNIT] input. 4288 * The name of the [RESOLVED_UNIT] input.
4174 */ 4289 */
4175 static const String UNIT_INPUT = 'UNIT_INPUT'; 4290 static const String UNIT_INPUT = 'UNIT_INPUT';
4176 4291
4177 /** 4292 /**
4178 * The name of the [TYPE_PROVIDER] input. 4293 * The name of the [TYPE_PROVIDER] input.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
4221 // 4336 //
4222 // Use the ErrorVerifier to compute errors. 4337 // Use the ErrorVerifier to compute errors.
4223 // 4338 //
4224 ErrorVerifier errorVerifier = new ErrorVerifier( 4339 ErrorVerifier errorVerifier = new ErrorVerifier(
4225 errorReporter, 4340 errorReporter,
4226 libraryElement, 4341 libraryElement,
4227 typeProvider, 4342 typeProvider,
4228 new InheritanceManager(libraryElement), 4343 new InheritanceManager(libraryElement),
4229 context.analysisOptions.enableSuperMixins); 4344 context.analysisOptions.enableSuperMixins);
4230 unit.accept(errorVerifier); 4345 unit.accept(errorVerifier);
4346
4231 // 4347 //
4232 // Record outputs. 4348 // Record outputs.
4233 // 4349 //
4234 outputs[VERIFY_ERRORS] = removeDuplicateErrors(errorListener.errors); 4350 outputs[VERIFY_ERRORS] = removeDuplicateErrors(errorListener.errors);
4235 } 4351 }
4236 4352
4237 /** 4353 /**
4238 * Check each directive in the given [unit] to see if the referenced source 4354 * Check each directive in the given [unit] to see if the referenced source
4239 * exists and report an error if it does not. 4355 * exists and report an error if it does not.
4240 */ 4356 */
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
4412 4528
4413 @override 4529 @override
4414 bool moveNext() { 4530 bool moveNext() {
4415 if (_newSources.isEmpty) { 4531 if (_newSources.isEmpty) {
4416 return false; 4532 return false;
4417 } 4533 }
4418 currentTarget = _newSources.removeLast(); 4534 currentTarget = _newSources.removeLast();
4419 return true; 4535 return true;
4420 } 4536 }
4421 } 4537 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/src/services/lint.dart ('k') | packages/analyzer/lib/src/task/dart_work_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698