use of com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl in project intellij-community by JetBrains.
the class RefreshSessionImpl method scan.
public void scan() {
List<VirtualFile> workQueue = myWorkQueue;
myWorkQueue = new ArrayList<>();
boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();
if (!workQueue.isEmpty()) {
LocalFileSystem fs = LocalFileSystem.getInstance();
if (fs instanceof LocalFileSystemImpl) {
((LocalFileSystemImpl) fs).markSuspiciousFilesDirty(workQueue);
}
long t = 0;
if (LOG.isTraceEnabled()) {
LOG.trace("scanning " + workQueue);
t = System.currentTimeMillis();
}
int count = 0;
refresh: do {
if (LOG.isTraceEnabled())
LOG.trace("try=" + count);
for (VirtualFile file : workQueue) {
if (myCancelled)
break refresh;
NewVirtualFile nvf = (NewVirtualFile) file;
if (!myIsRecursive && !myIsAsync) {
// always scan when non-recursive AND synchronous - needed e.g. when refreshing project files on open
nvf.markDirty();
}
RefreshWorker worker = new RefreshWorker(nvf, myIsRecursive);
myWorker = worker;
worker.scan();
haveEventsToFire |= myEvents.addAll(worker.getEvents());
}
count++;
if (LOG.isTraceEnabled())
LOG.trace("events=" + myEvents.size());
} while (!myCancelled && myIsRecursive && count < 3 && workQueue.stream().anyMatch(f -> ((NewVirtualFile) f).isDirty()));
if (t != 0) {
t = System.currentTimeMillis() - t;
LOG.trace((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
}
}
myWorker = null;
myHaveEventsToFire = haveEventsToFire;
}
use of com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl in project intellij-community by JetBrains.
the class PlatformTestCase method cleanupApplicationCaches.
public static void cleanupApplicationCaches(Project project) {
if (project != null && !project.isDisposed()) {
UndoManagerImpl globalInstance = (UndoManagerImpl) UndoManager.getGlobalInstance();
if (globalInstance != null) {
globalInstance.dropHistoryInTests();
}
((UndoManagerImpl) UndoManager.getInstance(project)).dropHistoryInTests();
((DocumentReferenceManagerImpl) DocumentReferenceManager.getInstance()).cleanupForNextTest();
((PsiManagerImpl) PsiManager.getInstance(project)).cleanupForNextTest();
}
final ProjectManager projectManager = ProjectManager.getInstance();
assert projectManager != null : "The ProjectManager is not initialized yet";
ProjectManagerImpl projectManagerImpl = (ProjectManagerImpl) projectManager;
if (projectManagerImpl.isDefaultProjectInitialized()) {
Project defaultProject = projectManager.getDefaultProject();
((PsiManagerImpl) PsiManager.getInstance(defaultProject)).cleanupForNextTest();
}
AsyncHighlighterUpdater.completeAsyncTasks();
((FileBasedIndexImpl) FileBasedIndex.getInstance()).cleanupForNextTest();
LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl) LocalFileSystem.getInstance();
if (localFileSystem != null) {
localFileSystem.cleanupForNextTest();
}
}
use of com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl in project intellij-community by JetBrains.
the class StartupManagerImpl method checkProjectRoots.
private void checkProjectRoots() {
VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
if (roots.length == 0)
return;
LocalFileSystem fs = LocalFileSystem.getInstance();
if (!(fs instanceof LocalFileSystemImpl))
return;
FileWatcher watcher = ((LocalFileSystemImpl) fs).getFileWatcher();
if (!watcher.isOperational())
return;
PooledThreadExecutor.INSTANCE.submit(() -> {
LOG.debug("FW/roots waiting started");
while (true) {
if (myProject.isDisposed())
return;
if (!watcher.isSettingRoots())
break;
TimeoutUtil.sleep(10);
}
LOG.debug("FW/roots waiting finished");
Collection<String> manualWatchRoots = watcher.getManualWatchRoots();
if (!manualWatchRoots.isEmpty()) {
List<String> nonWatched = new SmartList<>();
for (VirtualFile root : roots) {
if (!(root.getFileSystem() instanceof LocalFileSystem))
continue;
String rootPath = root.getPath();
for (String manualWatchRoot : manualWatchRoots) {
if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
nonWatched.add(rootPath);
}
}
}
if (!nonWatched.isEmpty()) {
String message = ApplicationBundle.message("watcher.non.watchable.project");
watcher.notifyOnFailure(message, null);
LOG.info("unwatched roots: " + nonWatched);
LOG.info("manual watches: " + manualWatchRoots);
}
}
});
}
Aggregations