private static <E extends WorkspaceEntity> void collectWFICIteratorsOnChange(@NotNull Change change,
                                                                               @Nullable E oldEntity,
                                                                               @Nullable E newEntity,
                                                                               @NotNull Project project,
                                                                               @NotNull Collection<? super IndexableIteratorBuilder> builders,
                                                                               @NotNull WorkspaceIndexingRootsBuilder descriptionsBuilder,
                                                                               @NotNull Class<? super E> entityClass,
                                                                               @NotNull EntityStorage entityStorage) {
    LOG.assertTrue(newEntity != null || change == Change.Removed, "New entity " + newEntity + ", change " + change);
    LOG.assertTrue(oldEntity != null || change == Change.Added, "Old entity " + oldEntity + ", change " + change);

    List<WorkspaceFileIndexContributor<?>> contributors = WorkspaceFileIndexImpl.Companion.getEP_NAME().getExtensionList();
    for (WorkspaceFileIndexContributor<?> uncheckedContributor : contributors) {
      if (uncheckedContributor.getStorageKind() != EntityStorageKind.MAIN) {
        continue;
      }
      if (entityClass == uncheckedContributor.getEntityClass()) {
        //noinspection unchecked
        WorkspaceFileIndexContributor<E> contributor = (WorkspaceFileIndexContributor<E>)uncheckedContributor;
        switch (change) {
          case Added -> descriptionsBuilder.registerAddedEntity(newEntity, contributor, entityStorage);
          case Replaced -> descriptionsBuilder.registerChangedEntity(oldEntity, newEntity, contributor, entityStorage);
          case Removed -> descriptionsBuilder.registerRemovedEntity(oldEntity, contributor, entityStorage);
        }
      }
      if (change == Change.Replaced) {
        handleDependencies(oldEntity, newEntity, descriptionsBuilder, entityClass, uncheckedContributor,
                           entityStorage);
      }
    }

    collectIEPIteratorsOnChange(change, oldEntity, newEntity, project, builders, entityClass);

    if (change != Change.Removed && isLibraryIgnoredByLibraryRootFileIndexContributor(newEntity)) {
      if (change == Change.Added) {
        // Sure, we are interested only in libraries used in the project, but in case a registered library is downloaded,
        // no change in dependencies happens, only Added event on LibraryEntity.
        // For debug see com.intellij.roots.libraries.LibraryTest
        builders.addAll(IndexableIteratorBuilders.INSTANCE.forLibraryEntity(((LibraryEntity)newEntity).getSymbolicId(), false));
      }
      else if (change == Change.Replaced && hasSomethingToIndex((LibraryEntity)oldEntity, (LibraryEntity)newEntity)) {
        builders.addAll(IndexableIteratorBuilders.INSTANCE.forLibraryEntity(((LibraryEntity)newEntity).getSymbolicId(), false));
      }
    }
  }
private static <E extends WorkspaceEntity> void collectWFICIteratorsOnChange(@NotNull Change change,
                                                                               @Nullable E oldEntity,
                                                                               @Nullable E newEntity,
                                                                               @NotNull Project project,
                                                                               @NotNull Collection<? super IndexableIteratorBuilder> builders,
                                                                               @NotNull WorkspaceIndexingRootsBuilder descriptionsBuilder,
                                                                               @NotNull Class<? super E> entityClass,
                                                                               @NotNull EntityStorage entityStorage)