当前位置: 首页>>代码示例>>Java>>正文


Java RefreshWorker类代码示例

本文整理汇总了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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:RefreshSessionImpl.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:LocalFileSystemTest.java

示例3: cancel

import com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker; //导入依赖的package包/类
void cancel() {
  myCancelled = true;

  RefreshWorker worker = myWorker;
  if (worker != null) {
    worker.cancel();
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:RefreshSessionImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:RefreshSessionImpl.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:43,代码来源:RefreshSessionImpl.java

示例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);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:42,代码来源:LocalFileSystemTest.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:50,代码来源:RefreshSessionImpl.java


注:本文中的com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。