DirectoryIndex: don't include roots from content to projectExcludeRoots set, update projectExcludeRoots on VFS change

This commit is contained in:
nik
2013-11-08 15:51:31 +04:00
parent 02f73054e0
commit 4d22f5e7fb
2 changed files with 27 additions and 10 deletions
@@ -412,7 +412,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
checkInfoNull(module2Output);
checkInfoNull(module2TestOutput);
assertTrue(myIndex.isProjectExcludeRoot(excluded));
assertFalse(myIndex.isProjectExcludeRoot(excluded));
excluded.delete(this);
projectOutput.delete(this);
@@ -430,7 +430,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
};
VirtualFileManager.getInstance().addVirtualFileListener(l, getTestRootDisposable());
excluded = myModule1Dir.createChildDirectory(this, excluded.getName());
//todo assertTrue(myIndex.isProjectExcludeRoot(excluded));
assertFalse(myIndex.isProjectExcludeRoot(excluded));
projectOutput = myModule1Dir.createChildDirectory(this, projectOutput.getName());
module2Output = myModule1Dir.createChildDirectory(this, module2Output.getName());
module2TestOutput = myModule2Dir.createChildDirectory(this, module2TestOutput.getName());
@@ -442,7 +442,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
assertEquals(created.toString(), 4, created.size());
assertTrue(myIndex.isProjectExcludeRoot(excluded));
assertFalse(myIndex.isProjectExcludeRoot(excluded));
}
public void testExcludesShouldBeRecognizedRightOnRefresh() throws Exception {
@@ -521,12 +521,24 @@ public class DirectoryIndexTest extends IdeaTestCase {
checkInfo(myExcludedLibClsDir, null, true, false, "lib.cls.exc", null, myModule3);
}
public void testExcludeCompilerOutputOutsideOfContentRoot() throws Exception {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
assertTrue(fileIndex.isIgnored(myOutputDir));
assertTrue(fileIndex.isIgnored(myModule1OutputDir));
assertFalse(fileIndex.isIgnored(myOutputDir.getParent()));
assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
assertFalse(myIndex.isProjectExcludeRoot(myModule1OutputDir));
String moduleOutputUrl = myModule1OutputDir.getUrl();
myOutputDir.delete(this);
PsiTestUtil.setCompilerOutputPath(myModule, moduleOutputUrl, false);
myOutputDir = myRootVFile.createChildDirectory(this, "out");
myModule1OutputDir = myOutputDir.createChildDirectory(this, "module1");
assertTrue(myIndex.isProjectExcludeRoot(myOutputDir));
assertTrue(myIndex.isProjectExcludeRoot(myModule1OutputDir));
assertTrue(fileIndex.isIgnored(myModule1OutputDir));
}
private void checkInfo(VirtualFile dir,
@@ -226,14 +226,19 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
}
if (parentInfo == null) return state;
Module module = parentInfo.getModule();
for (DirectoryIndexExcludePolicy policy : myExcludePolicies) {
if (policy.isExcludeRoot(file)) return state;
if (policy.isExcludeRoot(file)) {
if (parentInfo == null || parentInfo.getContentRoot() == null) {
if (state == originalState) state = state.copy(null);
state.myProjectExcludeRoots.add(file.getId());
}
return state;
}
}
if (parentInfo == null) return state;
Module module = parentInfo.getModule();
if (state == originalState) state = state.copy(null);
VirtualFile parentContentRoot = parentInfo.getContentRoot();
state.fillMapWithModuleContent(file, module, (NewVirtualFile)parentContentRoot, null);
@@ -1471,7 +1476,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
for (VirtualFile excludeRoot : contentEntry.getExcludeFolderFiles()) {
// Output paths should be excluded (if marked as such) regardless if they're under corresponding module's content root
if (excludeRoot instanceof NewVirtualFile) {
if (!FileUtil.startsWith(contentRoot.getUrl(), excludeRoot.getUrl())) {
if (!FileUtil.startsWith(excludeRoot.getUrl(), contentRoot.getUrl())) {
if (isExcludeRootForModule(module, excludeRoot)) {
putForFileAndAllAncestors((NewVirtualFile)excludeRoot, excludeRoot.getUrl());
}