void (@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<>(); for (ContentEntry contentEntry : contentEntries) { contentEntriesMap.put(contentEntry.getUrl(), 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); if (!importedContentEntries.contains(contentEntry)) { removeSourceFoldersIfAbsent(contentEntry, contentRoot); removeImportedExcludeFolders(contentEntry, modelsProvider, owner, project); importedContentEntries.add(contentEntry); } logDebug("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); } }