void (ModuleManager moduleManager, List<Module> modulesToRemove) { WriteAction.run(() -> { List<ModifiableRootModel> usingModels = new SmartList<>(); for (Module module : modulesToRemove) { ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); for (OrderEntry entry : moduleRootManager.getOrderEntries()) { if (entry instanceof ModuleOrderEntry) { usingModels.add(moduleRootManager.getModifiableModel()); break; } } } final ModifiableModuleModel moduleModel = moduleManager.getModifiableModel(); for (Module module : modulesToRemove) { ModuleDeleteProvider.removeModule(module, usingModels, moduleModel); } ModifiableModelCommitter.multiCommit(usingModels, moduleModel); }); }