void (Collection<? extends DataNode<ModuleData>> toImport, Project project) { if (toImport.isEmpty()) { return; } ProjectSystemId externalSystemId = toImport.iterator().next().getData().getOwner(); ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId); assert manager != null; final MultiMap<DataNode<ProjectData>, DataNode<ModuleData>> grouped = ExternalSystemApiUtil.groupBy(toImport, ProjectKeys.PROJECT); Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> data = new HashMap<>(); for (Map.Entry<DataNode<ProjectData>, Collection<DataNode<ModuleData>>> entry : grouped.entrySet()) { data.put(ExternalProjectPojo.from(entry.getKey().getData()), ContainerUtil.map(entry.getValue(), node -> ExternalProjectPojo.from(node.getData()))); } AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project); Set<String> pathsToForget = detectRenamedProjects(data, settings.getAvailableProjects()); if (!pathsToForget.isEmpty()) { settings.forgetExternalProjects(pathsToForget); } Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> projects = new HashMap<>(settings.getAvailableProjects()); projects.putAll(data); settings.setAvailableProjects(projects); }