Issue 21506. Fix for adding back previously excluded resources in sub-folders.
The server's part of the issue.
R=brianwilkerson@google.com
BUG= https://code.google.com/p/dart/issues/detail?id=21506
Review URL: https://codereview.chromium.org//692073004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41500 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 2447fcd..6f815d1 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -239,20 +239,23 @@
List<Resource> children = folder.getChildren();
for (Resource child in children) {
String path = child.path;
- // ignore if wasn't previously excluded
- bool wasExcluded =
- _isExcludedBy(oldExcludedPaths, path) &&
- !_isExcludedBy(excludedPaths, path);
- if (!wasExcluded) {
- continue;
- }
// add files, recurse into folders
if (child is File) {
- if (_shouldFileBeAnalyzed(child)) {
- Source source = child.createSource();
- changeSet.addedSource(source);
- info.sources[path] = source;
+ // ignore if should not be analyzed at all
+ if (!_shouldFileBeAnalyzed(child)) {
+ continue;
}
+ // ignore if was not excluded
+ bool wasExcluded =
+ _isExcludedBy(oldExcludedPaths, path) &&
+ !_isExcludedBy(excludedPaths, path);
+ if (!wasExcluded) {
+ continue;
+ }
+ // do add the file
+ Source source = child.createSource();
+ changeSet.addedSource(source);
+ info.sources[path] = source;
} else if (child is Folder) {
if (child.shortName == PACKAGES_NAME) {
continue;
diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
index 161c060..0fb2192 100644
--- a/pkg/analysis_server/test/context_manager_test.dart
+++ b/pkg/analysis_server/test/context_manager_test.dart
@@ -323,6 +323,24 @@
manager.assertContextFiles(project, [file1, file2]);
}
+ void test_setRoots_exclude_sameRoot_removeExcludedFile_inFolder() {
+ // prepare paths
+ String project = '/project';
+ String file1 = '$project/bin/file1.dart';
+ String file2 = '$project/bin/file2.dart';
+ // create files
+ resourceProvider.newFile(file1, '// 1');
+ resourceProvider.newFile(file2, '// 2');
+ // set roots
+ manager.setRoots(<String>[project], <String>[file2], <String, String>{});
+ manager.assertContextPaths([project]);
+ manager.assertContextFiles(project, [file1]);
+ // stop excluding "2"
+ manager.setRoots(<String>[project], <String>[], <String, String>{});
+ manager.assertContextPaths([project]);
+ manager.assertContextFiles(project, [file1, file2]);
+ }
+
void test_setRoots_exclude_sameRoot_removeExcludedFolder() {
// prepare paths
String project = '/project';