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

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

Issue 1124003007: In the new task model, use explicit dependencies on the type provider. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reformat 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 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 1673
1674 /** 1674 /**
1675 * A task that computes [CONSTANT_DEPENDENCIES] for a constant. 1675 * A task that computes [CONSTANT_DEPENDENCIES] for a constant.
1676 */ 1676 */
1677 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask { 1677 class ComputeConstantDependenciesTask extends ConstantEvaluationAnalysisTask {
1678 /** 1678 /**
1679 * The name of the [RESOLVED_UNIT6] input. 1679 * The name of the [RESOLVED_UNIT6] input.
1680 */ 1680 */
1681 static const String UNIT_INPUT = 'UNIT_INPUT'; 1681 static const String UNIT_INPUT = 'UNIT_INPUT';
1682 1682
1683 /**
1684 * The name of the [TYPE_PROVIDER] input.
1685 */
1686 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
1687
1683 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 1688 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
1684 'ComputeConstantDependenciesTask', createTask, buildInputs, 1689 'ComputeConstantDependenciesTask', createTask, buildInputs,
1685 <ResultDescriptor>[CONSTANT_DEPENDENCIES]); 1690 <ResultDescriptor>[CONSTANT_DEPENDENCIES]);
1686 1691
1687 ComputeConstantDependenciesTask( 1692 ComputeConstantDependenciesTask(
1688 InternalAnalysisContext context, ConstantEvaluationTarget constant) 1693 InternalAnalysisContext context, ConstantEvaluationTarget constant)
1689 : super(context, constant); 1694 : super(context, constant);
1690 1695
1691 @override 1696 @override
1692 TaskDescriptor get descriptor => DESCRIPTOR; 1697 TaskDescriptor get descriptor => DESCRIPTOR;
1693 1698
1694 @override 1699 @override
1695 void internalPerform() { 1700 void internalPerform() {
1696 // 1701 //
1697 // Prepare inputs. 1702 // Prepare inputs.
1698 // 1703 //
1699 // Note: UNIT_INPUT is not needed. It is merely a bookkeeping dependency 1704 // Note: UNIT_INPUT is not needed. It is merely a bookkeeping dependency
1700 // to ensure that resolution has occurred before we attempt to determine 1705 // to ensure that resolution has occurred before we attempt to determine
1701 // constant dependencies. 1706 // constant dependencies.
1702 // 1707 //
1703 ConstantEvaluationTarget constant = target; 1708 ConstantEvaluationTarget constant = target;
1704 AnalysisContext context = constant.context; 1709 AnalysisContext context = constant.context;
1705 TypeProvider typeProvider = context.typeProvider; 1710 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
1706 // 1711 //
1707 // Compute dependencies. 1712 // Compute dependencies.
1708 // 1713 //
1709 List<ConstantEvaluationTarget> dependencies = <ConstantEvaluationTarget>[]; 1714 List<ConstantEvaluationTarget> dependencies = <ConstantEvaluationTarget>[];
1710 new ConstantEvaluationEngine(typeProvider, context.declaredVariables) 1715 new ConstantEvaluationEngine(typeProvider, context.declaredVariables)
1711 .computeDependencies(constant, dependencies.add); 1716 .computeDependencies(constant, dependencies.add);
1712 // 1717 //
1713 // Record outputs. 1718 // Record outputs.
1714 // 1719 //
1715 outputs[CONSTANT_DEPENDENCIES] = dependencies; 1720 outputs[CONSTANT_DEPENDENCIES] = dependencies;
1716 } 1721 }
1717 1722
1718 /** 1723 /**
1719 * Return a map from the names of the inputs of this kind of task to the task 1724 * Return a map from the names of the inputs of this kind of task to the task
1720 * input descriptors describing those inputs for a task with the 1725 * input descriptors describing those inputs for a task with the
1721 * given [target]. 1726 * given [target].
1722 */ 1727 */
1723 static Map<String, TaskInput> buildInputs(ConstantEvaluationTarget target) { 1728 static Map<String, TaskInput> buildInputs(ConstantEvaluationTarget target) {
1724 if (target is Element) { 1729 if (target is Element) {
1725 CompilationUnitElementImpl unit = (target as Element) 1730 CompilationUnitElementImpl unit = (target as Element)
1726 .getAncestor((Element element) => element is CompilationUnitElement); 1731 .getAncestor((Element element) => element is CompilationUnitElement);
1727 return <String, TaskInput>{ 1732 return <String, TaskInput>{
1728 UNIT_INPUT: RESOLVED_UNIT6 1733 UNIT_INPUT: RESOLVED_UNIT6
1729 .of(new LibrarySpecificUnit(unit.librarySource, target.source)) 1734 .of(new LibrarySpecificUnit(unit.librarySource, target.source)),
1735 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
1730 }; 1736 };
1731 } else if (target is ConstantEvaluationTarget_Annotation) { 1737 } else if (target is ConstantEvaluationTarget_Annotation) {
1732 return <String, TaskInput>{ 1738 return <String, TaskInput>{
1733 UNIT_INPUT: RESOLVED_UNIT6 1739 UNIT_INPUT: RESOLVED_UNIT6
1734 .of(new LibrarySpecificUnit(target.librarySource, target.source)) 1740 .of(new LibrarySpecificUnit(target.librarySource, target.source)),
1741 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
1735 }; 1742 };
1736 } else { 1743 } else {
1737 // Should never happen. 1744 // Should never happen.
1738 assert(false); 1745 assert(false);
1739 return <String, TaskInput>{}; 1746 return <String, TaskInput>{};
1740 } 1747 }
1741 } 1748 }
1742 1749
1743 /** 1750 /**
1744 * Create a [ResolveReferencesTask] based on the given [target] in 1751 * Create a [ResolveReferencesTask] based on the given [target] in
1745 * the given [context]. 1752 * the given [context].
1746 */ 1753 */
1747 static ComputeConstantDependenciesTask createTask( 1754 static ComputeConstantDependenciesTask createTask(
1748 AnalysisContext context, AnalysisTarget target) { 1755 AnalysisContext context, AnalysisTarget target) {
1749 return new ComputeConstantDependenciesTask(context, target); 1756 return new ComputeConstantDependenciesTask(context, target);
1750 } 1757 }
1751 } 1758 }
1752 1759
1753 /** 1760 /**
1754 * A task that computes the value of a constant ([CONSTANT_VALUE]) and 1761 * A task that computes the value of a constant ([CONSTANT_VALUE]) and
1755 * stores it in the element model. 1762 * stores it in the element model.
1756 */ 1763 */
1757 class ComputeConstantValueTask extends ConstantEvaluationAnalysisTask { 1764 class ComputeConstantValueTask extends ConstantEvaluationAnalysisTask {
1758 /** 1765 /**
1759 * The name of the input which ensures that dependent constants are evaluated 1766 * The name of the input which ensures that dependent constants are evaluated
1760 * before the target. 1767 * before the target.
1761 */ 1768 */
1762 static const String DEPENDENCIES_INPUT = 'DEPENDENCIES_INPUT'; 1769 static const String DEPENDENCIES_INPUT = 'DEPENDENCIES_INPUT';
1763 1770
1771 /**
1772 * The name of the [TYPE_PROVIDER] input.
1773 */
1774 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
1775
1764 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 1776 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
1765 'ComputeConstantValueTask', createTask, buildInputs, 1777 'ComputeConstantValueTask', createTask, buildInputs,
1766 <ResultDescriptor>[CONSTANT_VALUE]); 1778 <ResultDescriptor>[CONSTANT_VALUE]);
1767 1779
1768 ComputeConstantValueTask( 1780 ComputeConstantValueTask(
1769 InternalAnalysisContext context, ConstantEvaluationTarget constant) 1781 InternalAnalysisContext context, ConstantEvaluationTarget constant)
1770 : super(context, constant); 1782 : super(context, constant);
1771 1783
1772 @override 1784 @override
1773 TaskDescriptor get descriptor => DESCRIPTOR; 1785 TaskDescriptor get descriptor => DESCRIPTOR;
1774 1786
1775 @override 1787 @override
1776 void internalPerform() { 1788 void internalPerform() {
1777 // 1789 //
1778 // Prepare inputs. 1790 // Prepare inputs.
1779 // 1791 //
1780 // Note: DEPENDENCIES_INPUT is not needed. It is merely a bookkeeping 1792 // Note: DEPENDENCIES_INPUT is not needed. It is merely a bookkeeping
1781 // dependency to ensure that the constants that this constant depends on 1793 // dependency to ensure that the constants that this constant depends on
1782 // are computed first. 1794 // are computed first.
1783 ConstantEvaluationTarget constant = target; 1795 ConstantEvaluationTarget constant = target;
1784 AnalysisContext context = constant.context; 1796 AnalysisContext context = constant.context;
1785 TypeProvider typeProvider = context.typeProvider; 1797 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
1786 // 1798 //
1787 // Compute the value of the constant. 1799 // Compute the value of the constant.
1788 // 1800 //
1789 new ConstantEvaluationEngine(typeProvider, context.declaredVariables) 1801 new ConstantEvaluationEngine(typeProvider, context.declaredVariables)
1790 .computeConstantValue(constant); 1802 .computeConstantValue(constant);
1791 // 1803 //
1792 // Record outputs. 1804 // Record outputs.
1793 // 1805 //
1794 outputs[CONSTANT_VALUE] = constant; 1806 outputs[CONSTANT_VALUE] = constant;
1795 } 1807 }
1796 1808
1797 /** 1809 /**
1798 * Return a map from the names of the inputs of this kind of task to the task 1810 * Return a map from the names of the inputs of this kind of task to the task
1799 * input descriptors describing those inputs for a task with the given 1811 * input descriptors describing those inputs for a task with the given
1800 * [target]. 1812 * [target].
1801 */ 1813 */
1802 static Map<String, TaskInput> buildInputs(ConstantEvaluationTarget target) { 1814 static Map<String, TaskInput> buildInputs(ConstantEvaluationTarget target) {
1803 return <String, TaskInput>{ 1815 return <String, TaskInput>{
1804 DEPENDENCIES_INPUT: 1816 DEPENDENCIES_INPUT:
1805 CONSTANT_DEPENDENCIES.of(target).toListOf(CONSTANT_VALUE) 1817 CONSTANT_DEPENDENCIES.of(target).toListOf(CONSTANT_VALUE),
1818 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
1806 }; 1819 };
1807 } 1820 }
1808 1821
1809 /** 1822 /**
1810 * Create a [ComputeConstantValueTask] based on the given [target] in the 1823 * Create a [ComputeConstantValueTask] based on the given [target] in the
1811 * given [context]. 1824 * given [context].
1812 */ 1825 */
1813 static ComputeConstantValueTask createTask( 1826 static ComputeConstantValueTask createTask(
1814 AnalysisContext context, AnalysisTarget target) { 1827 AnalysisContext context, AnalysisTarget target) {
1815 return new ComputeConstantValueTask(context, target); 1828 return new ComputeConstantValueTask(context, target);
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input. 2293 * The name of a list of [USED_LOCAL_ELEMENTS] for each library unit input.
2281 */ 2294 */
2282 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS'; 2295 static const String USED_LOCAL_ELEMENTS_INPUT = 'USED_LOCAL_ELEMENTS';
2283 2296
2284 /** 2297 /**
2285 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input. 2298 * The name of a list of [USED_IMPORTED_ELEMENTS] for each library unit input.
2286 */ 2299 */
2287 static const String USED_IMPORTED_ELEMENTS_INPUT = 'USED_IMPORTED_ELEMENTS'; 2300 static const String USED_IMPORTED_ELEMENTS_INPUT = 'USED_IMPORTED_ELEMENTS';
2288 2301
2289 /** 2302 /**
2303 * The name of the [TYPE_PROVIDER] input.
2304 */
2305 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
2306
2307 /**
2290 * The task descriptor describing this kind of task. 2308 * The task descriptor describing this kind of task.
2291 */ 2309 */
2292 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2310 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2293 'GenerateHintsTask', createTask, buildInputs, <ResultDescriptor>[HINTS]); 2311 'GenerateHintsTask', createTask, buildInputs, <ResultDescriptor>[HINTS]);
2294 2312
2295 GenerateHintsTask(InternalAnalysisContext context, AnalysisTarget target) 2313 GenerateHintsTask(InternalAnalysisContext context, AnalysisTarget target)
2296 : super(context, target); 2314 : super(context, target);
2297 2315
2298 @override 2316 @override
2299 TaskDescriptor get descriptor => DESCRIPTOR; 2317 TaskDescriptor get descriptor => DESCRIPTOR;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 new UnusedLocalElementsVerifier(errorListener, usedElements); 2351 new UnusedLocalElementsVerifier(errorListener, usedElements);
2334 unitElement.accept(visitor); 2352 unitElement.accept(visitor);
2335 } 2353 }
2336 // Dart2js analysis. 2354 // Dart2js analysis.
2337 if (context.analysisOptions.dart2jsHint) { 2355 if (context.analysisOptions.dart2jsHint) {
2338 unit.accept(new Dart2JSVerifier(errorReporter)); 2356 unit.accept(new Dart2JSVerifier(errorReporter));
2339 } 2357 }
2340 // Dart best practices. 2358 // Dart best practices.
2341 InheritanceManager inheritanceManager = 2359 InheritanceManager inheritanceManager =
2342 new InheritanceManager(libraryElement); 2360 new InheritanceManager(libraryElement);
2343 TypeProvider typeProvider = context.typeProvider; 2361 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
2344 unit.accept(new BestPracticesVerifier(errorReporter, typeProvider)); 2362 unit.accept(new BestPracticesVerifier(errorReporter, typeProvider));
2345 unit.accept(new OverrideVerifier(errorReporter, inheritanceManager)); 2363 unit.accept(new OverrideVerifier(errorReporter, inheritanceManager));
2346 // Find to-do comments. 2364 // Find to-do comments.
2347 new ToDoFinder(errorReporter).findIn(unit); 2365 new ToDoFinder(errorReporter).findIn(unit);
2348 // 2366 //
2349 // Record outputs. 2367 // Record outputs.
2350 // 2368 //
2351 outputs[HINTS] = errorListener.errors; 2369 outputs[HINTS] = errorListener.errors;
2352 } 2370 }
2353 2371
2354 /** 2372 /**
2355 * Return a map from the names of the inputs of this kind of task to the task 2373 * Return a map from the names of the inputs of this kind of task to the task
2356 * input descriptors describing those inputs for a task with the 2374 * input descriptors describing those inputs for a task with the
2357 * given [target]. 2375 * given [target].
2358 */ 2376 */
2359 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { 2377 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2360 Source libSource = target.library; 2378 Source libSource = target.library;
2361 return <String, TaskInput>{ 2379 return <String, TaskInput>{
2362 RESOLVED_UNIT_INPUT: RESOLVED_UNIT.of(target), 2380 RESOLVED_UNIT_INPUT: RESOLVED_UNIT.of(target),
2363 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { 2381 USED_LOCAL_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) {
2364 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); 2382 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit);
2365 return USED_LOCAL_ELEMENTS.of(target); 2383 return USED_LOCAL_ELEMENTS.of(target);
2366 }), 2384 }),
2367 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) { 2385 USED_IMPORTED_ELEMENTS_INPUT: UNITS.of(libSource).toList((unit) {
2368 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit); 2386 LibrarySpecificUnit target = new LibrarySpecificUnit(libSource, unit);
2369 return USED_IMPORTED_ELEMENTS.of(target); 2387 return USED_IMPORTED_ELEMENTS.of(target);
2370 }) 2388 }),
2389 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
2371 }; 2390 };
2372 } 2391 }
2373 2392
2374 /** 2393 /**
2375 * Create a [GenerateHintsTask] based on the given [target] in 2394 * Create a [GenerateHintsTask] based on the given [target] in
2376 * the given [context]. 2395 * the given [context].
2377 */ 2396 */
2378 static GenerateHintsTask createTask( 2397 static GenerateHintsTask createTask(
2379 AnalysisContext context, AnalysisTarget target) { 2398 AnalysisContext context, AnalysisTarget target) {
2380 return new GenerateHintsTask(context, target); 2399 return new GenerateHintsTask(context, target);
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 * The name of the [LIBRARY_ELEMENT] input. 2814 * The name of the [LIBRARY_ELEMENT] input.
2796 */ 2815 */
2797 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; 2816 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
2798 2817
2799 /** 2818 /**
2800 * The name of the [RESOLVED_UNIT5] input. 2819 * The name of the [RESOLVED_UNIT5] input.
2801 */ 2820 */
2802 static const String UNIT_INPUT = 'UNIT_INPUT'; 2821 static const String UNIT_INPUT = 'UNIT_INPUT';
2803 2822
2804 /** 2823 /**
2824 * The name of the [TYPE_PROVIDER] input.
2825 */
2826 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
2827
2828 /**
2805 * The task descriptor describing this kind of task. 2829 * The task descriptor describing this kind of task.
2806 */ 2830 */
2807 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2831 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2808 'ResolveReferencesTask', createTask, buildInputs, <ResultDescriptor>[ 2832 'ResolveReferencesTask', createTask, buildInputs, <ResultDescriptor>[
2809 RESOLVE_REFERENCES_ERRORS, 2833 RESOLVE_REFERENCES_ERRORS,
2810 RESOLVED_UNIT6 2834 RESOLVED_UNIT6
2811 ]); 2835 ]);
2812 2836
2813 ResolveReferencesTask(InternalAnalysisContext context, AnalysisTarget target) 2837 ResolveReferencesTask(InternalAnalysisContext context, AnalysisTarget target)
2814 : super(context, target); 2838 : super(context, target);
2815 2839
2816 @override 2840 @override
2817 TaskDescriptor get descriptor => DESCRIPTOR; 2841 TaskDescriptor get descriptor => DESCRIPTOR;
2818 2842
2819 @override 2843 @override
2820 void internalPerform() { 2844 void internalPerform() {
2821 RecordingErrorListener errorListener = new RecordingErrorListener(); 2845 RecordingErrorListener errorListener = new RecordingErrorListener();
2822 // 2846 //
2823 // Prepare inputs. 2847 // Prepare inputs.
2824 // 2848 //
2825 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); 2849 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
2826 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 2850 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
2827 CompilationUnitElement unitElement = unit.element; 2851 CompilationUnitElement unitElement = unit.element;
2828 TypeProvider typeProvider = unitElement.context.typeProvider; 2852 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
2829 // 2853 //
2830 // Resolve references. 2854 // Resolve references.
2831 // 2855 //
2832 InheritanceManager inheritanceManager = 2856 InheritanceManager inheritanceManager =
2833 new InheritanceManager(libraryElement); 2857 new InheritanceManager(libraryElement);
2834 AstVisitor visitor = new ResolverVisitor.con2(libraryElement, 2858 AstVisitor visitor = new ResolverVisitor.con2(libraryElement,
2835 unitElement.source, typeProvider, inheritanceManager, errorListener); 2859 unitElement.source, typeProvider, inheritanceManager, errorListener);
2836 unit.accept(visitor); 2860 unit.accept(visitor);
2837 // 2861 //
2838 // Record outputs. 2862 // Record outputs.
2839 // 2863 //
2840 outputs[RESOLVE_REFERENCES_ERRORS] = errorListener.errors; 2864 outputs[RESOLVE_REFERENCES_ERRORS] = errorListener.errors;
2841 outputs[RESOLVED_UNIT6] = unit; 2865 outputs[RESOLVED_UNIT6] = unit;
2842 } 2866 }
2843 2867
2844 /** 2868 /**
2845 * Return a map from the names of the inputs of this kind of task to the task 2869 * Return a map from the names of the inputs of this kind of task to the task
2846 * input descriptors describing those inputs for a task with the 2870 * input descriptors describing those inputs for a task with the
2847 * given [target]. 2871 * given [target].
2848 */ 2872 */
2849 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { 2873 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2850 return <String, TaskInput>{ 2874 return <String, TaskInput>{
2851 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library), 2875 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library),
2852 UNIT_INPUT: RESOLVED_UNIT5.of(target) 2876 UNIT_INPUT: RESOLVED_UNIT5.of(target),
2877 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
2853 }; 2878 };
2854 } 2879 }
2855 2880
2856 /** 2881 /**
2857 * Create a [ResolveReferencesTask] based on the given [target] in 2882 * Create a [ResolveReferencesTask] based on the given [target] in
2858 * the given [context]. 2883 * the given [context].
2859 */ 2884 */
2860 static ResolveReferencesTask createTask( 2885 static ResolveReferencesTask createTask(
2861 AnalysisContext context, AnalysisTarget target) { 2886 AnalysisContext context, AnalysisTarget target) {
2862 return new ResolveReferencesTask(context, target); 2887 return new ResolveReferencesTask(context, target);
2863 } 2888 }
2864 } 2889 }
2865 2890
2866 /** 2891 /**
2867 * A task that builds [RESOLVED_UNIT4] for a unit. 2892 * A task that builds [RESOLVED_UNIT4] for a unit.
2868 */ 2893 */
2869 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask { 2894 class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask {
2870 /** 2895 /**
2871 * The name of the [RESOLVED_UNIT3] input. 2896 * The name of the [RESOLVED_UNIT3] input.
2872 */ 2897 */
2873 static const String UNIT_INPUT = 'UNIT_INPUT'; 2898 static const String UNIT_INPUT = 'UNIT_INPUT';
2874 2899
2875 /** 2900 /**
2901 * The name of the [TYPE_PROVIDER] input.
2902 */
2903 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
2904
2905 /**
2876 * The task descriptor describing this kind of task. 2906 * The task descriptor describing this kind of task.
2877 */ 2907 */
2878 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2908 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2879 'ResolveUnitTypeNamesTask', createTask, buildInputs, <ResultDescriptor>[ 2909 'ResolveUnitTypeNamesTask', createTask, buildInputs, <ResultDescriptor>[
2880 RESOLVE_TYPE_NAMES_ERRORS, 2910 RESOLVE_TYPE_NAMES_ERRORS,
2881 RESOLVED_UNIT4 2911 RESOLVED_UNIT4
2882 ]); 2912 ]);
2883 2913
2884 ResolveUnitTypeNamesTask( 2914 ResolveUnitTypeNamesTask(
2885 InternalAnalysisContext context, AnalysisTarget target) 2915 InternalAnalysisContext context, AnalysisTarget target)
2886 : super(context, target); 2916 : super(context, target);
2887 2917
2888 @override 2918 @override
2889 TaskDescriptor get descriptor => DESCRIPTOR; 2919 TaskDescriptor get descriptor => DESCRIPTOR;
2890 2920
2891 @override 2921 @override
2892 void internalPerform() { 2922 void internalPerform() {
2893 RecordingErrorListener errorListener = new RecordingErrorListener(); 2923 RecordingErrorListener errorListener = new RecordingErrorListener();
2894 // 2924 //
2895 // Prepare inputs. 2925 // Prepare inputs.
2896 // 2926 //
2897 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 2927 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
2898 CompilationUnitElement unitElement = unit.element; 2928 CompilationUnitElement unitElement = unit.element;
2929 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
2899 // 2930 //
2900 // Resolve TypeName nodes. 2931 // Resolve TypeName nodes.
2901 // 2932 //
2902 TypeResolverVisitor visitor = new TypeResolverVisitor.con2( 2933 TypeResolverVisitor visitor = new TypeResolverVisitor.con2(
2903 unitElement.library, unitElement.source, context.typeProvider, 2934 unitElement.library, unitElement.source, typeProvider, errorListener);
2904 errorListener);
2905 unit.accept(visitor); 2935 unit.accept(visitor);
2906 // 2936 //
2907 // Record outputs. 2937 // Record outputs.
2908 // 2938 //
2909 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors; 2939 outputs[RESOLVE_TYPE_NAMES_ERRORS] = errorListener.errors;
2910 outputs[RESOLVED_UNIT4] = unit; 2940 outputs[RESOLVED_UNIT4] = unit;
2911 } 2941 }
2912 2942
2913 /** 2943 /**
2914 * Return a map from the names of the inputs of this kind of task to the task 2944 * Return a map from the names of the inputs of this kind of task to the task
2915 * input descriptors describing those inputs for a task with the 2945 * input descriptors describing those inputs for a task with the
2916 * given [target]. 2946 * given [target].
2917 */ 2947 */
2918 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { 2948 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2919 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT3.of(target)}; 2949 return <String, TaskInput>{
2950 UNIT_INPUT: RESOLVED_UNIT3.of(target),
2951 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
2952 };
2920 } 2953 }
2921 2954
2922 /** 2955 /**
2923 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in 2956 * Create a [ResolveUnitTypeNamesTask] based on the given [target] in
2924 * the given [context]. 2957 * the given [context].
2925 */ 2958 */
2926 static ResolveUnitTypeNamesTask createTask( 2959 static ResolveUnitTypeNamesTask createTask(
2927 AnalysisContext context, AnalysisTarget target) { 2960 AnalysisContext context, AnalysisTarget target) {
2928 return new ResolveUnitTypeNamesTask(context, target); 2961 return new ResolveUnitTypeNamesTask(context, target);
2929 } 2962 }
2930 } 2963 }
2931 2964
2932 /** 2965 /**
2933 * A task that builds [RESOLVED_UNIT5] for a unit. 2966 * A task that builds [RESOLVED_UNIT5] for a unit.
2934 */ 2967 */
2935 class ResolveVariableReferencesTask extends SourceBasedAnalysisTask { 2968 class ResolveVariableReferencesTask extends SourceBasedAnalysisTask {
2936 /** 2969 /**
2937 * The name of the [LIBRARY_ELEMENT] input. 2970 * The name of the [LIBRARY_ELEMENT] input.
2938 */ 2971 */
2939 static const String LIBRARY_INPUT = 'LIBRARY_INPUT'; 2972 static const String LIBRARY_INPUT = 'LIBRARY_INPUT';
2940 2973
2941 /** 2974 /**
2942 * The name of the [RESOLVED_UNIT4] input. 2975 * The name of the [RESOLVED_UNIT4] input.
2943 */ 2976 */
2944 static const String UNIT_INPUT = 'UNIT_INPUT'; 2977 static const String UNIT_INPUT = 'UNIT_INPUT';
2945 2978
2946 /** 2979 /**
2980 * The name of the [TYPE_PROVIDER] input.
2981 */
2982 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
2983
2984 /**
2947 * The task descriptor describing this kind of task. 2985 * The task descriptor describing this kind of task.
2948 */ 2986 */
2949 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 2987 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
2950 'ResolveVariableReferencesTask', createTask, buildInputs, 2988 'ResolveVariableReferencesTask', createTask, buildInputs,
2951 <ResultDescriptor>[RESOLVED_UNIT5]); 2989 <ResultDescriptor>[RESOLVED_UNIT5]);
2952 2990
2953 ResolveVariableReferencesTask( 2991 ResolveVariableReferencesTask(
2954 InternalAnalysisContext context, AnalysisTarget target) 2992 InternalAnalysisContext context, AnalysisTarget target)
2955 : super(context, target); 2993 : super(context, target);
2956 2994
2957 @override 2995 @override
2958 TaskDescriptor get descriptor => DESCRIPTOR; 2996 TaskDescriptor get descriptor => DESCRIPTOR;
2959 2997
2960 @override 2998 @override
2961 void internalPerform() { 2999 void internalPerform() {
2962 RecordingErrorListener errorListener = new RecordingErrorListener(); 3000 RecordingErrorListener errorListener = new RecordingErrorListener();
2963 // 3001 //
2964 // Prepare inputs. 3002 // Prepare inputs.
2965 // 3003 //
2966 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT); 3004 LibraryElement libraryElement = getRequiredInput(LIBRARY_INPUT);
2967 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 3005 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
2968 CompilationUnitElement unitElement = unit.element; 3006 CompilationUnitElement unitElement = unit.element;
2969 // 3007 //
2970 // Resolve local variables. 3008 // Resolve local variables.
2971 // 3009 //
2972 TypeProvider typeProvider = unitElement.context.typeProvider; 3010 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
2973 Scope nameScope = new LibraryScope(libraryElement, errorListener); 3011 Scope nameScope = new LibraryScope(libraryElement, errorListener);
2974 AstVisitor visitor = new VariableResolverVisitor.con2(libraryElement, 3012 AstVisitor visitor = new VariableResolverVisitor.con2(libraryElement,
2975 unitElement.source, typeProvider, nameScope, errorListener); 3013 unitElement.source, typeProvider, nameScope, errorListener);
2976 unit.accept(visitor); 3014 unit.accept(visitor);
2977 // 3015 //
2978 // Record outputs. 3016 // Record outputs.
2979 // 3017 //
2980 outputs[RESOLVED_UNIT5] = unit; 3018 outputs[RESOLVED_UNIT5] = unit;
2981 } 3019 }
2982 3020
2983 /** 3021 /**
2984 * Return a map from the names of the inputs of this kind of task to the task 3022 * Return a map from the names of the inputs of this kind of task to the task
2985 * input descriptors describing those inputs for a task with the 3023 * input descriptors describing those inputs for a task with the
2986 * given [target]. 3024 * given [target].
2987 */ 3025 */
2988 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { 3026 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
2989 return <String, TaskInput>{ 3027 return <String, TaskInput>{
2990 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library), 3028 LIBRARY_INPUT: LIBRARY_ELEMENT.of(target.library),
2991 UNIT_INPUT: RESOLVED_UNIT4.of(target) 3029 UNIT_INPUT: RESOLVED_UNIT4.of(target),
3030 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
2992 }; 3031 };
2993 } 3032 }
2994 3033
2995 /** 3034 /**
2996 * Create a [ResolveVariableReferencesTask] based on the given [target] in 3035 * Create a [ResolveVariableReferencesTask] based on the given [target] in
2997 * the given [context]. 3036 * the given [context].
2998 */ 3037 */
2999 static ResolveVariableReferencesTask createTask( 3038 static ResolveVariableReferencesTask createTask(
3000 AnalysisContext context, AnalysisTarget target) { 3039 AnalysisContext context, AnalysisTarget target) {
3001 return new ResolveVariableReferencesTask(context, target); 3040 return new ResolveVariableReferencesTask(context, target);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 /** 3111 /**
3073 * A task that builds [VERIFY_ERRORS] for a unit. 3112 * A task that builds [VERIFY_ERRORS] for a unit.
3074 */ 3113 */
3075 class VerifyUnitTask extends SourceBasedAnalysisTask { 3114 class VerifyUnitTask extends SourceBasedAnalysisTask {
3076 /** 3115 /**
3077 * The name of the [RESOLVED_UNIT] input. 3116 * The name of the [RESOLVED_UNIT] input.
3078 */ 3117 */
3079 static const String UNIT_INPUT = 'UNIT_INPUT'; 3118 static const String UNIT_INPUT = 'UNIT_INPUT';
3080 3119
3081 /** 3120 /**
3121 * The name of the [TYPE_PROVIDER] input.
3122 */
3123 static const String TYPE_PROVIDER_INPUT = 'TYPE_PROVIDER_INPUT';
3124
3125 /**
3082 * The task descriptor describing this kind of task. 3126 * The task descriptor describing this kind of task.
3083 */ 3127 */
3084 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('VerifyUnitTask', 3128 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor('VerifyUnitTask',
3085 createTask, buildInputs, <ResultDescriptor>[VERIFY_ERRORS]); 3129 createTask, buildInputs, <ResultDescriptor>[VERIFY_ERRORS]);
3086 3130
3087 /** 3131 /**
3088 * The [ErrorReporter] to report errors to. 3132 * The [ErrorReporter] to report errors to.
3089 */ 3133 */
3090 ErrorReporter errorReporter; 3134 ErrorReporter errorReporter;
3091 3135
3092 VerifyUnitTask(InternalAnalysisContext context, AnalysisTarget target) 3136 VerifyUnitTask(InternalAnalysisContext context, AnalysisTarget target)
3093 : super(context, target); 3137 : super(context, target);
3094 3138
3095 @override 3139 @override
3096 TaskDescriptor get descriptor => DESCRIPTOR; 3140 TaskDescriptor get descriptor => DESCRIPTOR;
3097 3141
3098 @override 3142 @override
3099 void internalPerform() { 3143 void internalPerform() {
3100 RecordingErrorListener errorListener = new RecordingErrorListener(); 3144 RecordingErrorListener errorListener = new RecordingErrorListener();
3101 Source source = getRequiredSource(); 3145 Source source = getRequiredSource();
3102 errorReporter = new ErrorReporter(errorListener, source); 3146 errorReporter = new ErrorReporter(errorListener, source);
3103 TypeProvider typeProvider = context.typeProvider; 3147 TypeProvider typeProvider = getRequiredInput(TYPE_PROVIDER_INPUT);
3104 // 3148 //
3105 // Prepare inputs. 3149 // Prepare inputs.
3106 // 3150 //
3107 CompilationUnit unit = getRequiredInput(UNIT_INPUT); 3151 CompilationUnit unit = getRequiredInput(UNIT_INPUT);
3108 CompilationUnitElement unitElement = unit.element; 3152 CompilationUnitElement unitElement = unit.element;
3109 LibraryElement libraryElement = unitElement.library; 3153 LibraryElement libraryElement = unitElement.library;
3110 // 3154 //
3111 // Use the ErrorVerifier to compute errors. 3155 // Use the ErrorVerifier to compute errors.
3112 // 3156 //
3113 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, 3157 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter,
3114 libraryElement, typeProvider, new InheritanceManager(libraryElement)); 3158 libraryElement, typeProvider, new InheritanceManager(libraryElement));
3115 unit.accept(errorVerifier); 3159 unit.accept(errorVerifier);
3116 // 3160 //
3117 // Record outputs. 3161 // Record outputs.
3118 // 3162 //
3119 outputs[VERIFY_ERRORS] = errorListener.errors; 3163 outputs[VERIFY_ERRORS] = errorListener.errors;
3120 } 3164 }
3121 3165
3122 /** 3166 /**
3123 * Return a map from the names of the inputs of this kind of task to the task 3167 * Return a map from the names of the inputs of this kind of task to the task
3124 * input descriptors describing those inputs for a task with the 3168 * input descriptors describing those inputs for a task with the
3125 * given [target]. 3169 * given [target].
3126 */ 3170 */
3127 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) { 3171 static Map<String, TaskInput> buildInputs(LibrarySpecificUnit target) {
3128 return <String, TaskInput>{UNIT_INPUT: RESOLVED_UNIT.of(target)}; 3172 return <String, TaskInput>{
3173 UNIT_INPUT: RESOLVED_UNIT.of(target),
3174 TYPE_PROVIDER_INPUT: TYPE_PROVIDER.of(AnalysisContextTarget.request)
3175 };
3129 } 3176 }
3130 3177
3131 /** 3178 /**
3132 * Create a [VerifyUnitTask] based on the given [target] in 3179 * Create a [VerifyUnitTask] based on the given [target] in
3133 * the given [context]. 3180 * the given [context].
3134 */ 3181 */
3135 static VerifyUnitTask createTask( 3182 static VerifyUnitTask createTask(
3136 AnalysisContext context, AnalysisTarget target) { 3183 AnalysisContext context, AnalysisTarget target) {
3137 return new VerifyUnitTask(context, target); 3184 return new VerifyUnitTask(context, target);
3138 } 3185 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3231 @override 3278 @override
3232 bool moveNext() { 3279 bool moveNext() {
3233 if (_newSources.isEmpty) { 3280 if (_newSources.isEmpty) {
3234 return false; 3281 return false;
3235 } 3282 }
3236 currentTarget = _newSources.first; 3283 currentTarget = _newSources.first;
3237 _newSources.remove(currentTarget); 3284 _newSources.remove(currentTarget);
3238 return true; 3285 return true;
3239 } 3286 }
3240 } 3287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698