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