Computable<Collection<Module>> (final @NotNull Collection<? extends DataNode<GradleSourceSetData>> toImport, @NotNull final ProjectData projectData, @NotNull final Project project, @NotNull final IdeModifiableModelsProvider modelsProvider) { return () -> { List<Module> orphanIdeModules = new SmartList<>(); for (Module module : modelsProvider.getModules()) { if (module.isDisposed()) continue; if (!ExternalSystemApiUtil.isExternalSystemAwareModule(projectData.getOwner(), module)) continue; if (!GradleConstants.GRADLE_SOURCE_SET_MODULE_TYPE_KEY.equals(ExternalSystemApiUtil.getExternalModuleType(module))) continue; final String rootProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module); if (projectData.getLinkedExternalProjectPath().equals(rootProjectPath)) { if (module.getUserData(AbstractModuleDataService.MODULE_DATA_KEY) == null) { orphanIdeModules.add(module); } } } return orphanIdeModules; }; }