private static @NotNull <K, V> Function<VirtualFile, ? extends Map<K, V>> getIndexer(@NotNull ID<K, V> indexId,
                                                                                       @Nullable Project project,
                                                                                       boolean binary) {
    UpdatableIndex<K, V, FileContent, ?> index = ((FileBasedIndexEx)FileBasedIndex.getInstance()).getIndex(indexId);
    FileBasedIndexExtension<K, V> indexExtension = Objects.requireNonNull(findIndexExtension(indexId));
    FileBasedIndex.InputFilter inputFilter = indexExtension.getInputFilter();
    DataIndexer<K, V, FileContent> indexer = indexExtension.getIndexer();
    FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    return file -> {
      IndexedFileImpl indexedFile = new IndexedFileImpl(file, project);
      if (!FileBasedIndexEx.acceptsInput(inputFilter, indexedFile)) return null;
      int fileId = FileBasedIndex.getFileId(file);
      Document document = fileDocumentManager.getCachedDocument(file);
      boolean unsavedDocument = document != null && fileDocumentManager.isDocumentUnsaved(document);
      try {
        if (!unsavedDocument && index.getIndexingStateForFile(fileId, indexedFile) == FileIndexingState.UP_TO_DATE) {
          try {
            return index.getIndexedFileData(fileId);
          }
          catch (StorageException e) {
            throw new RuntimeException(e);
          }
        }
        FileContent content = getFileContent(file, project, binary);
        Map<K, V> map = content == null ? null : indexer.map(content);
        if (unsavedDocument) return map;
        InputData<K, V> inputData = map == null || map.isEmpty() ? InputData.empty() : new InputData<>(map) {};
        Computable<Boolean> computable = index.prepareUpdate(fileId, inputData);
        ProgressManager.getInstance().computeInNonCancelableSection(computable::compute);
        IndexingStamp.setFileIndexedStateCurrent(fileId, indexId, false);
        return map;
      }
      finally {
        IndexingStamp.flushCache(fileId);
      }
    };
  }
private static @NotNull <K, V> Function<VirtualFile, ? extends Map<K, V>> getIndexer(@NotNull ID<K, V> indexId,
                                                                                       @Nullable Project project,
                                                                                       boolean binary)