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

Unified Diff: pkg/analysis_server/lib/src/context_directory_manager.dart

Issue 306733002: Make ContextDirectoryManager responsible for scanning directory contents. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
Index: pkg/analysis_server/lib/src/context_directory_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_directory_manager.dart b/pkg/analysis_server/lib/src/context_directory_manager.dart
index 457c67fe36ad8915cb1bfbd7c208c748addfa45f..ec728c445aadfa2f023ea431f22483f4ec870a95 100644
--- a/pkg/analysis_server/lib/src/context_directory_manager.dart
+++ b/pkg/analysis_server/lib/src/context_directory_manager.dart
@@ -5,6 +5,8 @@
library context.directory.manager;
import 'package:analysis_server/src/resource.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/source.dart';
/**
* Class that maintains a mapping from included/excluded paths to a set of
@@ -60,13 +62,45 @@ abstract class ContextDirectoryManager {
}
// add new contexts
for (Folder folder in newFolders) {
- addContext(folder);
+ File pubspecFile = folder.getChild('pubspec.yaml');
+ addContext(folder, pubspecFile.exists ? pubspecFile : null);
+ ChangeSet changeSet = new ChangeSet();
+ _addSourceFiles(changeSet, folder);
+ applyChangesToContext(folder, changeSet);
}
currentFolders = new Set<Folder>.from(includedFolders);
}
/**
- * Called when a new context needs to be created.
+ * Resursively adds all Dart and HTML files to the [changeSet].
*/
- void addContext(Folder folder);
+ static void _addSourceFiles(ChangeSet changeSet, Folder folder) {
+ List<Resource> children = folder.getChildren();
+ for (Resource child in children) {
+ if (child is File) {
+ String fileName = child.shortName;
+ if (AnalysisEngine.isDartFileName(fileName)
+ || AnalysisEngine.isHtmlFileName(fileName)) {
+ Source source = child.createSource(UriKind.FILE_URI);
+ changeSet.addedSource(source);
+ }
+ } else if (child is Folder) {
+ _addSourceFiles(changeSet, child);
+ }
+ }
+ }
+
+ /**
+ * Called when a new context needs to be created. If the context is
+ * associated with a pubspec file, that file is passed in [pubspecFile];
+ * otherwise it is null.
+ */
+ void addContext(Folder folder, File pubspecFile);
+
+ /**
+ * Called when the set of files associated with a context have changed (or
+ * some of those files have been modified). [changeSet] is the set of
+ * changes that need to be applied to the context.
+ */
+ void applyChangesToContext(Folder contextFolder, ChangeSet changeSet);
}

Powered by Google App Engine
This is Rietveld 408576698