mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
allow to check if DirectoryIndexImpl and RootIndex return same results
This commit is contained in:
@@ -405,6 +405,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
checkInfoNull(projectOutput);
|
||||
checkInfoNull(module2Output);
|
||||
checkInfoNull(module2TestOutput);
|
||||
|
||||
assertTrue(myIndex.isProjectExcludeRoot(excluded));
|
||||
|
||||
excluded.delete(this);
|
||||
projectOutput.delete(this);
|
||||
@@ -422,6 +424,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
};
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(l, getTestRootDisposable());
|
||||
excluded = myModule1Dir.createChildDirectory(this, excluded.getName());
|
||||
//todo assertTrue(myIndex.isProjectExcludeRoot(excluded));
|
||||
projectOutput = myModule1Dir.createChildDirectory(this, projectOutput.getName());
|
||||
module2Output = myModule1Dir.createChildDirectory(this, module2Output.getName());
|
||||
module2TestOutput = myModule2Dir.createChildDirectory(this, module2TestOutput.getName());
|
||||
@@ -432,6 +435,8 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
checkInfoNull(module2TestOutput);
|
||||
|
||||
assertEquals(created.toString(), 4, created.size());
|
||||
|
||||
assertTrue(myIndex.isProjectExcludeRoot(excluded));
|
||||
}
|
||||
|
||||
public void testExcludesShouldBeRecognizedRightOnRefresh() throws Exception {
|
||||
|
||||
@@ -344,10 +344,6 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
if (ourUseRootIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
myBatchChangePlanned = false;
|
||||
int directoriesRemoved = 0;
|
||||
int directoriesCreated = 0;
|
||||
@@ -392,10 +388,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
|
||||
@Override
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
if (ourUseRootIndex) {
|
||||
myRootIndex = null;
|
||||
return;
|
||||
}
|
||||
myRootIndex = null;
|
||||
|
||||
if (myBatchChangePlanned) {
|
||||
myBatchChangePlanned = false;
|
||||
@@ -492,7 +485,6 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
if (rootIndex != null) {
|
||||
rootIndex.checkConsistency();
|
||||
return;
|
||||
}
|
||||
|
||||
doCheckConsistency(false);
|
||||
@@ -549,10 +541,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
}
|
||||
|
||||
private void doInitialize() {
|
||||
if (ourUseRootIndex) {
|
||||
myRootIndex = null;
|
||||
return;
|
||||
}
|
||||
myRootIndex = null;
|
||||
|
||||
IndexState newState = new IndexState();
|
||||
newState.doInitialize(false);
|
||||
@@ -585,25 +574,28 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
checkAvailability();
|
||||
dispatchPendingEvents();
|
||||
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
if (rootIndex != null) {
|
||||
return rootIndex.getInfoForDirectory(dir);
|
||||
}
|
||||
|
||||
if (!(dir instanceof NewVirtualFile)) return null;
|
||||
return myState.getInfo(((NewVirtualFile)dir).getId());
|
||||
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
DirectoryInfo riInfo = rootIndex != null ? rootIndex.getInfoForDirectory(dir) : null;
|
||||
return assertConsistentResult(dir, riInfo, myState.getInfo(((NewVirtualFile)dir).getId()));
|
||||
}
|
||||
|
||||
private static <T> T assertConsistentResult(@Nullable VirtualFile dir, @Nullable T rootIndexResult, T standardResult) {
|
||||
//noinspection ConstantConditions
|
||||
if (ourUseRootIndex && !Comparing.equal(rootIndexResult, standardResult)) {
|
||||
LOG.error("DirectoryIndex differs from RootIndex at " + dir + "\nriInfo=" + rootIndexResult + "\nstandardResult=" + standardResult);
|
||||
}
|
||||
return standardResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JpsModuleSourceRootType<?> getSourceRootType(@NotNull DirectoryInfo info) {
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
if (rootIndex != null) {
|
||||
return rootIndex.getSourceRootType(info);
|
||||
}
|
||||
|
||||
if (info.isInModuleSource()) {
|
||||
return myState.getRootTypeById(info.getSourceRootTypeId());
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
JpsModuleSourceRootType<?> riType = rootIndex != null ? rootIndex.getSourceRootType(info) : null;
|
||||
return assertConsistentResult(null, riType, myState.getRootTypeById(info.getSourceRootTypeId()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -611,12 +603,16 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
@Override
|
||||
public boolean isProjectExcludeRoot(@NotNull VirtualFile dir) {
|
||||
checkAvailability();
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
if (rootIndex != null) {
|
||||
return rootIndex.isProjectExcludeRoot(dir);
|
||||
}
|
||||
if (!(dir instanceof NewVirtualFile)) return false;
|
||||
|
||||
return dir instanceof NewVirtualFile && myState.myProjectExcludeRoots.contains(((NewVirtualFile)dir).getId());
|
||||
//noinspection UnnecessaryLocalVariable
|
||||
boolean standardResult = myState.myProjectExcludeRoots.contains(((NewVirtualFile)dir).getId());
|
||||
/* todo
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
Boolean riResult = rootIndex != null ? rootIndex.isProjectExcludeRoot(dir) : null;
|
||||
return assertConsistentResult(dir, riResult, standardResult);
|
||||
*/
|
||||
return standardResult;
|
||||
}
|
||||
|
||||
private VirtualFile findFileById(int dir) {
|
||||
@@ -627,13 +623,10 @@ public class DirectoryIndexImpl extends DirectoryIndex {
|
||||
public String getPackageName(@NotNull VirtualFile dir) {
|
||||
checkAvailability();
|
||||
if (!(dir instanceof NewVirtualFile)) return null;
|
||||
|
||||
|
||||
RootIndex rootIndex = getRootIndex();
|
||||
if (rootIndex != null) {
|
||||
return rootIndex.getPackageName(dir);
|
||||
}
|
||||
|
||||
return myState.getPackageNameForDirectory((NewVirtualFile)dir);
|
||||
String riResult = rootIndex != null ? rootIndex.getPackageName(dir) : null;
|
||||
return assertConsistentResult(dir, riResult, myState.getPackageNameForDirectory((NewVirtualFile)dir));
|
||||
}
|
||||
|
||||
private static String decodePackageName(@NotNull int[] interned) {
|
||||
|
||||
Reference in New Issue
Block a user