mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
do not mutate registry value cache on setValue, fix updating registry options
GitOrigin-RevId: 14b5ff51f4ff65d202696a159f1c0d965f8d6a9c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
899f7b3421
commit
7d4a9e6be6
@@ -234,7 +234,7 @@ object DebuggerDiagnosticsUtil {
|
||||
val currentSuspendContext = (currentCommand as? SuspendContextCommandImpl)?.suspendContext
|
||||
val currentSuspendContextText = "Current Command Suspend context = $currentSuspendContext\n"
|
||||
val registryInfo = Registry.getAll()
|
||||
.filter { it.key.startsWith("debugger.") && it.isChangedFromDefault }
|
||||
.filter { it.key.startsWith("debugger.") && it.isChangedFromDefault() }
|
||||
.joinToString(separator = "") { "${it.key} = ${it.asString()}\n" }
|
||||
val content = registryInfo +
|
||||
currentCommandText +
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.scratch;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.PerFileMappings;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.CachedSingletonsRegistry;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.impl.VirtualFileEnumerationAware;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.CollectionFactory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -20,6 +20,8 @@ import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class ScratchFileService implements VirtualFileEnumerationAware {
|
||||
private static final boolean useWorkspaceModel = SystemProperties.getBooleanProperty("scratch.files.use.workspace.model", true);
|
||||
|
||||
public enum Option {existing_only, create_if_missing, create_new_always}
|
||||
|
||||
private static final Supplier<ScratchFileService> ourInstance = CachedSingletonsRegistry.lazy(() -> {
|
||||
@@ -27,7 +29,7 @@ public abstract class ScratchFileService implements VirtualFileEnumerationAware
|
||||
});
|
||||
|
||||
public static boolean isWorkspaceModelIntegrationEnabled() {
|
||||
return Registry.is("scratch.files.use.workspace.model");
|
||||
return useWorkspaceModel;
|
||||
}
|
||||
|
||||
public static ScratchFileService getInstance() {
|
||||
@@ -49,7 +51,9 @@ public abstract class ScratchFileService implements VirtualFileEnumerationAware
|
||||
}
|
||||
|
||||
public static @NotNull Set<VirtualFile> getAllRootPaths() {
|
||||
if (isWorkspaceModelIntegrationEnabled()) return Collections.emptySet();
|
||||
if (isWorkspaceModelIntegrationEnabled()) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
ScratchFileService instance = getInstance();
|
||||
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.platform.feedback.dialog
|
||||
|
||||
import com.intellij.ide.nls.NlsMessages
|
||||
@@ -97,7 +97,7 @@ data class CommonFeedbackSystemData(
|
||||
private fun getRegistryKeys(): List<String> = Registry.getAll().filter { value: RegistryValue ->
|
||||
val pluginId: String? = value.pluginId
|
||||
val pluginInfo = if (pluginId != null) getPluginInfoById(PluginId.getId(pluginId)) else platformPlugin
|
||||
value.isChangedFromDefault && pluginInfo.isSafeToReport()
|
||||
value.isChangedFromDefault() && pluginInfo.isSafeToReport()
|
||||
}.map { v: RegistryValue -> v.key + "=" + v.asString() }.toList()
|
||||
|
||||
private fun getDisabledPlugins(): List<String> = getPluginsNamesWithVersion { p: IdeaPluginDescriptor -> !p.isEnabled }
|
||||
|
||||
@@ -34,11 +34,10 @@ class RegistryKeyBean private constructor() {
|
||||
const val KEY_CONFLICT_LOG_CATEGORY: String = "com.intellij.openapi.util.registry.overrides"
|
||||
|
||||
@ApiStatus.Internal
|
||||
@JvmStatic
|
||||
fun addKeysFromPlugins() {
|
||||
val point = (ApplicationManager.getApplication().extensionArea)
|
||||
.getExtensionPoint<RegistryKeyBean>("com.intellij.registryKey") as ExtensionPointImpl
|
||||
Registry.setKeys(HashMap<String, RegistryKeyDescriptor>().let { mutator ->
|
||||
Registry.setContributedKeys(HashMap<String, RegistryKeyDescriptor>().let { mutator ->
|
||||
point.processUnsortedWithPluginDescriptor { bean, pluginDescriptor ->
|
||||
val descriptor = createRegistryKeyDescriptor(bean, pluginDescriptor)
|
||||
putNewDescriptorConsideringOverrides(mutator, descriptor, false)
|
||||
|
||||
@@ -17198,11 +17198,6 @@ f:com.intellij.ide.scratch.ScratchTreeStructureProvider
|
||||
- s:createRootNode(com.intellij.openapi.project.Project,com.intellij.ide.projectView.ViewSettings):com.intellij.ide.util.treeView.AbstractTreeNode
|
||||
- s:getVirtualFile(com.intellij.ide.scratch.RootType):com.intellij.openapi.vfs.VirtualFile
|
||||
- modify(com.intellij.ide.util.treeView.AbstractTreeNode,java.util.Collection,com.intellij.ide.projectView.ViewSettings):java.util.Collection
|
||||
f:com.intellij.ide.scratch.ScratchesAndConsolesIndexSetContributor
|
||||
- com.intellij.util.indexing.IndexableSetContributor
|
||||
- <init>():V
|
||||
- getAdditionalRootsToIndex():java.util.Set
|
||||
- getDebugName():java.lang.String
|
||||
f:com.intellij.ide.scratch.ScratchesNamedScope
|
||||
- com.intellij.psi.search.scope.packageSet.NamedScope
|
||||
- sf:ID:java.lang.String
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.scratch;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -7,10 +7,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public final class ScratchesAndConsolesIndexSetContributor extends IndexableSetContributor {
|
||||
@NotNull
|
||||
final class ScratchesAndConsolesIndexSetContributor extends IndexableSetContributor {
|
||||
@Override
|
||||
public Set<VirtualFile> getAdditionalRootsToIndex() {
|
||||
public @NotNull Set<VirtualFile> getAdditionalRootsToIndex() {
|
||||
return ScratchFileService.getAllRootPaths();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.wm.impl.IdeBackgroundUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.speedSearch.SpeedSearchUtil;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -45,8 +46,10 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Kirill Kalishev
|
||||
@@ -162,7 +165,6 @@ public class RegistryUi implements Disposable {
|
||||
}
|
||||
|
||||
private final class RevertAction extends AnAction implements DumbAware {
|
||||
|
||||
private RevertAction() {
|
||||
new ShadowAction(this, "EditorDelete", myTable, RegistryUi.this);
|
||||
}
|
||||
@@ -310,9 +312,8 @@ public class RegistryUi implements Disposable {
|
||||
|
||||
private AbstractAction myCloseAction;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createNorthPanel() {
|
||||
protected @Nullable JComponent createNorthPanel() {
|
||||
if (ApplicationManager.getApplication().isInternal()) {
|
||||
return null;
|
||||
}
|
||||
@@ -424,11 +425,9 @@ public class RegistryUi implements Disposable {
|
||||
@Override
|
||||
public void dispose() { }
|
||||
|
||||
private static String[] getOptions(@NotNull RegistryValue value) {
|
||||
String[] options = value.getOptions();
|
||||
for (int i = 0; i < options.length; i++) {
|
||||
options[i] = Strings.trimEnd(options[i], "*");
|
||||
}
|
||||
private static @NotNull List<String> getOptions(@NotNull RegistryValue value) {
|
||||
List<String> options = new ArrayList<>(value.asOptions());
|
||||
options.replaceAll(s -> Strings.trimEnd(s, "*"));
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -436,14 +435,13 @@ public class RegistryUi implements Disposable {
|
||||
private final JLabel myLabel = new JLabel();
|
||||
private final SimpleColoredComponent myComponent = new SimpleColoredComponent();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(@NotNull JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column) {
|
||||
public @NotNull Component getTableCellRendererComponent(@NotNull JTable table,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
boolean hasFocus,
|
||||
int row,
|
||||
int column) {
|
||||
int modelRow = table.convertRowIndexToModel(row);
|
||||
RegistryValue v = ((MyTableModel)table.getModel()).getRegistryValue(modelRow);
|
||||
|
||||
@@ -480,8 +478,8 @@ public class RegistryUi implements Disposable {
|
||||
return box;
|
||||
}
|
||||
else if (v.isMultiValue()) {
|
||||
String[] options = getOptions(v);
|
||||
ComboBox<String> combo = new ComboBox<>(options);
|
||||
List<String> options = getOptions(v);
|
||||
ComboBox<String> combo = new ComboBox<>(ArrayUtil.toStringArray(options));
|
||||
combo.setSelectedItem(v.getSelectedOption());
|
||||
return combo;
|
||||
}
|
||||
@@ -506,8 +504,7 @@ public class RegistryUi implements Disposable {
|
||||
return myLabel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static SimpleTextAttributes getAttributes(RegistryValue value, boolean isSelected) {
|
||||
private static @NotNull SimpleTextAttributes getAttributes(RegistryValue value, boolean isSelected) {
|
||||
boolean changedFromDefault = value.isChangedFromDefault();
|
||||
if (isSelected) {
|
||||
return new SimpleTextAttributes(changedFromDefault ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN,
|
||||
@@ -549,8 +546,7 @@ public class RegistryUi implements Disposable {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
public @Nullable Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
|
||||
int modelRow = table.convertRowIndexToModel(row);
|
||||
myValue = ((MyTableModel)table.getModel()).getRegistryValue(modelRow);
|
||||
if (myValue.asColor(null) != null) {
|
||||
@@ -567,7 +563,7 @@ public class RegistryUi implements Disposable {
|
||||
return myCheckBox;
|
||||
}
|
||||
else if (myValue.isMultiValue()) {
|
||||
myComboBox = new ComboBox<>(getOptions(myValue));
|
||||
myComboBox = new ComboBox<>(ArrayUtil.toStringArray(getOptions(myValue)));
|
||||
myComboBox.setSelectedItem(myValue.getSelectedOption());
|
||||
return myComboBox;
|
||||
}
|
||||
|
||||
@@ -6900,10 +6900,6 @@ f:com.intellij.ide.lightEdit.statusBar.LightEditStatusBarUI
|
||||
f:com.intellij.ide.logsUploader.DefaultLogsProcessor
|
||||
- <init>():V
|
||||
- getAdditionalLogFiles(com.intellij.openapi.project.Project):java.util.List
|
||||
f:com.intellij.ide.minimap.MinimapEditorFactoryListener
|
||||
- com.intellij.openapi.editor.event.EditorFactoryListener
|
||||
- <init>():V
|
||||
- editorCreated(com.intellij.openapi.editor.event.EditorFactoryEvent):V
|
||||
f:com.intellij.ide.minimap.MinimapImage
|
||||
- sf:Companion:com.intellij.ide.minimap.MinimapImage$Companion
|
||||
- <init>():V
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.minimap
|
||||
|
||||
import com.intellij.openapi.editor.event.EditorFactoryEvent
|
||||
import com.intellij.openapi.editor.event.EditorFactoryListener
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
|
||||
class MinimapEditorFactoryListener : EditorFactoryListener {
|
||||
private class MinimapEditorFactoryListener : EditorFactoryListener {
|
||||
override fun editorCreated(event: EditorFactoryEvent) {
|
||||
if (Registry.`is`("editor.minimap.enabled")) {
|
||||
MinimapService.getInstance().editorOpened(event.editor)
|
||||
|
||||
@@ -445,8 +445,6 @@
|
||||
<treeStructureProvider implementation="com.intellij.ide.scratch.ScratchTreeStructureProvider" order="last"/>
|
||||
<uiDataRule implementation="com.intellij.ide.scratch.ScratchTreeStructureProvider$DataRule"/>
|
||||
|
||||
<registryKey defaultValue="true" key="scratch.files.use.workspace.model" restartRequired="true"
|
||||
description="Use WorkspaceModel API for scratch files integration"/>
|
||||
<postStartupActivity implementation="com.intellij.ide.scratch.workspace.ScratchWorkspaceStartupActivity"/>
|
||||
<workspaceModel.fileIndexContributor implementation="com.intellij.ide.scratch.workspace.ScratchRootsEntityWorkspaceFileIndexContributor"/>
|
||||
<workspaceModel.entityLifecycleSupporter implementation="com.intellij.ide.scratch.workspace.ScratchEntityLifecycleSupporter"/>
|
||||
|
||||
@@ -1683,11 +1683,11 @@ c:com.intellij.openapi.util.registry.RegistryValue
|
||||
- f:asColor(java.awt.Color):java.awt.Color
|
||||
- f:asDouble():D
|
||||
- f:asInteger():I
|
||||
- f:asOptions():java.util.List
|
||||
- asString():java.lang.String
|
||||
- get(java.lang.String,java.lang.String,Z):java.lang.String
|
||||
- getDescription():java.lang.String
|
||||
- f:getKey():java.lang.String
|
||||
- f:getOptions():java.lang.String[]
|
||||
- f:getPluginId():java.lang.String
|
||||
- f:getSelectedOption():java.lang.String
|
||||
- isBoolean():Z
|
||||
|
||||
@@ -279,7 +279,7 @@ class Registry {
|
||||
val instance = getInstance()
|
||||
for (s in map.keys) {
|
||||
val eachValue = instance.resolveValue(s)
|
||||
if (eachValue.isRestartRequired && eachValue.isChangedSinceAppStart) {
|
||||
if (eachValue.isRestartRequired() && eachValue.isChangedSinceAppStart) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ class Registry {
|
||||
|
||||
@Internal
|
||||
@Synchronized
|
||||
fun setKeys(descriptors: Map<String, RegistryKeyDescriptor>) {
|
||||
fun setContributedKeys(descriptors: Map<String, RegistryKeyDescriptor>) {
|
||||
// getInstance must be not used here - phase COMPONENT_REGISTERED is not yet completed
|
||||
registry.contributedKeys = descriptors
|
||||
}
|
||||
@@ -351,28 +351,23 @@ class Registry {
|
||||
}
|
||||
|
||||
fun getBundleValueOrNull(key: @NonNls String): @NlsSafe String? {
|
||||
contributedKeys.get(key)?.let {
|
||||
return it.defaultValue
|
||||
}
|
||||
|
||||
return loadFromBundledConfig()?.get(key)
|
||||
return contributedKeys.get(key)?.defaultValue ?: loadFromBundledConfig()?.get(key)
|
||||
}
|
||||
|
||||
@Throws(MissingResourceException::class)
|
||||
internal fun getBundleValue(key: @NonNls String): @NlsSafe String {
|
||||
contributedKeys.get(key)?.let {
|
||||
return it.defaultValue
|
||||
}
|
||||
|
||||
return getBundleValueOrNull(key) ?: throw MissingResourceException("Registry key $key is not defined", REGISTRY_BUNDLE, key)
|
||||
internal fun getBundleValue(key: @NonNls String, keyDescriptor: RegistryKeyDescriptor?): @NlsSafe String {
|
||||
return keyDescriptor?.defaultValue
|
||||
?: contributedKeys.get(key)?.defaultValue
|
||||
?: loadFromBundledConfig()?.get(key)
|
||||
?: throw MissingResourceException("Registry key $key is not defined", REGISTRY_BUNDLE, key)
|
||||
}
|
||||
|
||||
@Internal
|
||||
fun getState(): Element {
|
||||
val state = Element("registry")
|
||||
for ((key, value) in userProperties) {
|
||||
val registryValue = getInstance().resolveValue(key)
|
||||
if (registryValue.isChangedFromDefault) {
|
||||
val registryValue = registry.resolveValue(key)
|
||||
if (registryValue.isChangedFromDefault()) {
|
||||
val entryElement = Element("entry")
|
||||
entryElement.setAttribute("key", key)
|
||||
entryElement.setAttribute("value", value)
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.NlsSafe
|
||||
import com.intellij.ui.ColorHexUtil
|
||||
import com.intellij.util.ArrayUtilRt
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -54,7 +53,7 @@ open class RegistryValue @Internal constructor(
|
||||
resolveRequiredValue(key = key).toInt()
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
registry.getBundleValue(key).toInt()
|
||||
registry.getBundleValue(key, keyDescriptor).toInt()
|
||||
}
|
||||
intCachedValue = result!!
|
||||
}
|
||||
@@ -64,8 +63,13 @@ open class RegistryValue @Internal constructor(
|
||||
val isMultiValue: Boolean
|
||||
get() = selectedOption != null
|
||||
|
||||
val options: Array<String>
|
||||
get() = getOptions(registry.getBundleValue(key))
|
||||
fun asOptions(): List<String> {
|
||||
val value = registry.getBundleValue(key, keyDescriptor)
|
||||
if (value.startsWith('[') && value.endsWith(']')) {
|
||||
return value.substring(1, value.length - 1).split("|").dropLastWhile { it.isEmpty() }
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
var selectedOption: @NlsSafe String?
|
||||
get() {
|
||||
@@ -87,11 +91,12 @@ open class RegistryValue @Internal constructor(
|
||||
return null
|
||||
}
|
||||
set(selected) {
|
||||
val options = options
|
||||
for (i in options.indices) {
|
||||
options[i] = options[i].trimEnd('*')
|
||||
if (options[i] == selected) {
|
||||
options[i] += "*"
|
||||
val options = asOptions().toMutableList()
|
||||
for ((i, option) in options.withIndex()) {
|
||||
val v = option.trimEnd('*')
|
||||
options.set(i, v)
|
||||
if (v == selected) {
|
||||
options.set(i, v.plus("*"))
|
||||
}
|
||||
}
|
||||
setValue("[" + options.joinToString(separator = "|") + "]")
|
||||
@@ -113,7 +118,7 @@ open class RegistryValue @Internal constructor(
|
||||
return get(key = key, defaultValue = "0.0", isValue = true)!!.toDouble()
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
return registry.getBundleValue(key).toDouble()
|
||||
return registry.getBundleValue(key, keyDescriptor).toDouble()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,23 +140,16 @@ open class RegistryValue @Internal constructor(
|
||||
}
|
||||
|
||||
open val description: @NlsSafe String
|
||||
get() {
|
||||
if (keyDescriptor != null) {
|
||||
return keyDescriptor.description
|
||||
}
|
||||
return get("$key.description", "", false)!!
|
||||
}
|
||||
get() = keyDescriptor?.description ?: get(key = "$key.description", defaultValue = "", isValue = false)!!
|
||||
|
||||
open val isRestartRequired: Boolean
|
||||
get() {
|
||||
if (keyDescriptor != null) {
|
||||
return keyDescriptor.isRestartRequired
|
||||
}
|
||||
return get(key = "$key.restartRequired", defaultValue = "false", isValue = false).toBoolean()
|
||||
open fun isRestartRequired(): Boolean {
|
||||
if (keyDescriptor != null) {
|
||||
return keyDescriptor.isRestartRequired
|
||||
}
|
||||
return get(key = "$key.restartRequired", defaultValue = "false", isValue = false).toBoolean()
|
||||
}
|
||||
|
||||
open val isChangedFromDefault: Boolean
|
||||
get() = isChangedFromDefault(asString(), registry)
|
||||
open fun isChangedFromDefault(): Boolean = isChangedFromDefault(asString(), registry)
|
||||
|
||||
val pluginId: String?
|
||||
get() = keyDescriptor?.pluginId
|
||||
@@ -164,7 +162,7 @@ open class RegistryValue @Internal constructor(
|
||||
open fun get(key: @NonNls String, defaultValue: String?, isValue: Boolean): String? {
|
||||
if (isValue) {
|
||||
if (stringCachedValue == null) {
|
||||
stringCachedValue = resolveRequiredValue(key = key)
|
||||
stringCachedValue = resolveRequiredValue(key)
|
||||
}
|
||||
return stringCachedValue
|
||||
}
|
||||
@@ -196,7 +194,7 @@ open class RegistryValue @Internal constructor(
|
||||
}
|
||||
|
||||
checkIsLoaded(key)
|
||||
return registry.getBundleValue(key)
|
||||
return registry.getBundleValue(key, keyDescriptor)
|
||||
}
|
||||
|
||||
private fun checkIsLoaded(key: @NonNls String) {
|
||||
@@ -233,11 +231,11 @@ open class RegistryValue @Internal constructor(
|
||||
LOG.info("Registry value '$key' has changed to '$value'")
|
||||
|
||||
globalValueChangeListener.afterValueChanged(this)
|
||||
for (each in listeners) {
|
||||
each.afterValueChanged(this)
|
||||
for (listener in listeners) {
|
||||
listener.afterValueChanged(this)
|
||||
}
|
||||
|
||||
if (!isChangedFromDefault && !isRestartRequired) {
|
||||
if (!isRestartRequired() && resolveNotRequiredValue(key = key, defaultValue = null) == registry.getBundleValueOrNull(key)) {
|
||||
registry.getUserProperties().remove(key)
|
||||
}
|
||||
|
||||
@@ -297,13 +295,6 @@ open class RegistryValue @Internal constructor(
|
||||
override fun toString(): String = "$key=${asString()}"
|
||||
}
|
||||
|
||||
private fun getOptions(value: String?): Array<String> {
|
||||
if (value != null && value.startsWith('[') && value.endsWith(']')) {
|
||||
return value.substring(1, value.length - 1).split("\\|").dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||
}
|
||||
return ArrayUtilRt.EMPTY_STRING_ARRAY
|
||||
}
|
||||
|
||||
private fun isBoolean(s: String): Boolean {
|
||||
return "true".equals(s, ignoreCase = true) || "false".equals(s, ignoreCase = true)
|
||||
}
|
||||
|
||||
@@ -12,24 +12,47 @@ import org.junit.Test;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static junit.framework.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class RegistryTest {
|
||||
private static final String INTEGER_KEY = "editor.mouseSelectionStateResetDeadZone";
|
||||
private static final String INT_KEY_REQUIRE_RESTART = "editor.caret.width";
|
||||
|
||||
|
||||
@After
|
||||
public void tearDown(){
|
||||
Registry.Companion.setValueChangeListener(null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInvalidInteger() {
|
||||
int originalValue = Registry.intValue(INTEGER_KEY);
|
||||
Registry.get(INTEGER_KEY).setValue("invalidNumber");
|
||||
assertEquals(originalValue, Registry.intValue(INTEGER_KEY));
|
||||
assertThat(Registry.intValue(INTEGER_KEY)).isEqualTo(originalValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void booleanValueFalse() {
|
||||
RegistryValue handle = Registry.get("ide.tree.experimental.layout.cache");
|
||||
try {
|
||||
assertThat(handle.asString()).isEqualTo("true");
|
||||
assertThat(handle.asBoolean()).isTrue();
|
||||
}
|
||||
finally {
|
||||
handle.resetToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void booleanValueTrue() {
|
||||
RegistryValue handle = Registry.get("ide.tree.painter.classic.compact");
|
||||
try {
|
||||
assertThat(handle.asString()).isEqualTo("false");
|
||||
assertThat(handle.asBoolean()).isFalse();
|
||||
}
|
||||
finally {
|
||||
handle.resetToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +151,7 @@ public class RegistryTest {
|
||||
RegistryValue newRegistryValue = Registry.get(newKey);
|
||||
String loadedNewValue = newRegistryValue.get(newRegistryValue.getKey(), null, false);
|
||||
assertNull(loadedNewValue);
|
||||
assertEquals(1, changedPairs.size());
|
||||
assertThat(changedPairs).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,15 +178,15 @@ public class RegistryTest {
|
||||
put(firstKey, firstKeyChangedVal);
|
||||
put(secondKey, secondKeyChangedValue);
|
||||
}}), null);
|
||||
assertEquals(firstKeyChangedVal, Registry.get(firstKey).asString());
|
||||
assertEquals(secondKeyChangedValue, Registry.get(secondKey).asString());
|
||||
assertThat(Registry.get(firstKey).asString()).isEqualTo(firstKeyChangedVal);
|
||||
assertThat(Registry.get(secondKey).asString()).isEqualTo(secondKeyChangedValue);
|
||||
|
||||
// drop key - reset to original
|
||||
Registry.Companion.loadState(registryElementFromMap(new LinkedHashMap<>(){{
|
||||
put(firstKey, firstKeyChangedVal);
|
||||
}}), null);
|
||||
assertEquals(firstKeyChangedVal, Registry.get(firstKey).asString());
|
||||
assertEquals(secondKeyInitValue, Registry.get(secondKey).asString());
|
||||
assertThat(Registry.get(firstKey).asString()).isEqualTo(firstKeyChangedVal);
|
||||
assertThat(Registry.get(secondKey).asString()).isEqualTo(secondKeyInitValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,7 +214,7 @@ public class RegistryTest {
|
||||
}
|
||||
});
|
||||
regValue.setValue(true);
|
||||
assertTrue(regValue.asBoolean());
|
||||
assertThat(regValue.asBoolean()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -211,6 +234,16 @@ public class RegistryTest {
|
||||
JDOMUtil.writeElement(Registry.getInstance().getState()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkOptionsUpdatedProperly() {
|
||||
String registryName = "testOptions";
|
||||
String registryValue = "[option1*|option2|option3]";
|
||||
RegistryValue registry = new RegistryValue(Registry.getInstance(), registryName, new RegistryKeyDescriptor(registryName, "", registryValue, false, false, null));
|
||||
assertEquals("option1", registry.getSelectedOption());
|
||||
registry.setSelectedOption("option2");
|
||||
assertThat(registry.getSelectedOption()).isEqualTo("option2");
|
||||
}
|
||||
|
||||
private static Map<String, String> populateMap(Comparator<String> comparator, String valueBase) {
|
||||
Map<String, String> map = new TreeMap<>(comparator);
|
||||
map.put("first.key", "first." + valueBase);
|
||||
|
||||
@@ -79,7 +79,7 @@ internal class ClientExperimentStatus : ExperimentStatus {
|
||||
}
|
||||
val matchingLanguage = findMatchingLanguage(language) ?: return ExperimentInfo(false, experimentConfig.version)
|
||||
val experimentGroupRegistry = Registry.get("completion.ml.override.experiment.group.number")
|
||||
if (experimentGroupRegistry.isChangedFromDefault && !experimentGroupRegistry.isChangedSinceAppStart) {
|
||||
if (experimentGroupRegistry.isChangedFromDefault() && !experimentGroupRegistry.isChangedSinceAppStart) {
|
||||
experimentGroupRegistryValue = experimentGroupRegistry.asInteger()
|
||||
}
|
||||
if (experimentGroupRegistryValue != null) {
|
||||
|
||||
@@ -43,7 +43,7 @@ class MLCompletionLocalModelsLoader(private val registryPathKey: String) {
|
||||
*/
|
||||
private fun scheduleInitModel(): Future<*> = executor.submit { initModelFromPathToZipSynchronously() }
|
||||
|
||||
private fun isPathToTheModelSet() = Registry.get(registryPathKey).isChangedFromDefault
|
||||
private fun isPathToTheModelSet() = Registry.get(registryPathKey).isChangedFromDefault()
|
||||
|
||||
private fun isPathToTheModelChanged() = Registry.stringValue(registryPathKey) != localModel?.path
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package git4idea.index.ui
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
@@ -48,7 +48,7 @@ class GitStageUiApplicationSettings : SimplePersistentStateComponent<GitStageUiA
|
||||
|
||||
override fun noStateLoaded() {
|
||||
val isCommitAllValue = Registry.get("git.stage.enable.commit.all")
|
||||
if (isCommitAllValue.isChangedFromDefault) {
|
||||
if (isCommitAllValue.isChangedFromDefault()) {
|
||||
state.isCommitAllEnabled = isCommitAllValue.asBoolean()
|
||||
isCommitAllValue.resetToDefault()
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ internal object LocalRankingModelProviderUtil {
|
||||
return provider.loadModel(path)
|
||||
}
|
||||
|
||||
fun isPathToLocalModelSpecified(tab: SearchEverywhereTabWithMlRanking) = Registry.get(getRegistryKey(tab)).isChangedFromDefault
|
||||
fun isPathToLocalModelSpecified(tab: SearchEverywhereTabWithMlRanking) = Registry.get(getRegistryKey(tab)).isChangedFromDefault()
|
||||
|
||||
private fun getRegistryKey(tab: SearchEverywhereTabWithMlRanking) = "search.everywhere.ml.${tab.name.lowercase()}.model.path"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2020 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.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.stats.completion.network.status
|
||||
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
@@ -21,7 +21,7 @@ object WebServiceStatusManager {
|
||||
private fun registerAnalyticsPlatformStatus() {
|
||||
try {
|
||||
val registry = Registry.get(ANALYTICS_PLATFORM_URL_REGISTRY)
|
||||
if (registry.isChangedFromDefault) {
|
||||
if (registry.isChangedFromDefault()) {
|
||||
register(AnalyticsPlatformServiceStatus(registry.asString()))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user