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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 1487953002: Clean-up the registration of plugins (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years 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
OLDNEW
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 engine; 5 library engine;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
(...skipping 5907 matching lines...) Expand 10 before | Expand all | Expand 10 after
5918 */ 5918 */
5919 final OptionsPlugin optionsPlugin = new OptionsPlugin(); 5919 final OptionsPlugin optionsPlugin = new OptionsPlugin();
5920 5920
5921 /** 5921 /**
5922 * The instrumentation service that is to be used by this analysis engine. 5922 * The instrumentation service that is to be used by this analysis engine.
5923 */ 5923 */
5924 InstrumentationService _instrumentationService = 5924 InstrumentationService _instrumentationService =
5925 InstrumentationService.NULL_SERVICE; 5925 InstrumentationService.NULL_SERVICE;
5926 5926
5927 /** 5927 /**
5928 * The list of supported plugins for processing by clients.
5929 */
5930 List<Plugin> _supportedPlugins;
5931
5932 /**
5933 * The partition manager being used to manage the shared partitions. 5928 * The partition manager being used to manage the shared partitions.
5934 */ 5929 */
5935 final PartitionManager partitionManager = new PartitionManager(); 5930 final PartitionManager partitionManager = new PartitionManager();
5936 5931
5937 /** 5932 /**
5938 * The partition manager being used to manage the shared partitions. 5933 * The partition manager being used to manage the shared partitions.
5939 */ 5934 */
5940 final newContext.PartitionManager partitionManager_new = 5935 final newContext.PartitionManager partitionManager_new =
5941 new newContext.PartitionManager(); 5936 new newContext.PartitionManager();
5942 5937
5943 /** 5938 /**
5944 * A flag indicating whether the (new) task model should be used to perform 5939 * A flag indicating whether the (new) task model should be used to perform
5945 * analysis. 5940 * analysis.
5946 */ 5941 */
5947 bool useTaskModel = true; 5942 bool useTaskModel = true;
5948 5943
5949 /** 5944 /**
5950 * A flag indicating whether the task model should attempt to limit 5945 * A flag indicating whether the task model should attempt to limit
5951 * invalidation after a change. 5946 * invalidation after a change.
5952 */ 5947 */
5953 bool limitInvalidationInTaskModel = false; 5948 bool limitInvalidationInTaskModel = false;
5954 5949
5955 /** 5950 /**
5956 * The plugins that are defined outside the `analyzer` package.
5957 */
5958 List<Plugin> _userDefinedPlugins = <Plugin>[];
5959
5960 /**
5961 * The task manager used to manage the tasks used to analyze code. 5951 * The task manager used to manage the tasks used to analyze code.
5962 */ 5952 */
5963 TaskManager _taskManager; 5953 TaskManager _taskManager;
5964 5954
5965 AnalysisEngine._(); 5955 AnalysisEngine._();
5966 5956
5967 /** 5957 /**
5968 * Return the instrumentation service that is to be used by this analysis 5958 * Return the instrumentation service that is to be used by this analysis
5969 * engine. 5959 * engine.
5970 */ 5960 */
(...skipping 19 matching lines...) Expand all
5990 5980
5991 /** 5981 /**
5992 * Set the logger that should receive information about errors within the 5982 * Set the logger that should receive information about errors within the
5993 * analysis engine to the given [logger]. 5983 * analysis engine to the given [logger].
5994 */ 5984 */
5995 void set logger(Logger logger) { 5985 void set logger(Logger logger) {
5996 this._logger = logger == null ? Logger.NULL : logger; 5986 this._logger = logger == null ? Logger.NULL : logger;
5997 } 5987 }
5998 5988
5999 /** 5989 /**
6000 * Return the list of supported plugins for processing by clients. 5990 * Return the list of plugins that clients are required to process, either by
5991 * creating an [ExtensionManager] or by using the method
5992 * [processRequiredPlugins].
6001 */ 5993 */
6002 List<Plugin> get supportedPlugins { 5994 List<Plugin> get requiredPlugins => <Plugin>[enginePlugin];
6003 if (_supportedPlugins == null) {
6004 _supportedPlugins = <Plugin>[
6005 enginePlugin,
6006 commandLinePlugin,
6007 optionsPlugin
6008 ];
6009 _supportedPlugins.addAll(_userDefinedPlugins);
6010 }
6011 return _supportedPlugins;
6012 }
6013 5995
6014 /** 5996 /**
6015 * Return the task manager used to manage the tasks used to analyze code. 5997 * Return the task manager used to manage the tasks used to analyze code.
6016 */ 5998 */
6017 TaskManager get taskManager { 5999 TaskManager get taskManager {
6018 if (_taskManager == null) { 6000 if (_taskManager == null) {
6019 new ExtensionManager().processPlugins(supportedPlugins); 6001 if (enginePlugin.taskExtensionPoint == null) {
6002 throw new IllegalStateException(
6003 'The analysis engine plugin has not been registered');
6004 }
6020 _taskManager = new TaskManager(); 6005 _taskManager = new TaskManager();
6021 _taskManager.addTaskDescriptors(enginePlugin.taskDescriptors); 6006 _taskManager.addTaskDescriptors(enginePlugin.taskDescriptors);
6022 // TODO(brianwilkerson) Create a way to associate different results with 6007 // TODO(brianwilkerson) Create a way to associate different results with
6023 // different file suffixes, then make this pluggable. 6008 // different file suffixes, then make this pluggable.
6024 _taskManager.addGeneralResult(DART_ERRORS); 6009 _taskManager.addGeneralResult(DART_ERRORS);
6025 } 6010 }
6026 return _taskManager; 6011 return _taskManager;
6027 } 6012 }
6028 6013
6029 /** 6014 /**
6030 * Set plugins that are defined outside the `analyzer` package.
6031 */
6032 void set userDefinedPlugins(List<Plugin> plugins) {
6033 if (plugins == null) {
6034 plugins = <Plugin>[];
6035 }
6036 _userDefinedPlugins = plugins;
6037 _supportedPlugins = null;
6038 _taskManager = null;
6039 }
6040
6041 /**
6042 * Clear any caches holding on to analysis results so that a full re-analysis 6015 * Clear any caches holding on to analysis results so that a full re-analysis
6043 * will be performed the next time an analysis context is created. 6016 * will be performed the next time an analysis context is created.
6044 */ 6017 */
6045 void clearCaches() { 6018 void clearCaches() {
6046 partitionManager.clearCache(); 6019 partitionManager.clearCache();
6047 } 6020 }
6048 6021
6049 /** 6022 /**
6050 * Create and return a new context in which analysis can be performed. 6023 * Create and return a new context in which analysis can be performed.
6051 */ 6024 */
6052 AnalysisContext createAnalysisContext() { 6025 AnalysisContext createAnalysisContext() {
6053 if (useTaskModel) { 6026 if (useTaskModel) {
6054 return new newContext.AnalysisContextImpl(); 6027 return new newContext.AnalysisContextImpl();
6055 } 6028 }
6056 return new AnalysisContextImpl(); 6029 return new AnalysisContextImpl();
6057 } 6030 }
6058 6031
6059 /** 6032 /**
6033 * A utility method that clients can use to process all of the required
6034 * plugins. This method can only be used by clients that do not need to
6035 * process any other plugins.
6036 */
6037 void processRequiredPlugins() {
6038 ExtensionManager manager = new ExtensionManager();
6039 manager.processPlugins(AnalysisEngine.instance.requiredPlugins);
6040 }
6041
6042 /**
6060 * Return `true` if the given [fileName] is an analysis options file. 6043 * Return `true` if the given [fileName] is an analysis options file.
6061 */ 6044 */
6062 static bool isAnalysisOptionsFileName(String fileName, 6045 static bool isAnalysisOptionsFileName(String fileName,
6063 [pathos.Context context]) { 6046 [pathos.Context context]) {
6064 if (fileName == null) { 6047 if (fileName == null) {
6065 return false; 6048 return false;
6066 } 6049 }
6067 return (context ?? pathos.posix).basename(fileName) == 6050 return (context ?? pathos.posix).basename(fileName) ==
6068 ANALYSIS_OPTIONS_FILE; 6051 ANALYSIS_OPTIONS_FILE;
6069 } 6052 }
(...skipping 6066 matching lines...) Expand 10 before | Expand all | Expand 10 after
12136 PendingFuture pendingFuture = 12119 PendingFuture pendingFuture =
12137 new PendingFuture<T>(_context, source, computeValue); 12120 new PendingFuture<T>(_context, source, computeValue);
12138 if (!pendingFuture.evaluate(sourceEntry)) { 12121 if (!pendingFuture.evaluate(sourceEntry)) {
12139 _context._pendingFutureSources 12122 _context._pendingFutureSources
12140 .putIfAbsent(source, () => <PendingFuture>[]) 12123 .putIfAbsent(source, () => <PendingFuture>[])
12141 .add(pendingFuture); 12124 .add(pendingFuture);
12142 } 12125 }
12143 return pendingFuture.future; 12126 return pendingFuture.future;
12144 } 12127 }
12145 } 12128 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/correction/assist_test.dart ('k') | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698