private static void importData(@NotNull Project project,
                                  @NotNull IdeModifiableModelsProvider modelsProvider,
                                 @NotNull final Collection<? extends DataNode<ContentRootData>> data,
                                 @NotNull final Module module, boolean forceDirectoriesCreation,
                                 @Nullable ProjectSystemId owner) {
    logUnitTest("Import data for module [" + module.getName() + "], data size [" + data.size() + "]");
    final SourceFolderManager sourceFolderManager = SourceFolderManager.getInstance(project);
    final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
    final ContentEntry[] contentEntries = modifiableRootModel.getContentEntries();
    final Map<String, ContentEntry> contentEntriesMap = new HashMap<>();
    final Map<String, ContentEntry> filePathToContentEntryMap = new HashMap<>();
    for (ContentEntry contentEntry : contentEntries) {
      contentEntriesMap.put(contentEntry.getUrl(), contentEntry);
      VirtualFile file = contentEntry.getFile();
      if (file != null) {
        filePathToContentEntryMap.put(ExternalSystemApiUtil.getLocalFileSystemPath(file), contentEntry);
      }
    }

    sourceFolderManager.removeSourceFolders(module);

    final Set<ContentEntry> importedContentEntries = new ReferenceOpenHashSet<>();
    for (final DataNode<ContentRootData> node : data) {
      final ContentRootData contentRoot = node.getData();

      final ContentEntry contentEntry = findOrCreateContentRoot(modifiableRootModel, contentRoot, filePathToContentEntryMap);
      if (!importedContentEntries.contains(contentEntry)) {
        removeSourceFoldersIfAbsent(contentEntry, contentRoot);
        removeImportedExcludeFolders(contentEntry, modelsProvider, owner, project);
        importedContentEntries.add(contentEntry);
      }
      logTrace("Importing content root '%s' for module '%s' forceDirectoriesCreation=[%b]",
               contentRoot.getRootPath(), module.getName(), forceDirectoriesCreation);

      Set<String> updatedSourceRoots = new HashSet<>();
      for (ExternalSystemSourceType externalSrcType : ExternalSystemSourceType.values()) {
        final JpsModuleSourceRootType<?> type = getJavaSourceRootType(externalSrcType);
        if (type != null) {
          for (SourceRoot sourceRoot : contentRoot.getPaths(externalSrcType)) {
            String sourceRootPath = sourceRoot.getPath();
            boolean createSourceFolder = !updatedSourceRoots.contains(sourceRootPath);
            if (createSourceFolder) {
              createOrReplaceSourceFolder(sourceFolderManager, contentEntry, sourceRoot, module, type, forceDirectoriesCreation,
                                          ExternalSystemApiUtil.toExternalSource(contentRoot.getOwner()));
              if (externalSrcType == ExternalSystemSourceType.SOURCE || externalSrcType == ExternalSystemSourceType.TEST) {
                updatedSourceRoots.add(sourceRootPath);
              }
            }
            configureSourceFolder(sourceFolderManager, contentEntry, sourceRoot, createSourceFolder, externalSrcType.isGenerated());
          }
        }
      }

      for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) {
        createExcludedRootIfAbsent(contentEntry, path, module.getName());
      }
      contentEntriesMap.remove(contentEntry.getUrl());
    }
    for (ContentEntry contentEntry : contentEntriesMap.values()) {
      modifiableRootModel.removeContentEntry(contentEntry);
    }
  }
private static void importData(@NotNull Project project,
                                  @NotNull IdeModifiableModelsProvider modelsProvider,
                                 @NotNull final Collection<? extends DataNode<ContentRootData>> data,
                                 @NotNull final Module module, boolean forceDirectoriesCreation,
                                 @Nullable ProjectSystemId owner)