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

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

Issue 1130763003: Get computeError working (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 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';
(...skipping 22 matching lines...) Expand all
33 33
34 /** 34 /**
35 * The errors produced while resolving a library directives. 35 * The errors produced while resolving a library directives.
36 * 36 *
37 * The list will be empty if there were no errors, but will not be `null`. 37 * The list will be empty if there were no errors, but will not be `null`.
38 * 38 *
39 * The result is only available for targets representing a Dart library. 39 * The result is only available for targets representing a Dart library.
40 */ 40 */
41 final ResultDescriptor<List<AnalysisError>> BUILD_DIRECTIVES_ERRORS = 41 final ResultDescriptor<List<AnalysisError>> BUILD_DIRECTIVES_ERRORS =
42 new ResultDescriptor<List<AnalysisError>>( 42 new ResultDescriptor<List<AnalysisError>>(
43 'BUILD_DIRECTIVES_ERRORS', AnalysisError.NO_ERRORS, 43 'BUILD_DIRECTIVES_ERRORS', AnalysisError.NO_ERRORS);
44 contributesTo: DART_ERRORS);
45 44
46 /** 45 /**
47 * The errors produced while building function type aliases. 46 * The errors produced while building function type aliases.
48 * 47 *
49 * The list will be empty if there were no errors, but will not be `null`. 48 * The list will be empty if there were no errors, but will not be `null`.
50 * 49 *
51 * The result is only available for targets representing a Dart library. 50 * The result is only available for targets representing a Dart library.
52 */ 51 */
53 final ResultDescriptor<List<AnalysisError>> BUILD_FUNCTION_TYPE_ALIASES_ERRORS = 52 final ResultDescriptor<List<AnalysisError>> BUILD_FUNCTION_TYPE_ALIASES_ERRORS =
54 new ResultDescriptor<List<AnalysisError>>( 53 new ResultDescriptor<List<AnalysisError>>(
55 'BUILD_FUNCTION_TYPE_ALIASES_ERRORS', AnalysisError.NO_ERRORS, 54 'BUILD_FUNCTION_TYPE_ALIASES_ERRORS', AnalysisError.NO_ERRORS);
56 contributesTo: DART_ERRORS);
57 55
58 /** 56 /**
59 * The errors produced while building a library element. 57 * The errors produced while building a library element.
60 * 58 *
61 * The list will be empty if there were no errors, but will not be `null`. 59 * The list will be empty if there were no errors, but will not be `null`.
62 * 60 *
63 * The result is only available for targets representing a Dart library. 61 * The result is only available for targets representing a Dart library.
64 */ 62 */
65 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS = 63 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS =
66 new ResultDescriptor<List<AnalysisError>>( 64 new ResultDescriptor<List<AnalysisError>>(
67 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS, 65 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS);
68 contributesTo: DART_ERRORS);
69 66
70 /** 67 /**
71 * The [ClassElement]s of a [LibrarySpecificUnit]. 68 * The [ClassElement]s of a [LibrarySpecificUnit].
72 */ 69 */
73 final ListResultDescriptor<ClassElement> CLASS_ELEMENTS = 70 final ListResultDescriptor<ClassElement> CLASS_ELEMENTS =
74 new ListResultDescriptor<ClassElement>('CLASS_ELEMENTS', null, 71 new ListResultDescriptor<ClassElement>('CLASS_ELEMENTS', null,
75 cachingPolicy: ELEMENT_CACHING_POLICY); 72 cachingPolicy: ELEMENT_CACHING_POLICY);
76 73
77 /** 74 /**
78 * The element model associated with a single compilation unit. 75 * The element model associated with a single compilation unit.
(...skipping 16 matching lines...) Expand all
95 * 92 *
96 * The list will be empty if there were no errors, but will not be `null`. 93 * The list will be empty if there were no errors, but will not be `null`.
97 * 94 *
98 * The result is only available for targets representing a [ClassElement]. 95 * The result is only available for targets representing a [ClassElement].
99 */ 96 */
100 final ResultDescriptor<List<AnalysisError>> CONSTRUCTORS_ERRORS = 97 final ResultDescriptor<List<AnalysisError>> CONSTRUCTORS_ERRORS =
101 new ResultDescriptor<List<AnalysisError>>( 98 new ResultDescriptor<List<AnalysisError>>(
102 'CONSTRUCTORS_ERRORS', AnalysisError.NO_ERRORS); 99 'CONSTRUCTORS_ERRORS', AnalysisError.NO_ERRORS);
103 100
104 /** 101 /**
102 * The sources representing the libraries that include a given source as a part.
103 *
104 * The result is only available for targets representing a compilation unit.
105 */
106 final ListResultDescriptor<Source> CONTAINING_LIBRARIES =
107 new ListResultDescriptor<Source>('CONTAINING_LIBRARIES', Source.EMPTY_LIST);
108
109 /**
105 * The [ResultCachingPolicy] for [Element]s. 110 * The [ResultCachingPolicy] for [Element]s.
106 */ 111 */
107 const ResultCachingPolicy ELEMENT_CACHING_POLICY = 112 const ResultCachingPolicy ELEMENT_CACHING_POLICY =
108 const SimpleResultCachingPolicy(-1, -1); 113 const SimpleResultCachingPolicy(-1, -1);
109 114
110 /** 115 /**
111 * The sources representing the export closure of a library. 116 * The sources representing the export closure of a library.
112 * The [Source]s include only library sources, not their units. 117 * The [Source]s include only library sources, not their units.
113 * 118 *
114 * The result is only available for targets representing a Dart library. 119 * The result is only available for targets representing a Dart library.
115 */ 120 */
116 final ListResultDescriptor<Source> EXPORT_SOURCE_CLOSURE = 121 final ListResultDescriptor<Source> EXPORT_SOURCE_CLOSURE =
117 new ListResultDescriptor<Source>('EXPORT_SOURCE_CLOSURE', null); 122 new ListResultDescriptor<Source>('EXPORT_SOURCE_CLOSURE', null);
118 123
119 /** 124 /**
120 * The errors produced while generating hints a compilation unit. 125 * The errors produced while generating hints a compilation unit.
121 * 126 *
122 * The list will be empty if there were no errors, but will not be `null`. 127 * The list will be empty if there were no errors, but will not be `null`.
123 * 128 *
124 * The result is only available for targets representing a Dart compilation unit . 129 * The result is only available for targets representing a Dart compilation unit .
125 */ 130 */
126 final ResultDescriptor<List<AnalysisError>> HINTS = 131 final ResultDescriptor<List<AnalysisError>> HINTS =
127 new ResultDescriptor<List<AnalysisError>>( 132 new ResultDescriptor<List<AnalysisError>>(
128 'HINT_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); 133 'HINT_ERRORS', AnalysisError.NO_ERRORS);
129 134
130 /** 135 /**
131 * The sources representing the import closure of a library. 136 * The sources representing the import closure of a library.
132 * The [Source]s include only library sources, not their units. 137 * The [Source]s include only library sources, not their units.
133 * 138 *
134 * The result is only available for targets representing a Dart library. 139 * The result is only available for targets representing a Dart library.
135 */ 140 */
136 final ListResultDescriptor<Source> IMPORT_SOURCE_CLOSURE = 141 final ListResultDescriptor<Source> IMPORT_SOURCE_CLOSURE =
137 new ListResultDescriptor<Source>('IMPORT_SOURCE_CLOSURE', null); 142 new ListResultDescriptor<Source>('IMPORT_SOURCE_CLOSURE', null);
138 143
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 * 196 *
192 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit. 197 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit.
193 * 198 *
194 * The result is only available for targets representing a Dart library. 199 * The result is only available for targets representing a Dart library.
195 */ 200 */
196 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 = 201 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 =
197 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null, 202 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null,
198 cachingPolicy: ELEMENT_CACHING_POLICY); 203 cachingPolicy: ELEMENT_CACHING_POLICY);
199 204
200 /** 205 /**
206 * The analysis errors associated with a compilation unit in a specific library.
207 *
208 * The result is only available for targets representing a Dart compilation unit
209 * in a specific library.
210 */
211 final ResultDescriptor<List<AnalysisError>> LIBRARY_UNIT_ERRORS =
212 new ResultDescriptor<List<AnalysisError>>(
213 'LIBRARY_UNIT_ERRORS', AnalysisError.NO_ERRORS);
214
215 /**
201 * The errors produced while parsing a compilation unit. 216 * The errors produced while parsing a compilation unit.
202 * 217 *
203 * The list will be empty if there were no errors, but will not be `null`. 218 * The list will be empty if there were no errors, but will not be `null`.
204 * 219 *
205 * The result is only available for targets representing a Dart compilation unit . 220 * The result is only available for targets representing a Dart compilation unit .
206 */ 221 */
207 final ResultDescriptor<List<AnalysisError>> PARSE_ERRORS = 222 final ResultDescriptor<List<AnalysisError>> PARSE_ERRORS =
208 new ResultDescriptor<List<AnalysisError>>( 223 new ResultDescriptor<List<AnalysisError>>(
209 'PARSE_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); 224 'PARSE_ERRORS', AnalysisError.NO_ERRORS);
210 225
211 /** 226 /**
212 * The errors produced while resolving references. 227 * The errors produced while resolving references.
213 * 228 *
214 * The list will be empty if there were no errors, but will not be `null`. 229 * The list will be empty if there were no errors, but will not be `null`.
215 * 230 *
216 * The result is only available for targets representing a unit. 231 * The result is only available for targets representing a unit.
217 */ 232 */
218 final ResultDescriptor<List<AnalysisError>> RESOLVE_REFERENCES_ERRORS = 233 final ResultDescriptor<List<AnalysisError>> RESOLVE_REFERENCES_ERRORS =
219 new ResultDescriptor<List<AnalysisError>>( 234 new ResultDescriptor<List<AnalysisError>>(
220 'RESOLVE_REFERENCES_ERRORS', AnalysisError.NO_ERRORS, 235 'RESOLVE_REFERENCES_ERRORS', AnalysisError.NO_ERRORS);
221 contributesTo: DART_ERRORS);
222 236
223 /** 237 /**
224 * The errors produced while resolving type names. 238 * The errors produced while resolving type names.
225 * 239 *
226 * The list will be empty if there were no errors, but will not be `null`. 240 * The list will be empty if there were no errors, but will not be `null`.
227 * 241 *
228 * The result is only available for targets representing a Dart library. 242 * The result is only available for targets representing a Dart library.
229 */ 243 */
230 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS = 244 final ResultDescriptor<List<AnalysisError>> RESOLVE_TYPE_NAMES_ERRORS =
231 new ResultDescriptor<List<AnalysisError>>( 245 new ResultDescriptor<List<AnalysisError>>(
232 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS, 246 'RESOLVE_TYPE_NAMES_ERRORS', AnalysisError.NO_ERRORS);
233 contributesTo: DART_ERRORS);
234 247
235 /** 248 /**
236 * The partially resolved [CompilationUnit] associated with a unit. 249 * The partially resolved [CompilationUnit] associated with a unit.
237 * 250 *
238 * All declarations bound to the element defined by the declaration. 251 * All declarations bound to the element defined by the declaration.
239 * 252 *
240 * The result is only available for targets representing a unit. 253 * The result is only available for targets representing a unit.
241 */ 254 */
242 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = 255 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 =
243 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null, 256 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 302
290 /** 303 /**
291 * The errors produced while scanning a compilation unit. 304 * The errors produced while scanning a compilation unit.
292 * 305 *
293 * The list will be empty if there were no errors, but will not be `null`. 306 * The list will be empty if there were no errors, but will not be `null`.
294 * 307 *
295 * The result is only available for targets representing a Dart compilation unit . 308 * The result is only available for targets representing a Dart compilation unit .
296 */ 309 */
297 final ResultDescriptor<List<AnalysisError>> SCAN_ERRORS = 310 final ResultDescriptor<List<AnalysisError>> SCAN_ERRORS =
298 new ResultDescriptor<List<AnalysisError>>( 311 new ResultDescriptor<List<AnalysisError>>(
299 'SCAN_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); 312 'SCAN_ERRORS', AnalysisError.NO_ERRORS);
300 313
301 /** 314 /**
302 * The [ResultCachingPolicy] for [TOKEN_STREAM]. 315 * The [ResultCachingPolicy] for [TOKEN_STREAM].
303 */ 316 */
304 const ResultCachingPolicy TOKEN_STREAM_CACHING_POLICY = 317 const ResultCachingPolicy TOKEN_STREAM_CACHING_POLICY =
305 const SimpleResultCachingPolicy(1, 1); 318 const SimpleResultCachingPolicy(1, 1);
306 319
307 /** 320 /**
308 * The [TypeProvider] of the context. 321 * The [TypeProvider] of the context.
309 */ 322 */
(...skipping 16 matching lines...) Expand all
326 339
327 /** 340 /**
328 * The errors produced while verifying a compilation unit. 341 * The errors produced while verifying a compilation unit.
329 * 342 *
330 * The list will be empty if there were no errors, but will not be `null`. 343 * The list will be empty if there were no errors, but will not be `null`.
331 * 344 *
332 * The result is only available for targets representing a Dart compilation unit . 345 * The result is only available for targets representing a Dart compilation unit .
333 */ 346 */
334 final ResultDescriptor<List<AnalysisError>> VERIFY_ERRORS = 347 final ResultDescriptor<List<AnalysisError>> VERIFY_ERRORS =
335 new ResultDescriptor<List<AnalysisError>>( 348 new ResultDescriptor<List<AnalysisError>>(
336 'VERIFY_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); 349 'VERIFY_ERRORS', AnalysisError.NO_ERRORS);
337 350
338 /** 351 /**
339 * A task that builds implicit constructors for a [ClassElement], or keeps 352 * A task that builds implicit constructors for a [ClassElement], or keeps
340 * the existing explicit constructors if the class has them. 353 * the existing explicit constructors if the class has them.
341 */ 354 */
342 class BuildClassConstructorsTask extends SourceBasedAnalysisTask { 355 class BuildClassConstructorsTask extends SourceBasedAnalysisTask {
343 /** 356 /**
344 * The name of the [CONSTRUCTORS] input for the superclass. 357 * The name of the [CONSTRUCTORS] input for the superclass.
345 */ 358 */
346 static const String SUPER_CONSTRUCTORS = 'SUPER_CONSTRUCTORS'; 359 static const String SUPER_CONSTRUCTORS = 'SUPER_CONSTRUCTORS';
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 /** 1633 /**
1621 * Create a [BuildTypeProviderTask] based on the given [context]. 1634 * Create a [BuildTypeProviderTask] based on the given [context].
1622 */ 1635 */
1623 static BuildTypeProviderTask createTask( 1636 static BuildTypeProviderTask createTask(
1624 AnalysisContext context, AnalysisContextTarget target) { 1637 AnalysisContext context, AnalysisContextTarget target) {
1625 return new BuildTypeProviderTask(context, target); 1638 return new BuildTypeProviderTask(context, target);
1626 } 1639 }
1627 } 1640 }
1628 1641
1629 /** 1642 /**
1643 * A task that merges all of the errors for a single source into a single list
1644 * of errors.
scheglov 2015/05/07 18:11:38 It seems that the comment should be updated.
Brian Wilkerson 2015/05/07 18:30:08 Done
1645 */
1646 class ContainingLibrariesTask extends SourceBasedAnalysisTask {
1647 /**
1648 * The task descriptor describing this kind of task.
1649 */
1650 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
1651 'ContainingLibrariesTask', createTask, buildInputs,
1652 <ResultDescriptor>[CONTAINING_LIBRARIES]);
1653
1654 ContainingLibrariesTask(
1655 InternalAnalysisContext context, AnalysisTarget target)
1656 : super(context, target);
1657
1658 @override
1659 TaskDescriptor get descriptor => DESCRIPTOR;
1660
1661 @override
1662 void internalPerform() {
1663 Source source = getRequiredSource();
1664 outputs[CONTAINING_LIBRARIES] = context.getLibrariesContaining(source);
1665 }
1666
1667 /**
1668 * Return a map from the names of the inputs of this kind of task to the task
1669 * input descriptors describing those inputs for a task with the
1670 * given [target].
1671 */
1672 static Map<String, TaskInput> buildInputs(Source target) {
1673 return <String, TaskInput>{};
1674 }
1675
1676 /**
1677 * Create a [ContainingLibrariesTask] based on the given [target] in the given
1678 * [context].
1679 */
1680 static ContainingLibrariesTask createTask(
1681 AnalysisContext context, AnalysisTarget target) {
1682 return new ContainingLibrariesTask(context, target);
1683 }
1684 }
1685
1686 /**
1687 * A task that merges all of the errors for a single source into a single list
1688 * of errors.
1689 */
1690 class DartErrorsTask extends SourceBasedAnalysisTask {
1691 /**
1692 * The name of the [BUILD_DIRECTIVES_ERRORS] input.
1693 */
1694 static const String BUILD_DIRECTIVES_ERRORS_INPUT = 'BUILD_DIRECTIVES_ERRORS';
1695
1696 /**
1697 * The name of the [BUILD_LIBRARY_ERRORS] input.
1698 */
1699 static const String BUILD_LIBRARY_ERRORS_INPUT = 'BUILD_LIBRARY_ERRORS';
1700
1701 /**
1702 * The name of the [LIBRARY_UNIT_ERRORS] input.
1703 */
1704 static const String LIBRARY_UNIT_ERRORS_INPUT = 'LIBRARY_UNIT_ERRORS';
1705
1706 /**
1707 * The name of the [PARSE_ERRORS] input.
1708 */
1709 static const String PARSE_ERRORS_INPUT = 'PARSE_ERRORS';
1710
1711 /**
1712 * The name of the [SCAN_ERRORS] input.
1713 */
1714 static const String SCAN_ERRORS_INPUT = 'SCAN_ERRORS';
1715
1716 /**
1717 * The task descriptor describing this kind of task.
1718 */
1719 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('DartErrorsTask',
1720 createTask, buildInputs, <ResultDescriptor>[DART_ERRORS]);
1721
1722 DartErrorsTask(InternalAnalysisContext context, AnalysisTarget target)
1723 : super(context, target);
1724
1725 @override
1726 TaskDescriptor get descriptor => DESCRIPTOR;
1727
1728 @override
1729 void internalPerform() {
1730 //
1731 // Prepare inputs.
1732 //
1733 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[];
1734 errorLists.add(getRequiredInput(BUILD_DIRECTIVES_ERRORS_INPUT));
1735 errorLists.add(getRequiredInput(BUILD_LIBRARY_ERRORS_INPUT));
1736 errorLists.add(getRequiredInput(PARSE_ERRORS_INPUT));
1737 errorLists.add(getRequiredInput(SCAN_ERRORS_INPUT));
1738 Map unitErrors = getRequiredInput(LIBRARY_UNIT_ERRORS_INPUT);
scheglov 2015/05/07 18:11:38 Type arguments?
Brian Wilkerson 2015/05/07 18:30:08 Done
1739 for (List<AnalysisError> errors in unitErrors.values) {
1740 errorLists.add(errors);
1741 }
1742 //
1743 // Record outputs.
1744 //
1745 outputs[DART_ERRORS] = AnalysisError.mergeLists(errorLists);
1746 }
1747
1748 /**
1749 * Return a map from the names of the inputs of this kind of task to the task
1750 * input descriptors describing those inputs for a task with the
1751 * given [target].
1752 */
1753 static Map<String, TaskInput> buildInputs(Source target) {
1754 return <String, TaskInput>{
1755 BUILD_DIRECTIVES_ERRORS_INPUT: BUILD_DIRECTIVES_ERRORS.of(target),
1756 BUILD_LIBRARY_ERRORS_INPUT: BUILD_LIBRARY_ERRORS.of(target),
1757 PARSE_ERRORS_INPUT: PARSE_ERRORS.of(target),
1758 SCAN_ERRORS_INPUT: SCAN_ERRORS.of(target),
1759 LIBRARY_UNIT_ERRORS_INPUT: CONTAINING_LIBRARIES
1760 .of(target)
1761 .toMap((Source library) {
1762 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, target);
1763 return LIBRARY_UNIT_ERRORS.of(unit);
1764 })
1765 };
1766 }
1767
1768 /**
1769 * Create a [DartErrorsTask] based on the given [target] in the given
1770 * [context].
1771 */
1772 static DartErrorsTask createTask(
1773 AnalysisContext context, AnalysisTarget target) {
1774 return new DartErrorsTask(context, target);
1775 }
1776 }
1777
1778 /**
1630 * The helper for building the export [Namespace] of a [LibraryElement]. 1779 * The helper for building the export [Namespace] of a [LibraryElement].
1631 */ 1780 */
1632 class ExportNamespaceBuilder { 1781 class ExportNamespaceBuilder {
1633 /** 1782 /**
1634 * Build the export [Namespace] of the given [LibraryElement]. 1783 * Build the export [Namespace] of the given [LibraryElement].
1635 */ 1784 */
1636 Namespace build(LibraryElement library) { 1785 Namespace build(LibraryElement library) {
1637 return new Namespace( 1786 return new Namespace(
1638 _createExportMapping(library, new HashSet<LibraryElement>())); 1787 _createExportMapping(library, new HashSet<LibraryElement>()));
1639 } 1788 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 } 1996 }
1848 } 1997 }
1849 1998
1850 /** 1999 /**
1851 * A task that generates [HINTS] for a unit. 2000 * A task that generates [HINTS] for a unit.
1852 */ 2001 */
1853 class GenerateHintsTask extends SourceBasedAnalysisTask { 2002 class GenerateHintsTask extends SourceBasedAnalysisTask {
1854 /** 2003 /**
1855 * The name of the [RESOLVED_UNIT] input. 2004 * The name of the [RESOLVED_UNIT] input.
1856 */ 2005 */
1857 static const String UNIT_INPUT = 'UNIT_INPUT'; 2006 static const String RESOLVED_UNIT_INPUT = 'RESOLVED_UNIT';
1858 2007
1859 /** 2008 /**
1860 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. 2009 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input.
1861 */ 2010 */
1862 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; 2011 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS';
1863 2012
1864 /** 2013 /**
1865 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. 2014 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input.
1866 */ 2015 */
1867 static const String USED_IMPORTED_ELEMENTS_INPUT = 'USED_IMPORTED_ELEMENTS'; 2016 static const String USED_IMPORTED_ELEMENTS_INPUT = 'USED_IMPORTED_ELEMENTS';
(...skipping 11 matching lines...) Expand all
1879 TaskDescriptor get descriptor => DESCRIPTOR; 2028 TaskDescriptor get descriptor => DESCRIPTOR;
1880 2029
1881 @override 2030 @override
1882 void internalPerform() { 2031 void internalPerform() {
1883 RecordingErrorListener errorListener = new RecordingErrorListener(); 2032 RecordingErrorListener errorListener = new RecordingErrorListener();
1884 Source source = getRequiredSource(); 2033 Source source = getRequiredSource();
1885 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 2034 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
1886 // 2035 //
1887 // Prepare inputs. 2036 // Prepare inputs.
1888 // 2037 //
1889 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 2038 CompilationUnit unit = getRequiredInput(RESOLVED_UNIT_INPUT);
1890 List<UsedImportedElements> usedImportedElementsList = 2039 List<UsedImportedElements> usedImportedElementsList =
1891 getRequiredInput(USED_IMPORTED_ELEMENTS_INPUT); 2040 getRequiredInput(USED_IMPORTED_ELEMENTS_INPUT);
1892 List<UsedLocalElements> usedLocalElementsList = 2041 List<UsedLocalElements> usedLocalElementsList =
1893 getRequiredInput(USED_LOCAL_ELEMENTS_INPUT); 2042 getRequiredInput(USED_LOCAL_ELEMENTS_INPUT);
1894 CompilationUnitElement unitElement = unit.element; 2043 CompilationUnitElement unitElement = unit.element;
1895 LibraryElement libraryElement = unitElement.library; 2044 LibraryElement libraryElement = unitElement.library;
1896 // 2045 //
1897 // Generate errors. 2046 // Generate errors.
1898 // 2047 //
1899 unit.accept(new DeadCodeVerifier(errorReporter)); 2048 unit.accept(new DeadCodeVerifier(errorReporter));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 } 2081 }
1933 2082
1934 /** 2083 /**
1935 * Return a map from the names of the inputs of this kind of task to the task 2084 * Return a map from the names of the inputs of this kind of task to the task
1936 * input descriptors describing those inputs for a task with the 2085 * input descriptors describing those inputs for a task with the
1937 * given [target]. 2086 * given [target].
1938 */ 2087 */
1939 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { 2088 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
1940 Source libSource = target.library; 2089 Source libSource = target.library;
1941 return <String, TaskInput>{ 2090 return <String, TaskInput>{
1942 UNIT_INPUT: RESOLVED_UNIT.of(target), 2091 RESOLVED_UNIT_INPUT: RESOLVED_UNIT.of(target),
1943 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { 2092 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) {
1944 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); 2093 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit);
1945 return USED_LOCAL_ELEMENTS.of(target); 2094 return USED_LOCAL_ELEMENTS.of(target);
1946 }), 2095 }),
1947 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { 2096 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) {
1948 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); 2097 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit);
1949 return USED_IMPORTED_ELEMENTS.of(target); 2098 return USED_IMPORTED_ELEMENTS.of(target);
1950 }) 2099 })
1951 }; 2100 };
1952 } 2101 }
1953 2102
1954 /** 2103 /**
1955 * Create a [GenerateHintsTask] based on the given [target] in 2104 * Create a [GenerateHintsTask] based on the given [target] in
1956 * the given [context]. 2105 * the given [context].
1957 */ 2106 */
1958 static GenerateHintsTask createTask( 2107 static GenerateHintsTask createTask(
1959 AnalysisContext context, AnalysisTarget target) { 2108 AnalysisContext context, AnalysisTarget target) {
1960 return new GenerateHintsTask(context, target); 2109 return new GenerateHintsTask(context, target);
1961 } 2110 }
1962 } 2111 }
1963 2112
1964 /** 2113 /**
2114 * A task that merges all of the errors for a single source into a single list
2115 * of errors.
2116 */
2117 class LibraryUnitErrorsTask extends SourceBasedAnalysisTask {
2118 /**
2119 * The name of the [BUILD_FUNCTION_TYPE_ALIASES_ERRORS] input.
2120 */
2121 static const String BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT =
2122 'BUILD_FUNCTION_TYPE_ALIASES_ERRORS';
2123
2124 /**
2125 * The name of the [HINTS] input.
2126 */
2127 static const String HINTS_INPUT = 'HINTS';
2128
2129 /**
2130 * The name of the [RESOLVE_REFERENCES_ERRORS] input.
2131 */
2132 static const String RESOLVE_REFERENCES_ERRORS_INPUT =
2133 'RESOLVE_REFERENCES_ERRORS';
2134
2135 /**
2136 * The name of the [RESOLVE_TYPE_NAMES_ERRORS] input.
2137 */
2138 static const String RESOLVE_TYPE_NAMES_ERRORS_INPUT =
2139 'RESOLVE_TYPE_NAMES_ERRORS';
2140
2141 /**
2142 * The name of the [VERIFY_ERRORS] input.
2143 */
2144 static const String VERIFY_ERRORS_INPUT = 'VERIFY_ERRORS';
2145
2146 /**
2147 * The task descriptor describing this kind of task.
2148 */
2149 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2150 'LibraryUnitErrorsTask', createTask, buildInputs,
2151 <ResultDescriptor>[LIBRARY_UNIT_ERRORS]);
2152
2153 LibraryUnitErrorsTask(InternalAnalysisContext context, AnalysisTarget target)
2154 : super(context, target);
2155
2156 @override
2157 TaskDescriptor get descriptor => DESCRIPTOR;
2158
2159 @override
2160 void internalPerform() {
2161 //
2162 // Prepare inputs.
2163 //
2164 List<List<AnalysisError>> errorLists = <List<AnalysisError>>[];
2165 errorLists.add(getRequiredInput(BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT));
2166 errorLists.add(getRequiredInput(HINTS_INPUT));
2167 errorLists.add(getRequiredInput(RESOLVE_REFERENCES_ERRORS_INPUT));
2168 errorLists.add(getRequiredInput(RESOLVE_TYPE_NAMES_ERRORS_INPUT));
2169 errorLists.add(getRequiredInput(VERIFY_ERRORS_INPUT));
2170 //
2171 // Record outputs.
2172 //
2173 outputs[LIBRARY_UNIT_ERRORS] = AnalysisError.mergeLists(errorLists);
2174 }
2175
2176 /**
2177 * Return a map from the names of the inputs of this kind of task to the task
2178 * input descriptors describing those inputs for a task with the
2179 * given [unit].
2180 */
2181 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit unit) {
2182 return <String, TaskInput>{
2183 BUILD_FUNCTION_TYPE_ALIASES_ERRORS_INPUT:
2184 BUILD_FUNCTION_TYPE_ALIASES_ERRORS.of(unit),
2185 HINTS_INPUT: HINTS.of(unit),
2186 RESOLVE_REFERENCES_ERRORS_INPUT: RESOLVE_REFERENCES_ERRORS.of(unit),
2187 RESOLVE_TYPE_NAMES_ERRORS_INPUT: RESOLVE_TYPE_NAMES_ERRORS.of(unit),
2188 VERIFY_ERRORS_INPUT: VERIFY_ERRORS.of(unit)
2189 };
2190 }
2191
2192 /**
2193 * Create a [LibraryUnitErrorsTask] based on the given [target] in the given
2194 * [context].
2195 */
2196 static LibraryUnitErrorsTask createTask(
2197 AnalysisContext context, AnalysisTarget target) {
2198 return new LibraryUnitErrorsTask(context, target);
2199 }
2200 }
2201
2202 /**
1965 * The memento for [ParseDartTask]. 2203 * The memento for [ParseDartTask].
1966 */ 2204 */
1967 class ParseDartMemento { 2205 class ParseDartMemento {
1968 final Token inputTokenStream; 2206 final Token inputTokenStream;
1969 final List<Source> explicitlyImportedLibraries; 2207 final List<Source> explicitlyImportedLibraries;
1970 final List<Source> exportedLibraries; 2208 final List<Source> exportedLibraries;
1971 final List<Source> importedLibraries; 2209 final List<Source> importedLibraries;
1972 final List<Source> includedParts; 2210 final List<Source> includedParts;
1973 final List<AnalysisError> parseErrors; 2211 final List<AnalysisError> parseErrors;
1974 final CompilationUnit parsedUnit; 2212 final CompilationUnit parsedUnit;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 2523
2286 /** 2524 /**
2287 * The name of the [RESOLVED_UNIT5] input. 2525 * The name of the [RESOLVED_UNIT5] input.
2288 */ 2526 */
2289 static const String UNIT_INPUT = 'UNIT_INPUT'; 2527 static const String UNIT_INPUT = 'UNIT_INPUT';
2290 2528
2291 /** 2529 /**
2292 * The task descriptor describing this kind of task. 2530 * The task descriptor describing this kind of task.
2293 */ 2531 */
2294 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2532 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2295 'ResolveReferencesTask', createTask, buildInputs, 2533 'ResolveReferencesTask', createTask, buildInputs, <ResultDescriptor>[
2296 <ResultDescriptor>[RESOLVED_UNIT]); 2534 RESOLVE_REFERENCES_ERRORS,
2535 RESOLVED_UNIT
2536 ]);
2297 2537
2298 ResolveReferencesTask(InternalAnalysisContext context, AnalysisTarget target) 2538 ResolveReferencesTask(InternalAnalysisContext context, AnalysisTarget target)
2299 : super(context, target); 2539 : super(context, target);
2300 2540
2301 @override 2541 @override
2302 TaskDescriptor get descriptor => DESCRIPTOR; 2542 TaskDescriptor get descriptor => DESCRIPTOR;
2303 2543
2304 @override 2544 @override
2305 void internalPerform() { 2545 void internalPerform() {
2306 RecordingErrorListener errorListener = new RecordingErrorListener(); 2546 RecordingErrorListener errorListener = new RecordingErrorListener();
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 @override 2979 @override
2740 bool moveNext() { 2980 bool moveNext() {
2741 if (_newSources.isEmpty) { 2981 if (_newSources.isEmpty) {
2742 return false; 2982 return false;
2743 } 2983 }
2744 currentTarget = _newSources.first; 2984 currentTarget = _newSources.first;
2745 _newSources.remove(currentTarget); 2985 _newSources.remove(currentTarget);
2746 return true; 2986 return true;
2747 } 2987 }
2748 } 2988 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698