private <Key> void tryFixIndexesForProblemFiles(@NotNull StubIndexKey<Key, ?> indexKey, @NotNull Key key, @NotNull Project project) {
    Set<VirtualFile> filesWithProblems = myStubProcessingHelper.takeAccumulatedFilesWithIndexProblems();

    if (filesWithProblems != null) {
      List<String> fileNames = ContainerUtil.map(filesWithProblems, f -> f.getName());
      String fileNamesStr = StringUtil.first(StringUtil.join(fileNames, ","), 300, true);
      getLogger().info("Data for " + fileNamesStr + " will be re-indexes because of internal stub processing error. Recomputing index request");

      // clear possibly inconsistent key
      ((FileBasedIndexEx)FileBasedIndex.getInstance()).runCleanupAction(() -> {
        UpdatableIndex<Integer, SerializedStubTree, FileContent, ?> index = getStubUpdatingIndex();

        for (VirtualFile file : filesWithProblems) {
          int fileId = FileBasedIndex.getFileId(file);
          index.mapInputAndPrepareUpdate(fileId, null).compute();
        }

        Lock writeLock = getIndex(indexKey).getLock().writeLock();
        writeLock.lock();
        try {
          for (VirtualFile file : filesWithProblems) {
            int fileId = FileBasedIndex.getFileId(file);
            updateIndex(indexKey,
                        fileId,
                        Collections.singleton(key),
                        Collections.emptySet());
          }
        }
        finally {
          writeLock.unlock();
        }

        index.cleanupMemoryStorage();
      });

      // schedule indexes to rebuild
      for (VirtualFile file: filesWithProblems) {
        FileBasedIndex.getInstance().requestReindex(file);
      }

      // drop caches
      ApplicationManager.getApplication().invokeLater(() -> WriteAction.run(() -> {
        PsiManager psiManager = PsiManager.getInstance(project);
        psiManager.dropPsiCaches();
        psiManager.dropResolveCaches();
      }), project.getDisposed());
    }
  }
private <Key> void tryFixIndexesForProblemFiles(@NotNull StubIndexKey<Key, ?> indexKey, @NotNull Key key, @NotNull Project project)