Java 类com.intellij.util.text.FilePathHashingStrategy 实例源码

项目:intellij-ce-playground    文件:RefreshWorker.java   
private void processQueue(NewVirtualFileSystem fs, PersistentFS persistence) throws RefreshCancelledException {
  TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive());

  while (!myRefreshQueue.isEmpty()) {
    Pair<NewVirtualFile, FileAttributes> pair = myRefreshQueue.pullFirst();
    NewVirtualFile file = pair.first;
    boolean fileDirty = file.isDirty();
    debug(LOG, "file=%s dirty=%b", file, fileDirty);
    if (!fileDirty) continue;

    checkCancelled(file);

    FileAttributes attributes = pair.second != null ? pair.second : fs.getAttributes(file);
    if (attributes == null) {
      scheduleDeletion(file);
      continue;
    }

    NewVirtualFile parent = file.getParent();
    if (parent != null && checkAndScheduleFileTypeChange(parent, file, attributes)) {
      // ignore everything else
      file.markClean();
      continue ;
    }

    if (file.isDirectory()) {
      boolean fullSync = ((VirtualDirectoryImpl)file).allChildrenLoaded();
      if (fullSync) {
        fullDirRefresh(fs, persistence, strategy, (VirtualDirectoryImpl)file);
      }
      else {
        partialDirRefresh(fs, strategy, (VirtualDirectoryImpl)file);
      }
    }
    else {
      long currentTimestamp = persistence.getTimeStamp(file);
      long upToDateTimestamp = attributes.lastModified;
      long currentLength = persistence.getLastRecordedLength(file);
      long upToDateLength = attributes.length;

      if (currentTimestamp != upToDateTimestamp || currentLength != upToDateLength) {
        scheduleUpdateContent(file);
      }
    }

    boolean currentWritable = persistence.isWritable(file);
    boolean upToDateWritable = attributes.isWritable();
    if (LOG_ATTRIBUTES.isDebugEnabled()) {
      LOG_ATTRIBUTES.debug("file=" + file + " writable vfs=" + file.isWritable() + " persistence=" + currentWritable + " real=" + upToDateWritable);
    }
    if (currentWritable != upToDateWritable) {
      scheduleAttributeChange(file, VirtualFile.PROP_WRITABLE, currentWritable, upToDateWritable);
    }

    if (SystemInfo.isWindows) {
      boolean currentHidden = file.is(VFileProperty.HIDDEN);
      boolean upToDateHidden = attributes.isHidden();
      if (currentHidden != upToDateHidden) {
        scheduleAttributeChange(file, VirtualFile.PROP_HIDDEN, currentHidden, upToDateHidden);
      }
    }

    if (attributes.isSymLink()) {
      String currentTarget = file.getCanonicalPath();
      String upToDateTarget = fs.resolveSymLink(file);
      String upToDateVfsTarget = upToDateTarget != null ? FileUtil.toSystemIndependentName(upToDateTarget) : null;
      if (!Comparing.equal(currentTarget, upToDateVfsTarget)) {
        scheduleAttributeChange(file, VirtualFile.PROP_SYMLINK_TARGET, currentTarget, upToDateVfsTarget);
      }
    }

    if (myIsRecursive || !file.isDirectory()) {
      file.markClean();
    }
  }
}
项目:consulo    文件:RefreshWorker.java   
private void processQueue(NewVirtualFileSystem fs, PersistentFS persistence) throws RefreshCancelledException {
  TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive());

  while (!myRefreshQueue.isEmpty()) {
    Pair<NewVirtualFile, FileAttributes> pair = myRefreshQueue.pullFirst();
    NewVirtualFile file = pair.first;
    boolean fileDirty = file.isDirty();
    if (LOG.isTraceEnabled()) LOG.trace("file=" + file + " dirty=" + fileDirty);
    if (!fileDirty) continue;

    checkCancelled(file);

    FileAttributes attributes = pair.second != null ? pair.second : fs.getAttributes(file);
    if (attributes == null) {
      scheduleDeletion(file);
      continue;
    }

    NewVirtualFile parent = file.getParent();
    if (parent != null && checkAndScheduleFileTypeChange(parent, file, attributes)) {
      // ignore everything else
      file.markClean();
      continue ;
    }

    if (file.isDirectory()) {
      boolean fullSync = ((VirtualDirectoryImpl)file).allChildrenLoaded();
      if (fullSync) {
        fullDirRefresh(fs, persistence, strategy, (VirtualDirectoryImpl)file);
      }
      else {
        partialDirRefresh(fs, strategy, (VirtualDirectoryImpl)file);
      }
    }
    else {
      long currentTimestamp = persistence.getTimeStamp(file);
      long upToDateTimestamp = attributes.lastModified;
      long currentLength = persistence.getLastRecordedLength(file);
      long upToDateLength = attributes.length;

      if (currentTimestamp != upToDateTimestamp || currentLength != upToDateLength) {
        scheduleUpdateContent(file);
      }
    }

    boolean currentWritable = persistence.isWritable(file);
    boolean upToDateWritable = attributes.isWritable();
    if (LOG_ATTRIBUTES.isDebugEnabled()) {
      LOG_ATTRIBUTES.debug("file=" + file + " writable vfs=" + file.isWritable() + " persistence=" + currentWritable + " real=" + upToDateWritable);
    }
    if (currentWritable != upToDateWritable) {
      scheduleAttributeChange(file, VirtualFile.PROP_WRITABLE, currentWritable, upToDateWritable);
    }

    if (SystemInfo.isWindows) {
      boolean currentHidden = file.is(VFileProperty.HIDDEN);
      boolean upToDateHidden = attributes.isHidden();
      if (currentHidden != upToDateHidden) {
        scheduleAttributeChange(file, VirtualFile.PROP_HIDDEN, currentHidden, upToDateHidden);
      }
    }

    if (attributes.isSymLink()) {
      String currentTarget = file.getCanonicalPath();
      String upToDateTarget = fs.resolveSymLink(file);
      String upToDateVfsTarget = upToDateTarget != null ? FileUtil.toSystemIndependentName(upToDateTarget) : null;
      if (!Comparing.equal(currentTarget, upToDateVfsTarget)) {
        scheduleAttributeChange(file, VirtualFile.PROP_SYMLINK_TARGET, currentTarget, upToDateVfsTarget);
      }
    }

    if (myIsRecursive || !file.isDirectory()) {
      file.markClean();
    }
  }
}