summaryrefslogtreecommitdiff
path: root/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java')
-rw-r--r--java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java198
1 files changed, 105 insertions, 93 deletions
diff --git a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
index 1e3e08a33ae7..56624594bb0e 100644
--- a/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
+++ b/java/java-tests/testSrc/com/intellij/openapi/roots/impl/DirectoryIndexTest.java
@@ -49,7 +49,7 @@ import static java.util.Collections.singletonList;
public class DirectoryIndexTest extends IdeaTestCase {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.DirectoryIndexTest");
- private DirectoryIndex myIndex;
+ private DirectoryIndexImpl myIndex;
private Module myModule2, myModule3;
private VirtualFile myRootVFile;
@@ -65,6 +65,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
private VirtualFile myModule1OutputDir;
private VirtualFile myResDir, myTestResDir;
private VirtualFile myExcludedLibSrcDir, myExcludedLibClsDir;
+ private ProjectFileIndex myFileIndex;
@Override
protected void setUp() throws Exception {
@@ -176,7 +177,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
}
});
- myIndex = DirectoryIndex.getInstance(myProject);
+ myIndex = (DirectoryIndexImpl)DirectoryIndex.getInstance(myProject);
+ myFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
// to not interfere with previous test firing vfs events
VirtualFileManager.getInstance().syncRefresh();
}
@@ -221,12 +223,12 @@ public class DirectoryIndexTest extends IdeaTestCase {
VirtualFile cvs = myPack1Dir.createChildDirectory(this, "CVS");
assertNotInProject(cvs);
- assertNull(ProjectRootManager.getInstance(myProject).getFileIndex().getPackageNameByDirectory(cvs));
+ assertNull(myFileIndex.getPackageNameByDirectory(cvs));
}
public void testDirsByPackageName() throws IOException {
- checkPackage("", true, mySrcDir1, myTestSrc1, myResDir, myTestResDir, myFileLibSrc, myFileLibCls, mySrcDir2, myLibSrcDir, myLibClsDir);
- checkPackage("", false, mySrcDir1, myTestSrc1, myResDir, myTestResDir, myFileLibCls, mySrcDir2, myLibClsDir);
+ checkPackage("", true, mySrcDir1, myTestSrc1, myResDir, myTestResDir, mySrcDir2, myLibSrcDir, myLibClsDir);
+ checkPackage("", false, mySrcDir1, myTestSrc1, myResDir, myTestResDir, mySrcDir2, myLibClsDir);
checkPackage("pack1", true, myPack1Dir);
checkPackage("pack1", false, myPack1Dir);
@@ -257,6 +259,18 @@ public class DirectoryIndexTest extends IdeaTestCase {
checkPackage("pack1", true, myPack1Dir, myModule3Dir);
}
+ public void testPackageDirectoriesWithDots() throws IOException {
+ VirtualFile fooBar = mySrcDir1.createChildDirectory(this, "foo.bar");
+ VirtualFile goo1 = fooBar.createChildDirectory(this, "goo");
+ VirtualFile foo = mySrcDir2.createChildDirectory(this, "foo");
+ VirtualFile bar = foo.createChildDirectory(this, "bar");
+ VirtualFile goo2 = bar.createChildDirectory(this, "goo");
+
+ checkPackage("foo", false, foo);
+ checkPackage("foo.bar", false, bar, fooBar);
+ checkPackage("foo.bar.goo", false, goo2, goo1);
+ }
+
public void testCreateDir() throws Exception {
String path = mySrcDir1.getPath().replace('/', File.separatorChar);
assertTrue(new File(path + File.separatorChar + "dir1" + File.separatorChar + "dir2").mkdirs());
@@ -362,7 +376,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
VirtualFile ignoredFile = myModule1Dir.createChildData(this, "CVS");
DirectoryInfo info = myIndex.getInfoForFile(ignoredFile);
assertTrue(info.isIgnored());
- assertTrue(ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(ignoredFile));
+ assertTrue(myFileIndex.isExcluded(ignoredFile));
+ assertTrue(myFileIndex.isUnderIgnored(ignoredFile));
}
public void testAddModule() throws Exception {
@@ -386,10 +401,12 @@ public class DirectoryIndexTest extends IdeaTestCase {
public void testModuleUnderIgnoredDir() throws IOException {
final VirtualFile ignored = myRootVFile.createChildDirectory(this, "RCS");
assertTrue(FileTypeManager.getInstance().isFileIgnored(ignored));
- assertTrue(ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(ignored));
+ assertTrue(myFileIndex.isExcluded(ignored));
+ assertTrue(myFileIndex.isUnderIgnored(ignored));
final VirtualFile module4 = ignored.createChildDirectory(this, "module4");
assertFalse(FileTypeManager.getInstance().isFileIgnored(module4));
- assertTrue(ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(module4));
+ assertTrue(myFileIndex.isExcluded(module4));
+ assertTrue(myFileIndex.isUnderIgnored(module4));
new WriteCommandAction.Simple(getProject()) {
@Override
@@ -425,11 +442,12 @@ public class DirectoryIndexTest extends IdeaTestCase {
}
public void testExcludedDirsInLibraries() {
- ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
- assertFalse(index.isInLibraryClasses(myExcludedLibClsDir));
- assertTrue(index.isExcluded(myExcludedLibClsDir));
- assertFalse(index.isInLibrarySource(myExcludedLibSrcDir));
- assertTrue(index.isExcluded(myExcludedLibSrcDir));
+ assertFalse(myFileIndex.isInLibraryClasses(myExcludedLibClsDir));
+ assertTrue(myFileIndex.isExcluded(myExcludedLibClsDir));
+ assertFalse(myFileIndex.isUnderIgnored(myExcludedLibClsDir));
+ assertFalse(myFileIndex.isInLibrarySource(myExcludedLibSrcDir));
+ assertTrue(myFileIndex.isExcluded(myExcludedLibSrcDir));
+ assertFalse(myFileIndex.isUnderIgnored(myExcludedLibSrcDir));
}
public void testExplicitExcludeOfInner() throws Exception {
@@ -469,12 +487,12 @@ public class DirectoryIndexTest extends IdeaTestCase {
ModuleRootModificationUtil.addModuleLibrary(myModule, "someLib", Collections.<String>emptyList(), Arrays.asList(mySrcDir1.getUrl()));
checkInfo(mySrcDir1, myModule, false, true, "", JavaSourceRootType.SOURCE, myModule, myModule);
- OrderEntry[] entries = myIndex.getInfoForFile(mySrcDir1).getOrderEntries();
+ OrderEntry[] entries = myIndex.getOrderEntries(myIndex.getInfoForFile(mySrcDir1));
assertInstanceOf(entries[0], LibraryOrderEntry.class);
assertInstanceOf(entries[1], ModuleSourceOrderEntry.class);
checkInfo(myTestSrc1, myModule, false, true, "testSrc", JavaSourceRootType.TEST_SOURCE, myModule, myModule);
- entries = myIndex.getInfoForFile(myTestSrc1).getOrderEntries();
+ entries = myIndex.getOrderEntries(myIndex.getInfoForFile(myTestSrc1));
assertInstanceOf(entries[0], LibraryOrderEntry.class);
assertInstanceOf(entries[1], ModuleSourceOrderEntry.class);
}
@@ -482,7 +500,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
public void testModuleSourceAsLibraryClasses() throws Exception {
ModuleRootModificationUtil.addModuleLibrary(myModule, "someLib", Arrays.asList(mySrcDir1.getUrl()), Collections.<String>emptyList());
checkInfo(mySrcDir1, myModule, true, false, "", JavaSourceRootType.SOURCE, myModule);
- assertInstanceOf(assertOneElement(assertInProject(mySrcDir1).getOrderEntries()), ModuleSourceOrderEntry.class);
+ assertInstanceOf(assertOneElement(myIndex.getOrderEntries(assertInProject(mySrcDir1))), ModuleSourceOrderEntry.class);
}
public void testModulesWithSameSourceContentRoot() {
@@ -645,7 +663,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
checkInfo(myLibSrcDir, myModule, true, true, "", null, myModule, myModule3);
checkInfo(myResDir, myModule, true, false, "", JavaResourceRootType.RESOURCE, myModule);
- assertInstanceOf(assertOneElement(assertInProject(myResDir).getOrderEntries()), ModuleSourceOrderEntry.class);
+ assertInstanceOf(assertOneElement(myIndex.getOrderEntries(assertInProject(myResDir))), ModuleSourceOrderEntry.class);
checkInfo(myExcludedLibSrcDir, null, true, false, "lib.src.exc", null, myModule3, myModule);
checkInfo(myExcludedLibClsDir, null, true, false, "lib.cls.exc", null, myModule3);
@@ -661,10 +679,10 @@ public class DirectoryIndexTest extends IdeaTestCase {
}
public void testExcludeCompilerOutputOutsideOfContentRoot() throws Exception {
- final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
- assertTrue(fileIndex.isExcluded(myOutputDir));
- assertTrue(fileIndex.isExcluded(myModule1OutputDir));
- assertFalse(fileIndex.isExcluded(myOutputDir.getParent()));
+ assertTrue(myFileIndex.isExcluded(myOutputDir));
+ assertFalse(myFileIndex.isUnderIgnored(myOutputDir));
+ assertTrue(myFileIndex.isExcluded(myModule1OutputDir));
+ assertFalse(myFileIndex.isExcluded(myOutputDir.getParent()));
assertExcludedFromProject(myOutputDir);
assertExcludedFromProject(myModule1OutputDir);
String moduleOutputUrl = myModule1OutputDir.getUrl();
@@ -677,7 +695,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
assertExcludedFromProject(myOutputDir);
assertExcludedFromProject(myModule1OutputDir);
- assertTrue(fileIndex.isExcluded(myModule1OutputDir));
+ assertTrue(myFileIndex.isExcluded(myModule1OutputDir));
PsiTestUtil.setCompilerOutputPath(myModule, moduleOutputUrl, true);
PsiTestUtil.setCompilerOutputPath(myModule2, moduleOutputUrl, false);
@@ -703,49 +721,47 @@ public class DirectoryIndexTest extends IdeaTestCase {
}
public void testFileContentAndSourceRoots() throws IOException {
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
-
VirtualFile fileRoot = myRootVFile.createChildData(this, "fileRoot.txt");
VirtualFile fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
VirtualFile fileTestSourceRoot = myRootVFile.createChildData(this, "fileTestSourceRoot.txt");
assertNotInProject(fileRoot);
- assertFalse(fileIndex.isInContent(fileRoot));
- assertIteratedContent(fileIndex, null, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot));
+ assertFalse(myFileIndex.isInContent(fileRoot));
+ assertIteratedContent(myFileIndex, null, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot));
ContentEntry contentEntry = PsiTestUtil.addContentRoot(myModule, fileRoot);
assertEquals(fileRoot, contentEntry.getFile());
checkInfo(fileRoot, myModule, false, false, "", null);
- assertTrue(fileIndex.isInContent(fileRoot));
- assertFalse(fileIndex.isInSource(fileRoot));
+ assertTrue(myFileIndex.isInContent(fileRoot));
+ assertFalse(myFileIndex.isInSource(fileRoot));
PsiTestUtil.addContentRoot(myModule, fileSourceRoot);
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
PsiTestUtil.addContentRoot(myModule, fileTestSourceRoot);
PsiTestUtil.addSourceRoot(myModule, fileTestSourceRoot, true);
checkInfo(fileTestSourceRoot, myModule, false, false, "", JavaSourceRootType.TEST_SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileTestSourceRoot));
- assertTrue(fileIndex.isInSource(fileTestSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileTestSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileTestSourceRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
+ assertIteratedContent(myFileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
// removing file source root
PsiTestUtil.removeSourceRoot(myModule, fileTestSourceRoot);
checkInfo(fileTestSourceRoot, myModule, false, false, "", null);
- assertTrue(fileIndex.isInContent(fileTestSourceRoot));
- assertFalse(fileIndex.isInSource(fileTestSourceRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
+ assertTrue(myFileIndex.isInContent(fileTestSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileTestSourceRoot));
+ assertIteratedContent(myFileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
// removing file content root
- PsiTestUtil.removeContentEntry(myModule, contentEntry);
+ PsiTestUtil.removeContentEntry(myModule, contentEntry.getFile());
assertNotInProject(fileRoot);
- assertFalse(fileIndex.isInContent(fileRoot));
- assertFalse(fileIndex.isInSource(fileRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileSourceRoot, fileTestSourceRoot), Arrays.asList(fileRoot));
+ assertFalse(myFileIndex.isInContent(fileRoot));
+ assertFalse(myFileIndex.isInSource(fileRoot));
+ assertIteratedContent(myFileIndex, Arrays.asList(fileSourceRoot, fileTestSourceRoot), Arrays.asList(fileRoot));
}
private void assertIteratedContent(ProjectFileIndex fileIndex,
@@ -764,63 +780,57 @@ public class DirectoryIndexTest extends IdeaTestCase {
}
public void testFileSourceRootsUnderDirContentRoot() throws IOException {
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
-
VirtualFile fileSourceRoot = myModule1Dir.createChildData(this, "fileSourceRoot.txt");
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertFalse(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileSourceRoot));
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
// removing file source root
PsiTestUtil.removeSourceRoot(myModule, fileSourceRoot);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertFalse(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileSourceRoot));
}
public void testFileModuleExcludeRootUnderDirectoryRoot() throws IOException {
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
-
VirtualFile fileExcludeRoot = mySrcDir1.createChildData(this, "fileExcludeRoot.txt");
- assertTrue(fileIndex.isInContent(fileExcludeRoot));
- assertTrue(fileIndex.isInSource(fileExcludeRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileExcludeRoot), null);
+ assertTrue(myFileIndex.isInContent(fileExcludeRoot));
+ assertTrue(myFileIndex.isInSource(fileExcludeRoot));
+ assertIteratedContent(myFileIndex, Arrays.asList(fileExcludeRoot), null);
PsiTestUtil.addExcludedRoot(myModule, fileExcludeRoot);
- assertFalse(fileIndex.isInContent(fileExcludeRoot));
- assertFalse(fileIndex.isInSource(fileExcludeRoot));
+ assertFalse(myFileIndex.isInContent(fileExcludeRoot));
+ assertFalse(myFileIndex.isInSource(fileExcludeRoot));
assertExcluded(fileExcludeRoot, myModule);
- assertIteratedContent(fileIndex, null, Arrays.asList(fileExcludeRoot));
+ assertIteratedContent(myFileIndex, null, Arrays.asList(fileExcludeRoot));
// removing file exclude root
PsiTestUtil.removeExcludedRoot(myModule, fileExcludeRoot);
- assertTrue(fileIndex.isInContent(fileExcludeRoot));
- assertTrue(fileIndex.isInSource(fileExcludeRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileExcludeRoot), null);
+ assertTrue(myFileIndex.isInContent(fileExcludeRoot));
+ assertTrue(myFileIndex.isInSource(fileExcludeRoot));
+ assertIteratedContent(myFileIndex, Arrays.asList(fileExcludeRoot), null);
}
public void testFileModuleExcludeRootUnderFileRoot() throws IOException {
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
-
VirtualFile fileRoot = myRootVFile.createChildData(this, "fileRoot.txt");
PsiTestUtil.addContentRoot(myModule, fileRoot);
checkInfo(fileRoot, myModule, false, false, "", null);
- assertTrue(fileIndex.isInContent(fileRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileRoot), null);
+ assertTrue(myFileIndex.isInContent(fileRoot));
+ assertIteratedContent(myFileIndex, Arrays.asList(fileRoot), null);
PsiTestUtil.addExcludedRoot(myModule, fileRoot);
- assertFalse(fileIndex.isInContent(fileRoot));
+ assertFalse(myFileIndex.isInContent(fileRoot));
assertExcluded(fileRoot, myModule);
- assertIteratedContent(fileIndex, null, Arrays.asList(fileRoot));
+ assertIteratedContent(myFileIndex, null, Arrays.asList(fileRoot));
// removing file exclude root
PsiTestUtil.removeExcludedRoot(myModule, fileRoot);
checkInfo(fileRoot, myModule, false, false, "", null);
- assertTrue(fileIndex.isInContent(fileRoot));
- assertIteratedContent(fileIndex, Arrays.asList(fileRoot), null);
+ assertTrue(myFileIndex.isInContent(fileRoot));
+ assertIteratedContent(myFileIndex, Arrays.asList(fileRoot), null);
}
public void testFileLibraryInsideFolderLibrary() throws IOException {
@@ -835,8 +845,6 @@ public class DirectoryIndexTest extends IdeaTestCase {
}
public void testFileContentRootsModifications() throws IOException {
- ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
-
VirtualFile temp = myRootVFile.createChildDirectory(this, "temp");
VirtualFile fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
@@ -845,54 +853,54 @@ public class DirectoryIndexTest extends IdeaTestCase {
PsiTestUtil.addContentRoot(myModule, fileSourceRoot);
PsiTestUtil.addSourceRoot(myModule, fileSourceRoot);
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
// delete and recreate
fileSourceRoot.delete(this);
assertNotInProject(fileSourceRoot);
- assertFalse(fileIndex.isInContent(fileSourceRoot));
- assertFalse(fileIndex.isInSource(fileSourceRoot));
+ assertFalse(myFileIndex.isInContent(fileSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileSourceRoot));
fileSourceRoot = myRootVFile.createChildData(this, "fileSourceRoot.txt");
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
// delete and move from another dir
fileSourceRoot.delete(this);
assertNotInProject(fileSourceRoot);
- assertFalse(fileIndex.isInContent(fileSourceRoot));
- assertFalse(fileIndex.isInSource(fileSourceRoot));
+ assertFalse(myFileIndex.isInContent(fileSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileSourceRoot));
fileSourceRoot = temp.createChildData(this, "fileSourceRoot.txt");
assertNotInProject(fileSourceRoot);
fileSourceRoot.move(this, myRootVFile);
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
// delete and copy from another dir
fileSourceRoot.delete(this);
assertNotInProject(fileSourceRoot);
- assertFalse(fileIndex.isInContent(fileSourceRoot));
- assertFalse(fileIndex.isInSource(fileSourceRoot));
+ assertFalse(myFileIndex.isInContent(fileSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileSourceRoot));
fileSourceRoot = temp.createChildData(this, "fileSourceRoot.txt");
assertNotInProject(fileSourceRoot);
fileSourceRoot = fileSourceRoot.copy(this, myRootVFile, "fileSourceRoot.txt");
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
// delete and rename from another file
fileSourceRoot.delete(this);
assertNotInProject(fileSourceRoot);
- assertFalse(fileIndex.isInContent(fileSourceRoot));
- assertFalse(fileIndex.isInSource(fileSourceRoot));
+ assertFalse(myFileIndex.isInContent(fileSourceRoot));
+ assertFalse(myFileIndex.isInSource(fileSourceRoot));
fileSourceRoot = myRootVFile.createChildData(this, "temp_file.txt");
assertNotInProject(fileSourceRoot);
fileSourceRoot.rename(this, "fileSourceRoot.txt");
checkInfo(fileSourceRoot, myModule, false, false, "", JavaSourceRootType.SOURCE, myModule);
- assertTrue(fileIndex.isInContent(fileSourceRoot));
- assertTrue(fileIndex.isInSource(fileSourceRoot));
+ assertTrue(myFileIndex.isInContent(fileSourceRoot));
+ assertTrue(myFileIndex.isInSource(fileSourceRoot));
}
private void checkInfo(VirtualFile file,
@@ -914,15 +922,14 @@ public class DirectoryIndexTest extends IdeaTestCase {
assertEquals(isInLibrary, info.hasLibraryClassRoot());
assertEquals(isInLibrarySource, info.isInLibrarySource());
- final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
if (file.isDirectory()) {
- assertEquals(packageName, fileIndex.getPackageNameByDirectory(file));
+ assertEquals(packageName, myFileIndex.getPackageNameByDirectory(file));
}
- assertEquals(Arrays.toString(info.getOrderEntries()), modulesOfOrderEntries.length, info.getOrderEntries().length);
+ assertEquals(Arrays.toString(myIndex.getOrderEntries(info)), modulesOfOrderEntries.length, myIndex.getOrderEntries(info).length);
for (Module aModule : modulesOfOrderEntries) {
- OrderEntry found = info.findOrderEntryWithOwnerModule(aModule);
- assertNotNull("not found: " + aModule + " in " + Arrays.toString(info.getOrderEntries()), found);
+ OrderEntry found = myIndex.findOrderEntryWithOwnerModule(info, aModule);
+ assertNotNull("not found: " + aModule + " in " + Arrays.toString(myIndex.getOrderEntries(info)), found);
}
}
@@ -941,7 +948,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
private DirectoryInfo assertInProject(VirtualFile file) {
DirectoryInfo info = myIndex.getInfoForFile(file);
assertTrue(file.toString(), info.isInProject());
- info.assertConsistency();
+ myIndex.assertConsistency(info);
return info;
}
@@ -957,6 +964,11 @@ public class DirectoryIndexTest extends IdeaTestCase {
VirtualFile[] actualDirs = myIndex.getDirectoriesByPackageName(packageName, includeLibrarySources).toArray(VirtualFile.EMPTY_ARRAY);
assertNotNull(actualDirs);
assertOrderedEquals(actualDirs, expectedDirs);
+
+ for (VirtualFile dir : expectedDirs) {
+ String actualName = myIndex.getPackageName(dir);
+ assertEquals("Invalid package name for dir " + dir + ": " + packageName, packageName, actualName);
+ }
}
}