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

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

Issue 1005693007: Add toMap / toMapOf / toList (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months 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 | Annotate | Revision Log
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/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';
11 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 11 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
12 import 'package:analyzer/src/generated/error.dart'; 12 import 'package:analyzer/src/generated/error.dart';
13 import 'package:analyzer/src/generated/java_engine.dart'; 13 import 'package:analyzer/src/generated/java_engine.dart';
14 import 'package:analyzer/src/generated/parser.dart'; 14 import 'package:analyzer/src/generated/parser.dart';
15 import 'package:analyzer/src/generated/resolver.dart'; 15 import 'package:analyzer/src/generated/resolver.dart';
16 import 'package:analyzer/src/generated/scanner.dart'; 16 import 'package:analyzer/src/generated/scanner.dart';
17 import 'package:analyzer/src/generated/sdk.dart'; 17 import 'package:analyzer/src/generated/sdk.dart';
18 import 'package:analyzer/src/generated/source.dart'; 18 import 'package:analyzer/src/generated/source.dart';
19 import 'package:analyzer/src/generated/utilities_general.dart'; 19 import 'package:analyzer/src/generated/utilities_general.dart';
20 import 'package:analyzer/src/task/driver.dart'; 20 import 'package:analyzer/src/task/driver.dart';
21 import 'package:analyzer/src/task/general.dart'; 21 import 'package:analyzer/src/task/general.dart';
22 import 'package:analyzer/src/task/inputs.dart';
23 import 'package:analyzer/task/dart.dart'; 22 import 'package:analyzer/task/dart.dart';
24 import 'package:analyzer/task/general.dart'; 23 import 'package:analyzer/task/general.dart';
25 import 'package:analyzer/task/model.dart'; 24 import 'package:analyzer/task/model.dart';
26 25
27 /** 26 /**
28 * The errors produced while resolving a library directives. 27 * The errors produced while resolving a library directives.
29 * 28 *
30 * The list will be empty if there were no errors, but will not be `null`. 29 * The list will be empty if there were no errors, but will not be `null`.
31 * 30 *
32 * The result is only available for targets representing a Dart library. 31 * The result is only available for targets representing a Dart library.
(...skipping 25 matching lines...) Expand all
58 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS = 57 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS =
59 new ResultDescriptor<List<AnalysisError>>( 58 new ResultDescriptor<List<AnalysisError>>(
60 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS, 59 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS,
61 contributesTo: DART_ERRORS); 60 contributesTo: DART_ERRORS);
62 61
63 /** 62 /**
64 * The sources representing the export closure of a library. 63 * The sources representing the export closure of a library.
65 * 64 *
66 * The result is only available for targets representing a Dart library. 65 * The result is only available for targets representing a Dart library.
67 */ 66 */
68 final ResultDescriptor<List<Source>> EXPORT_SOURCE_CLOSURE = 67 final ListResultDescriptor<Source> EXPORT_SOURCE_CLOSURE =
69 new ResultDescriptor<List<Source>>('EXPORT_SOURCE_CLOSURE', null); 68 new ListResultDescriptor<Source>('EXPORT_SOURCE_CLOSURE', null);
70 69
71 /** 70 /**
72 * The partial [LibraryElement] associated with a library. 71 * The partial [LibraryElement] associated with a library.
73 * 72 *
74 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each 73 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each
75 * other. Directives 'library', 'part' and 'part of' are resolved. 74 * other. Directives 'library', 'part' and 'part of' are resolved.
76 * 75 *
77 * The result is only available for targets representing a Dart library. 76 * The result is only available for targets representing a Dart library.
78 */ 77 */
79 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 = 78 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = 175 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 =
177 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); 176 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null);
178 177
179 /** 178 /**
180 * The [TypeProvider] of the context. 179 * The [TypeProvider] of the context.
181 */ 180 */
182 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = 181 final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
183 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); 182 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null);
184 183
185 /** 184 /**
185 * Return a [MapTaskInput] that maps unit [Source]s into [result]s for the
186 * pair of [libSource] and the unit [Source].
187 */
188 MapTaskInput _lutMapInput(Source libSource, ResultDescriptor result) {
Brian Wilkerson 2015/03/24 15:07:10 I'd really prefer a name that didn't include an ab
scheglov 2015/03/24 17:16:38 Done.
189 return (Source unitSource) {
190 LibraryUnitTarget lut = new LibraryUnitTarget(libSource, unitSource);
191 return result.of(lut);
192 };
193 }
194
195 /**
186 * A task that builds a compilation unit element for a single compilation unit. 196 * A task that builds a compilation unit element for a single compilation unit.
187 */ 197 */
188 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { 198 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask {
189 /** 199 /**
190 * The name of the input whose value is the line information for the 200 * The name of the input whose value is the line information for the
191 * compilation unit. 201 * compilation unit.
192 */ 202 */
193 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; 203 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME';
194 204
195 /** 205 /**
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 outputs[RESOLVED_UNIT1] = unit; 245 outputs[RESOLVED_UNIT1] = unit;
236 } 246 }
237 247
238 /** 248 /**
239 * Return a map from the names of the inputs of this kind of task to the task 249 * Return a map from the names of the inputs of this kind of task to the task
240 * input descriptors describing those inputs for a task with the given 250 * input descriptors describing those inputs for a task with the given
241 * [target]. 251 * [target].
242 */ 252 */
243 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 253 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) {
244 return <String, TaskInput>{ 254 return <String, TaskInput>{
245 PARSED_UNIT_INPUT_NAME: PARSED_UNIT.inputFor(target.unit) 255 PARSED_UNIT_INPUT_NAME: PARSED_UNIT.of(target.unit)
246 }; 256 };
247 } 257 }
248 258
249 /** 259 /**
250 * Create a [BuildCompilationUnitElementTask] based on the given [target] in 260 * Create a [BuildCompilationUnitElementTask] based on the given [target] in
251 * the given [context]. 261 * the given [context].
252 */ 262 */
253 static BuildCompilationUnitElementTask createTask( 263 static BuildCompilationUnitElementTask createTask(
254 AnalysisContext context, AnalysisTarget target) { 264 AnalysisContext context, AnalysisTarget target) {
255 return new BuildCompilationUnitElementTask(context, target); 265 return new BuildCompilationUnitElementTask(context, target);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 outputs[LIBRARY_ELEMENT2] = libraryElement; 442 outputs[LIBRARY_ELEMENT2] = libraryElement;
433 outputs[BUILD_DIRECTIVES_ERRORS] = errors; 443 outputs[BUILD_DIRECTIVES_ERRORS] = errors;
434 } 444 }
435 445
436 /** 446 /**
437 * Return a map from the names of the inputs of this kind of task to the task 447 * Return a map from the names of the inputs of this kind of task to the task
438 * input descriptors describing those inputs for a task with the 448 * input descriptors describing those inputs for a task with the
439 * given library [libSource]. 449 * given library [libSource].
440 */ 450 */
441 static Map<String, TaskInput> buildInputs(Source libSource) { 451 static Map<String, TaskInput> buildInputs(Source libSource) {
452 lut(Source unit) => new LibraryUnitTarget(libSource, unit);
Brian Wilkerson 2015/03/24 15:07:10 I don't understand the point of defining a local m
scheglov 2015/03/24 17:16:38 Done.
442 return <String, TaskInput>{ 453 return <String, TaskInput>{
443 'defining_LIBRARY_ELEMENT1': LIBRARY_ELEMENT1.inputFor(libSource), 454 'defining_LIBRARY_ELEMENT1': LIBRARY_ELEMENT1.of(libSource),
444 UNIT_INPUT_NAME: 455 UNIT_INPUT_NAME: RESOLVED_UNIT1.of(lut(libSource)),
445 RESOLVED_UNIT1.inputFor(new LibraryUnitTarget(libSource, libSource)),
446 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME: 456 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME:
447 new ListToMapTaskInput<Source, LibraryElement>( 457 IMPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1),
448 IMPORTED_LIBRARIES.inputFor(libSource),
449 (Source source) => LIBRARY_ELEMENT1.inputFor(source)),
450 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME: 458 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME:
451 new ListToMapTaskInput<Source, LibraryElement>( 459 EXPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1),
452 EXPORTED_LIBRARIES.inputFor(libSource),
453 (Source source) => LIBRARY_ELEMENT1.inputFor(source)),
454 IMPORTS_SOURCE_KIND_INPUT_NAME: 460 IMPORTS_SOURCE_KIND_INPUT_NAME:
455 new ListToMapTaskInput<Source, SourceKind>( 461 IMPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND),
456 IMPORTED_LIBRARIES.inputFor(libSource),
457 (Source source) => SOURCE_KIND.inputFor(source)),
458 EXPORTS_SOURCE_KIND_INPUT_NAME: 462 EXPORTS_SOURCE_KIND_INPUT_NAME:
459 new ListToMapTaskInput<Source, SourceKind>( 463 EXPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND)
460 EXPORTED_LIBRARIES.inputFor(libSource),
461 (Source source) => SOURCE_KIND.inputFor(source))
462 }; 464 };
463 } 465 }
464 466
465 /** 467 /**
466 * Create a [BuildDirectiveElementsTask] based on the given [target] in 468 * Create a [BuildDirectiveElementsTask] based on the given [target] in
467 * the given [context]. 469 * the given [context].
468 */ 470 */
469 static BuildDirectiveElementsTask createTask( 471 static BuildDirectiveElementsTask createTask(
470 AnalysisContext context, AnalysisTarget target) { 472 AnalysisContext context, AnalysisTarget target) {
471 return new BuildDirectiveElementsTask(context, target); 473 return new BuildDirectiveElementsTask(context, target);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 outputs[RESOLVED_UNIT2] = unit; 548 outputs[RESOLVED_UNIT2] = unit;
547 } 549 }
548 550
549 /** 551 /**
550 * Return a map from the names of the inputs of this kind of task to the task 552 * Return a map from the names of the inputs of this kind of task to the task
551 * input descriptors describing those inputs for a task with the 553 * input descriptors describing those inputs for a task with the
552 * given [target]. 554 * given [target].
553 */ 555 */
554 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 556 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) {
555 return <String, TaskInput>{ 557 return <String, TaskInput>{
556 TYPE_PROVIDER_INPUT: 558 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
557 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), 559 UNIT_INPUT: RESOLVED_UNIT1.of(target)
558 UNIT_INPUT: RESOLVED_UNIT1.inputFor(target)
559 }; 560 };
560 } 561 }
561 562
562 /** 563 /**
563 * Create a [BuildEnumMemberElementsTask] based on the given [target] in 564 * Create a [BuildEnumMemberElementsTask] based on the given [target] in
564 * the given [context]. 565 * the given [context].
565 */ 566 */
566 static BuildEnumMemberElementsTask createTask( 567 static BuildEnumMemberElementsTask createTask(
567 AnalysisContext context, AnalysisTarget target) { 568 AnalysisContext context, AnalysisTarget target) {
568 return new BuildEnumMemberElementsTask(context, target); 569 return new BuildEnumMemberElementsTask(context, target);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 outputs[LIBRARY_ELEMENT4] = library; 617 outputs[LIBRARY_ELEMENT4] = library;
617 } 618 }
618 619
619 /** 620 /**
620 * Return a map from the names of the inputs of this kind of task to the task 621 * Return a map from the names of the inputs of this kind of task to the task
621 * input descriptors describing those inputs for a task with the 622 * input descriptors describing those inputs for a task with the
622 * given library [libSource]. 623 * given library [libSource].
623 */ 624 */
624 static Map<String, TaskInput> buildInputs(Source libSource) { 625 static Map<String, TaskInput> buildInputs(Source libSource) {
625 return <String, TaskInput>{ 626 return <String, TaskInput>{
626 LIBRARY_INPUT: LIBRARY_ELEMENT3.inputFor(libSource), 627 LIBRARY_INPUT: LIBRARY_ELEMENT3.of(libSource),
627 'exportsLibraryPublicNamespace': 628 'exportsLibraryPublicNamespace':
628 new ListToMapTaskInput<Source, LibraryElement>( 629 EXPORT_SOURCE_CLOSURE.of(libSource).toMapOf(LIBRARY_ELEMENT3)
629 EXPORT_SOURCE_CLOSURE.inputFor(libSource),
630 (Source source) => LIBRARY_ELEMENT3.inputFor(source))
631 }; 630 };
632 } 631 }
633 632
634 /** 633 /**
635 * Create a [BuildExportNamespaceTask] based on the given [target] in 634 * Create a [BuildExportNamespaceTask] based on the given [target] in
636 * the given [context]. 635 * the given [context].
637 */ 636 */
638 static BuildExportNamespaceTask createTask( 637 static BuildExportNamespaceTask createTask(
639 AnalysisContext context, AnalysisTarget target) { 638 AnalysisContext context, AnalysisTarget target) {
640 return new BuildExportNamespaceTask(context, target); 639 return new BuildExportNamespaceTask(context, target);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 outputs[EXPORT_SOURCE_CLOSURE] = sources; 678 outputs[EXPORT_SOURCE_CLOSURE] = sources;
680 } 679 }
681 680
682 /** 681 /**
683 * Return a map from the names of the inputs of this kind of task to the task 682 * Return a map from the names of the inputs of this kind of task to the task
684 * input descriptors describing those inputs for a task with the 683 * input descriptors describing those inputs for a task with the
685 * given library [libSource]. 684 * given library [libSource].
686 */ 685 */
687 static Map<String, TaskInput> buildInputs(Source libSource) { 686 static Map<String, TaskInput> buildInputs(Source libSource) {
688 return <String, TaskInput>{ 687 return <String, TaskInput>{
689 LIBRARY2_ELEMENT_INPUT: LIBRARY_ELEMENT2.inputFor(libSource) 688 LIBRARY2_ELEMENT_INPUT: LIBRARY_ELEMENT2.of(libSource)
690 }; 689 };
691 } 690 }
692 691
693 /** 692 /**
694 * Create a [BuildExportSourceClosureTask] based on the given [target] in 693 * Create a [BuildExportSourceClosureTask] based on the given [target] in
695 * the given [context]. 694 * the given [context].
696 */ 695 */
697 static BuildExportSourceClosureTask createTask( 696 static BuildExportSourceClosureTask createTask(
698 AnalysisContext context, AnalysisTarget target) { 697 AnalysisContext context, AnalysisTarget target) {
699 return new BuildExportSourceClosureTask(context, target); 698 return new BuildExportSourceClosureTask(context, target);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 outputs[RESOLVED_UNIT3] = unit; 771 outputs[RESOLVED_UNIT3] = unit;
773 } 772 }
774 773
775 /** 774 /**
776 * Return a map from the names of the inputs of this kind of task to the task 775 * Return a map from the names of the inputs of this kind of task to the task
777 * input descriptors describing those inputs for a task with the 776 * input descriptors describing those inputs for a task with the
778 * given [target]. 777 * given [target].
779 */ 778 */
780 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 779 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) {
781 return <String, TaskInput>{ 780 return <String, TaskInput>{
782 TYPE_PROVIDER_INPUT: 781 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
783 TYPE_PROVIDER.inputFor(AnalysisContextTarget.request), 782 'importsExportNamespace':
784 'importsExportNamespace': new ListToMapTaskInput<Source, LibraryElement>( 783 IMPORTED_LIBRARIES.of(target.library).toMapOf(LIBRARY_ELEMENT4),
785 IMPORTED_LIBRARIES.inputFor(target.library), 784 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(target.library),
786 (Source importSource) => LIBRARY_ELEMENT4.inputFor(importSource)), 785 UNIT_INPUT: RESOLVED_UNIT2.of(target)
787 LIBRARY_INPUT: LIBRARY_ELEMENT4.inputFor(target.library),
788 UNIT_INPUT: RESOLVED_UNIT2.inputFor(target)
789 }; 786 };
790 } 787 }
791 788
792 /** 789 /**
793 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in 790 * Create a [BuildFunctionTypeAliasesTask] based on the given [target] in
794 * the given [context]. 791 * the given [context].
795 */ 792 */
796 static BuildFunctionTypeAliasesTask createTask( 793 static BuildFunctionTypeAliasesTask createTask(
797 AnalysisContext context, AnalysisTarget target) { 794 AnalysisContext context, AnalysisTarget target) {
798 return new BuildFunctionTypeAliasesTask(context, target); 795 return new BuildFunctionTypeAliasesTask(context, target);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 } 1034 }
1038 } 1035 }
1039 } 1036 }
1040 1037
1041 /** 1038 /**
1042 * Return a map from the names of the inputs of this kind of task to the task 1039 * Return a map from the names of the inputs of this kind of task to the task
1043 * input descriptors describing those inputs for a task with the given 1040 * input descriptors describing those inputs for a task with the given
1044 * [libSource]. 1041 * [libSource].
1045 */ 1042 */
1046 static Map<String, TaskInput> buildInputs(Source libSource) { 1043 static Map<String, TaskInput> buildInputs(Source libSource) {
1044 lut(Source unit) => new LibraryUnitTarget(libSource, unit);
1047 return <String, TaskInput>{ 1045 return <String, TaskInput>{
1048 DEFINING_UNIT_INPUT: 1046 DEFINING_UNIT_INPUT: RESOLVED_UNIT1.of(lut(libSource)),
1049 RESOLVED_UNIT1.inputFor(new LibraryUnitTarget(libSource, libSource)), 1047 PARTS_UNIT_INPUT: INCLUDED_PARTS
1050 PARTS_UNIT_INPUT: new ListToListTaskInput<Source, CompilationUnit>( 1048 .of(libSource)
1051 INCLUDED_PARTS.inputFor(libSource), (Source source) => 1049 .toList(_lutMapInput(libSource, RESOLVED_UNIT1))
1052 RESOLVED_UNIT1.inputFor(new LibraryUnitTarget(libSource, source)))
1053 }; 1050 };
1054 } 1051 }
1055 1052
1056 /** 1053 /**
1057 * Create a [BuildLibraryElementTask] based on the given [target] in the 1054 * Create a [BuildLibraryElementTask] based on the given [target] in the
1058 * given [context]. 1055 * given [context].
1059 */ 1056 */
1060 static BuildLibraryElementTask createTask( 1057 static BuildLibraryElementTask createTask(
1061 AnalysisContext context, AnalysisTarget target) { 1058 AnalysisContext context, AnalysisTarget target) {
1062 return new BuildLibraryElementTask(context, target); 1059 return new BuildLibraryElementTask(context, target);
(...skipping 29 matching lines...) Expand all
1092 library.publicNamespace = new PublicNamespaceBuilder().build(library); 1089 library.publicNamespace = new PublicNamespaceBuilder().build(library);
1093 outputs[LIBRARY_ELEMENT3] = library; 1090 outputs[LIBRARY_ELEMENT3] = library;
1094 } 1091 }
1095 1092
1096 /** 1093 /**
1097 * Return a map from the names of the inputs of this kind of task to the task 1094 * Return a map from the names of the inputs of this kind of task to the task
1098 * input descriptors describing those inputs for a task with the 1095 * input descriptors describing those inputs for a task with the
1099 * given library [libSource]. 1096 * given library [libSource].
1100 */ 1097 */
1101 static Map<String, TaskInput> buildInputs(Source libSource) { 1098 static Map<String, TaskInput> buildInputs(Source libSource) {
1102 return <String, TaskInput>{ 1099 return <String, TaskInput>{LIBRARY_INPUT: LIBRARY_ELEMENT2.of(libSource)};
1103 LIBRARY_INPUT: LIBRARY_ELEMENT2.inputFor(libSource)
1104 };
1105 } 1100 }
1106 1101
1107 /** 1102 /**
1108 * Create a [BuildPublicNamespaceTask] based on the given [target] in 1103 * Create a [BuildPublicNamespaceTask] based on the given [target] in
1109 * the given [context]. 1104 * the given [context].
1110 */ 1105 */
1111 static BuildPublicNamespaceTask createTask( 1106 static BuildPublicNamespaceTask createTask(
1112 AnalysisContext context, AnalysisTarget target) { 1107 AnalysisContext context, AnalysisTarget target) {
1113 return new BuildPublicNamespaceTask(context, target); 1108 return new BuildPublicNamespaceTask(context, target);
1114 } 1109 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace); 1150 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace);
1156 (context as ExtendedAnalysisContext).typeProvider = typeProvider; 1151 (context as ExtendedAnalysisContext).typeProvider = typeProvider;
1157 outputs[TYPE_PROVIDER] = typeProvider; 1152 outputs[TYPE_PROVIDER] = typeProvider;
1158 } 1153 }
1159 1154
1160 static Map<String, TaskInput> buildInputs(AnalysisContextTarget target) { 1155 static Map<String, TaskInput> buildInputs(AnalysisContextTarget target) {
1161 SourceFactory sourceFactory = target.context.sourceFactory; 1156 SourceFactory sourceFactory = target.context.sourceFactory;
1162 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 1157 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
1163 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); 1158 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC);
1164 return <String, TaskInput>{ 1159 return <String, TaskInput>{
1165 CORE_INPUT: LIBRARY_ELEMENT3.inputFor(coreSource), 1160 CORE_INPUT: LIBRARY_ELEMENT3.of(coreSource),
1166 ASYNC_INPUT: LIBRARY_ELEMENT3.inputFor(asyncSource) 1161 ASYNC_INPUT: LIBRARY_ELEMENT3.of(asyncSource)
1167 }; 1162 };
1168 } 1163 }
1169 1164
1170 /** 1165 /**
1171 * Create a [BuildTypeProviderTask] based on the given [context]. 1166 * Create a [BuildTypeProviderTask] based on the given [context].
1172 */ 1167 */
1173 static BuildTypeProviderTask createTask( 1168 static BuildTypeProviderTask createTask(
1174 AnalysisContext context, AnalysisContextTarget target) { 1169 AnalysisContext context, AnalysisContextTarget target) {
1175 return new BuildTypeProviderTask(context, target); 1170 return new BuildTypeProviderTask(context, target);
1176 } 1171 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 outputs[SOURCE_KIND] = sourceKind; 1403 outputs[SOURCE_KIND] = sourceKind;
1409 } 1404 }
1410 1405
1411 /** 1406 /**
1412 * Return a map from the names of the inputs of this kind of task to the task 1407 * Return a map from the names of the inputs of this kind of task to the task
1413 * input descriptors describing those inputs for a task with the given 1408 * input descriptors describing those inputs for a task with the given
1414 * [source]. 1409 * [source].
1415 */ 1410 */
1416 static Map<String, TaskInput> buildInputs(Source source) { 1411 static Map<String, TaskInput> buildInputs(Source source) {
1417 return <String, TaskInput>{ 1412 return <String, TaskInput>{
1418 LINE_INFO_INPUT_NAME: LINE_INFO.inputFor(source), 1413 LINE_INFO_INPUT_NAME: LINE_INFO.of(source),
1419 TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.inputFor(source) 1414 TOKEN_STREAM_INPUT_NAME: TOKEN_STREAM.of(source)
1420 }; 1415 };
1421 } 1416 }
1422 1417
1423 /** 1418 /**
1424 * Create a [ParseDartTask] based on the given [target] in the given 1419 * Create a [ParseDartTask] based on the given [target] in the given
1425 * [context]. 1420 * [context].
1426 */ 1421 */
1427 static ParseDartTask createTask( 1422 static ParseDartTask createTask(
1428 AnalysisContext context, AnalysisTarget target) { 1423 AnalysisContext context, AnalysisTarget target) {
1429 return new ParseDartTask(context, target); 1424 return new ParseDartTask(context, target);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1539 LibraryElement library = getRequiredInput(LIBRARY_INPUT); 1534 LibraryElement library = getRequiredInput(LIBRARY_INPUT);
1540 outputs[LIBRARY_ELEMENT5] = library; 1535 outputs[LIBRARY_ELEMENT5] = library;
1541 } 1536 }
1542 1537
1543 /** 1538 /**
1544 * Return a map from the names of the inputs of this kind of task to the task 1539 * 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 1540 * input descriptors describing those inputs for a task with the
1546 * given [target]. 1541 * given [target].
1547 */ 1542 */
1548 static Map<String, TaskInput> buildInputs(Source libSource) { 1543 static Map<String, TaskInput> buildInputs(Source libSource) {
1544 lut(Source unit) => new LibraryUnitTarget(libSource, unit);
Brian Wilkerson 2015/03/24 15:07:10 Even if it's useful to abbreviate the code here (w
scheglov 2015/03/24 17:16:38 Given that this local function is declared 3 lines
1549 return <String, TaskInput>{ 1545 return <String, TaskInput>{
1550 LIBRARY_INPUT: LIBRARY_ELEMENT4.inputFor(libSource), 1546 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(libSource),
1551 'resolvedDefiningUnit': 1547 'resolvedDefiningUnit': RESOLVED_UNIT4.of(lut(libSource)),
1552 RESOLVED_UNIT4.inputFor(new LibraryUnitTarget(libSource, libSource)), 1548 'resolvedPartsUnit': INCLUDED_PARTS
1553 'resolvedPartsUnit': new ListToMapTaskInput<Source, CompilationUnit>( 1549 .of(libSource)
1554 INCLUDED_PARTS.inputFor(libSource), (Source source) => RESOLVED_UNIT4 1550 .toMap((Source source) => RESOLVED_UNIT4.of(lut(source)))
1555 .inputFor(new LibraryUnitTarget(libSource, source))),
1556 }; 1551 };
1557 } 1552 }
1558 1553
1559 /** 1554 /**
1560 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in 1555 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in
1561 * the given [context]. 1556 * the given [context].
1562 */ 1557 */
1563 static ResolveLibraryTypeNamesTask createTask( 1558 static ResolveLibraryTypeNamesTask createTask(
1564 AnalysisContext context, AnalysisTarget target) { 1559 AnalysisContext context, AnalysisTarget target) {
1565 return new ResolveLibraryTypeNamesTask(context, target); 1560 return new ResolveLibraryTypeNamesTask(context, target);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; 1607 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors;
1613 outputs[RESOLVED_UNIT4] = unit; 1608 outputs[RESOLVED_UNIT4] = unit;
1614 } 1609 }
1615 1610
1616 /** 1611 /**
1617 * Return a map from the names of the inputs of this kind of task to the task 1612 * Return a map from the names of the inputs of this kind of task to the task
1618 * input descriptors describing those inputs for a task with the 1613 * input descriptors describing those inputs for a task with the
1619 * given [target]. 1614 * given [target].
1620 */ 1615 */
1621 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 1616 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) {
1622 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT3.inputFor(target)}; 1617 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT3.of(target)};
1623 } 1618 }
1624 1619
1625 /** 1620 /**
1626 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in 1621 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in
1627 * the given [context]. 1622 * the given [context].
1628 */ 1623 */
1629 static ResolveUnitTypeNamesTask createTask( 1624 static ResolveUnitTypeNamesTask createTask(
1630 AnalysisContext context, AnalysisTarget target) { 1625 AnalysisContext context, AnalysisTarget target) {
1631 return new ResolveUnitTypeNamesTask(context, target); 1626 return new ResolveUnitTypeNamesTask(context, target);
1632 } 1627 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 outputs[LINE_INFO] = new LineInfo(scanner.lineStarts); 1669 outputs[LINE_INFO] = new LineInfo(scanner.lineStarts);
1675 outputs[SCAN_ERRORS] = errorListener.getErrorsForSource(source); 1670 outputs[SCAN_ERRORS] = errorListener.getErrorsForSource(source);
1676 } 1671 }
1677 1672
1678 /** 1673 /**
1679 * Return a map from the names of the inputs of this kind of task to the task 1674 * Return a map from the names of the inputs of this kind of task to the task
1680 * input descriptors describing those inputs for a task with the given 1675 * input descriptors describing those inputs for a task with the given
1681 * [source]. 1676 * [source].
1682 */ 1677 */
1683 static Map<String, TaskInput> buildInputs(Source source) { 1678 static Map<String, TaskInput> buildInputs(Source source) {
1684 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.inputFor(source)}; 1679 return <String, TaskInput>{CONTENT_INPUT_NAME: CONTENT.of(source)};
1685 } 1680 }
1686 1681
1687 /** 1682 /**
1688 * Create a [ScanDartTask] based on the given [target] in the given [context]. 1683 * Create a [ScanDartTask] based on the given [target] in the given [context].
1689 */ 1684 */
1690 static ScanDartTask createTask( 1685 static ScanDartTask createTask(
1691 AnalysisContext context, AnalysisTarget target) { 1686 AnalysisContext context, AnalysisTarget target) {
1692 return new ScanDartTask(context, target); 1687 return new ScanDartTask(context, target);
1693 } 1688 }
1694 } 1689 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/inputs.dart » ('j') | pkg/analyzer/lib/src/task/inputs.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698