void (@NotNull Collection<? extends IdeaPluginDescriptor> descriptors, @NotNull Map<PluginId, PluginEnabledState> enabledMap, @NotNull PluginEnableDisableAction action, @NotNull BiConsumer<? super IdeaPluginDescriptor, ? super @NotNull Pair<PluginEnableDisableAction, PluginEnabledState>> beforeHandler) { for (IdeaPluginDescriptor descriptor : descriptors) { PluginId pluginId = descriptor.getPluginId(); PluginEnabledState oldState = enabledMap.get(pluginId); PluginEnabledState newState = oldState == null ? PluginEnabledState.DISABLED : action.apply(oldState); if (newState != null) { beforeHandler.accept(descriptor, Pair.create(action, newState)); enabledMap.put(pluginId, newState); } } }