| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.task.dart; | 5 library analyzer.src.task.dart; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 AnalysisContext context, AnalysisTarget target) { | 823 AnalysisContext context, AnalysisTarget target) { |
| 824 return new BuildPublicNamespaceTask(context, target); | 824 return new BuildPublicNamespaceTask(context, target); |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 /** | 828 /** |
| 829 * A task that builds [TYPE_PROVIDER] for a context. | 829 * A task that builds [TYPE_PROVIDER] for a context. |
| 830 */ | 830 */ |
| 831 class BuildTypeProviderTask extends SourceBasedAnalysisTask { | 831 class BuildTypeProviderTask extends SourceBasedAnalysisTask { |
| 832 /** | 832 /** |
| 833 * The [RESOLVED_UNIT3] input of the `dart:core` library. | 833 * The [PUBLIC_NAMESPACE] input of the `dart:core` library. |
| 834 */ | 834 */ |
| 835 static const String CORE_INPUT = 'CORE_INPUT'; | 835 static const String CORE_INPUT = 'CORE_INPUT'; |
| 836 | 836 |
| 837 /** | 837 /** |
| 838 * The [RESOLVED_UNIT3] input of the `dart:async` library. | 838 * The [PUBLIC_NAMESPACE] input of the `dart:async` library. |
| 839 */ | 839 */ |
| 840 static const String ASYNC_INPUT = 'ASYNC_INPUT'; | 840 static const String ASYNC_INPUT = 'ASYNC_INPUT'; |
| 841 | 841 |
| 842 /** | 842 /** |
| 843 * The task descriptor describing this kind of task. | 843 * The task descriptor describing this kind of task. |
| 844 */ | 844 */ |
| 845 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( | 845 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 846 'BuildTypeProviderTask', createTask, buildInputs, | 846 'BuildTypeProviderTask', createTask, buildInputs, |
| 847 <ResultDescriptor>[TYPE_PROVIDER]); | 847 <ResultDescriptor>[TYPE_PROVIDER]); |
| 848 | 848 |
| 849 BuildTypeProviderTask( | 849 BuildTypeProviderTask( |
| 850 InternalAnalysisContext context, AnalysisContextTarget target) | 850 InternalAnalysisContext context, AnalysisContextTarget target) |
| 851 : super(context, target); | 851 : super(context, target); |
| 852 | 852 |
| 853 @override | 853 @override |
| 854 TaskDescriptor get descriptor => DESCRIPTOR; | 854 TaskDescriptor get descriptor => DESCRIPTOR; |
| 855 | 855 |
| 856 @override | 856 @override |
| 857 void internalPerform() { | 857 void internalPerform() { |
| 858 CompilationUnit coreUnit = getRequiredInput(CORE_INPUT); | 858 Namespace coreNamespace = getRequiredInput(CORE_INPUT); |
| 859 CompilationUnit asyncUnit = getRequiredInput(ASYNC_INPUT); | 859 Namespace asyncNamespace = getRequiredInput(ASYNC_INPUT); |
| 860 LibraryElement coreLibrary = coreUnit.element.library; | |
| 861 LibraryElement asyncLibrary = asyncUnit.element.library; | |
| 862 // | 860 // |
| 863 // Record outputs. | 861 // Record outputs. |
| 864 // | 862 // |
| 865 TypeProvider typeProvider = new TypeProviderImpl(coreLibrary, asyncLibrary); | 863 TypeProvider typeProvider = |
| 864 new TypeProviderImpl.forNamespaces(coreNamespace, asyncNamespace); |
| 866 (context as ExtendedAnalysisContext).typeProvider = typeProvider; | 865 (context as ExtendedAnalysisContext).typeProvider = typeProvider; |
| 867 outputs[TYPE_PROVIDER] = typeProvider; | 866 outputs[TYPE_PROVIDER] = typeProvider; |
| 868 } | 867 } |
| 869 | 868 |
| 870 static Map<String, TaskInput> buildInputs(AnalysisContextTarget target) { | 869 static Map<String, TaskInput> buildInputs(AnalysisContextTarget target) { |
| 871 SourceFactory sourceFactory = target.context.sourceFactory; | 870 SourceFactory sourceFactory = target.context.sourceFactory; |
| 872 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); | 871 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 873 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); | 872 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); |
| 874 return <String, TaskInput>{ | 873 return <String, TaskInput>{ |
| 875 CORE_INPUT: RESOLVED_UNIT3.inputFor(coreSource), | 874 CORE_INPUT: PUBLIC_NAMESPACE.inputFor(coreSource), |
| 876 ASYNC_INPUT: RESOLVED_UNIT3.inputFor(asyncSource) | 875 ASYNC_INPUT: PUBLIC_NAMESPACE.inputFor(asyncSource) |
| 877 }; | 876 }; |
| 878 } | 877 } |
| 879 | 878 |
| 880 /** | 879 /** |
| 881 * Create a [BuildTypeProviderTask] based on the given [context]. | 880 * Create a [BuildTypeProviderTask] based on the given [context]. |
| 882 */ | 881 */ |
| 883 static BuildTypeProviderTask createTask( | 882 static BuildTypeProviderTask createTask( |
| 884 AnalysisContext context, AnalysisContextTarget target) { | 883 AnalysisContext context, AnalysisContextTarget target) { |
| 885 return new BuildTypeProviderTask(context, target); | 884 return new BuildTypeProviderTask(context, target); |
| 886 } | 885 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 } | 1129 } |
| 1131 | 1130 |
| 1132 /** | 1131 /** |
| 1133 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 1132 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 1134 */ | 1133 */ |
| 1135 static ScanDartTask createTask( | 1134 static ScanDartTask createTask( |
| 1136 AnalysisContext context, AnalysisTarget target) { | 1135 AnalysisContext context, AnalysisTarget target) { |
| 1137 return new ScanDartTask(context, target); | 1136 return new ScanDartTask(context, target); |
| 1138 } | 1137 } |
| 1139 } | 1138 } |
| OLD | NEW |