void (@NotNull Collection<? extends DataNode<ContentRootData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) { logUnitTest("Importing data. Data size is [" + toImport.size() + "]"); if (toImport.isEmpty()) { return; } boolean isNewlyImportedProject = project.getUserData(ExternalSystemDataKeys.NEWLY_IMPORTED_PROJECT) == Boolean.TRUE; boolean forceDirectoriesCreation = false; DataNode<ProjectData> projectDataNode = ExternalSystemApiUtil.findParent(toImport.iterator().next(), ProjectKeys.PROJECT); if (projectDataNode != null) { forceDirectoriesCreation = projectDataNode.getUserData(CREATE_EMPTY_DIRECTORIES) == Boolean.TRUE; } Set<Module> modulesToExpand = CollectionFactory.createSmallMemoryFootprintSet(); MultiMap<DataNode<ModuleData>, DataNode<ContentRootData>> byModule = ExternalSystemApiUtil.groupBy(toImport, ModuleData.class); filterAndReportDuplicatingContentRoots(byModule, project); for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : byModule.entrySet()) { Module module = entry.getKey().getUserData(AbstractModuleDataService.MODULE_KEY); module = module != null ? module : modelsProvider.findIdeModule(entry.getKey().getData()); if (module == null) { LOG.warn(String.format( "Can't import content roots. Reason: target module (%s) is not found at the ide. Content roots: %s", entry.getKey(), entry.getValue() )); continue; } importData(project, modelsProvider, entry.getValue(), module, forceDirectoriesCreation, projectData == null ? null : projectData.getOwner()); if (forceDirectoriesCreation || (isNewlyImportedProject && projectData != null && projectData.getLinkedExternalProjectPath().equals(ExternalSystemApiUtil.getExternalProjectPath(module)))) { modulesToExpand.add(module); } } if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !modulesToExpand.isEmpty()) { for (Module module : modulesToExpand) { String productionModuleName = modelsProvider.getProductionModuleName(module); if (productionModuleName == null || !modulesToExpand.contains(modelsProvider.findIdeModule(productionModuleName))) { VirtualFile[] roots = modelsProvider.getModifiableRootModel(module).getContentRoots(); if (roots.length > 0) { VirtualFile virtualFile = roots[0]; StartupManager.getInstance(project).runAfterOpened(() -> { ApplicationManager.getApplication().invokeLater(() -> { final ProjectView projectView = ProjectView.getInstance(project); projectView.changeViewCB(ProjectViewPane.ID, null).doWhenProcessed(() -> projectView.selectCB(null, virtualFile, false)); }, ModalityState.nonModal(), project.getDisposed()); }); } } } } }