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

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

Issue 2830063002: Update PluginWatcher to be more efficient (Closed)
Patch Set: Created 3 years, 8 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 | no next file » | 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 3f2d312b0d972efb87e56b7158da8a2db6417d4a..ab3111da39b31178f95aa83e15719acfaf594c53 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_watcher.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_watcher.dart
@@ -52,8 +52,8 @@ class PluginWatcher implements DriverWatcher {
void addedDriver(AnalysisDriver driver, ContextRoot contextRoot) {
_driverInfo[driver] = new _DriverInfo(
contextRoot, <String>[contextRoot.root, _getSdkPath(driver)]);
- driver.results.listen((AnalysisResult result) {
- List<String> addedPluginPaths = _checkPluginsFor(driver);
+ driver.fsState.knownFilesSetChanges.listen((KnownFilesSetChange change) {
+ List<String> addedPluginPaths = _checkPluginsFor(driver, change);
for (String pluginPath in addedPluginPaths) {
manager.addPluginToContextRoot(contextRoot, pluginPath);
}
@@ -78,9 +78,17 @@ class PluginWatcher implements DriverWatcher {
* seen that defines a plugin. Return a list of the roots of all such plugins
* that are found.
*/
- List<String> _checkPluginsFor(AnalysisDriver driver) {
+ List<String> _checkPluginsFor(
+ AnalysisDriver driver, KnownFilesSetChange change) {
+ _DriverInfo info = _driverInfo[driver];
+ if (info == null) {
+ // The driver must have been removed prior to getting the notification of
+ // newly analyzed files.
+ return const <String>[];
+ }
+ List<String> packageRoots = info.packageRoots;
+ FileSystemState fileSystemState = driver.fsState;
AbsolutePathContext context = resourceProvider.absolutePathContext;
- List<String> packageRoots = _driverInfo[driver].packageRoots;
bool isInRoot(String path) {
for (String root in packageRoots) {
@@ -99,8 +107,8 @@ class PluginWatcher implements DriverWatcher {
}
List<String> addedPluginPaths = <String>[];
- for (FileState state in driver.fsState.knownFiles) {
- String path = state.path;
+ for (String path in change.added) {
+ FileState state = fileSystemState.getFileForPath(path);
if (!isInRoot(path)) {
// Found a file not in a previously known package.
Uri uri = state.uri;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698