本文整理汇总了Java中com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker类的典型用法代码示例。如果您正苦于以下问题:Java RefreshWorker类的具体用法?Java RefreshWorker怎么用?Java RefreshWorker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RefreshWorker类属于com.intellij.openapi.vfs.newvfs.persistent包,在下文中一共展示了RefreshWorker类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cancel
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
public void cancel() {
myCancelled = true;
RefreshWorker worker = myWorker;
if (worker != null) {
worker.cancel();
}
}
示例2: doTestInterruptedRefresh
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
public static void doTestInterruptedRefresh(@NotNull File top) throws Exception {
File sub = IoTestUtil.createTestDir(top, "sub");
File subSub = IoTestUtil.createTestDir(sub, "sub_sub");
File file1 = IoTestUtil.createTestFile(sub, "sub_file_to_stop_at");
File file2 = IoTestUtil.createTestFile(subSub, "sub_sub_file");
LocalFileSystem lfs = LocalFileSystem.getInstance();
NewVirtualFile topDir = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(top);
assertNotNull(topDir);
NewVirtualFile subFile1 = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(file1);
assertNotNull(subFile1);
NewVirtualFile subFile2 = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(file2);
assertNotNull(subFile2);
topDir.refresh(false, true);
assertFalse(topDir.isDirty());
assertFalse(subFile1.isDirty());
assertFalse(subFile2.isDirty());
try {
subFile1.markDirty();
subFile2.markDirty();
RefreshWorker.setCancellingCondition(file -> "sub_file_to_stop_at".equals(file.getName()));
topDir.refresh(false, true);
// should remain dirty after aborted refresh
assertTrue(subFile1.isDirty());
assertTrue(subFile2.isDirty());
RefreshWorker.setCancellingCondition(null);
topDir.refresh(false, true);
assertFalse(topDir.isDirty());
assertFalse(subFile1.isDirty());
assertFalse(subFile2.isDirty());
}
finally {
RefreshWorker.setCancellingCondition(null);
}
}
示例3: cancel
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
void cancel() {
myCancelled = true;
RefreshWorker worker = myWorker;
if (worker != null) {
worker.cancel();
}
}
示例4: scan
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
public void scan() {
List<VirtualFile> workQueue = myWorkQueue;
myWorkQueue = new ArrayList<VirtualFile>();
boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();
if (!workQueue.isEmpty()) {
final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
final FileWatcher watcher;
if (fileSystem instanceof LocalFileSystemImpl) {
LocalFileSystemImpl fs = (LocalFileSystemImpl)fileSystem;
fs.markSuspiciousFilesDirty(workQueue);
watcher = fs.getFileWatcher();
}
else {
watcher = null;
}
long t = 0;
if (LOG.isDebugEnabled()) {
LOG.debug("scanning " + workQueue);
t = System.currentTimeMillis();
}
for (VirtualFile file : workQueue) {
if (myCancelled) break;
NewVirtualFile nvf = (NewVirtualFile)file;
if (!myIsRecursive && (!myIsAsync || (watcher != null && !watcher.isWatched(nvf)))) {
// we're unable to definitely refresh synchronously by means of file watcher.
nvf.markDirty();
}
RefreshWorker worker = myWorker = new RefreshWorker(nvf, myIsRecursive);
worker.scan();
List<VFileEvent> events = worker.getEvents();
if (myEvents.addAll(events)) {
haveEventsToFire = true;
}
}
if (t != 0) {
t = System.currentTimeMillis() - t;
LOG.debug((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
}
}
myWorker = null;
iHaveEventsToFire = haveEventsToFire;
}
示例5: scan
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
public void scan() {
List<VirtualFile> workQueue = myWorkQueue;
myWorkQueue = new ArrayList<VirtualFile>();
boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();
if (!workQueue.isEmpty()) {
LocalFileSystemImpl fs = (LocalFileSystemImpl)LocalFileSystem.getInstance();
fs.markSuspiciousFilesDirty(workQueue);
FileWatcher watcher = fs.getFileWatcher();
long t = 0;
if (LOG.isDebugEnabled()) {
LOG.debug("scanning " + workQueue);
t = System.currentTimeMillis();
}
for (VirtualFile file : workQueue) {
if (myCancelled) break;
NewVirtualFile nvf = (NewVirtualFile)file;
if (!myIsRecursive && (!myIsAsync || !watcher.isWatched(nvf))) {
// we're unable to definitely refresh synchronously by means of file watcher.
nvf.markDirty();
}
RefreshWorker worker = myWorker = new RefreshWorker(nvf, myIsRecursive);
worker.scan();
List<VFileEvent> events = worker.getEvents();
if (myEvents.addAll(events)) {
haveEventsToFire = true;
}
}
if (t != 0) {
t = System.currentTimeMillis() - t;
LOG.debug((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
}
}
myWorker = null;
iHaveEventsToFire = haveEventsToFire;
}
示例6: doTestInterruptedRefresh
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
public static void doTestInterruptedRefresh(@Nonnull File top) throws Exception {
File sub = IoTestUtil.createTestDir(top, "sub");
File subSub = IoTestUtil.createTestDir(sub, "sub_sub");
File file1 = IoTestUtil.createTestFile(sub, "sub_file_to_stop_at");
File file2 = IoTestUtil.createTestFile(subSub, "sub_sub_file");
LocalFileSystem lfs = LocalFileSystem.getInstance();
NewVirtualFile topDir = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(top);
assertNotNull(topDir);
NewVirtualFile subFile1 = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(file1);
assertNotNull(subFile1);
NewVirtualFile subFile2 = (NewVirtualFile)lfs.refreshAndFindFileByIoFile(file2);
assertNotNull(subFile2);
topDir.refresh(false, true);
assertFalse(topDir.isDirty());
assertFalse(subFile1.isDirty());
assertFalse(subFile2.isDirty());
try {
subFile1.markDirty();
subFile2.markDirty();
RefreshWorker.setCancellingCondition(new Function<VirtualFile, Boolean>() {
@Override
public Boolean fun(VirtualFile file) {
return "sub_file_to_stop_at".equals(file.getName());
}
});
topDir.refresh(false, true);
// should remain dirty after aborted refresh
assertTrue(subFile1.isDirty());
assertTrue(subFile2.isDirty());
RefreshWorker.setCancellingCondition(null);
topDir.refresh(false, true);
assertFalse(topDir.isDirty());
assertFalse(subFile1.isDirty());
assertFalse(subFile2.isDirty());
}
finally {
RefreshWorker.setCancellingCondition(null);
}
}
示例7: scan
import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
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) {
nvf.markDirty(); // always scan when non-recursive AND synchronous - needed e.g. when refreshing project files on open
}
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;
}