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

The following examples show how to use com.intellij.openapi.vfs.newvfs.NewVirtualFile#markClean() . 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: LocalFileSystemRefreshWorker.java    From consulo with Apache License 2.0 6 votes vote down vote up
void scan() {
  NewVirtualFile root = myRefreshRoot;
  boolean rootDirty = root.isDirty();
  if (LOG.isDebugEnabled()) LOG.debug("root=" + root + " dirty=" + rootDirty);
  if (!rootDirty) return;

  NewVirtualFileSystem fs = root.getFileSystem();
  FileAttributes rootAttributes = fs.getAttributes(root);
  if (rootAttributes == null) {
    myHelper.scheduleDeletion(root);
    root.markClean();
    return;
  }
  if (rootAttributes.isDirectory()) {
    fs = PersistentFS.replaceWithNativeFS(fs);
  }

  RefreshContext context = createRefreshContext(fs, PersistentFS.getInstance(), FilePathHashingStrategy.create(fs.isCaseSensitive()));
  context.submitRefreshRequest(() -> processFile(root, context));
  context.waitForRefreshToFinish();
}
 
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: 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");
    }
  }
}
 
Example 4
Source File: RefreshWorker.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void checkAndScheduleChildRefresh(@Nonnull NewVirtualFileSystem fs,
                                          @Nonnull PersistentFS persistence,
                                          @Nullable NewVirtualFile parent,
                                          @Nonnull NewVirtualFile child,
                                          @Nonnull FileAttributes childAttributes) {
  if (!VfsEventGenerationHelper.checkDirty(child)) {
    return;
  }

  if (checkAndScheduleFileTypeChange(fs, parent, child, childAttributes)) {
    child.markClean();
    return;
  }

  myHelper.checkWritableAttributeChange(child, persistence.isWritable(child), childAttributes.isWritable());

  if (SystemInfo.isWindows) {
    myHelper.checkHiddenAttributeChange(child, child.is(VFileProperty.HIDDEN), childAttributes.isHidden());
  }

  if (childAttributes.isSymLink()) {
    myHelper.checkSymbolicLinkChange(child, child.getCanonicalPath(), fs.resolveSymLink(child));
  }

  if (!childAttributes.isDirectory()) {
    long oltTS = persistence.getTimeStamp(child), newTS = childAttributes.lastModified;
    long oldLength = persistence.getLastRecordedLength(child), newLength = childAttributes.length;
    myHelper.checkContentChanged(child, oltTS, newTS, oldLength, newLength);
    child.markClean();
  }
  else if (myIsRecursive) {
    queueDirectory(child);
  }
}
 
Example 5
Source File: RefreshWorker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void forceMarkDirty(@Nonnull NewVirtualFile file) {
  file.markClean();  // otherwise consequent markDirty() won't have any effect
  file.markDirty();
}
 
Example 6
Source File: LocalFileSystemRefreshWorker.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static void forceMarkDirty(@Nonnull NewVirtualFile file) {
  file.markClean();  // otherwise consequent markDirty() won't have any effect
  file.markDirty();
}