void (@NotNull Collection<DataNode<E>> imported, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModelsProvider modelsProvider) { Set<Path> orphanModules = project.getUserData(ORPHAN_MODULE_FILES); if (orphanModules == null || orphanModules.isEmpty()) { return; } AtomicInteger counter = project.getUserData(ORPHAN_MODULE_HANDLERS_COUNTER); if (counter == null) { return; } if (counter.decrementAndGet() == 0) { project.putUserData(ORPHAN_MODULE_FILES, null); project.putUserData(ORPHAN_MODULE_HANDLERS_COUNTER, null); StringBuilder modulesToRestoreText = new StringBuilder(); List<Pair<String, Path>> modulesToRestore = new ArrayList<>(); for (Path modulePath : orphanModules) { try { String path = FileUtil.loadFile(modulePath.resolveSibling(modulePath.getFileName() + ".path").toFile()); modulesToRestoreText.append(FileUtilRt.getNameWithoutExtension(new File(path).getName())).append("\n"); modulesToRestore.add(Pair.create(path, modulePath)); } catch (IOException e) { LOG.warn(e); } } String buildSystem = projectData != null ? projectData.getOwner().getReadableName() : "build system"; String content = ExternalSystemBundle.message("orphan.modules.text", buildSystem, StringUtil.shortenTextWithEllipsis(modulesToRestoreText.toString(), 50, 0)); Notification cleanUpNotification = ORPHAN_MODULE_NOTIFICATION_GROUP.createNotification(content, NotificationType.INFORMATION) .setListener((notification, event) -> { if (event.getEventType() != HyperlinkEvent.EventType.ACTIVATED) return; if (showRemovedOrphanModules(modulesToRestore, project)) { notification.expire(); } }) .whenExpired(() -> { List<File> filesToRemove = ContainerUtil.map(orphanModules, Path::toFile); List<File> toRemove2 = ContainerUtil.map(orphanModules, path -> path.resolveSibling(path.getFileName() + ".path").toFile()); FileUtil.asyncDelete(ContainerUtil.concat(filesToRemove, toRemove2)); }); Disposer.register(project, cleanUpNotification::expire); cleanUpNotification.notify(project); } }