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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_directory_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 38c2f7e050fb88b4a16fd015bd4a9d0ca6646735..327153f0be41a9cc8fb31a0c815bd64c9a1bc793 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -34,11 +34,15 @@ class AnalysisServerContextDirectoryManager extends ContextDirectoryManager {
AnalysisServerContextDirectoryManager(this.analysisServer, ResourceProvider resourceProvider)
: super(resourceProvider);
- void addContext(Folder folder) {
- PubFolder pubFolder = new PubFolder(analysisServer.defaultSdk, folder);
+ void addContext(Folder folder, File pubspecFile) {
+ PubFolder pubFolder = new PubFolder(analysisServer.defaultSdk, folder, pubspecFile);
analysisServer.folderMap[folder] = pubFolder;
analysisServer.addContextToWorkQueue(pubFolder.context);
}
+
+ void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) {
+ analysisServer.folderMap[contextFolder].context.applyChanges(changeSet);
+ }
}
/**
@@ -443,7 +447,7 @@ class PubFolder {
final Folder _folder;
/**
- * The `pubspec.yaml` file in [_folder].
+ * The `pubspec.yaml` file in [_folder], or null if there isn't one.
*/
File _pubspecFile;
@@ -452,12 +456,7 @@ class PubFolder {
*/
AnalysisContext _context;
- PubFolder(DartSdk sdk, this._folder) {
- // prepare pubspec.yaml
- _pubspecFile = _folder.getChild('pubspec.yaml');
- if (!_pubspecFile.exists) {
- throw new ArgumentError('$_pubspecFile does not exist');
- }
+ PubFolder(DartSdk sdk, this._folder, this._pubspecFile) {
// create AnalysisContext
_context = AnalysisEngine.instance.createAnalysisContext();
// TODO(scheglov) replace FileUriResolver with an Resource based resolver
@@ -467,37 +466,12 @@ class PubFolder {
new FileUriResolver(),
// new PackageUriResolver(),
]);
- // add folder files
- {
- ChangeSet changeSet = new ChangeSet();
- _addSourceFiles(changeSet, _folder);
- _context.applyChanges(changeSet);
- }
}
/**
* Return the [AnalysisContext] of this folder.
*/
AnalysisContext get context => _context;
-
- /**
- * Resursively adds all Dart and HTML files to the [changeSet].
- */
- 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);
- }
- }
- }
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_directory_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698