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

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

Issue 1082913007: Move LibraryUnitTarget into API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 5 years, 8 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/task/dart.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 12 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
13 import 'package:analyzer/src/generated/error.dart'; 13 import 'package:analyzer/src/generated/error.dart';
14 import 'package:analyzer/src/generated/error_verifier.dart'; 14 import 'package:analyzer/src/generated/error_verifier.dart';
15 import 'package:analyzer/src/generated/java_engine.dart'; 15 import 'package:analyzer/src/generated/java_engine.dart';
16 import 'package:analyzer/src/generated/parser.dart'; 16 import 'package:analyzer/src/generated/parser.dart';
17 import 'package:analyzer/src/generated/resolver.dart'; 17 import 'package:analyzer/src/generated/resolver.dart';
18 import 'package:analyzer/src/generated/scanner.dart'; 18 import 'package:analyzer/src/generated/scanner.dart';
19 import 'package:analyzer/src/generated/sdk.dart'; 19 import 'package:analyzer/src/generated/sdk.dart';
20 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
21 import 'package:analyzer/src/generated/utilities_general.dart';
22 import 'package:analyzer/src/task/driver.dart'; 21 import 'package:analyzer/src/task/driver.dart';
23 import 'package:analyzer/src/task/general.dart'; 22 import 'package:analyzer/src/task/general.dart';
24 import 'package:analyzer/task/dart.dart'; 23 import 'package:analyzer/task/dart.dart';
25 import 'package:analyzer/task/general.dart'; 24 import 'package:analyzer/task/general.dart';
26 import 'package:analyzer/task/model.dart'; 25 import 'package:analyzer/task/model.dart';
27 26
28 /** 27 /**
29 * The errors produced while resolving a library directives. 28 * The errors produced while resolving a library directives.
30 * 29 *
31 * The list will be empty if there were no errors, but will not be `null`. 30 * The list will be empty if there were no errors, but will not be `null`.
(...skipping 23 matching lines...) Expand all
55 * The list will be empty if there were no errors, but will not be `null`. 54 * The list will be empty if there were no errors, but will not be `null`.
56 * 55 *
57 * The result is only available for targets representing a Dart library. 56 * The result is only available for targets representing a Dart library.
58 */ 57 */
59 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS = 58 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS =
60 new ResultDescriptor<List<AnalysisError>>( 59 new ResultDescriptor<List<AnalysisError>>(
61 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS, 60 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS,
62 contributesTo: DART_ERRORS); 61 contributesTo: DART_ERRORS);
63 62
64 /** 63 /**
65 * The [ClassElement]s of a [LibraryUnitTarget]. 64 * The [ClassElement]s of a [LibrarySpecificUnit].
66 */ 65 */
67 final ListResultDescriptor<ClassElement> CLASS_ELEMENTS = 66 final ListResultDescriptor<ClassElement> CLASS_ELEMENTS =
68 new ListResultDescriptor<ClassElement>('CLASS_ELEMENTS', null); 67 new ListResultDescriptor<ClassElement>('CLASS_ELEMENTS', null);
69 68
70 /** 69 /**
71 * The element model associated with a single compilation unit. 70 * The element model associated with a single compilation unit.
72 * 71 *
73 * The result is only available for targets representing a Dart compilation unit . 72 * The result is only available for targets representing a Dart compilation unit .
74 */ 73 */
75 final ResultDescriptor<CompilationUnitElement> COMPILATION_UNIT_ELEMENT = 74 final ResultDescriptor<CompilationUnitElement> COMPILATION_UNIT_ELEMENT =
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 new ResultDescriptor<List<AnalysisError>>( 273 new ResultDescriptor<List<AnalysisError>>(
275 'SCAN_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); 274 'SCAN_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS);
276 275
277 /** 276 /**
278 * The [TypeProvider] of the context. 277 * The [TypeProvider] of the context.
279 */ 278 */
280 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = 279 final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
281 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); 280 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null);
282 281
283 /** 282 /**
284 * The [UsedImportedElements] of a [LibraryUnitTarget]. 283 * The [UsedImportedElements] of a [LibrarySpecificUnit].
285 */ 284 */
286 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS = 285 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS =
287 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null); 286 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null);
288 287
289 /** 288 /**
290 * The [UsedLocalElements] of a [LibraryUnitTarget]. 289 * The [UsedLocalElements] of a [LibrarySpecificUnit].
291 */ 290 */
292 final ResultDescriptor<UsedLocalElements> USED_LOCAL_ELEMENTS = 291 final ResultDescriptor<UsedLocalElements> USED_LOCAL_ELEMENTS =
293 new ResultDescriptor<UsedLocalElements>('USED_LOCAL_ELEMENTS', null); 292 new ResultDescriptor<UsedLocalElements>('USED_LOCAL_ELEMENTS', null);
294 293
295 /** 294 /**
296 * The errors produced while verifying a compilation unit. 295 * The errors produced while verifying a compilation unit.
297 * 296 *
298 * The list will be empty if there were no errors, but will not be `null`. 297 * The list will be empty if there were no errors, but will not be `null`.
299 * 298 *
300 * The result is only available for targets representing a Dart compilation unit . 299 * The result is only available for targets representing a Dart compilation unit .
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 outputs[CLASS_ELEMENTS] = element.types; 578 outputs[CLASS_ELEMENTS] = element.types;
580 outputs[COMPILATION_UNIT_ELEMENT] = element; 579 outputs[COMPILATION_UNIT_ELEMENT] = element;
581 outputs[RESOLVED_UNIT1] = unit; 580 outputs[RESOLVED_UNIT1] = unit;
582 } 581 }
583 582
584 /** 583 /**
585 * Return a map from the names of the inputs of this kind of task to the task 584 * Return a map from the names of the inputs of this kind of task to the task
586 * input descriptors describing those inputs for a task with the given 585 * input descriptors describing those inputs for a task with the given
587 * [target]. 586 * [target].
588 */ 587 */
589 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 588 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
590 return <String, TaskInput>{ 589 return <String, TaskInput>{
591 PARSED_UNIT_INPUT_NAME: PARSED_UNIT.of(target.unit) 590 PARSED_UNIT_INPUT_NAME: PARSED_UNIT.of(target.unit)
592 }; 591 };
593 } 592 }
594 593
595 /** 594 /**
596 * Create a [BuildCompilationUnitElementTask] based on the given [target] in 595 * Create a [BuildCompilationUnitElementTask] based on the given [target] in
597 * the given [context]. 596 * the given [context].
598 */ 597 */
599 static BuildCompilationUnitElementTask createTask( 598 static BuildCompilationUnitElementTask createTask(
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 780
782 /** 781 /**
783 * Return a map from the names of the inputs of this kind of task to the task 782 * Return a map from the names of the inputs of this kind of task to the task
784 * input descriptors describing those inputs for a task with the 783 * input descriptors describing those inputs for a task with the
785 * given library [libSource]. 784 * given library [libSource].
786 */ 785 */
787 static Map<String, TaskInput> buildInputs(Source libSource) { 786 static Map<String, TaskInput> buildInputs(Source libSource) {
788 return <String, TaskInput>{ 787 return <String, TaskInput>{
789 'defining_LIBRARY_ELEMENT1': LIBRARY_ELEMENT1.of(libSource), 788 'defining_LIBRARY_ELEMENT1': LIBRARY_ELEMENT1.of(libSource),
790 UNIT_INPUT_NAME: 789 UNIT_INPUT_NAME:
791 RESOLVED_UNIT1.of(new LibraryUnitTarget(libSource, libSource)), 790 RESOLVED_UNIT1.of(new LibrarySpecificUnit(libSource, libSource)),
792 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME: 791 IMPORTS_LIBRARY_ELEMENT_INPUT_NAME:
793 IMPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1), 792 IMPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1),
794 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME: 793 EXPORTS_LIBRARY_ELEMENT_INPUT_NAME:
795 EXPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1), 794 EXPORTED_LIBRARIES.of(libSource).toMapOf(LIBRARY_ELEMENT1),
796 IMPORTS_SOURCE_KIND_INPUT_NAME: 795 IMPORTS_SOURCE_KIND_INPUT_NAME:
797 IMPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND), 796 IMPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND),
798 EXPORTS_SOURCE_KIND_INPUT_NAME: 797 EXPORTS_SOURCE_KIND_INPUT_NAME:
799 EXPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND) 798 EXPORTED_LIBRARIES.of(libSource).toMapOf(SOURCE_KIND)
800 }; 799 };
801 } 800 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider); 881 EnumMemberBuilder builder = new EnumMemberBuilder(typeProvider);
883 unit.accept(builder); 882 unit.accept(builder);
884 outputs[RESOLVED_UNIT2] = unit; 883 outputs[RESOLVED_UNIT2] = unit;
885 } 884 }
886 885
887 /** 886 /**
888 * Return a map from the names of the inputs of this kind of task to the task 887 * Return a map from the names of the inputs of this kind of task to the task
889 * input descriptors describing those inputs for a task with the 888 * input descriptors describing those inputs for a task with the
890 * given [target]. 889 * given [target].
891 */ 890 */
892 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 891 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
893 return <String, TaskInput>{ 892 return <String, TaskInput>{
894 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 893 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
895 UNIT_INPUT: RESOLVED_UNIT1.of(target) 894 UNIT_INPUT: RESOLVED_UNIT1.of(target)
896 }; 895 };
897 } 896 }
898 897
899 /** 898 /**
900 * Create a [BuildEnumMemberElementsTask] based on the given [target] in 899 * Create a [BuildEnumMemberElementsTask] based on the given [target] in
901 * the given [context]. 900 * the given [context].
902 */ 901 */
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 // 1033 //
1035 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errorListener.errors; 1034 outputs[BUILD_FUNCTION_TYPE_ALIASES_ERRORS] = errorListener.errors;
1036 outputs[RESOLVED_UNIT3] = unit; 1035 outputs[RESOLVED_UNIT3] = unit;
1037 } 1036 }
1038 1037
1039 /** 1038 /**
1040 * 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
1041 * input descriptors describing those inputs for a task with the 1040 * input descriptors describing those inputs for a task with the
1042 * given [target]. 1041 * given [target].
1043 */ 1042 */
1044 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 1043 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
1045 return <String, TaskInput>{ 1044 return <String, TaskInput>{
1046 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request), 1045 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request),
1047 'importsExportNamespace': 1046 'importsExportNamespace':
1048 IMPORTED_LIBRARIES.of(target.library).toMapOf(LIBRARY_ELEMENT4), 1047 IMPORTED_LIBRARIES.of(target.library).toMapOf(LIBRARY_ELEMENT4),
1049 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(target.library), 1048 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(target.library),
1050 UNIT_INPUT: RESOLVED_UNIT2.of(target) 1049 UNIT_INPUT: RESOLVED_UNIT2.of(target)
1051 }; 1050 };
1052 } 1051 }
1053 1052
1054 /** 1053 /**
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 } 1356 }
1358 1357
1359 /** 1358 /**
1360 * Return a map from the names of the inputs of this kind of task to the task 1359 * Return a map from the names of the inputs of this kind of task to the task
1361 * input descriptors describing those inputs for a task with the given 1360 * input descriptors describing those inputs for a task with the given
1362 * [libSource]. 1361 * [libSource].
1363 */ 1362 */
1364 static Map<String, TaskInput> buildInputs(Source libSource) { 1363 static Map<String, TaskInput> buildInputs(Source libSource) {
1365 return <String, TaskInput>{ 1364 return <String, TaskInput>{
1366 DEFINING_UNIT_INPUT: 1365 DEFINING_UNIT_INPUT:
1367 RESOLVED_UNIT1.of(new LibraryUnitTarget(libSource, libSource)), 1366 RESOLVED_UNIT1.of(new LibrarySpecificUnit(libSource, libSource)),
1368 PARTS_UNIT_INPUT: INCLUDED_PARTS.of(libSource).toList((Source unit) { 1367 PARTS_UNIT_INPUT: INCLUDED_PARTS.of(libSource).toList((Source unit) {
1369 LibraryUnitTarget lut = new LibraryUnitTarget(libSource, unit); 1368 return RESOLVED_UNIT1.of(new LibrarySpecificUnit(libSource, unit));
1370 return RESOLVED_UNIT1.of(lut);
1371 }) 1369 })
1372 }; 1370 };
1373 } 1371 }
1374 1372
1375 /** 1373 /**
1376 * Create a [BuildLibraryElementTask] based on the given [target] in the 1374 * Create a [BuildLibraryElementTask] based on the given [target] in the
1377 * given [context]. 1375 * given [context].
1378 */ 1376 */
1379 static BuildLibraryElementTask createTask( 1377 static BuildLibraryElementTask createTask(
1380 AnalysisContext context, AnalysisTarget target) { 1378 AnalysisContext context, AnalysisTarget target) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 // Record outputs. 1700 // Record outputs.
1703 // 1701 //
1704 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements; 1702 outputs[USED_IMPORTED_ELEMENTS] = visitor.usedElements;
1705 } 1703 }
1706 1704
1707 /** 1705 /**
1708 * Return a map from the names of the inputs of this kind of task to the task 1706 * Return a map from the names of the inputs of this kind of task to the task
1709 * input descriptors describing those inputs for a task with the 1707 * input descriptors describing those inputs for a task with the
1710 * given [target]. 1708 * given [target].
1711 */ 1709 */
1712 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 1710 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
1713 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)}; 1711 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)};
1714 } 1712 }
1715 1713
1716 /** 1714 /**
1717 * Create a [GatherUsedImportedElementsTask] based on the given [target] in 1715 * Create a [GatherUsedImportedElementsTask] based on the given [target] in
1718 * the given [context]. 1716 * the given [context].
1719 */ 1717 */
1720 static GatherUsedImportedElementsTask createTask( 1718 static GatherUsedImportedElementsTask createTask(
1721 AnalysisContext context, LibraryUnitTarget target) { 1719 AnalysisContext context, LibrarySpecificUnit target) {
1722 return new GatherUsedImportedElementsTask(context, target); 1720 return new GatherUsedImportedElementsTask(context, target);
1723 } 1721 }
1724 } 1722 }
1725 1723
1726 /** 1724 /**
1727 * A task that builds [USED_LOCAL_ELEMENTS] for a unit. 1725 * A task that builds [USED_LOCAL_ELEMENTS] for a unit.
1728 */ 1726 */
1729 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask { 1727 class GatherUsedLocalElementsTask extends SourceBasedAnalysisTask {
1730 /** 1728 /**
1731 * The name of the [RESOLVED_UNIT] input. 1729 * The name of the [RESOLVED_UNIT] input.
(...skipping 29 matching lines...) Expand all
1761 // Record outputs. 1759 // Record outputs.
1762 // 1760 //
1763 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements; 1761 outputs[USED_LOCAL_ELEMENTS] = visitor.usedElements;
1764 } 1762 }
1765 1763
1766 /** 1764 /**
1767 * Return a map from the names of the inputs of this kind of task to the task 1765 * Return a map from the names of the inputs of this kind of task to the task
1768 * input descriptors describing those inputs for a task with the 1766 * input descriptors describing those inputs for a task with the
1769 * given [target]. 1767 * given [target].
1770 */ 1768 */
1771 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 1769 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
1772 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)}; 1770 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)};
1773 } 1771 }
1774 1772
1775 /** 1773 /**
1776 * Create a [GatherUsedLocalElementsTask] based on the given [target] in 1774 * Create a [GatherUsedLocalElementsTask] based on the given [target] in
1777 * the given [context]. 1775 * the given [context].
1778 */ 1776 */
1779 static GatherUsedLocalElementsTask createTask( 1777 static GatherUsedLocalElementsTask createTask(
1780 AnalysisContext context, LibraryUnitTarget target) { 1778 AnalysisContext context, LibrarySpecificUnit target) {
1781 return new GatherUsedLocalElementsTask(context, target); 1779 return new GatherUsedLocalElementsTask(context, target);
1782 } 1780 }
1783 } 1781 }
1784 1782
1785 /** 1783 /**
1786 * A task that generates [HINTS] for a unit. 1784 * A task that generates [HINTS] for a unit.
1787 */ 1785 */
1788 class GenerateHintsTask extends SourceBasedAnalysisTask { 1786 class GenerateHintsTask extends SourceBasedAnalysisTask {
1789 /** 1787 /**
1790 * The name of the [RESOLVED_UNIT] input. 1788 * The name of the [RESOLVED_UNIT] input.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1864 // Record outputs. 1862 // Record outputs.
1865 // 1863 //
1866 outputs[HINTS] = errorListener.errors; 1864 outputs[HINTS] = errorListener.errors;
1867 } 1865 }
1868 1866
1869 /** 1867 /**
1870 * Return a map from the names of the inputs of this kind of task to the task 1868 * Return a map from the names of the inputs of this kind of task to the task
1871 * input descriptors describing those inputs for a task with the 1869 * input descriptors describing those inputs for a task with the
1872 * given [target]. 1870 * given [target].
1873 */ 1871 */
1874 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 1872 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
1875 Source libSource = target.library; 1873 Source libSource = target.library;
1876 return <String, TaskInput>{ 1874 return <String, TaskInput>{
1877 UNIT_INPUT: RESOLVED_UNIT.of(target), 1875 UNIT_INPUT: RESOLVED_UNIT.of(target),
1878 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { 1876 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) {
1879 LibraryUnitTarget target = new LibraryUnitTarget(libSource, unit); 1877 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit);
1880 return USED_LOCAL_ELEMENTS.of(target); 1878 return USED_LOCAL_ELEMENTS.of(target);
1881 }), 1879 }),
1882 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { 1880 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) {
1883 LibraryUnitTarget target = new LibraryUnitTarget(libSource, unit); 1881 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit);
1884 return USED_IMPORTED_ELEMENTS.of(target); 1882 return USED_IMPORTED_ELEMENTS.of(target);
1885 }) 1883 })
1886 }; 1884 };
1887 } 1885 }
1888 1886
1889 /** 1887 /**
1890 * Create a [GenerateHintsTask] based on the given [target] in 1888 * Create a [GenerateHintsTask] based on the given [target] in
1891 * the given [context]. 1889 * the given [context].
1892 */ 1890 */
1893 static GenerateHintsTask createTask( 1891 static GenerateHintsTask createTask(
1894 AnalysisContext context, AnalysisTarget target) { 1892 AnalysisContext context, AnalysisTarget target) {
1895 return new GenerateHintsTask(context, target); 1893 return new GenerateHintsTask(context, target);
1896 } 1894 }
1897 } 1895 }
1898 1896
1899 /** 1897 /**
1900 * A pair of a library [Source] and a unit [Source] in this library.
1901 */
1902 class LibraryUnitTarget implements AnalysisTarget {
1903 final Source library;
1904 final Source unit;
1905
1906 LibraryUnitTarget(this.library, this.unit);
1907
1908 @override
1909 int get hashCode {
1910 return JenkinsSmiHash.combine(library.hashCode, unit.hashCode);
1911 }
1912
1913 @override
1914 Source get source => unit;
1915
1916 @override
1917 bool operator ==(other) {
1918 return other is LibraryUnitTarget &&
1919 other.library == library &&
1920 other.unit == unit;
1921 }
1922 }
1923
1924 /**
1925 * A task that parses the content of a Dart file, producing an AST structure. 1898 * A task that parses the content of a Dart file, producing an AST structure.
1926 */ 1899 */
1927 class ParseDartTask extends SourceBasedAnalysisTask { 1900 class ParseDartTask extends SourceBasedAnalysisTask {
1928 /** 1901 /**
1929 * The name of the input whose value is the line information produced for the 1902 * The name of the input whose value is the line information produced for the
1930 * file. 1903 * file.
1931 */ 1904 */
1932 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; 1905 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME';
1933 1906
1934 /** 1907 /**
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 * input descriptors describing those inputs for a task with the 2137 * input descriptors describing those inputs for a task with the
2165 * given [target]. 2138 * given [target].
2166 */ 2139 */
2167 static Map<String, TaskInput> buildInputs(Source libSource) { 2140 static Map<String, TaskInput> buildInputs(Source libSource) {
2168 return <String, TaskInput>{ 2141 return <String, TaskInput>{
2169 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(libSource), 2142 LIBRARY_INPUT: LIBRARY_ELEMENT4.of(libSource),
2170 'resolvedUnits': IMPORT_SOURCE_CLOSURE 2143 'resolvedUnits': IMPORT_SOURCE_CLOSURE
2171 .of(libSource) 2144 .of(libSource)
2172 .toMapOf(UNITS) 2145 .toMapOf(UNITS)
2173 .toFlattenList((Source library, Source unit) => 2146 .toFlattenList((Source library, Source unit) =>
2174 RESOLVED_UNIT4.of(new LibraryUnitTarget(library, unit))) 2147 RESOLVED_UNIT4.of(new LibrarySpecificUnit(library, unit)))
2175 }; 2148 };
2176 } 2149 }
2177 2150
2178 /** 2151 /**
2179 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in 2152 * Create a [ResolveLibraryTypeNamesTask] based on the given [target] in
2180 * the given [context]. 2153 * the given [context].
2181 */ 2154 */
2182 static ResolveLibraryTypeNamesTask createTask( 2155 static ResolveLibraryTypeNamesTask createTask(
2183 AnalysisContext context, AnalysisTarget target) { 2156 AnalysisContext context, AnalysisTarget target) {
2184 return new ResolveLibraryTypeNamesTask(context, target); 2157 return new ResolveLibraryTypeNamesTask(context, target);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 // 2208 //
2236 outputs[RESOLVE_REFERENCES_ERRORS] = errorListener.errors; 2209 outputs[RESOLVE_REFERENCES_ERRORS] = errorListener.errors;
2237 outputs[RESOLVED_UNIT] = unit; 2210 outputs[RESOLVED_UNIT] = unit;
2238 } 2211 }
2239 2212
2240 /** 2213 /**
2241 * Return a map from the names of the inputs of this kind of task to the task 2214 * Return a map from the names of the inputs of this kind of task to the task
2242 * input descriptors describing those inputs for a task with the 2215 * input descriptors describing those inputs for a task with the
2243 * given [target]. 2216 * given [target].
2244 */ 2217 */
2245 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 2218 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2246 return <String, TaskInput>{ 2219 return <String, TaskInput>{
2247 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library), 2220 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library),
2248 UNIT_INPUT: RESOLVED_UNIT5.of(target) 2221 UNIT_INPUT: RESOLVED_UNIT5.of(target)
2249 }; 2222 };
2250 } 2223 }
2251 2224
2252 /** 2225 /**
2253 * Create a [ResolveReferencesTask] based on the given [target] in 2226 * Create a [ResolveReferencesTask] based on the given [target] in
2254 * the given [context]. 2227 * the given [context].
2255 */ 2228 */
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 // 2277 //
2305 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; 2278 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors;
2306 outputs[RESOLVED_UNIT4] = unit; 2279 outputs[RESOLVED_UNIT4] = unit;
2307 } 2280 }
2308 2281
2309 /** 2282 /**
2310 * Return a map from the names of the inputs of this kind of task to the task 2283 * Return a map from the names of the inputs of this kind of task to the task
2311 * input descriptors describing those inputs for a task with the 2284 * input descriptors describing those inputs for a task with the
2312 * given [target]. 2285 * given [target].
2313 */ 2286 */
2314 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 2287 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2315 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT3.of(target)}; 2288 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT3.of(target)};
2316 } 2289 }
2317 2290
2318 /** 2291 /**
2319 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in 2292 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in
2320 * the given [context]. 2293 * the given [context].
2321 */ 2294 */
2322 static ResolveUnitTypeNamesTask createTask( 2295 static ResolveUnitTypeNamesTask createTask(
2323 AnalysisContext context, AnalysisTarget target) { 2296 AnalysisContext context, AnalysisTarget target) {
2324 return new ResolveUnitTypeNamesTask(context, target); 2297 return new ResolveUnitTypeNamesTask(context, target);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 // Record outputs. 2347 // Record outputs.
2375 // 2348 //
2376 outputs[RESOLVED_UNIT5] = unit; 2349 outputs[RESOLVED_UNIT5] = unit;
2377 } 2350 }
2378 2351
2379 /** 2352 /**
2380 * Return a map from the names of the inputs of this kind of task to the task 2353 * Return a map from the names of the inputs of this kind of task to the task
2381 * input descriptors describing those inputs for a task with the 2354 * input descriptors describing those inputs for a task with the
2382 * given [target]. 2355 * given [target].
2383 */ 2356 */
2384 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 2357 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2385 return <String, TaskInput>{ 2358 return <String, TaskInput>{
2386 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library), 2359 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library),
2387 UNIT_INPUT: RESOLVED_UNIT4.of(target) 2360 UNIT_INPUT: RESOLVED_UNIT4.of(target)
2388 }; 2361 };
2389 } 2362 }
2390 2363
2391 /** 2364 /**
2392 * Create a [ResolveVariableReferencesTask] based on the given [target] in 2365 * Create a [ResolveVariableReferencesTask] based on the given [target] in
2393 * the given [context]. 2366 * the given [context].
2394 */ 2367 */
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 // Record outputs. 2482 // Record outputs.
2510 // 2483 //
2511 outputs[VERIFY_ERRORS] = errorListener.errors; 2484 outputs[VERIFY_ERRORS] = errorListener.errors;
2512 } 2485 }
2513 2486
2514 /** 2487 /**
2515 * Return a map from the names of the inputs of this kind of task to the task 2488 * Return a map from the names of the inputs of this kind of task to the task
2516 * input descriptors describing those inputs for a task with the 2489 * input descriptors describing those inputs for a task with the
2517 * given [target]. 2490 * given [target].
2518 */ 2491 */
2519 static Map<String, TaskInput> buildInputs(LibraryUnitTarget target) { 2492 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2520 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)}; 2493 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)};
2521 } 2494 }
2522 2495
2523 /** 2496 /**
2524 * Create a [VerifyUnitTask] based on the given [target] in 2497 * Create a [VerifyUnitTask] based on the given [target] in
2525 * the given [context]. 2498 * the given [context].
2526 */ 2499 */
2527 static VerifyUnitTask createTask( 2500 static VerifyUnitTask createTask(
2528 AnalysisContext context, AnalysisTarget target) { 2501 AnalysisContext context, AnalysisTarget target) {
2529 return new VerifyUnitTask(context, target); 2502 return new VerifyUnitTask(context, target);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 @override 2578 @override
2606 bool moveNext() { 2579 bool moveNext() {
2607 if (_newSources.isEmpty) { 2580 if (_newSources.isEmpty) {
2608 return false; 2581 return false;
2609 } 2582 }
2610 currentTarget = _newSources.first; 2583 currentTarget = _newSources.first;
2611 _newSources.remove(currentTarget); 2584 _newSources.remove(currentTarget);
2612 return true; 2585 return true;
2613 } 2586 }
2614 } 2587 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/task/dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698