protected void fireEventsInWriteAction() { final VirtualFileManagerEx manager = (VirtualFileManagerEx) VirtualFileManager.getInstance(); manager.fireBeforeRefreshStart(myIsAsync); try { while (!myWorkQueue.isEmpty() || !myEvents.isEmpty()) { ManagingFS.getInstance().processEvents(mergeEventsAndReset()); scan(); } } finally { try { manager.fireAfterRefreshFinish(myIsAsync); } finally { if (myFinishRunnable != null) { myFinishRunnable.run(); } } } }
public void testChildrenAccessedButNotCached() throws Exception { File dir = createTempDirectory(false); ManagingFS managingFS = ManagingFS.getInstance(); VirtualFile vFile = LocalFileSystem.getInstance() .refreshAndFindFileByPath(dir.getPath().replace(File.separatorChar, '/')); assertNotNull(vFile); assertFalse(managingFS.areChildrenLoaded(vFile)); assertFalse(managingFS.wereChildrenAccessed(vFile)); File child = new File(dir, "child"); boolean created = child.createNewFile(); assertTrue(created); File subdir = new File(dir, "subdir"); boolean subdirCreated = subdir.mkdir(); assertTrue(subdirCreated); File subChild = new File(subdir, "subdir"); boolean subChildCreated = subChild.createNewFile(); assertTrue(subChildCreated); VirtualFile childVFile = LocalFileSystem.getInstance() .refreshAndFindFileByPath(child.getPath().replace(File.separatorChar, '/')); assertNotNull(childVFile); assertFalse(managingFS.areChildrenLoaded(vFile)); assertTrue(managingFS.wereChildrenAccessed(vFile)); VirtualFile subdirVFile = LocalFileSystem.getInstance() .refreshAndFindFileByPath(subdir.getPath().replace(File.separatorChar, '/')); assertNotNull(subdirVFile); assertFalse(managingFS.areChildrenLoaded(subdirVFile)); assertFalse(managingFS.wereChildrenAccessed(subdirVFile)); assertFalse(managingFS.areChildrenLoaded(vFile)); assertTrue(managingFS.wereChildrenAccessed(vFile)); vFile.getChildren(); assertTrue(managingFS.areChildrenLoaded(vFile)); assertTrue(managingFS.wereChildrenAccessed(vFile)); assertFalse(managingFS.areChildrenLoaded(subdirVFile)); assertFalse(managingFS.wereChildrenAccessed(subdirVFile)); VirtualFile subChildVFile = LocalFileSystem.getInstance() .refreshAndFindFileByPath(subChild.getPath().replace(File.separatorChar, '/')); assertNotNull(subChildVFile); assertTrue(managingFS.areChildrenLoaded(vFile)); assertTrue(managingFS.wereChildrenAccessed(vFile)); assertFalse(managingFS.areChildrenLoaded(subdirVFile)); assertTrue(managingFS.wereChildrenAccessed(subdirVFile)); }