OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.engine; | 5 library analyzer.src.generated.engine; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
11 import 'package:analyzer/dart/ast/visitor.dart'; | 11 import 'package:analyzer/dart/ast/visitor.dart'; |
12 import 'package:analyzer/dart/element/element.dart'; | 12 import 'package:analyzer/dart/element/element.dart'; |
13 import 'package:analyzer/error/error.dart'; | 13 import 'package:analyzer/error/error.dart'; |
14 import 'package:analyzer/exception/exception.dart'; | 14 import 'package:analyzer/exception/exception.dart'; |
15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
16 import 'package:analyzer/plugin/resolver_provider.dart'; | 16 import 'package:analyzer/plugin/resolver_provider.dart'; |
17 import 'package:analyzer/source/error_processor.dart'; | 17 import 'package:analyzer/source/error_processor.dart'; |
18 import 'package:analyzer/src/cancelable_future.dart'; | 18 import 'package:analyzer/src/cancelable_future.dart'; |
19 import 'package:analyzer/src/context/builder.dart' show EmbedderYamlLocator; | 19 import 'package:analyzer/src/context/builder.dart' show EmbedderYamlLocator; |
20 import 'package:analyzer/src/context/cache.dart'; | 20 import 'package:analyzer/src/context/cache.dart'; |
21 import 'package:analyzer/src/context/context.dart'; | 21 import 'package:analyzer/src/context/context.dart'; |
22 import 'package:analyzer/src/generated/constant.dart'; | 22 import 'package:analyzer/src/generated/constant.dart'; |
23 import 'package:analyzer/src/generated/java_engine.dart'; | 23 import 'package:analyzer/src/generated/java_engine.dart'; |
24 import 'package:analyzer/src/generated/resolver.dart'; | 24 import 'package:analyzer/src/generated/resolver.dart'; |
25 import 'package:analyzer/src/generated/source.dart'; | 25 import 'package:analyzer/src/generated/source.dart'; |
26 import 'package:analyzer/src/generated/utilities_general.dart'; | 26 import 'package:analyzer/src/generated/utilities_general.dart'; |
27 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 27 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
28 import 'package:analyzer/src/services/lint.dart'; | 28 import 'package:analyzer/src/services/lint.dart'; |
29 import 'package:analyzer/src/task/dart.dart'; | |
30 import 'package:analyzer/src/task/general.dart'; | |
31 import 'package:analyzer/src/task/html.dart'; | |
32 import 'package:analyzer/src/task/manager.dart'; | 29 import 'package:analyzer/src/task/manager.dart'; |
33 import 'package:analyzer/src/task/options.dart'; | |
34 import 'package:analyzer/src/task/yaml.dart'; | |
35 import 'package:analyzer/task/dart.dart'; | 30 import 'package:analyzer/task/dart.dart'; |
36 import 'package:analyzer/task/model.dart'; | 31 import 'package:analyzer/task/model.dart'; |
37 import 'package:front_end/src/base/timestamped_data.dart'; | 32 import 'package:front_end/src/base/timestamped_data.dart'; |
38 import 'package:html/dom.dart' show Document; | 33 import 'package:html/dom.dart' show Document; |
39 import 'package:path/path.dart' as pathos; | 34 import 'package:path/path.dart' as pathos; |
40 import 'package:plugin/manager.dart'; | 35 import 'package:plugin/manager.dart'; |
41 import 'package:plugin/plugin.dart'; | 36 import 'package:plugin/plugin.dart'; |
42 | 37 |
43 export 'package:analyzer/error/listener.dart' show RecordingErrorListener; | 38 export 'package:analyzer/error/listener.dart' show RecordingErrorListener; |
44 export 'package:front_end/src/base/timestamped_data.dart' show TimestampedData; | 39 export 'package:front_end/src/base/timestamped_data.dart' show TimestampedData; |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 * creating an [ExtensionManager] or by using the method | 815 * creating an [ExtensionManager] or by using the method |
821 * [processRequiredPlugins]. | 816 * [processRequiredPlugins]. |
822 */ | 817 */ |
823 List<Plugin> get requiredPlugins => <Plugin>[enginePlugin]; | 818 List<Plugin> get requiredPlugins => <Plugin>[enginePlugin]; |
824 | 819 |
825 /** | 820 /** |
826 * Return the task manager used to manage the tasks used to analyze code. | 821 * Return the task manager used to manage the tasks used to analyze code. |
827 */ | 822 */ |
828 TaskManager get taskManager { | 823 TaskManager get taskManager { |
829 if (_taskManager == null) { | 824 if (_taskManager == null) { |
| 825 if (enginePlugin.taskExtensionPoint == null) { |
| 826 processRequiredPlugins(); |
| 827 } |
830 _taskManager = new TaskManager(); | 828 _taskManager = new TaskManager(); |
831 _initializeTaskMap(); | 829 _taskManager.addTaskDescriptors(enginePlugin.taskDescriptors); |
832 _initializeResults(); | 830 // TODO(brianwilkerson) Create a way to associate different results with |
| 831 // different file suffixes, then make this pluggable. |
| 832 _taskManager.addGeneralResult(DART_ERRORS); |
833 } | 833 } |
834 return _taskManager; | 834 return _taskManager; |
835 } | 835 } |
836 | 836 |
837 /** | 837 /** |
838 * Clear any caches holding on to analysis results so that a full re-analysis | 838 * Clear any caches holding on to analysis results so that a full re-analysis |
839 * will be performed the next time an analysis context is created. | 839 * will be performed the next time an analysis context is created. |
840 */ | 840 */ |
841 void clearCaches() { | 841 void clearCaches() { |
842 partitionManager.clearCache(); | 842 partitionManager.clearCache(); |
843 } | 843 } |
844 | 844 |
845 /** | 845 /** |
846 * Create and return a new context in which analysis can be performed. | 846 * Create and return a new context in which analysis can be performed. |
847 */ | 847 */ |
848 AnalysisContext createAnalysisContext() { | 848 AnalysisContext createAnalysisContext() { |
849 return new AnalysisContextImpl(); | 849 return new AnalysisContextImpl(); |
850 } | 850 } |
851 | 851 |
852 /** | 852 /** |
853 * A utility method that clients can use to process all of the required | 853 * A utility method that clients can use to process all of the required |
854 * plugins. This method can only be used by clients that do not need to | 854 * plugins. This method can only be used by clients that do not need to |
855 * process any other plugins. | 855 * process any other plugins. |
856 */ | 856 */ |
857 void processRequiredPlugins() { | 857 void processRequiredPlugins() { |
858 ExtensionManager manager = new ExtensionManager(); | 858 ExtensionManager manager = new ExtensionManager(); |
859 manager.processPlugins(requiredPlugins); | 859 manager.processPlugins(requiredPlugins); |
860 } | 860 } |
861 | 861 |
862 void _initializeResults() { | |
863 _taskManager.addGeneralResult(DART_ERRORS); | |
864 } | |
865 | |
866 void _initializeTaskMap() { | |
867 // | |
868 // Register general tasks. | |
869 // | |
870 _taskManager.addTaskDescriptor(GetContentTask.DESCRIPTOR); | |
871 // | |
872 // Register Dart tasks. | |
873 // | |
874 _taskManager.addTaskDescriptor(BuildCompilationUnitElementTask.DESCRIPTOR); | |
875 _taskManager.addTaskDescriptor(BuildDirectiveElementsTask.DESCRIPTOR); | |
876 _taskManager.addTaskDescriptor(BuildEnumMemberElementsTask.DESCRIPTOR); | |
877 _taskManager.addTaskDescriptor(BuildExportNamespaceTask.DESCRIPTOR); | |
878 _taskManager.addTaskDescriptor(BuildLibraryElementTask.DESCRIPTOR); | |
879 _taskManager.addTaskDescriptor(BuildPublicNamespaceTask.DESCRIPTOR); | |
880 _taskManager.addTaskDescriptor(BuildSourceExportClosureTask.DESCRIPTOR); | |
881 _taskManager.addTaskDescriptor(BuildTypeProviderTask.DESCRIPTOR); | |
882 _taskManager.addTaskDescriptor(ComputeConstantDependenciesTask.DESCRIPTOR); | |
883 _taskManager.addTaskDescriptor(ComputeConstantValueTask.DESCRIPTOR); | |
884 _taskManager.addTaskDescriptor( | |
885 ComputeInferableStaticVariableDependenciesTask.DESCRIPTOR); | |
886 _taskManager.addTaskDescriptor(ComputeLibraryCycleTask.DESCRIPTOR); | |
887 _taskManager.addTaskDescriptor(ComputeRequiredConstantsTask.DESCRIPTOR); | |
888 _taskManager.addTaskDescriptor(ContainingLibrariesTask.DESCRIPTOR); | |
889 _taskManager.addTaskDescriptor(DartErrorsTask.DESCRIPTOR); | |
890 _taskManager.addTaskDescriptor(EvaluateUnitConstantsTask.DESCRIPTOR); | |
891 _taskManager.addTaskDescriptor(GatherUsedImportedElementsTask.DESCRIPTOR); | |
892 _taskManager.addTaskDescriptor(GatherUsedLocalElementsTask.DESCRIPTOR); | |
893 _taskManager.addTaskDescriptor(GenerateHintsTask.DESCRIPTOR); | |
894 _taskManager.addTaskDescriptor(GenerateLintsTask.DESCRIPTOR); | |
895 _taskManager.addTaskDescriptor(InferInstanceMembersInUnitTask.DESCRIPTOR); | |
896 _taskManager | |
897 .addTaskDescriptor(InferStaticVariableTypesInUnitTask.DESCRIPTOR); | |
898 _taskManager.addTaskDescriptor(InferStaticVariableTypeTask.DESCRIPTOR); | |
899 _taskManager.addTaskDescriptor(LibraryErrorsReadyTask.DESCRIPTOR); | |
900 _taskManager.addTaskDescriptor(LibraryUnitErrorsTask.DESCRIPTOR); | |
901 _taskManager.addTaskDescriptor(ParseDartTask.DESCRIPTOR); | |
902 _taskManager | |
903 .addTaskDescriptor(PartiallyResolveUnitReferencesTask.DESCRIPTOR); | |
904 _taskManager.addTaskDescriptor(ReadyLibraryElement2Task.DESCRIPTOR); | |
905 _taskManager.addTaskDescriptor(ReadyLibraryElement5Task.DESCRIPTOR); | |
906 _taskManager.addTaskDescriptor(ReadyLibraryElement7Task.DESCRIPTOR); | |
907 _taskManager.addTaskDescriptor(ReadyResolvedUnitTask.DESCRIPTOR); | |
908 _taskManager.addTaskDescriptor(ResolveConstantExpressionTask.DESCRIPTOR); | |
909 _taskManager.addTaskDescriptor(ResolveDirectiveElementsTask.DESCRIPTOR); | |
910 _taskManager | |
911 .addTaskDescriptor(ResolvedUnit7InLibraryClosureTask.DESCRIPTOR); | |
912 _taskManager.addTaskDescriptor(ResolvedUnit7InLibraryTask.DESCRIPTOR); | |
913 _taskManager.addTaskDescriptor(ResolveInstanceFieldsInUnitTask.DESCRIPTOR); | |
914 _taskManager.addTaskDescriptor(ResolveLibraryReferencesTask.DESCRIPTOR); | |
915 _taskManager.addTaskDescriptor(ResolveLibraryTask.DESCRIPTOR); | |
916 _taskManager.addTaskDescriptor(ResolveLibraryTypeNamesTask.DESCRIPTOR); | |
917 _taskManager | |
918 .addTaskDescriptor(ResolveTopLevelLibraryTypeBoundsTask.DESCRIPTOR); | |
919 _taskManager | |
920 .addTaskDescriptor(ResolveTopLevelUnitTypeBoundsTask.DESCRIPTOR); | |
921 _taskManager.addTaskDescriptor(ResolveUnitTask.DESCRIPTOR); | |
922 _taskManager.addTaskDescriptor(ResolveUnitTypeNamesTask.DESCRIPTOR); | |
923 _taskManager.addTaskDescriptor(ResolveVariableReferencesTask.DESCRIPTOR); | |
924 _taskManager.addTaskDescriptor(ScanDartTask.DESCRIPTOR); | |
925 _taskManager.addTaskDescriptor(StrongModeVerifyUnitTask.DESCRIPTOR); | |
926 _taskManager.addTaskDescriptor(VerifyUnitTask.DESCRIPTOR); | |
927 // | |
928 // Register HTML tasks. | |
929 // | |
930 _taskManager.addTaskDescriptor(DartScriptsTask.DESCRIPTOR); | |
931 _taskManager.addTaskDescriptor(HtmlErrorsTask.DESCRIPTOR); | |
932 _taskManager.addTaskDescriptor(ParseHtmlTask.DESCRIPTOR); | |
933 // | |
934 // Register YAML tasks. | |
935 // | |
936 _taskManager.addTaskDescriptor(ParseYamlTask.DESCRIPTOR); | |
937 // | |
938 // Register analysis option file tasks. | |
939 // | |
940 _taskManager.addTaskDescriptor(GenerateOptionsErrorsTask.DESCRIPTOR); | |
941 } | |
942 | |
943 /** | 862 /** |
944 * Return `true` if the given [fileName] is an analysis options file. | 863 * Return `true` if the given [fileName] is an analysis options file. |
945 */ | 864 */ |
946 static bool isAnalysisOptionsFileName(String fileName, | 865 static bool isAnalysisOptionsFileName(String fileName, |
947 [pathos.Context context]) { | 866 [pathos.Context context]) { |
948 if (fileName == null) { | 867 if (fileName == null) { |
949 return false; | 868 return false; |
950 } | 869 } |
951 String basename = (context ?? pathos.posix).basename(fileName); | 870 String basename = (context ?? pathos.posix).basename(fileName); |
952 return basename == ANALYSIS_OPTIONS_FILE || | 871 return basename == ANALYSIS_OPTIONS_FILE || |
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 */ | 2822 */ |
2904 bool get wereSourcesAdded => _changeSet.addedSources.length > 0; | 2823 bool get wereSourcesAdded => _changeSet.addedSources.length > 0; |
2905 | 2824 |
2906 /** | 2825 /** |
2907 * Return `true` if any sources were removed or deleted. | 2826 * Return `true` if any sources were removed or deleted. |
2908 */ | 2827 */ |
2909 bool get wereSourcesRemoved => | 2828 bool get wereSourcesRemoved => |
2910 _changeSet.removedSources.length > 0 || | 2829 _changeSet.removedSources.length > 0 || |
2911 _changeSet.removedContainers.length > 0; | 2830 _changeSet.removedContainers.length > 0; |
2912 } | 2831 } |
OLD | NEW |