Skip to content

Commit 7f4d5bb

Browse files
committed
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
1 parent 7688ecb commit 7f4d5bb

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

pkg/analysis_server/lib/src/context_manager.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,23 @@ abstract class ContextManager {
239239
List<Resource> children = folder.getChildren();
240240
for (Resource child in children) {
241241
String path = child.path;
242-
// ignore if wasn't previously excluded
243-
bool wasExcluded =
244-
_isExcludedBy(oldExcludedPaths, path) &&
245-
!_isExcludedBy(excludedPaths, path);
246-
if (!wasExcluded) {
247-
continue;
248-
}
249242
// add files, recurse into folders
250243
if (child is File) {
251-
if (_shouldFileBeAnalyzed(child)) {
252-
Source source = child.createSource();
253-
changeSet.addedSource(source);
254-
info.sources[path] = source;
244+
// ignore if should not be analyzed at all
245+
if (!_shouldFileBeAnalyzed(child)) {
246+
continue;
255247
}
248+
// ignore if was not excluded
249+
bool wasExcluded =
250+
_isExcludedBy(oldExcludedPaths, path) &&
251+
!_isExcludedBy(excludedPaths, path);
252+
if (!wasExcluded) {
253+
continue;
254+
}
255+
// do add the file
256+
Source source = child.createSource();
257+
changeSet.addedSource(source);
258+
info.sources[path] = source;
256259
} else if (child is Folder) {
257260
if (child.shortName == PACKAGES_NAME) {
258261
continue;

pkg/analysis_server/test/context_manager_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,24 @@ class ContextManagerTest {
323323
manager.assertContextFiles(project, [file1, file2]);
324324
}
325325

326+
void test_setRoots_exclude_sameRoot_removeExcludedFile_inFolder() {
327+
// prepare paths
328+
String project = '/project';
329+
String file1 = '$project/bin/file1.dart';
330+
String file2 = '$project/bin/file2.dart';
331+
// create files
332+
resourceProvider.newFile(file1, '// 1');
333+
resourceProvider.newFile(file2, '// 2');
334+
// set roots
335+
manager.setRoots(<String>[project], <String>[file2], <String, String>{});
336+
manager.assertContextPaths([project]);
337+
manager.assertContextFiles(project, [file1]);
338+
// stop excluding "2"
339+
manager.setRoots(<String>[project], <String>[], <String, String>{});
340+
manager.assertContextPaths([project]);
341+
manager.assertContextFiles(project, [file1, file2]);
342+
}
343+
326344
void test_setRoots_exclude_sameRoot_removeExcludedFolder() {
327345
// prepare paths
328346
String project = '/project';

0 commit comments

Comments
 (0)