| 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);
|
| }
|
|
|