From dca7ec41109c173ff82b9c8fc51d0f484a05fa87 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 23 Apr 2018 16:11:12 +0200 Subject: [PATCH] clearBindingCache for MPS (hot swap friendly) --- .../testSrc/xml/XmlSerializerTest.kt | 9 +++++++++ .../configurationStore/xmlSerializer.kt | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt index 64a9d7c6b4b5..81a6f345947f 100644 --- a/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt +++ b/platform/configuration-store-impl/testSrc/xml/XmlSerializerTest.kt @@ -4,9 +4,11 @@ package com.intellij.configurationStore.xml import com.intellij.configurationStore.StoredPropertyStateTest +import com.intellij.configurationStore.clearBindingCache import com.intellij.configurationStore.deserialize import com.intellij.configurationStore.serialize import com.intellij.openapi.util.text.StringUtil +import com.intellij.testFramework.UsefulTestCase import com.intellij.testFramework.assertConcurrent import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.util.loadElement @@ -15,6 +17,7 @@ import com.intellij.util.xmlb.annotations.* import junit.framework.TestCase import org.intellij.lang.annotations.Language import org.jdom.Element +import org.junit.Assume.assumeTrue import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.Suite @@ -52,6 +55,12 @@ internal class XmlSerializerTest { """, data) } + @Test + fun testClearBindingCache() { + assumeTrue(!UsefulTestCase.IS_UNDER_TEAMCITY) + clearBindingCache() + } + @Test fun emptyBeanSerialization() { class EmptyBean diff --git a/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt b/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt index eca4f3173335..dfcbfb018e13 100644 --- a/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt +++ b/platform/projectModel-api/src/com/intellij/configurationStore/xmlSerializer.kt @@ -1,6 +1,4 @@ -/* - * Copyright 2000-2017 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-2018 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("XmlSerializer") package com.intellij.configurationStore @@ -179,6 +177,19 @@ private val serializer = object : XmlSerializerImpl.XmlSerializerBase() { binding } } + + fun clearBindingCache() { + cacheLock.write { + _bindingCache?.clear() + } + } +} + +/** + * used by MPS. Do not use if not approved. + */ +fun clearBindingCache() { + serializer.clearBindingCache() } private data class BindingCacheKey(val type: Type, val accessor: MutableAccessor?)