private static void removeImportedExcludeFolders(@NotNull ContentEntry contentEntry,
                                                   @NotNull IdeModifiableModelsProvider modelsProvider,
                                                   @Nullable ProjectSystemId owner, @NotNull Project project) {
    if (owner == null) {
      return; // can not remove imported exclude folders is source is not known
    }
    if (modelsProvider instanceof IdeModifiableModelsProviderImpl impl) {
      MutableEntityStorage diff = impl.getActualStorageBuilder();

      VirtualFileUrl vfu = WorkspaceModel.getInstance(project).getVirtualFileUrlManager().getOrCreateFromUrl(contentEntry.getUrl());
      WorkspaceEntity workspaceEntity = ContainerUtil.find(diff.getVirtualFileUrlIndex().findEntitiesByUrl(vfu).iterator(), entity -> {
        return entity instanceof ContentRootEntity;
      });

      if (workspaceEntity instanceof ContentRootEntity contentRootEntity) {
        for (ExcludeUrlEntity excludeEntity : contentRootEntity.getExcludedUrls()) {
          if (isImportedEntity(owner, excludeEntity)) {
            diff.removeEntity(excludeEntity);
          }
        }
      }
    }
  }
private static void removeImportedExcludeFolders(@NotNull ContentEntry contentEntry,
                                                   @NotNull IdeModifiableModelsProvider modelsProvider,
                                                   @Nullable ProjectSystemId owner, @NotNull Project project)