private static void replaceWithUnknownRootType(Project project, Collection<? extends JpsModuleSourceRootPropertiesSerializer<?>> unregisteredSerializers) {
    if (unregisteredSerializers.isEmpty()) {
      return;
    }
    Map<JpsModuleSourceRootType<?>, JpsModuleSourceRootPropertiesSerializer<?>> serializers = new HashMap<>();
    for (JpsModuleSourceRootPropertiesSerializer<?> serializer : unregisteredSerializers) {
      serializers.put(serializer.getType(), serializer);
    }
    for (Module module : ModuleManager.getInstance(project).getModules()) {
      ModuleRootModificationUtil.modifyModel(module, model -> {
        boolean shouldCommit = false;
        for (ContentEntry contentEntry : model.getContentEntries()) {
          for (SourceFolder folder : contentEntry.getSourceFolders()) {
            JpsModuleSourceRootPropertiesSerializer<?> removedSerializer = serializers.get(folder.getRootType());
            if (removedSerializer != null) {
              changeType(
                folder,
                UnknownSourceRootPropertiesSerializer.forType(removedSerializer.getTypeId()),
                serializeProperties(folder, removedSerializer)
              );
              shouldCommit = true;
            }
          }
        }
        return shouldCommit;
      });
    }
  }
private static void replaceWithUnknownRootType(Project project, Collection<? extends JpsModuleSourceRootPropertiesSerializer<?>> unregisteredSerializers)