Java Code Examples for com.intellij.openapi.vfs.newvfs.NewVirtualFile#isDirectory()

The following examples show how to use com.intellij.openapi.vfs.newvfs.NewVirtualFile#isDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RefreshWorker.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean checkAndScheduleFileTypeChange(@Nonnull NewVirtualFileSystem fs, @Nullable NewVirtualFile parent, @Nonnull NewVirtualFile child, @Nonnull FileAttributes childAttributes) {
  boolean currentIsDirectory = child.isDirectory(), upToDateIsDirectory = childAttributes.isDirectory();
  boolean currentIsSymlink = child.is(VFileProperty.SYMLINK), upToDateIsSymlink = childAttributes.isSymLink();
  boolean currentIsSpecial = child.is(VFileProperty.SPECIAL), upToDateIsSpecial = childAttributes.isSpecial();

  if (currentIsDirectory != upToDateIsDirectory || currentIsSymlink != upToDateIsSymlink || currentIsSpecial != upToDateIsSpecial) {
    myHelper.scheduleDeletion(child);
    if (parent != null) {
      String symlinkTarget = upToDateIsSymlink ? fs.resolveSymLink(child) : null;
      myHelper.scheduleCreation(parent, child.getName(), childAttributes, symlinkTarget, () -> checkCancelled(parent));
    }
    else {
      LOG.error("transgender orphan: " + child + ' ' + childAttributes);
    }
    return true;
  }

  return false;
}
 
Example 2
Source File: LocalFileSystemRefreshWorker.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void processFile(@Nonnull NewVirtualFile file, @Nonnull RefreshContext refreshContext) {
  if (!VfsEventGenerationHelper.checkDirty(file) || isCancelled(file, refreshContext)) {
    return;
  }

  if (file.isDirectory()) {
    boolean fullSync = ((VirtualDirectoryImpl)file).allChildrenLoaded();
    if (fullSync) {
      fullDirRefresh((VirtualDirectoryImpl)file, refreshContext);
    }
    else {
      partialDirRefresh((VirtualDirectoryImpl)file, refreshContext);
    }
  }
  else {
    refreshFile(file, refreshContext);
  }

  if (isCancelled(file, refreshContext)) {
    return;
  }

  if (myIsRecursive || !file.isDirectory()) {
    file.markClean();
  }
}
 
Example 3
Source File: LoadAllVfsStoredContentsAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public boolean processFile(NewVirtualFile file) {
  if (file.isDirectory() || file.is(VFileProperty.SPECIAL)) {
    return true;
  }
  try {
    try (InputStream stream = PersistentFS.getInstance().getInputStream(file)) {
      // check if it's really cached in VFS
      if (!(stream instanceof DataInputStream)) return true;
      byte[] bytes = FileUtil.loadBytes(stream);
      totalSize.addAndGet(bytes.length);
      count.incrementAndGet();
      ProgressManager.getInstance().getProgressIndicator().setText(file.getPresentableUrl());
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
  return true;
}
 
Example 4
Source File: RefreshWorker.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void scan() {
  if (myLocalFileSystemRefreshWorker != null) {
    myLocalFileSystemRefreshWorker.scan();
    return;
  }

  NewVirtualFile root = myRefreshQueue.pullFirst();
  NewVirtualFileSystem fs = root.getFileSystem();
  if (root.isDirectory()) {
    fs = PersistentFS.replaceWithNativeFS(fs);
  }
  PersistentFS persistence = PersistentFS.getInstance();

  FileAttributes attributes = fs.getAttributes(root);
  if (attributes == null) {
    myHelper.scheduleDeletion(root);
    root.markClean();
    return;
  }

  if (fs instanceof LocalFileSystemBase) {
    DirectoryAccessChecker.refresh();
  }

  checkAndScheduleChildRefresh(fs, persistence, root.getParent(), root, attributes);

  if (root.isDirty()) {
    if (myRefreshQueue.isEmpty()) {
      queueDirectory(root);
    }
    try {
      processQueue(fs, persistence);
    }
    catch (RefreshCancelledException e) {
      LOG.trace("refresh cancelled");
    }
  }
}