diff --git a/platform/extensions/src/com/intellij/openapi/extensions/impl/XmlExtensionAdapter.kt b/platform/extensions/src/com/intellij/openapi/extensions/impl/XmlExtensionAdapter.kt index b43feffc9d91..0adeb59688b3 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/impl/XmlExtensionAdapter.kt +++ b/platform/extensions/src/com/intellij/openapi/extensions/impl/XmlExtensionAdapter.kt @@ -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.openapi.extensions.impl import com.intellij.openapi.components.ComponentManager @@ -55,6 +55,7 @@ internal open class XmlExtensionAdapter(implementationClassName: String, } val element = extensionElement if (element != null) { + @Suppress("UsagesOfObsoleteApi") XmlSerializer.getBeanBinding(instance::class.java).deserializeInto(instance, element) extensionElement = null } diff --git a/platform/lang-impl/testSources/com/intellij/toolWindow/HideSidebarButtonTest.kt b/platform/lang-impl/testSources/com/intellij/toolWindow/HideSidebarButtonTest.kt index ed66ec566ed4..e2c00f4a0cf0 100644 --- a/platform/lang-impl/testSources/com/intellij/toolWindow/HideSidebarButtonTest.kt +++ b/platform/lang-impl/testSources/com/intellij/toolWindow/HideSidebarButtonTest.kt @@ -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. @file:Suppress("RAW_RUN_BLOCKING") package com.intellij.toolWindow @@ -31,7 +31,7 @@ class HideSidebarButtonTest : ToolWindowManagerTestCase() { "" + - ""), false, false) + ""), false) for (extension in ToolWindowEP.EP_NAME.extensionList) { if (listOf(ToolWindowId.TODO_VIEW, ToolWindowId.FIND, ToolWindowId.PROJECT_VIEW).contains(extension.id)) { manager!!.initToolWindow(extension) diff --git a/platform/object-serializer/src/xml/xmlSerializer.kt b/platform/object-serializer/src/xml/xmlSerializer.kt index 3840add76c7b..a30ebffe5a33 100644 --- a/platform/object-serializer/src/xml/xmlSerializer.kt +++ b/platform/object-serializer/src/xml/xmlSerializer.kt @@ -120,6 +120,10 @@ private class JdomSerializerImpl : JdomSerializer { clearBindingCache() } + override fun getBeanBinding(aClass: Class): BeanBinding { + return serializer.getRootBinding(aClass, aClass) as BeanBinding + } + override fun deserializeInto(obj: Any, element: Element) { try { (serializer.getRootBinding(obj.javaClass) as BeanBinding).deserializeInto(obj, element) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/DesktopLayout.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/DesktopLayout.kt index 4d77f85d5317..34f57b852827 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/DesktopLayout.kt +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/DesktopLayout.kt @@ -1,13 +1,13 @@ -// 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. @file:Suppress("ReplacePutWithAssignment", "ReplaceGetOrSet") package com.intellij.openapi.wm.impl +import com.intellij.configurationStore.jdomSerializer import com.intellij.configurationStore.serialize import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.wm.* -import com.intellij.util.xmlb.XmlSerializer import org.jdom.Element import org.jetbrains.annotations.ApiStatus.Internal import org.jetbrains.annotations.NonNls @@ -66,7 +66,7 @@ class DesktopLayout( /** * Sets new `anchor` and `id` for the specified tool window. - * Also, the method properly updates order of all other tool windows. + * Also, the method properly updates the order of all other tool windows. */ fun setAnchor(info: WindowInfoImpl, newPaneId: String, @@ -75,7 +75,7 @@ class DesktopLayout( var newOrder = suppliedNewOrder val affected = ArrayList() - // if order isn't defined then the window will be the last in the stripe + // if order isn't defined, then the window will be the last in the stripe if (newOrder == -1) { newOrder = getMaxOrder(newPaneId, newAnchor) + 1 } @@ -96,8 +96,8 @@ class DesktopLayout( return affected } - fun readExternal(layoutElement: Element, isNewUi: Boolean, isFromPersistentSettings: Boolean = true) { - val infoBinding = XmlSerializer.getBeanBinding(WindowInfoImpl::class.java) + fun readExternal(layoutElement: Element, isFromPersistentSettings: Boolean = true) { + val infoBinding = jdomSerializer.getBeanBinding(WindowInfoImpl::class.java) val list = mutableListOf() for (element in layoutElement.getChildren(WindowInfoImpl.TAG)) { @@ -117,8 +117,7 @@ class DesktopLayout( val unifiedWeightsElement = layoutElement.getChild(UnifiedToolWindowWeights.TAG) if (unifiedWeightsElement != null) { - val unifiedWeightsBinding = XmlSerializer.getBeanBinding(UnifiedToolWindowWeights::class.java) - unifiedWeightsBinding.deserializeInto(unifiedWeights, unifiedWeightsElement) + jdomSerializer.deserializeInto(unifiedWeights, unifiedWeightsElement) } normalizeOrder(list) @@ -190,7 +189,7 @@ internal val windowInfoComparator: Comparator = Comparator { o1, o2 } /** - * Normalizes order of windows in the array. Order of first window will be `0`. + * Normalizes the order of windows in the array. Order of a first window will be `0`. */ private fun normalizeOrder(list: MutableList) { list.sortWith(windowInfoComparator) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerState.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerState.kt index 9a33b4ee9a3c..832e4e951dbe 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerState.kt +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerState.kt @@ -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.openapi.wm.impl import com.intellij.openapi.components.PersistentStateComponent @@ -99,7 +99,7 @@ class ToolWindowManagerStateImpl : ToolWindowManagerState { when (element.name) { DesktopLayout.TAG -> { val layout = DesktopLayout() - layout.readExternal(element, isNewUi = false) + layout.readExternal(element) if (isNewUi) { oldLayout = layout } @@ -110,7 +110,7 @@ class ToolWindowManagerStateImpl : ToolWindowManagerState { } "layoutV2" -> { val layout = DesktopLayout() - layout.readExternal(element, isNewUi = true) + layout.readExternal(element) if (isNewUi) { scheduledLayout.set(layout) layoutIsScheduled = true @@ -120,7 +120,7 @@ class ToolWindowManagerStateImpl : ToolWindowManagerState { } } LAYOUT_TO_RESTORE -> { - layoutToRestoreLater = DesktopLayout().also { it.readExternal(element, isNewUi) } + layoutToRestoreLater = DesktopLayout().also { it.readExternal(element) } } RECENT_TW_TAG -> { recentToolWindows.clear() diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.kt index 7dfea30164ad..2ac29d242544 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/WindowManagerImpl.kt @@ -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. @file:Suppress("ReplaceGetOrSet", "ReplacePutWithAssignment") package com.intellij.openapi.wm.impl @@ -27,7 +27,6 @@ import com.intellij.openapi.wm.impl.FrameInfoHelper.Companion.isMaximized import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame import com.intellij.ui.ComponentUtil -import com.intellij.ui.ExperimentalUI import com.intellij.ui.ScreenUtil import com.intellij.util.concurrency.annotations.RequiresEdt import com.sun.jna.platform.WindowUtils @@ -351,7 +350,7 @@ class WindowManagerImpl : WindowManagerEx(), PersistentStateComponentWithModific } state.getChild(DesktopLayout.TAG)?.let { val layout = DesktopLayout() - layout.readExternal(it, ExperimentalUI.isNewUI()) + layout.readExternal(it) oldLayout = layout } } diff --git a/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt b/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt index 0d613bb63ce6..26de37ed8ac2 100644 --- a/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt +++ b/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt @@ -5,6 +5,7 @@ package com.intellij.configurationStore import com.intellij.openapi.components.BaseState import com.intellij.openapi.components.PersistentStateComponent import com.intellij.util.xml.dom.XmlElement +import com.intellij.util.xmlb.BeanBinding import com.intellij.util.xmlb.SerializationFilter import com.intellij.util.xmlb.SkipDefaultsSerializationFilter import org.jdom.Element @@ -76,4 +77,6 @@ interface JdomSerializer { fun getDefaultSerializationFilter(): SkipDefaultsSerializationFilter fun clearSerializationCaches() + + fun getBeanBinding(aClass: Class): BeanBinding } \ No newline at end of file diff --git a/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java b/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java index 87893e5fe046..f47155a05c2a 100644 --- a/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java +++ b/platform/util/src/com/intellij/util/xmlb/XmlSerializer.java @@ -57,7 +57,8 @@ public final class XmlSerializer { public static void deserializeInto(@NotNull Object bean, @NotNull Element element) { try { - getBeanBinding(bean.getClass()).deserializeInto(bean, element); + Class aClass = bean.getClass(); + ((BeanBinding)XmlSerializerImpl.serializer.getRootBinding(aClass, aClass)).deserializeInto(bean, element); } catch (SerializationException e) { throw e; @@ -67,10 +68,8 @@ public final class XmlSerializer { } } - /** - * Use only if it is a hot spot, otherwise use {@link #deserializeInto(Object, Element)} or {@link #serializeInto(Object, Element)}. - */ @ApiStatus.Internal + @ApiStatus.Obsolete public static @NotNull BeanBinding getBeanBinding(@NotNull Class aClass) { return (BeanBinding)XmlSerializerImpl.serializer.getRootBinding(aClass, aClass); } @@ -81,7 +80,8 @@ public final class XmlSerializer { public static void serializeInto(@NotNull Object bean, @NotNull Element element, @Nullable SerializationFilter filter) { try { - getBeanBinding(bean.getClass()).serializeInto(bean, element, filter); + Class aClass = bean.getClass(); + ((BeanBinding)XmlSerializerImpl.serializer.getRootBinding(aClass, aClass)).serializeInto(bean, element, filter); } catch (SerializationException e) { throw e;