@NotNull
  private FileIndexesValuesApplier doIndexFileContent(@Nullable Project project,
                                                      @NotNull CachedFileContent content,
                                                      @Nullable FileType cachedFileType,
                                                      @NotNull ApplicationMode applicationMode,
                                                      FileIndexingStamp indexingStamp) {
    ProgressManager.checkCanceled();
    final VirtualFile file = content.getVirtualFile();
    Ref<Boolean> setIndexedStatus = Ref.create(Boolean.TRUE);
    Ref<FileType> fileTypeRef = Ref.create();

    //todo check file still from project
    int inputId = getFileId(file);
    Project guessedProject = project != null ? project : findProjectForFileId(inputId);
    IndexedFileImpl indexedFile = new IndexedFileImpl(file, guessedProject);

    List<SingleIndexValueApplier<?>> appliers = new ArrayList<>();
    List<SingleIndexValueRemover> removers = new ArrayList<>();

    FileTypeManagerEx fileTypeManagerEx = FileTypeManagerEx.getInstanceEx();
    if (fileTypeManagerEx instanceof FileTypeManagerImpl) {
      ((FileTypeManagerImpl)fileTypeManagerEx).freezeFileTypeTemporarilyWithProvidedValueIn(file, cachedFileType, () -> {
        ProgressManager.checkCanceled();
        FileContentImpl fc = null;

        Set<ID<?, ?>> currentIndexedStates = getAppliedIndexes(inputId);
        List<ID<?, ?>> requiredIndexes = getRequiredIndexes(indexedFile);
        for (ID<?, ?> indexId : requiredIndexes) {
          currentIndexedStates.remove(indexId);
          if (FileBasedIndexScanUtil.isManuallyManaged(indexId)) continue;
          ProgressManager.checkCanceled();

          if (fc == null) {
            fc = (FileContentImpl)FileContentImpl.createByContent(file, () -> content.getBytesOrEmpty(), guessedProject);
            fc.setSubstituteFileType(indexedFile.getFileType());
            ProgressManager.checkCanceled();

            fileTypeRef.set(fc.getFileType());

            ProgressManager.checkCanceled();
          }

          boolean update;
          boolean acceptedAndRequired = getIndexingState(fc, indexId, indexingStamp).updateRequired();
          if (acceptedAndRequired) {
            update = RebuildStatus.isOk(indexId);
            if (!update) {
              setIndexedStatus.set(Boolean.FALSE);
            }
          }
          else {
            update = false;
          }

          if (!update && doTraceStubUpdates(indexId)) {
            String reason;
            if (acceptedAndRequired) {
              reason = "index is required to rebuild, and indexing does not update such";
            }
            else {
              reason = "update is not required";
            }

            LOG.info("index " + indexId + " should not be updated for " + fc.getFileName() + " because " + reason);
          }

          if (update) {
            ProgressManager.checkCanceled();
            SingleIndexValueApplier<?> singleIndexValueApplier = createSingleIndexValueApplier(indexId, file, inputId, fc);
            if (singleIndexValueApplier == null) {
              setIndexedStatus.set(Boolean.FALSE);
            }
            else {
              appliers.add(singleIndexValueApplier);
            }
          }
        }

        for (ID<?, ?> indexId : currentIndexedStates) {
          ProgressManager.checkCanceled();
          SingleIndexValueRemover remover = createSingleIndexRemover(indexId, file, fc, inputId, applicationMode);
          if (remover == null) {
            setIndexedStatus.set(Boolean.FALSE);
          }
          else {
            removers.add(remover);
          }
        }

        fileTypeRef.set(fc != null ? fc.getFileType() : file.getFileType());
      });
    }

    file.putUserData(IndexingDataKeys.REBUILD_REQUESTED, null);
    return new FileIndexesValuesApplier(this,
                                        inputId, file, indexingStamp, appliers, removers, false, setIndexedStatus.get(), applicationMode,
                                        fileTypeRef.get(), doTraceSharedIndexUpdates()
    );
  }
@NotNull
  private FileIndexesValuesApplier doIndexFileContent(@Nullable Project project,
                                                      @NotNull CachedFileContent content,
                                                      @Nullable FileType cachedFileType,
                                                      @NotNull ApplicationMode applicationMode,
                                                      FileIndexingStamp indexingStamp)