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

Unified Diff: pkg/analysis_server/lib/src/plugin/plugin_watcher.dart

Issue 2988343002: Initial support for an explicit plugin list (Closed)
Patch Set: Created 3 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/status/diagnostics.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/plugin/plugin_watcher.dart
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_watcher.dart b/pkg/analysis_server/lib/src/plugin/plugin_watcher.dart
index 553f65a2a4890b0821f398b2fef6ea592b9c41c3..e68e31e5d1e8b4cd73218bc3673cb63efb35d9b5 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_watcher.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_watcher.dart
@@ -10,6 +10,8 @@ import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/util/absolute_path.dart';
+import 'package:front_end/src/base/source.dart';
+import 'package:path/src/context.dart';
/**
* An object that watches the results produced by analysis drivers to identify
@@ -52,12 +54,39 @@ class PluginWatcher implements DriverWatcher {
void addedDriver(AnalysisDriver driver, ContextRoot contextRoot) {
_driverInfo[driver] = new _DriverInfo(
contextRoot, <String>[contextRoot.root, _getSdkPath(driver)]);
- driver.fsState.knownFilesSetChanges.listen((KnownFilesSetChange change) {
- List<String> addedPluginPaths = _checkPluginsFor(driver, change);
- for (String pluginPath in addedPluginPaths) {
- manager.addPluginToContextRoot(contextRoot, pluginPath);
+ List<String> enabledPlugins = driver.analysisOptions.enabledPluginNames;
+ if (enabledPlugins.isNotEmpty) {
+ for (String package in enabledPlugins) {
+ //
+ // Determine whether the package exists and defines a plugin.
+ //
+ Source source =
+ driver.sourceFactory.forUri('package:$package/$package.dart');
+ Context context = resourceProvider.pathContext;
+ String packageRoot = context.dirname(context.dirname(source.fullName));
+ String pluginPath = _locator.findPlugin(packageRoot);
+ if (pluginPath != null) {
+ //
+ // Add the plugin to the context root.
+ //
+ // TODO(brianwilkerson) Do we need to wait for the plugin to be added?
+ // If we don't, then tests don't have any way to know when to expect
+ // that the list of plugins has been updated.
+ manager.addPluginToContextRoot(contextRoot, pluginPath);
+ }
}
- });
+ } else {
+ //
+ // Remove this code after users are switched over to use an explicit list
+ // of plugins.
+ //
+ driver.fsState.knownFilesSetChanges.listen((KnownFilesSetChange change) {
+ List<String> addedPluginPaths = _checkPluginsFor(driver, change);
+ for (String pluginPath in addedPluginPaths) {
+ manager.addPluginToContextRoot(contextRoot, pluginPath);
+ }
+ });
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/status/diagnostics.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698