void (@NotNull Project project, @NotNull CodeStyleSettings baseSettings, @NotNull Consumer<? super CodeStyleSettings> tempSettingsConsumer) { final CodeStyleSettingsManager settingsManager = CodeStyleSettingsManager.getInstance(project); CodeStyleSettings tempSettingsBefore = settingsManager.getTemporarySettings(); try { CodeStyleSettings tempSettings = settingsManager.createTemporarySettings(); tempSettings.copyFrom(baseSettings); tempSettingsConsumer.accept(tempSettings); } finally { if (tempSettingsBefore != null) { settingsManager.setTemporarySettings(tempSettingsBefore); } else { settingsManager.dropTemporarySettings(); } } }