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/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 * libraries exports one. | 108 * libraries exports one. |
| 109 * | 109 * |
| 110 * Also [LibraryElement.exportNamespace] is set. | 110 * Also [LibraryElement.exportNamespace] is set. |
| 111 * | 111 * |
| 112 * The result is only available for targets representing a Dart library. | 112 * The result is only available for targets representing a Dart library. |
| 113 */ | 113 */ |
| 114 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 = | 114 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 = |
| 115 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null); | 115 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null); |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * The partial [LibraryElement] associated with a library. | |
| 119 * | |
| 120 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit. | |
| 121 * | |
| 122 * The result is only available for targets representing a Dart library. | |
| 123 */ | |
| 124 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 = | |
| 125 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null); | |
| 126 | |
| 127 /** | |
| 118 * The errors produced while resolving type names. | 128 * The errors produced while resolving type names. |
| 119 * | 129 * |
| 120 * The list will be empty if there were no errors, but will not be `null`. | 130 * The list will be empty if there were no errors, but will not be `null`. |
| 121 * | 131 * |
| 122 * The result is only available for targets representing a Dart library. | 132 * The result is only available for targets representing a Dart library. |
| 123 */ | 133 */ |
| 124 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS = | 134 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS = |
| 125 new ResultDescriptor<List<AnalysisError>>( | 135 new ResultDescriptor<List<AnalysisError>>( |
| 126 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS, | 136 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS, |
| 127 contributesTo: DART_ERRORS); | 137 contributesTo: DART_ERRORS); |
| 128 | 138 |
| 129 /** | 139 /** |
| 130 * The partially resolved [CompilationUnit] associated with a unit. | 140 * The partially resolved [CompilationUnit] associated with a unit. |
| 131 * | 141 * |
| 132 * All declarations bound to the element defined by the declaration. | 142 * All declarations bound to the element defined by the declaration. |
| 133 * | 143 * |
| 134 * The result is only available for targets representing a unit. | 144 * The result is only available for targets representing a unit. |
| 135 */ | 145 */ |
| 136 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = | 146 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = |
| 137 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null); | 147 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null); |
| 138 | 148 |
| 139 /** | 149 /** |
| 140 * The partially resolved [CompilationUnit] associated with a unit. | 150 * The partially resolved [CompilationUnit] associated with a unit. |
| 141 * | 151 * |
| 142 * Directives 'library', 'part' and 'part of' are resolved. | 152 * All the enum member elements are built. |
| 143 * | 153 * |
| 144 * The result is only available for targets representing a library. | 154 * The result is only available for targets representing a unit. |
| 145 */ | 155 */ |
| 146 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 = | 156 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 = |
| 147 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null); | 157 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null); |
| 148 | 158 |
| 149 /** | 159 /** |
| 150 * The partially resolved [CompilationUnit] associated with a library. | 160 * The partially resolved [CompilationUnit] associated with a unit. |
| 151 * | 161 * |
| 152 * All the directives are resolved. | 162 * All the function type aliases are resolved. |
| 153 * | 163 * |
| 154 * The result is only available for targets representing a library. | 164 * The result is only available for targets representing a unit. |
| 155 */ | 165 */ |
| 156 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = | 166 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = |
| 157 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); | 167 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); |
| 158 | 168 |
| 159 /** | 169 /** |
| 160 * The partially resolved [CompilationUnit] associated with a unit. | 170 * The partially resolved [CompilationUnit] associated with a unit. |
| 161 * | 171 * |
| 162 * All the enum member elements are built. | 172 * [RESOLVED_UNIT3] with resolved type names. |
| 163 * | 173 * |
| 164 * The result is only available for targets representing a unit. | 174 * The result is only available for targets representing a unit. |
| 165 */ | 175 */ |
| 166 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = | 176 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = |
| 167 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); | 177 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); |
| 168 | 178 |
| 169 /** | 179 /** |
| 170 * The partially resolved [CompilationUnit] associated with a unit. | |
| 171 * | |
| 172 * All the function type aliases are resolved. | |
| 173 * | |
| 174 * The result is only available for targets representing a unit. | |
| 175 */ | |
| 176 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 = | |
| 177 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null); | |
| 178 | |
| 179 /** | |
| 180 * The partially resolved [CompilationUnit] associated with a unit. | |
| 181 * | |
| 182 * [RESOLVED_UNIT5] with resolved type names. | |
| 183 * | |
| 184 * The result is only available for targets representing a unit. | |
| 185 */ | |
| 186 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT6 = | |
| 187 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT6', null); | |
| 188 | |
| 189 /** | |
| 190 * The [TypeProvider] of the context. | 180 * The [TypeProvider] of the context. |
| 191 */ | 181 */ |
| 192 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = | 182 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = |
| 193 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); | 183 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); |
| 194 | 184 |
| 195 /** | 185 /** |
| 196 * A task that builds a compilation unit element for a single compilation unit. | 186 * A task that builds a compilation unit element for a single compilation unit. |
| 197 */ | 187 */ |
| 198 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { | 188 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { |
| 199 /** | 189 /** |
| 200 * The name of the input whose value is the line information for the | 190 * The name of the input whose value is the line information for the |
| 201 * compilation unit. | 191 * compilation unit. |
| 202 */ | 192 */ |
| 203 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; | 193 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; |
| 204 | 194 |
| 205 /** | 195 /** |
| 206 * The name of the input whose value is the AST for the compilation unit. | 196 * The name of the input whose value is the AST for the compilation unit. |
| 207 */ | 197 */ |
| 208 static const String PARSED_UNIT_INPUT_NAME = 'PARSED_UNIT_INPUT_NAME'; | 198 static const String PARSED_UNIT_INPUT_NAME = 'PARSED_UNIT_INPUT_NAME'; |
| 209 | 199 |
| 210 /** | 200 /** |
| 211 * The task descriptor describing this kind of task. | 201 * The task descriptor describing this kind of task. |
| 212 */ | 202 */ |
| 213 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 203 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 214 'BUILD_COMPILATION_UNIT_ELEMENT', createTask, buildInputs, | 204 'BuildCompilationUnitElementTask', createTask, buildInputs, |
| 215 <ResultDescriptor>[COMPILATION_UNIT_ELEMENT, RESOLVED_UNIT1]); | 205 <ResultDescriptor>[COMPILATION_UNIT_ELEMENT, RESOLVED_UNIT1]); |
| 216 | 206 |
| 217 /** | 207 /** |
| 218 * Initialize a newly created task to build a compilation unit element for | 208 * Initialize a newly created task to build a compilation unit element for |
| 219 * the given [target] in the given [context]. | 209 * the given [target] in the given [context]. |
| 220 */ | 210 */ |
| 221 BuildCompilationUnitElementTask( | 211 BuildCompilationUnitElementTask( |
| 222 InternalAnalysisContext context, AnalysisTarget target) | 212 InternalAnalysisContext context, AnalysisTarget target) |
| 223 : super(context, target); | 213 : super(context, target); |
| 224 | 214 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 AnalysisContext context, AnalysisTarget target) { | 254 AnalysisContext context, AnalysisTarget target) { |
| 265 return new BuildCompilationUnitElementTask(context, target); | 255 return new BuildCompilationUnitElementTask(context, target); |
| 266 } | 256 } |
| 267 } | 257 } |
| 268 | 258 |
| 269 /** | 259 /** |
| 270 * A task that builds imports and export directive elements for a library. | 260 * A task that builds imports and export directive elements for a library. |
| 271 */ | 261 */ |
| 272 class BuildDirectiveElementsTask extends SourceBasedAnalysisTask { | 262 class BuildDirectiveElementsTask extends SourceBasedAnalysisTask { |
| 273 /** | 263 /** |
| 274 * The name of the input for [RESOLVED_UNIT2] of a library unit. | 264 * The name of the input for [RESOLVED_UNIT1] of a library unit. |
| 275 */ | 265 */ |
| 276 static const String RESOLVED_UNIT2_INPUT_NAME = 'RESOLVED_UNIT2_INPUT_NAME'; | 266 static const String UNIT_INPUT_NAME = 'UNIT_INPUT_NAME'; |
| 277 | 267 |
| 278 /** | 268 /** |
| 279 * The input with a list of [LIBRARY_ELEMENT3]s of imported libraries. | 269 * The input with a list of [LIBRARY_ELEMENT3]s of imported libraries. |
| 280 */ | 270 */ |
| 281 static const String IMPORTS_LIBRARY_ELEMENT_INPUT_NAME = | 271 static const String IMPORTS_LIBRARY_ELEMENT_INPUT_NAME = |
| 282 'IMPORTS_LIBRARY_ELEMENT1_INPUT_NAME'; | 272 'IMPORTS_LIBRARY_ELEMENT1_INPUT_NAME'; |
| 283 | 273 |
| 284 /** | 274 /** |
| 285 * The input with a list of [LIBRARY_ELEMENT3]s of exported libraries. | 275 * The input with a list of [LIBRARY_ELEMENT3]s of exported libraries. |
| 286 */ | 276 */ |
| 287 static const String EXPORTS_LIBRARY_ELEMENT_INPUT_NAME = | 277 static const String EXPORTS_LIBRARY_ELEMENT_INPUT_NAME = |
| 288 'EXPORTS_LIBRARY_ELEMENT_INPUT_NAME'; | 278 'EXPORTS_LIBRARY_ELEMENT_INPUT_NAME'; |
| 289 | 279 |
| 290 /** | 280 /** |
| 291 * The input with a list of [SOURCE_KIND]s of imported libraries. | 281 * The input with a list of [SOURCE_KIND]s of imported libraries. |
| 292 */ | 282 */ |
| 293 static const String IMPORTS_SOURCE_KIND_INPUT_NAME = | 283 static const String IMPORTS_SOURCE_KIND_INPUT_NAME = |
| 294 'IMPORTS_SOURCE_KIND_INPUT_NAME'; | 284 'IMPORTS_SOURCE_KIND_INPUT_NAME'; |
| 295 | 285 |
| 296 /** | 286 /** |
| 297 * The input with a list of [SOURCE_KIND]s of exported libraries. | 287 * The input with a list of [SOURCE_KIND]s of exported libraries. |
| 298 */ | 288 */ |
| 299 static const String EXPORTS_SOURCE_KIND_INPUT_NAME = | 289 static const String EXPORTS_SOURCE_KIND_INPUT_NAME = |
| 300 'EXPORTS_SOURCE_KIND_INPUT_NAME'; | 290 'EXPORTS_SOURCE_KIND_INPUT_NAME'; |
| 301 | 291 |
| 302 /** | 292 /** |
| 303 * The task descriptor describing this kind of task. | 293 * The task descriptor describing this kind of task. |
| 304 */ | 294 */ |
| 305 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 295 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 306 'BUILD_RESOLVED_UNIT3', createTask, buildInputs, <ResultDescriptor>[ | 296 'BuildDirectiveElementsTask', createTask, buildInputs, <ResultDescriptor>[ |
| 307 LIBRARY_ELEMENT2, | 297 LIBRARY_ELEMENT2, |
| 308 RESOLVED_UNIT3, | |
| 309 BUILD_DIRECTIVES_ERRORS | 298 BUILD_DIRECTIVES_ERRORS |
| 310 ]); | 299 ]); |
| 311 | 300 |
| 312 BuildDirectiveElementsTask( | 301 BuildDirectiveElementsTask( |
| 313 InternalAnalysisContext context, AnalysisTarget target) | 302 InternalAnalysisContext context, AnalysisTarget target) |
| 314 : super(context, target); | 303 : super(context, target); |
| 315 | 304 |
| 316 @override | 305 @override |
| 317 TaskDescriptor get descriptor => DESCRIPTOR; | 306 TaskDescriptor get descriptor => DESCRIPTOR; |
| 318 | 307 |
| 319 @override | 308 @override |
| 320 void internalPerform() { | 309 void internalPerform() { |
| 321 List<AnalysisError> errors = <AnalysisError>[]; | 310 List<AnalysisError> errors = <AnalysisError>[]; |
| 322 // | 311 // |
| 323 // Prepare inputs. | 312 // Prepare inputs. |
| 324 // | 313 // |
| 325 CompilationUnit libraryUnit = getRequiredInput(RESOLVED_UNIT2_INPUT_NAME); | 314 CompilationUnit libraryUnit = getRequiredInput(UNIT_INPUT_NAME); |
| 326 Map<Source, LibraryElement> importLibraryMap = | 315 Map<Source, LibraryElement> importLibraryMap = |
| 327 getRequiredInput(IMPORTS_LIBRARY_ELEMENT_INPUT_NAME); | 316 getRequiredInput(IMPORTS_LIBRARY_ELEMENT_INPUT_NAME); |
| 328 Map<Source, LibraryElement> exportLibraryMap = | 317 Map<Source, LibraryElement> exportLibraryMap = |
| 329 getRequiredInput(EXPORTS_LIBRARY_ELEMENT_INPUT_NAME); | 318 getRequiredInput(EXPORTS_LIBRARY_ELEMENT_INPUT_NAME); |
| 330 Map<Source, SourceKind> importSourceKindMap = | 319 Map<Source, SourceKind> importSourceKindMap = |
| 331 getRequiredInput(IMPORTS_SOURCE_KIND_INPUT_NAME); | 320 getRequiredInput(IMPORTS_SOURCE_KIND_INPUT_NAME); |
| 332 Map<Source, SourceKind> exportSourceKindMap = | 321 Map<Source, SourceKind> exportSourceKindMap = |
| 333 getRequiredInput(EXPORTS_SOURCE_KIND_INPUT_NAME); | 322 getRequiredInput(EXPORTS_SOURCE_KIND_INPUT_NAME); |
| 334 // | 323 // |
| 335 // Process inputs. | 324 // Process inputs. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 } | 423 } |
| 435 // | 424 // |
| 436 // Populate the library element. | 425 // Populate the library element. |
| 437 // | 426 // |
| 438 libraryElement.imports = imports; | 427 libraryElement.imports = imports; |
| 439 libraryElement.exports = exports; | 428 libraryElement.exports = exports; |
| 440 // | 429 // |
| 441 // Record outputs. | 430 // Record outputs. |
| 442 // | 431 // |
| 443 outputs[LIBRARY_ELEMENT2] = libraryElement; | 432 outputs[LIBRARY_ELEMENT2] = libraryElement; |
| 444 outputs[RESOLVED_UNIT3] = libraryUnit; | |
| 445 outputs[BUILD_DIRECTIVES_ERRORS] = errors; | 433 outputs[BUILD_DIRECTIVES_ERRORS] = errors; |
| 446 } | 434 } |
| 447 | 435 |
| 448 /** | 436 /** |
| 449 * Return a map from the names of the inputs of this kind of task to the task | 437 * Return a map from the names of the inputs of this kind of task to the task |
| 450 * input descriptors describing those inputs for a task with the | 438 * input descriptors describing those inputs for a task with the |
| 451 * given library [source]. | 439 * given library [libSource]. |
| 452 */ | 440 */ |
| 453 static Map<String, TaskInput> buildInputs(Source source) { | 441 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 454 return <String, TaskInput>{ | 442 return <String, TaskInput>{ |
| 455 RESOLVED_UNIT2_INPUT_NAME: RESOLVED_UNIT2.inputFor(source), | 443 'defining_LIBRARY_ELEMENT1': LIBRARY_ELEMENT1.inputFor(libSource), |
| 444 UNIT_INPUT_NAME: | |
| 445 RESOLVED_UNIT1.inputFor(new LibraryUnitTarget(libSource, libSource)), | |
| 456 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME: | 446 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME: |
| 457 new ListToMapTaskInput<Source, LibraryElement>( | 447 new ListToMapTaskInput<Source, LibraryElement>( |
| 458 IMPORTED_LIBRARIES.inputFor(source), | 448 IMPORTED_LIBRARIES.inputFor(libSource), |
| 459 (Source source) => LIBRARY_ELEMENT1.inputFor(source)), | 449 (Source source) => LIBRARY_ELEMENT1.inputFor(source)), |
| 460 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME: | 450 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME: |
| 461 new ListToMapTaskInput<Source, LibraryElement>( | 451 new ListToMapTaskInput<Source, LibraryElement>( |
| 462 EXPORTED_LIBRARIES.inputFor(source), | 452 EXPORTED_LIBRARIES.inputFor(libSource), |
| 463 (Source source) => LIBRARY_ELEMENT1.inputFor(source)), | 453 (Source source) => LIBRARY_ELEMENT1.inputFor(source)), |
| 464 IMPORTS_SOURCE_KIND_INPUT_NAME: | 454 IMPORTS_SOURCE_KIND_INPUT_NAME: |
| 465 new ListToMapTaskInput<Source, SourceKind>( | 455 new ListToMapTaskInput<Source, SourceKind>( |
| 466 IMPORTED_LIBRARIES.inputFor(source), | 456 IMPORTED_LIBRARIES.inputFor(libSource), |
| 467 (Source source) => SOURCE_KIND.inputFor(source)), | 457 (Source source) => SOURCE_KIND.inputFor(source)), |
| 468 EXPORTS_SOURCE_KIND_INPUT_NAME: | 458 EXPORTS_SOURCE_KIND_INPUT_NAME: |
| 469 new ListToMapTaskInput<Source, SourceKind>( | 459 new ListToMapTaskInput<Source, SourceKind>( |
| 470 EXPORTED_LIBRARIES.inputFor(source), | 460 EXPORTED_LIBRARIES.inputFor(libSource), |
| 471 (Source source) => SOURCE_KIND.inputFor(source)) | 461 (Source source) => SOURCE_KIND.inputFor(source)) |
| 472 }; | 462 }; |
| 473 } | 463 } |
| 474 | 464 |
| 475 /** | 465 /** |
| 476 * Create a [BuildDirectiveElementsTask] based on the given [target] in | 466 * Create a [BuildDirectiveElementsTask] based on the given [target] in |
| 477 * the given [context]. | 467 * the given [context]. |
| 478 */ | 468 */ |
| 479 static BuildDirectiveElementsTask createTask( | 469 static BuildDirectiveElementsTask createTask( |
| 480 AnalysisContext context, AnalysisTarget target) { | 470 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 * A task that builds the elements representing the members of enum | 506 * A task that builds the elements representing the members of enum |
| 517 * declarations. | 507 * declarations. |
| 518 */ | 508 */ |
| 519 class BuildEnumMemberElementsTask extends SourceBasedAnalysisTask { | 509 class BuildEnumMemberElementsTask extends SourceBasedAnalysisTask { |
| 520 /** | 510 /** |
| 521 * The name of the [TYPE_PROVIDER] input. | 511 * The name of the [TYPE_PROVIDER] input. |
| 522 */ | 512 */ |
| 523 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 513 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 524 | 514 |
| 525 /** | 515 /** |
| 526 * The name of the [RESOLVED_UNIT3] input. | 516 * The name of the [RESOLVED_UNIT1] input. |
| 527 */ | 517 */ |
| 528 static const String UNIT_INPUT = 'UNIT_INPUT'; | 518 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 529 | 519 |
| 530 /** | 520 /** |
| 531 * The task descriptor describing this kind of task. | 521 * The task descriptor describing this kind of task. |
| 532 */ | 522 */ |
| 533 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 523 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 534 'BuildEnumMemberElementsTask', createTask, buildInputs, | 524 'BuildEnumMemberElementsTask', createTask, buildInputs, |
| 535 <ResultDescriptor>[RESOLVED_UNIT4]); | 525 <ResultDescriptor>[RESOLVED_UNIT2]); |
| 536 | 526 |
| 537 BuildEnumMemberElementsTask( | 527 BuildEnumMemberElementsTask( |
| 538 InternalAnalysisContext context, AnalysisTarget target) | 528 InternalAnalysisContext context, AnalysisTarget target) |
| 539 : super(context, target); | 529 : super(context, target); |
| 540 | 530 |
| 541 @override | 531 @override |
| 542 TaskDescriptor get descriptor => DESCRIPTOR; | 532 TaskDescriptor get descriptor => DESCRIPTOR; |
| 543 | 533 |
| 544 @override | 534 @override |
| 545 void internalPerform() { | 535 void internalPerform() { |
| 546 // | 536 // |
| 547 // Prepare inputs. | 537 // Prepare inputs. |
| 548 // | 538 // |
| 549 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 539 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 550 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 540 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 551 // | 541 // |
| 552 // Record outputs. | 542 // Record outputs. |
| 553 // | 543 // |
| 554 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); | 544 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); |
| 555 unit.accept(builder); | 545 unit.accept(builder); |
| 556 outputs[RESOLVED_UNIT4] = unit; | 546 outputs[RESOLVED_UNIT2] = unit; |
| 557 } | 547 } |
| 558 | 548 |
| 559 /** | 549 /** |
| 560 * Return a map from the names of the inputs of this kind of task to the task | 550 * Return a map from the names of the inputs of this kind of task to the task |
| 561 * input descriptors describing those inputs for a task with the | 551 * input descriptors describing those inputs for a task with the |
| 562 * given [target]. | 552 * given [target]. |
| 563 */ | 553 */ |
| 564 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | 554 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 565 return <String, TaskInput>{ | 555 return <String, TaskInput>{ |
| 566 TYPE_PROVIDER_INPUT: | 556 TYPE_PROVIDER_INPUT: |
| 567 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), | 557 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), |
| 568 UNIT_INPUT: RESOLVED_UNIT3.inputFor(target) | 558 UNIT_INPUT: RESOLVED_UNIT1.inputFor(target) |
| 569 }; | 559 }; |
| 570 } | 560 } |
| 571 | 561 |
| 572 /** | 562 /** |
| 573 * Create a [BuildEnumMemberElementsTask] based on the given [target] in | 563 * Create a [BuildEnumMemberElementsTask] based on the given [target] in |
| 574 * the given [context]. | 564 * the given [context]. |
| 575 */ | 565 */ |
| 576 static BuildEnumMemberElementsTask createTask( | 566 static BuildEnumMemberElementsTask createTask( |
| 577 AnalysisContext context, AnalysisTarget target) { | 567 AnalysisContext context, AnalysisTarget target) { |
| 578 return new BuildEnumMemberElementsTask(context, target); | 568 return new BuildEnumMemberElementsTask(context, target); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 } | 612 } |
| 623 // | 613 // |
| 624 // Record outputs. | 614 // Record outputs. |
| 625 // | 615 // |
| 626 outputs[LIBRARY_ELEMENT4] = library; | 616 outputs[LIBRARY_ELEMENT4] = library; |
| 627 } | 617 } |
| 628 | 618 |
| 629 /** | 619 /** |
| 630 * Return a map from the names of the inputs of this kind of task to the task | 620 * Return a map from the names of the inputs of this kind of task to the task |
| 631 * input descriptors describing those inputs for a task with the | 621 * input descriptors describing those inputs for a task with the |
| 632 * given library [source]. | 622 * given library [libSource]. |
| 633 */ | 623 */ |
| 634 static Map<String, TaskInput> buildInputs(Source source) { | 624 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 635 return <String, TaskInput>{ | 625 return <String, TaskInput>{ |
| 636 LIBRARY_INPUT: LIBRARY_ELEMENT3.inputFor(source), | 626 LIBRARY_INPUT: LIBRARY_ELEMENT3.inputFor(libSource), |
| 637 'exportsLibraryPublicNamespace': | 627 'exportsLibraryPublicNamespace': |
| 638 new ListToMapTaskInput<Source, LibraryElement>( | 628 new ListToMapTaskInput<Source, LibraryElement>( |
| 639 EXPORT_SOURCE_CLOSURE.inputFor(source), | 629 EXPORT_SOURCE_CLOSURE.inputFor(libSource), |
| 640 (Source source) => LIBRARY_ELEMENT3.inputFor(source)) | 630 (Source source) => LIBRARY_ELEMENT3.inputFor(source)) |
| 641 }; | 631 }; |
| 642 } | 632 } |
| 643 | 633 |
| 644 /** | 634 /** |
| 645 * Create a [BuildExportNamespaceTask] based on the given [target] in | 635 * Create a [BuildExportNamespaceTask] based on the given [target] in |
| 646 * the given [context]. | 636 * the given [context]. |
| 647 */ | 637 */ |
| 648 static BuildExportNamespaceTask createTask( | 638 static BuildExportNamespaceTask createTask( |
| 649 AnalysisContext context, AnalysisTarget target) { | 639 AnalysisContext context, AnalysisTarget target) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 List<Source> sources = libraries.map((lib) => lib.source).toList(); | 675 List<Source> sources = libraries.map((lib) => lib.source).toList(); |
| 686 // | 676 // |
| 687 // Record outputs. | 677 // Record outputs. |
| 688 // | 678 // |
| 689 outputs[EXPORT_SOURCE_CLOSURE] = sources; | 679 outputs[EXPORT_SOURCE_CLOSURE] = sources; |
| 690 } | 680 } |
| 691 | 681 |
| 692 /** | 682 /** |
| 693 * Return a map from the names of the inputs of this kind of task to the task | 683 * Return a map from the names of the inputs of this kind of task to the task |
| 694 * input descriptors describing those inputs for a task with the | 684 * input descriptors describing those inputs for a task with the |
| 695 * given library [source]. | 685 * given library [libSource]. |
| 696 */ | 686 */ |
| 697 static Map<String, TaskInput> buildInputs(Source source) { | 687 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 698 return <String, TaskInput>{ | 688 return <String, TaskInput>{ |
| 699 LIBRARY2_ELEMENT_INPUT: LIBRARY_ELEMENT2.inputFor(source) | 689 LIBRARY2_ELEMENT_INPUT: LIBRARY_ELEMENT2.inputFor(libSource) |
| 700 }; | 690 }; |
| 701 } | 691 } |
| 702 | 692 |
| 703 /** | 693 /** |
| 704 * Create a [BuildExportSourceClosureTask] based on the given [target] in | 694 * Create a [BuildExportSourceClosureTask] based on the given [target] in |
| 705 * the given [context]. | 695 * the given [context]. |
| 706 */ | 696 */ |
| 707 static BuildExportSourceClosureTask createTask( | 697 static BuildExportSourceClosureTask createTask( |
| 708 AnalysisContext context, AnalysisTarget target) { | 698 AnalysisContext context, AnalysisTarget target) { |
| 709 return new BuildExportSourceClosureTask(context, target); | 699 return new BuildExportSourceClosureTask(context, target); |
| 710 } | 700 } |
| 711 | 701 |
| 712 /** | 702 /** |
| 713 * Create a set representing the export closure of the given [library]. | 703 * Create a set representing the export closure of the given [library]. |
| 714 */ | 704 */ |
| 715 static void _buildExportClosure( | 705 static void _buildExportClosure( |
| 716 Set<LibraryElement> libraries, LibraryElement library) { | 706 Set<LibraryElement> libraries, LibraryElement library) { |
| 717 if (library != null && libraries.add(library)) { | 707 if (library != null && libraries.add(library)) { |
| 718 for (ExportElement exportElement in library.exports) { | 708 for (ExportElement exportElement in library.exports) { |
| 719 _buildExportClosure(libraries, exportElement.exportedLibrary); | 709 _buildExportClosure(libraries, exportElement.exportedLibrary); |
| 720 } | 710 } |
| 721 } | 711 } |
| 722 } | 712 } |
| 723 } | 713 } |
| 724 | 714 |
| 725 /** | 715 /** |
| 726 * A task that builds [RESOLVED_UNIT5] for a unit. | 716 * A task that builds [RESOLVED_UNIT3] for a unit. |
| 727 */ | 717 */ |
| 728 class BuildFunctionTypeAliasesTask extends SourceBasedAnalysisTask { | 718 class BuildFunctionTypeAliasesTask extends SourceBasedAnalysisTask { |
| 729 /** | 719 /** |
| 730 * The name of the [TYPE_PROVIDER] input. | 720 * The name of the [TYPE_PROVIDER] input. |
| 731 */ | 721 */ |
| 732 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | 722 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; |
| 733 | 723 |
| 734 /** | 724 /** |
| 735 * The name of the [RESOLVED_UNIT3] input. | 725 * The name of the [LIBRARY_ELEMENT4] input. |
| 726 */ | |
| 727 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
| 728 | |
| 729 /** | |
| 730 * The name of the [RESOLVED_UNIT2] input. | |
| 736 */ | 731 */ |
| 737 static const String UNIT_INPUT = 'UNIT_INPUT'; | 732 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 738 | 733 |
| 739 /** | 734 /** |
| 740 * The task descriptor describing this kind of task. | 735 * The task descriptor describing this kind of task. |
| 741 */ | 736 */ |
| 742 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 737 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 743 'BuildFunctionTypeAliasesTask', createTask, buildInputs, | 738 'BuildFunctionTypeAliasesTask', createTask, buildInputs, |
| 744 <ResultDescriptor>[BUILD_FUNCTION_TYPE_ALIASES_ERRORS, RESOLVED_UNIT5]); | 739 <ResultDescriptor>[BUILD_FUNCTION_TYPE_ALIASES_ERRORS, RESOLVED_UNIT3]); |
| 745 | 740 |
| 746 BuildFunctionTypeAliasesTask( | 741 BuildFunctionTypeAliasesTask( |
| 747 InternalAnalysisContext context, AnalysisTarget target) | 742 InternalAnalysisContext context, AnalysisTarget target) |
| 748 : super(context, target); | 743 : super(context, target); |
| 749 | 744 |
| 750 @override | 745 @override |
| 751 TaskDescriptor get descriptor => DESCRIPTOR; | 746 TaskDescriptor get descriptor => DESCRIPTOR; |
| 752 | 747 |
| 753 @override | 748 @override |
| 754 void internalPerform() { | 749 void internalPerform() { |
| 755 RecordingErrorListener errorListener = new RecordingErrorListener(); | 750 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 756 // | 751 // |
| 757 // Prepare inputs. | 752 // Prepare inputs. |
| 758 // | 753 // |
| 759 Source source = getRequiredSource(); | 754 Source source = getRequiredSource(); |
| 760 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | 755 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); |
| 761 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 756 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 762 LibraryElement libraryElement = unit.element.library; | 757 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); |
| 763 // | 758 // |
| 764 // Resolve FunctionTypeAlias declarations. | 759 // Resolve FunctionTypeAlias declarations. |
| 765 // | 760 // |
| 766 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( | 761 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
| 767 libraryElement, source, typeProvider, errorListener); | 762 libraryElement, source, typeProvider, errorListener); |
| 768 for (CompilationUnitMember member in unit.declarations) { | 763 for (CompilationUnitMember member in unit.declarations) { |
| 769 if (member is FunctionTypeAlias) { | 764 if (member is FunctionTypeAlias) { |
| 770 member.accept(visitor); | 765 member.accept(visitor); |
| 771 } | 766 } |
| 772 } | 767 } |
| 773 // | 768 // |
| 774 // Record outputs. | 769 // Record outputs. |
| 775 // | 770 // |
| 776 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errorListener.errors; | 771 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errorListener.errors; |
| 777 outputs[RESOLVED_UNIT5] = unit; | 772 outputs[RESOLVED_UNIT3] = unit; |
| 778 } | 773 } |
| 779 | 774 |
| 780 /** | 775 /** |
| 781 * Return a map from the names of the inputs of this kind of task to the task | 776 * Return a map from the names of the inputs of this kind of task to the task |
| 782 * input descriptors describing those inputs for a task with the | 777 * input descriptors describing those inputs for a task with the |
| 783 * given [target]. | 778 * given [target]. |
| 784 */ | 779 */ |
| 785 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { | 780 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 786 return <String, TaskInput>{ | 781 return <String, TaskInput>{ |
| 787 TYPE_PROVIDER_INPUT: | 782 TYPE_PROVIDER_INPUT: |
| 788 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), | 783 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), |
| 789 'importsExportNamespace': new ListToMapTaskInput<Source, LibraryElement>( | 784 'importsExportNamespace': new ListToMapTaskInput<Source, LibraryElement>( |
| 790 IMPORTED_LIBRARIES.inputFor(target.library), | 785 IMPORTED_LIBRARIES.inputFor(target.library), |
| 791 (Source importSource) => LIBRARY_ELEMENT4.inputFor(importSource)), | 786 (Source importSource) => LIBRARY_ELEMENT4.inputFor(importSource)), |
| 792 UNIT_INPUT: RESOLVED_UNIT4.inputFor(target.unit) | 787 LIBRARY_INPUT: LIBRARY_ELEMENT4.inputFor(target.library), |
| 788 UNIT_INPUT: RESOLVED_UNIT2.inputFor(target) | |
| 793 }; | 789 }; |
| 794 } | 790 } |
| 795 | 791 |
| 796 /** | 792 /** |
| 797 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in | 793 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in |
| 798 * the given [context]. | 794 * the given [context]. |
| 799 */ | 795 */ |
| 800 static BuildFunctionTypeAliasesTask createTask( | 796 static BuildFunctionTypeAliasesTask createTask( |
| 801 AnalysisContext context, AnalysisTarget target) { | 797 AnalysisContext context, AnalysisTarget target) { |
| 802 return new BuildFunctionTypeAliasesTask(context, target); | 798 return new BuildFunctionTypeAliasesTask(context, target); |
| 803 } | 799 } |
| 804 } | 800 } |
| 805 | 801 |
| 806 /** | 802 /** |
| 807 * A task that builds a library element for a Dart library. | 803 * A task that builds a library element for a Dart library. |
| 808 */ | 804 */ |
| 809 class BuildLibraryElementTask extends SourceBasedAnalysisTask { | 805 class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
| 810 /** | 806 /** |
| 811 * The name of the input whose value is the defining [RESOLVED_UNIT1]. | 807 * The name of the input whose value is the defining [RESOLVED_UNIT1]. |
| 812 */ | 808 */ |
| 813 static const String DEFINING_RESOLVER_UNIT1_INPUT_NAME = | 809 static const String DEFINING_UNIT_INPUT = 'DEFINING_UNIT_INPUT'; |
| 814 'DEFINING_RESOLVER_UNIT1_INPUT_NAME'; | |
| 815 | 810 |
| 816 /** | 811 /** |
| 817 * The name of the input whose value is a list of built [RESOLVED_UNIT1]s | 812 * The name of the input whose value is a list of built [RESOLVED_UNIT1]s |
| 818 * of the parts sourced by a library. | 813 * of the parts sourced by a library. |
| 819 */ | 814 */ |
| 820 static const String PARTS_RESOLVED_UNIT1_INPUT_NAME = | 815 static const String PARTS_UNIT_INPUT = 'PARTS_UNIT_INPUT'; |
| 821 'PARTS_RESOLVED_UNIT1_INPUT_NAME'; | |
| 822 | 816 |
| 823 /** | 817 /** |
| 824 * The task descriptor describing this kind of task. | 818 * The task descriptor describing this kind of task. |
| 825 */ | 819 */ |
| 826 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 820 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 827 'BUILD_LIBRARY_ELEMENT', createTask, buildInputs, <ResultDescriptor>[ | 821 'BuildLibraryElementTask', createTask, buildInputs, <ResultDescriptor>[ |
| 828 BUILD_LIBRARY_ERRORS, | 822 BUILD_LIBRARY_ERRORS, |
| 829 RESOLVED_UNIT2, | |
| 830 LIBRARY_ELEMENT1, | 823 LIBRARY_ELEMENT1, |
| 831 IS_LAUNCHABLE, | 824 IS_LAUNCHABLE, |
| 832 HAS_HTML_IMPORT | 825 HAS_HTML_IMPORT |
| 833 ]); | 826 ]); |
| 834 | 827 |
| 835 /** | 828 /** |
| 836 * The constant used as an unknown common library name in parts. | 829 * The constant used as an unknown common library name in parts. |
| 837 */ | 830 */ |
| 838 static const String _UNKNOWN_LIBRARY_NAME = 'unknown-library-name'; | 831 static const String _UNKNOWN_LIBRARY_NAME = 'unknown-library-name'; |
| 839 | 832 |
| 840 /** | 833 /** |
| 841 * Initialize a newly created task to build a library element for the given | 834 * Initialize a newly created task to build a library element for the given |
| 842 * [target] in the given [context]. | 835 * [target] in the given [context]. |
| 843 */ | 836 */ |
| 844 BuildLibraryElementTask( | 837 BuildLibraryElementTask( |
| 845 InternalAnalysisContext context, AnalysisTarget target) | 838 InternalAnalysisContext context, AnalysisTarget target) |
| 846 : super(context, target); | 839 : super(context, target); |
| 847 | 840 |
| 848 @override | 841 @override |
| 849 TaskDescriptor get descriptor => DESCRIPTOR; | 842 TaskDescriptor get descriptor => DESCRIPTOR; |
| 850 | 843 |
| 851 @override | 844 @override |
| 852 void internalPerform() { | 845 void internalPerform() { |
| 853 List<AnalysisError> errors = <AnalysisError>[]; | 846 List<AnalysisError> errors = <AnalysisError>[]; |
| 854 // | 847 // |
| 855 // Prepare inputs. | 848 // Prepare inputs. |
| 856 // | 849 // |
| 857 Source librarySource = getRequiredSource(); | 850 Source librarySource = getRequiredSource(); |
| 858 CompilationUnit definingCompilationUnit = | 851 CompilationUnit definingCompilationUnit = |
| 859 getRequiredInput(DEFINING_RESOLVER_UNIT1_INPUT_NAME); | 852 getRequiredInput(DEFINING_UNIT_INPUT); |
| 860 List<CompilationUnit> partUnits = | 853 List<CompilationUnit> partUnits = getRequiredInput(PARTS_UNIT_INPUT); |
| 861 getRequiredInput(PARTS_RESOLVED_UNIT1_INPUT_NAME); | |
| 862 // | 854 // |
| 863 // Process inputs. | 855 // Process inputs. |
| 864 // | 856 // |
| 865 CompilationUnitElementImpl definingCompilationUnitElement = | 857 CompilationUnitElementImpl definingCompilationUnitElement = |
| 866 definingCompilationUnit.element; | 858 definingCompilationUnit.element; |
| 867 Map<Source, CompilationUnit> partUnitMap = | 859 Map<Source, CompilationUnit> partUnitMap = |
| 868 new HashMap<Source, CompilationUnit>(); | 860 new HashMap<Source, CompilationUnit>(); |
| 869 for (CompilationUnit partUnit in partUnits) { | 861 for (CompilationUnit partUnit in partUnits) { |
| 870 Source partSource = partUnit.element.source; | 862 Source partSource = partUnit.element.source; |
| 871 partUnitMap[partSource] = partUnit; | 863 partUnitMap[partSource] = partUnit; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 for (Directive directive in directivesToResolve) { | 949 for (Directive directive in directivesToResolve) { |
| 958 directive.element = libraryElement; | 950 directive.element = libraryElement; |
| 959 } | 951 } |
| 960 if (sourcedCompilationUnits.isNotEmpty) { | 952 if (sourcedCompilationUnits.isNotEmpty) { |
| 961 _patchTopLevelAccessors(libraryElement); | 953 _patchTopLevelAccessors(libraryElement); |
| 962 } | 954 } |
| 963 // | 955 // |
| 964 // Record outputs. | 956 // Record outputs. |
| 965 // | 957 // |
| 966 outputs[BUILD_LIBRARY_ERRORS] = errors; | 958 outputs[BUILD_LIBRARY_ERRORS] = errors; |
| 967 outputs[RESOLVED_UNIT2] = definingCompilationUnit; | |
| 968 outputs[LIBRARY_ELEMENT1] = libraryElement; | 959 outputs[LIBRARY_ELEMENT1] = libraryElement; |
| 969 outputs[IS_LAUNCHABLE] = entryPoint != null; | 960 outputs[IS_LAUNCHABLE] = entryPoint != null; |
| 970 outputs[HAS_HTML_IMPORT] = hasHtmlImport; | 961 outputs[HAS_HTML_IMPORT] = hasHtmlImport; |
| 971 } | 962 } |
| 972 | 963 |
| 973 /** | 964 /** |
| 974 * Add all of the non-synthetic [getters] and [setters] defined in the given | 965 * Add all of the non-synthetic [getters] and [setters] defined in the given |
| 975 * [unit] that have no corresponding accessor to one of the given collections. | 966 * [unit] that have no corresponding accessor to one of the given collections. |
| 976 */ | 967 */ |
| 977 void _collectAccessors(Map<String, PropertyAccessorElement> getters, | 968 void _collectAccessors(Map<String, PropertyAccessorElement> getters, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1043 setterUnit.replaceTopLevelVariable(setterVariable, variable); | 1034 setterUnit.replaceTopLevelVariable(setterVariable, variable); |
| 1044 variable.setter = setter; | 1035 variable.setter = setter; |
| 1045 setter.variable = variable; | 1036 setter.variable = variable; |
| 1046 } | 1037 } |
| 1047 } | 1038 } |
| 1048 } | 1039 } |
| 1049 | 1040 |
| 1050 /** | 1041 /** |
| 1051 * Return a map from the names of the inputs of this kind of task to the task | 1042 * Return a map from the names of the inputs of this kind of task to the task |
| 1052 * input descriptors describing those inputs for a task with the given | 1043 * input descriptors describing those inputs for a task with the given |
| 1053 * [librarySource]. | 1044 * [libSource]. |
| 1054 */ | 1045 */ |
| 1055 static Map<String, TaskInput> buildInputs(Source librarySource) { | 1046 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 1056 return <String, TaskInput>{ | 1047 return <String, TaskInput>{ |
| 1057 DEFINING_RESOLVER_UNIT1_INPUT_NAME: RESOLVED_UNIT1 | 1048 DEFINING_UNIT_INPUT: |
| 1058 .inputFor(new LibraryUnitTarget(librarySource, librarySource)), | 1049 RESOLVED_UNIT1.inputFor(new LibraryUnitTarget(libSource, libSource)), |
| 1059 PARTS_RESOLVED_UNIT1_INPUT_NAME: | 1050 PARTS_UNIT_INPUT: new ListToListTaskInput<Source, CompilationUnit>( |
| 1060 new ListToListTaskInput<Source, CompilationUnit>( | 1051 INCLUDED_PARTS.inputFor(libSource), (Source source) => |
| 1061 INCLUDED_PARTS.inputFor(librarySource), | 1052 RESOLVED_UNIT1.inputFor(new LibraryUnitTarget(libSource, source))) |
| 1062 (Source source) => RESOLVED_UNIT1 | |
| 1063 .inputFor(new LibraryUnitTarget(librarySource, source))) | |
| 1064 }; | 1053 }; |
| 1065 } | 1054 } |
| 1066 | 1055 |
| 1067 /** | 1056 /** |
| 1068 * Create a [BuildLibraryElementTask] based on the given [target] in the | 1057 * Create a [BuildLibraryElementTask] based on the given [target] in the |
| 1069 * given [context]. | 1058 * given [context]. |
| 1070 */ | 1059 */ |
| 1071 static BuildLibraryElementTask createTask( | 1060 static BuildLibraryElementTask createTask( |
| 1072 AnalysisContext context, AnalysisTarget target) { | 1061 AnalysisContext context, AnalysisTarget target) { |
| 1073 return new BuildLibraryElementTask(context, target); | 1062 return new BuildLibraryElementTask(context, target); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1100 @override | 1089 @override |
| 1101 void internalPerform() { | 1090 void internalPerform() { |
| 1102 LibraryElementImpl library = getRequiredInput(LIBRARY_INPUT); | 1091 LibraryElementImpl library = getRequiredInput(LIBRARY_INPUT); |
| 1103 library.publicNamespace = new PublicNamespaceBuilder().build(library); | 1092 library.publicNamespace = new PublicNamespaceBuilder().build(library); |
| 1104 outputs[LIBRARY_ELEMENT3] = library; | 1093 outputs[LIBRARY_ELEMENT3] = library; |
| 1105 } | 1094 } |
| 1106 | 1095 |
| 1107 /** | 1096 /** |
| 1108 * Return a map from the names of the inputs of this kind of task to the task | 1097 * Return a map from the names of the inputs of this kind of task to the task |
| 1109 * input descriptors describing those inputs for a task with the | 1098 * input descriptors describing those inputs for a task with the |
| 1110 * given library [source]. | 1099 * given library [libSource]. |
| 1111 */ | 1100 */ |
| 1112 static Map<String, TaskInput> buildInputs(Source source) { | 1101 static Map<String, TaskInput> buildInputs(Source libSource) { |
| 1113 return <String, TaskInput>{ | 1102 return <String, TaskInput>{ |
| 1114 LIBRARY_INPUT: LIBRARY_ELEMENT2.inputFor(source) | 1103 LIBRARY_INPUT: LIBRARY_ELEMENT2.inputFor(libSource) |
| 1115 }; | 1104 }; |
| 1116 } | 1105 } |
| 1117 | 1106 |
| 1118 /** | 1107 /** |
| 1119 * Create a [BuildPublicNamespaceTask] based on the given [target] in | 1108 * Create a [BuildPublicNamespaceTask] based on the given [target] in |
| 1120 * the given [context]. | 1109 * the given [context]. |
| 1121 */ | 1110 */ |
| 1122 static BuildPublicNamespaceTask createTask( | 1111 static BuildPublicNamespaceTask createTask( |
| 1123 AnalysisContext context, AnalysisTarget target) { | 1112 AnalysisContext context, AnalysisTarget target) { |
| 1124 return new BuildPublicNamespaceTask(context, target); | 1113 return new BuildPublicNamespaceTask(context, target); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1326 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; | 1315 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; |
| 1327 | 1316 |
| 1328 /** | 1317 /** |
| 1329 * The name of the input whose value is the token stream produced for the file . | 1318 * The name of the input whose value is the token stream produced for the file . |
| 1330 */ | 1319 */ |
| 1331 static const String TOKEN_STREAM_INPUT_NAME = 'TOKEN_STREAM_INPUT_NAME'; | 1320 static const String TOKEN_STREAM_INPUT_NAME = 'TOKEN_STREAM_INPUT_NAME'; |
| 1332 | 1321 |
| 1333 /** | 1322 /** |
| 1334 * The task descriptor describing this kind of task. | 1323 * The task descriptor describing this kind of task. |
| 1335 */ | 1324 */ |
| 1336 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('PARSE_DART', | 1325 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('ParseDartTask', |
| 1337 createTask, buildInputs, <ResultDescriptor>[ | 1326 createTask, buildInputs, <ResultDescriptor>[ |
| 1338 EXPORTED_LIBRARIES, | 1327 EXPORTED_LIBRARIES, |
| 1339 IMPORTED_LIBRARIES, | 1328 IMPORTED_LIBRARIES, |
| 1340 INCLUDED_PARTS, | 1329 INCLUDED_PARTS, |
| 1341 PARSE_ERRORS, | 1330 PARSE_ERRORS, |
| 1342 PARSED_UNIT, | 1331 PARSED_UNIT, |
| 1343 SOURCE_KIND | 1332 SOURCE_KIND |
| 1344 ]); | 1333 ]); |
| 1345 | 1334 |
| 1346 /** | 1335 /** |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1515 void _addPublicNames(CompilationUnitElement compilationUnit) { | 1504 void _addPublicNames(CompilationUnitElement compilationUnit) { |
| 1516 compilationUnit.accessors.forEach(_addIfPublic); | 1505 compilationUnit.accessors.forEach(_addIfPublic); |
| 1517 compilationUnit.enums.forEach(_addIfPublic); | 1506 compilationUnit.enums.forEach(_addIfPublic); |
| 1518 compilationUnit.functions.forEach(_addIfPublic); | 1507 compilationUnit.functions.forEach(_addIfPublic); |
| 1519 compilationUnit.functionTypeAliases.forEach(_addIfPublic); | 1508 compilationUnit.functionTypeAliases.forEach(_addIfPublic); |
| 1520 compilationUnit.types.forEach(_addIfPublic); | 1509 compilationUnit.types.forEach(_addIfPublic); |
| 1521 } | 1510 } |
| 1522 } | 1511 } |
| 1523 | 1512 |
| 1524 /** | 1513 /** |
| 1525 * A task that builds [RESOLVED_UNIT6] for a unit. | 1514 * An artifitial task that does nothing exept of forcing type names resolution |
|
Brian Wilkerson
2015/03/20 21:57:41
"exept of forcing type names" --> "except to force
| |
| 1515 * for the defining and part units of a library. | |
| 1526 */ | 1516 */ |
| 1527 class ResolveTypeNamesTask extends SourceBasedAnalysisTask { | 1517 class ResolveLibraryTypeNamesTask extends SourceBasedAnalysisTask { |
| 1528 /** | 1518 /** |
| 1529 * The name of the [RESOLVED_UNIT5] input. | 1519 * The name of the [LIBRARY_ELEMENT4] input. |
| 1520 */ | |
| 1521 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; | |
| 1522 | |
| 1523 /** | |
| 1524 * The task descriptor describing this kind of task. | |
| 1525 */ | |
| 1526 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 1527 'ResolveLibraryTypeNamesTask', createTask, buildInputs, | |
| 1528 <ResultDescriptor>[LIBRARY_ELEMENT5]); | |
| 1529 | |
| 1530 ResolveLibraryTypeNamesTask( | |
| 1531 InternalAnalysisContext context, AnalysisTarget target) | |
| 1532 : super(context, target); | |
| 1533 | |
| 1534 @override | |
| 1535 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 1536 | |
| 1537 @override | |
| 1538 void internalPerform() { | |
| 1539 LibraryElement library = getRequiredInput(LIBRARY_INPUT); | |
| 1540 outputs[LIBRARY_ELEMENT5] = library; | |
| 1541 } | |
| 1542 | |
| 1543 /** | |
| 1544 * Return a map from the names of the inputs of this kind of task to the task | |
| 1545 * input descriptors describing those inputs for a task with the | |
| 1546 * given [target]. | |
| 1547 */ | |
| 1548 static Map<String, TaskInput> buildInputs(Source libSource) { | |
| 1549 return <String, TaskInput>{ | |
| 1550 LIBRARY_INPUT: LIBRARY_ELEMENT4.inputFor(libSource), | |
| 1551 'resolvedDefiningUnit': | |
| 1552 RESOLVED_UNIT4.inputFor(new LibraryUnitTarget(libSource, libSource)), | |
| 1553 'resolvedPartsUnit': new ListToMapTaskInput<Source, CompilationUnit>( | |
| 1554 INCLUDED_PARTS.inputFor(libSource), (Source source) => RESOLVED_UNIT4 | |
| 1555 .inputFor(new LibraryUnitTarget(libSource, source))), | |
| 1556 }; | |
| 1557 } | |
| 1558 | |
| 1559 /** | |
| 1560 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in | |
| 1561 * the given [context]. | |
| 1562 */ | |
| 1563 static ResolveLibraryTypeNamesTask createTask( | |
| 1564 AnalysisContext context, AnalysisTarget target) { | |
| 1565 return new ResolveLibraryTypeNamesTask(context, target); | |
| 1566 } | |
| 1567 } | |
| 1568 | |
| 1569 /** | |
| 1570 * A task that builds [RESOLVED_UNIT4] for a unit. | |
| 1571 */ | |
| 1572 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { | |
| 1573 /** | |
| 1574 * The name of the [RESOLVED_UNIT3] input. | |
| 1530 */ | 1575 */ |
| 1531 static const String UNIT_INPUT = 'UNIT_INPUT'; | 1576 static const String UNIT_INPUT = 'UNIT_INPUT'; |
| 1532 | 1577 |
| 1533 /** | 1578 /** |
| 1534 * The task descriptor describing this kind of task. | 1579 * The task descriptor describing this kind of task. |
| 1535 */ | 1580 */ |
| 1536 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 1581 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 1537 'ResolveTypeNamesTask', createTask, buildInputs, <ResultDescriptor>[ | 1582 'ResolveUnitTypeNamesTask', createTask, buildInputs, <ResultDescriptor>[ |
| 1538 RESOLVE_TYPE_NAMES_ERRORS, | 1583 RESOLVE_TYPE_NAMES_ERRORS, |
| 1539 RESOLVED_UNIT6 | 1584 RESOLVED_UNIT4 |
| 1540 ]); | 1585 ]); |
| 1541 | 1586 |
| 1542 ResolveTypeNamesTask(InternalAnalysisContext context, AnalysisTarget target) | 1587 ResolveUnitTypeNamesTask( |
| 1588 InternalAnalysisContext context, AnalysisTarget target) | |
| 1543 : super(context, target); | 1589 : super(context, target); |
| 1544 | 1590 |
| 1545 @override | 1591 @override |
| 1546 TaskDescriptor get descriptor => DESCRIPTOR; | 1592 TaskDescriptor get descriptor => DESCRIPTOR; |
| 1547 | 1593 |
| 1548 @override | 1594 @override |
| 1549 void internalPerform() { | 1595 void internalPerform() { |
| 1550 RecordingErrorListener errorListener = new RecordingErrorListener(); | 1596 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1551 // | 1597 // |
| 1552 // Prepare inputs. | 1598 // Prepare inputs. |
| 1553 // | 1599 // |
| 1554 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | 1600 CompilationUnit unit = getRequiredInput(UNIT_INPUT); |
| 1555 CompilationUnitElement unitElement = unit.element; | 1601 CompilationUnitElement unitElement = unit.element; |
| 1556 // | 1602 // |
| 1557 // Resolve TypeName nodes. | 1603 // Resolve TypeName nodes. |
| 1558 // | 1604 // |
| 1559 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( | 1605 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( |
| 1560 unitElement.library, unitElement.source, context.typeProvider, | 1606 unitElement.library, unitElement.source, context.typeProvider, |
| 1561 errorListener); | 1607 errorListener); |
| 1562 unit.accept(visitor); | 1608 unit.accept(visitor); |
| 1563 // | 1609 // |
| 1564 // Record outputs. | 1610 // Record outputs. |
| 1565 // | 1611 // |
| 1566 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; | 1612 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; |
| 1567 outputs[RESOLVED_UNIT6] = unit; | 1613 outputs[RESOLVED_UNIT4] = unit; |
| 1568 } | 1614 } |
| 1569 | 1615 |
| 1570 /** | 1616 /** |
| 1571 * Return a map from the names of the inputs of this kind of task to the task | 1617 * Return a map from the names of the inputs of this kind of task to the task |
| 1572 * input descriptors describing those inputs for a task with the | 1618 * input descriptors describing those inputs for a task with the |
| 1573 * given [target]. | 1619 * given [target]. |
| 1574 */ | 1620 */ |
| 1575 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { | 1621 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { |
| 1576 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT5.inputFor(target)}; | 1622 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT3.inputFor(target)}; |
| 1577 } | 1623 } |
| 1578 | 1624 |
| 1579 /** | 1625 /** |
| 1580 * Create a [ResolveTypeNamesTask] based on the given [target] in | 1626 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in |
| 1581 * the given [context]. | 1627 * the given [context]. |
| 1582 */ | 1628 */ |
| 1583 static ResolveTypeNamesTask createTask( | 1629 static ResolveUnitTypeNamesTask createTask( |
| 1584 AnalysisContext context, AnalysisTarget target) { | 1630 AnalysisContext context, AnalysisTarget target) { |
| 1585 return new ResolveTypeNamesTask(context, target); | 1631 return new ResolveUnitTypeNamesTask(context, target); |
| 1586 } | 1632 } |
| 1587 } | 1633 } |
| 1588 | 1634 |
| 1589 /** | 1635 /** |
| 1590 * A task that scans the content of a file, producing a set of Dart tokens. | 1636 * A task that scans the content of a file, producing a set of Dart tokens. |
| 1591 */ | 1637 */ |
| 1592 class ScanDartTask extends SourceBasedAnalysisTask { | 1638 class ScanDartTask extends SourceBasedAnalysisTask { |
| 1593 /** | 1639 /** |
| 1594 * The name of the input whose value is the content of the file. | 1640 * The name of the input whose value is the content of the file. |
| 1595 */ | 1641 */ |
| 1596 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; | 1642 static const String CONTENT_INPUT_NAME = 'CONTENT_INPUT_NAME'; |
| 1597 | 1643 |
| 1598 /** | 1644 /** |
| 1599 * The task descriptor describing this kind of task. | 1645 * The task descriptor describing this kind of task. |
| 1600 */ | 1646 */ |
| 1601 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('SCAN_DART', | 1647 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('ScanDartTask', |
| 1602 createTask, buildInputs, <ResultDescriptor>[ | 1648 createTask, buildInputs, <ResultDescriptor>[ |
| 1603 LINE_INFO, | 1649 LINE_INFO, |
| 1604 SCAN_ERRORS, | 1650 SCAN_ERRORS, |
| 1605 TOKEN_STREAM | 1651 TOKEN_STREAM |
| 1606 ]); | 1652 ]); |
| 1607 | 1653 |
| 1608 /** | 1654 /** |
| 1609 * Initialize a newly created task to access the content of the source | 1655 * Initialize a newly created task to access the content of the source |
| 1610 * associated with the given [target] in the given [context]. | 1656 * associated with the given [target] in the given [context]. |
| 1611 */ | 1657 */ |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1639 } | 1685 } |
| 1640 | 1686 |
| 1641 /** | 1687 /** |
| 1642 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 1688 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 1643 */ | 1689 */ |
| 1644 static ScanDartTask createTask( | 1690 static ScanDartTask createTask( |
| 1645 AnalysisContext context, AnalysisTarget target) { | 1691 AnalysisContext context, AnalysisTarget target) { |
| 1646 return new ScanDartTask(context, target); | 1692 return new ScanDartTask(context, target); |
| 1647 } | 1693 } |
| 1648 } | 1694 } |
| OLD | NEW |