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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 * The partially resolved [CompilationUnit] associated with a library. | 82 * The partially resolved [CompilationUnit] associated with a library. |
| 83 * | 83 * |
| 84 * All the directives are resolved. | 84 * All the directives are resolved. |
| 85 * | 85 * |
| 86 * The result is only available for targets representing a library. | 86 * The result is only available for targets representing a library. |
| 87 */ | 87 */ |
| 88 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = | 88 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = |
| 89 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); | 89 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * The partially resolved [CompilationUnit] associated with a unit. | |
| 93 * | |
| 94 * All the enum member elements are built. | |
| 95 * | |
| 96 * The result is only available for targets representing a unit. | |
| 97 */ | |
| 98 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = | |
| 99 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); | |
| 100 | |
| 101 /** | |
| 92 * The [TypeProvider] of the context. | 102 * The [TypeProvider] of the context. |
| 93 */ | 103 */ |
| 94 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = | 104 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = |
| 95 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); | 105 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); |
| 96 | 106 |
| 97 /** | 107 /** |
| 98 * A task that builds a compilation unit element for a single compilation unit. | 108 * A task that builds a compilation unit element for a single compilation unit. |
| 99 */ | 109 */ |
| 100 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { | 110 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { |
| 101 /** | 111 /** |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 | 416 |
| 407 /** | 417 /** |
| 408 * Return the lexical identifiers associated with the given [identifiers]. | 418 * Return the lexical identifiers associated with the given [identifiers]. |
| 409 */ | 419 */ |
| 410 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 420 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { |
| 411 return identifiers.map((identifier) => identifier.name).toList(); | 421 return identifiers.map((identifier) => identifier.name).toList(); |
| 412 } | 422 } |
| 413 } | 423 } |
| 414 | 424 |
| 415 /** | 425 /** |
| 426 * A task that builds [RESOLVED_UNIT4]. | |
|
Brian Wilkerson
2015/03/14 14:45:14
How about:
A task that builds the elements repres
| |
| 427 */ | |
| 428 class BuildEnumMemberElementsTask extends SourceBasedAnalysisTask { | |
| 429 /** | |
| 430 * The name of the [TYPE_PROVIDER] input. | |
| 431 */ | |
| 432 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT'; | |
| 433 | |
| 434 /** | |
| 435 * The name of the [RESOLVED_UNIT3] input. | |
| 436 */ | |
| 437 static const String UNIT_INPUT = 'UNIT_INPUT'; | |
| 438 | |
| 439 /** | |
| 440 * The task descriptor describing this kind of task. | |
| 441 */ | |
| 442 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | |
| 443 'BuildEnumMemberElementsTask', createTask, buildInputs, | |
| 444 <ResultDescriptor>[RESOLVED_UNIT4]); | |
| 445 | |
| 446 BuildEnumMemberElementsTask( | |
| 447 InternalAnalysisContext context, AnalysisTarget target) | |
| 448 : super(context, target); | |
| 449 | |
| 450 @override | |
| 451 TaskDescriptor get descriptor => DESCRIPTOR; | |
| 452 | |
| 453 @override | |
| 454 void internalPerform() { | |
| 455 // | |
| 456 // Prepare inputs. | |
| 457 // | |
| 458 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT); | |
| 459 CompilationUnit unit = getRequiredInput(UNIT_INPUT); | |
| 460 // | |
| 461 // Record outputs. | |
| 462 // | |
| 463 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); | |
| 464 unit.accept(builder); | |
| 465 outputs[RESOLVED_UNIT4] = unit; | |
| 466 } | |
| 467 | |
| 468 /** | |
| 469 * Return a map from the names of the inputs of this kind of task to the task | |
| 470 * input descriptors describing those inputs for a task with the | |
| 471 * given [target]. | |
| 472 */ | |
| 473 static Map<String, TaskInput> buildInputs(AnalysisTarget target) { | |
| 474 return <String, TaskInput>{ | |
| 475 TYPE_PROVIDER_INPUT: | |
| 476 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), | |
| 477 UNIT_INPUT: RESOLVED_UNIT3.inputFor(target) | |
| 478 }; | |
| 479 } | |
| 480 | |
| 481 /** | |
| 482 * Create a [BuildEnumMemberElementsTask] based on the given [target] in | |
| 483 * the given [context]. | |
| 484 */ | |
| 485 static BuildEnumMemberElementsTask createTask( | |
| 486 AnalysisContext context, AnalysisTarget target) { | |
| 487 return new BuildEnumMemberElementsTask(context, target); | |
| 488 } | |
| 489 } | |
| 490 | |
| 491 /** | |
| 416 * A task that builds a library element for a Dart library. | 492 * A task that builds a library element for a Dart library. |
| 417 */ | 493 */ |
| 418 class BuildLibraryElementTask extends SourceBasedAnalysisTask { | 494 class BuildLibraryElementTask extends SourceBasedAnalysisTask { |
| 419 /** | 495 /** |
| 420 * The name of the input whose value is the defining [RESOLVED_UNIT1]. | 496 * The name of the input whose value is the defining [RESOLVED_UNIT1]. |
| 421 */ | 497 */ |
| 422 static const String DEFINING_RESOLVER_UNIT1_INPUT_NAME = | 498 static const String DEFINING_RESOLVER_UNIT1_INPUT_NAME = |
| 423 'DEFINING_RESOLVER_UNIT1_INPUT_NAME'; | 499 'DEFINING_RESOLVER_UNIT1_INPUT_NAME'; |
| 424 | 500 |
| 425 /** | 501 /** |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1000 } | 1076 } |
| 1001 | 1077 |
| 1002 /** | 1078 /** |
| 1003 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 1079 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 1004 */ | 1080 */ |
| 1005 static ScanDartTask createTask( | 1081 static ScanDartTask createTask( |
| 1006 AnalysisContext context, AnalysisTarget target) { | 1082 AnalysisContext context, AnalysisTarget target) { |
| 1007 return new ScanDartTask(context, target); | 1083 return new ScanDartTask(context, target); |
| 1008 } | 1084 } |
| 1009 } | 1085 } |
| OLD | NEW |