| 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'; |
| 11 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 11 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 12 import 'package:analyzer/src/generated/error.dart'; | 12 import 'package:analyzer/src/generated/error.dart'; |
| 13 import 'package:analyzer/src/generated/java_engine.dart'; | 13 import 'package:analyzer/src/generated/java_engine.dart'; |
| 14 import 'package:analyzer/src/generated/parser.dart'; | 14 import 'package:analyzer/src/generated/parser.dart'; |
| 15 import 'package:analyzer/src/generated/resolver.dart'; | 15 import 'package:analyzer/src/generated/resolver.dart'; |
| 16 import 'package:analyzer/src/generated/scanner.dart'; | 16 import 'package:analyzer/src/generated/scanner.dart'; |
| 17 import 'package:analyzer/src/generated/sdk.dart'; | 17 import 'package:analyzer/src/generated/sdk.dart'; |
| 18 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
| 19 import 'package:analyzer/src/task/driver.dart'; |
| 19 import 'package:analyzer/src/task/general.dart'; | 20 import 'package:analyzer/src/task/general.dart'; |
| 20 import 'package:analyzer/src/task/inputs.dart'; | 21 import 'package:analyzer/src/task/inputs.dart'; |
| 21 import 'package:analyzer/task/dart.dart'; | 22 import 'package:analyzer/task/dart.dart'; |
| 22 import 'package:analyzer/task/general.dart'; | 23 import 'package:analyzer/task/general.dart'; |
| 23 import 'package:analyzer/task/model.dart'; | 24 import 'package:analyzer/task/model.dart'; |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * The errors produced while resolving a library directives. | 27 * The errors produced while resolving a library directives. |
| 27 * | 28 * |
| 28 * The list will be empty if there were no errors, but will not be `null`. | 29 * The list will be empty if there were no errors, but will not be `null`. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 * The partially resolved [CompilationUnit] associated with a library. | 82 * The partially resolved [CompilationUnit] associated with a library. |
| 82 * | 83 * |
| 83 * All the directives are resolved. | 84 * All the directives are resolved. |
| 84 * | 85 * |
| 85 * The result is only available for targets representing a library. | 86 * The result is only available for targets representing a library. |
| 86 */ | 87 */ |
| 87 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = | 88 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = |
| 88 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); | 89 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); |
| 89 | 90 |
| 90 /** | 91 /** |
| 92 * The [TypeProvider] of the context. |
| 93 */ |
| 94 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = |
| 95 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); |
| 96 |
| 97 /** |
| 91 * A task that builds a compilation unit element for a single compilation unit. | 98 * A task that builds a compilation unit element for a single compilation unit. |
| 92 */ | 99 */ |
| 93 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { | 100 class BuildCompilationUnitElementTask extends SourceBasedAnalysisTask { |
| 94 /** | 101 /** |
| 95 * The name of the input whose value is the line information for the | 102 * The name of the input whose value is the line information for the |
| 96 * compilation unit. | 103 * compilation unit. |
| 97 */ | 104 */ |
| 98 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; | 105 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; |
| 99 | 106 |
| 100 /** | 107 /** |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 * Create a [BuildPublicNamespaceTask] based on the given [target] in | 715 * Create a [BuildPublicNamespaceTask] based on the given [target] in |
| 709 * the given [context]. | 716 * the given [context]. |
| 710 */ | 717 */ |
| 711 static BuildPublicNamespaceTask createTask( | 718 static BuildPublicNamespaceTask createTask( |
| 712 AnalysisContext context, AnalysisTarget target) { | 719 AnalysisContext context, AnalysisTarget target) { |
| 713 return new BuildPublicNamespaceTask(context, target); | 720 return new BuildPublicNamespaceTask(context, target); |
| 714 } | 721 } |
| 715 } | 722 } |
| 716 | 723 |
| 717 /** | 724 /** |
| 725 * A task that builds [TYPE_PROVIDER] for a context. |
| 726 */ |
| 727 class BuildTypeProviderTask extends SourceBasedAnalysisTask { |
| 728 /** |
| 729 * The [RESOLVED_UNIT3] input of the `dart:core` library. |
| 730 */ |
| 731 static const String CORE_INPUT = 'CORE_INPUT'; |
| 732 |
| 733 /** |
| 734 * The [RESOLVED_UNIT3] input of the `dart:async` library. |
| 735 */ |
| 736 static const String ASYNC_INPUT = 'ASYNC_INPUT'; |
| 737 |
| 738 /** |
| 739 * The task descriptor describing this kind of task. |
| 740 */ |
| 741 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( |
| 742 'BuildTypeProviderTask', createTask, buildInputs, |
| 743 <ResultDescriptor>[TYPE_PROVIDER]); |
| 744 |
| 745 BuildTypeProviderTask( |
| 746 InternalAnalysisContext context, AnalysisContextTarget target) |
| 747 : super(context, target); |
| 748 |
| 749 @override |
| 750 TaskDescriptor get descriptor => DESCRIPTOR; |
| 751 |
| 752 @override |
| 753 void internalPerform() { |
| 754 CompilationUnit coreUnit = getRequiredInput(CORE_INPUT); |
| 755 CompilationUnit asyncUnit = getRequiredInput(ASYNC_INPUT); |
| 756 LibraryElement coreLibrary = coreUnit.element.library; |
| 757 LibraryElement asyncLibrary = asyncUnit.element.library; |
| 758 // |
| 759 // Record outputs. |
| 760 // |
| 761 TypeProvider typeProvider = new TypeProviderImpl(coreLibrary, asyncLibrary); |
| 762 (context as ExtendedAnalysisContext).typeProvider = typeProvider; |
| 763 outputs[TYPE_PROVIDER] = typeProvider; |
| 764 } |
| 765 |
| 766 static Map<String, TaskInput> buildInputs(AnalysisContextTarget target) { |
| 767 SourceFactory sourceFactory = target.context.sourceFactory; |
| 768 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 769 Source asyncSource = sourceFactory.forUri(DartSdk.DART_ASYNC); |
| 770 return <String, TaskInput>{ |
| 771 CORE_INPUT: RESOLVED_UNIT3.inputFor(coreSource), |
| 772 ASYNC_INPUT: RESOLVED_UNIT3.inputFor(asyncSource) |
| 773 }; |
| 774 } |
| 775 |
| 776 /** |
| 777 * Create a [BuildTypeProviderTask] based on the given [context]. |
| 778 */ |
| 779 static BuildTypeProviderTask createTask( |
| 780 AnalysisContext context, AnalysisContextTarget target) { |
| 781 return new BuildTypeProviderTask(context, target); |
| 782 } |
| 783 } |
| 784 |
| 785 /** |
| 718 * A task that parses the content of a Dart file, producing an AST structure. | 786 * A task that parses the content of a Dart file, producing an AST structure. |
| 719 */ | 787 */ |
| 720 class ParseDartTask extends SourceBasedAnalysisTask { | 788 class ParseDartTask extends SourceBasedAnalysisTask { |
| 721 /** | 789 /** |
| 722 * The name of the input whose value is the line information produced for the | 790 * The name of the input whose value is the line information produced for the |
| 723 * file. | 791 * file. |
| 724 */ | 792 */ |
| 725 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; | 793 static const String LINE_INFO_INPUT_NAME = 'LINE_INFO_INPUT_NAME'; |
| 726 | 794 |
| 727 /** | 795 /** |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 } | 1000 } |
| 933 | 1001 |
| 934 /** | 1002 /** |
| 935 * Create a [ScanDartTask] based on the given [target] in the given [context]. | 1003 * Create a [ScanDartTask] based on the given [target] in the given [context]. |
| 936 */ | 1004 */ |
| 937 static ScanDartTask createTask( | 1005 static ScanDartTask createTask( |
| 938 AnalysisContext context, AnalysisTarget target) { | 1006 AnalysisContext context, AnalysisTarget target) { |
| 939 return new ScanDartTask(context, target); | 1007 return new ScanDartTask(context, target); |
| 940 } | 1008 } |
| 941 } | 1009 } |
| OLD | NEW |