From b846a86e9e8710746bc3269e46b6735e461e008a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 24 Jul 2019 20:22:07 +0200 Subject: [PATCH] [test framework] utility method for temporary setting a registry value GitOrigin-RevId: dcfd782b7546cd4ff1948f20fe3b89f76c802a0f --- .../openapi/util/registry/RegistryTestUtil.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 platform/testFramework/src/com/intellij/openapi/util/registry/RegistryTestUtil.kt diff --git a/platform/testFramework/src/com/intellij/openapi/util/registry/RegistryTestUtil.kt b/platform/testFramework/src/com/intellij/openapi/util/registry/RegistryTestUtil.kt new file mode 100644 index 000000000000..eb32c8b4176e --- /dev/null +++ b/platform/testFramework/src/com/intellij/openapi/util/registry/RegistryTestUtil.kt @@ -0,0 +1,14 @@ +// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +@file:JvmName("RegistryTestUtil") +package com.intellij.openapi.util.registry + +fun RegistryValue.withValue(tempValue: Boolean, block: () -> Unit) { + val currentValue = asBoolean() + try { + setValue(tempValue) + block() + } + finally { + setValue(currentValue) + } +} \ No newline at end of file