void (@NotNull List<? extends ModuleEditor> selectedEditors) { WriteAction.run(() -> { for (ModuleEditor editor : selectedEditors) { myModuleEditors.remove(editor.getModule()); final Module moduleToRemove = editor.getModule(); // remove all dependencies on the module which is about to be removed List<ModifiableRootModel> modifiableRootModels = new ArrayList<>(); for (final ModuleEditor moduleEditor : myModuleEditors.values()) { final ModifiableRootModel modifiableRootModel = moduleEditor.getModifiableRootModelProxy(); ContainerUtil.addIfNotNull(modifiableRootModels, modifiableRootModel); } ModuleDeleteProvider.removeModule(moduleToRemove, modifiableRootModels, myModuleModel); Disposer.dispose(editor); } }); processModuleCountChanged(); }