From 86e1009135d040ca4e43c727e38af9a1593afc00 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 7 Dec 2018 20:19:42 +0100 Subject: [PATCH] deprecate jdom.kt loadElement methods because now JDOMUtil uses the same StAX parser (~ several month ago migrated from SAX to StAX and make new behaviour default) --- .../javadoc/LightJavadocGeneratorTest.kt | 19 +-- .../ProjectInspectionProfileManager.kt | 4 +- .../src/FileBasedStorage.kt | 3 +- .../src/ModuleStateStorageManager.kt | 4 +- .../src/XmlElementStorage.kt | 3 +- .../testSrc/BinaryXmlOutputterTest.kt | 3 +- .../testSrc/CodeStyleTest.kt | 12 +- .../testSrc/DefaultProjectStoreTest.kt | 4 +- .../testSrc/DirectoryBasedStorageTest.kt | 4 +- .../testSrc/StoredPropertyStateTest.kt | 4 +- .../testSrc/xml/KotlinXmlSerializerTest.kt | 38 +++--- .../xml/XmlSerializerCollectionTest.kt | 117 +++++++++--------- .../testSrc/xml/XmlSerializerTest.kt | 40 +++--- .../src/kdbx/KeePassDatabase.kt | 74 +++++------ .../PersistentMapManager.kt | 4 +- .../project/loadSaveModuleRenameMapping.kt | 6 +- .../internal/ShowUpdateInfoDialogAction.kt | 8 +- .../openapi/keymap/impl/DefaultKeymap.kt | 4 +- .../updateSettings/impl/UpdateChecker.kt | 10 +- .../ide/updates/UpdateInfoParsingTest.kt | 6 +- .../ide/updates/UpdateStrategyTest.kt | 16 +-- .../updateSettings/UpdateOptionsTest.kt | 32 ++--- .../testSrc/com/intellij/util/JDOMUtilTest.kt | 49 ++++---- .../src/com/intellij/util/jdom.kt | 7 +- .../SchemeManagerIprProvider.kt | 8 +- .../src/com/intellij/testFramework/runUtil.kt | 4 +- .../MigrateModuleNamesInSourcesAction.kt | 4 +- 27 files changed, 242 insertions(+), 245 deletions(-) diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/LightJavadocGeneratorTest.kt b/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/LightJavadocGeneratorTest.kt index 5251395e12d8..40a5c7752182 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/LightJavadocGeneratorTest.kt +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/javadoc/LightJavadocGeneratorTest.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// 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. package com.intellij.java.codeInsight.javadoc import com.intellij.codeInsight.javadoc.JavaDocInfoGeneratorFactory @@ -20,14 +6,13 @@ import com.intellij.psi.PsiJavaFile import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.assertions.Assertions.assertThat import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase -import com.intellij.util.loadElement class LightJavadocGeneratorTest : LightCodeInsightFixtureTestCase() { override fun getProjectDescriptor(): LightProjectDescriptor = JAVA_9 fun testPlainModule() = doTestModule("module M.N { }", """
module M.N
""".trimIndent()) - fun testDocumentedModule() = doTestModule("/** One humble module. */\n@Deprecated\nmodule M.N { }", """
@Deprecated 
+  fun testDocumentedModule() = doTestModule("/** One humble module. */\n@Deprecated\nmodule M.N { }", """
@Deprecated
 module M.N
One humble module.

""".trimIndent()) private fun doTestModule(text: String, expected: String) { diff --git a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt index f05a1d9dd680..ee1bce9d6587 100644 --- a/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt +++ b/platform/analysis-impl/src/com/intellij/profile/codeInspection/ProjectInspectionProfileManager.kt @@ -17,6 +17,7 @@ import com.intellij.openapi.project.ProjectManager import com.intellij.openapi.project.ProjectManagerListener import com.intellij.openapi.startup.StartupActivity import com.intellij.openapi.util.Disposer +import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.packageDependencies.DependencyValidationManager import com.intellij.profile.ProfileChangeAdapter @@ -25,7 +26,6 @@ import com.intellij.psi.search.scope.packageSet.NamedScopeManager import com.intellij.psi.search.scope.packageSet.NamedScopesHolder import com.intellij.util.containers.ContainerUtil import com.intellij.util.getAttributeBooleanValue -import com.intellij.util.loadElement import com.intellij.util.xmlb.Accessor import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters import com.intellij.util.xmlb.XmlSerializer @@ -42,7 +42,7 @@ import java.util.function.Function private const val VERSION = "1.0" private const val PROJECT_DEFAULT_PROFILE_NAME = "Project Default" -private val defaultSchemeDigest = loadElement(""" +private val defaultSchemeDigest = JDOMUtil.load(""" diff --git a/platform/configuration-store-impl/src/FileBasedStorage.kt b/platform/configuration-store-impl/src/FileBasedStorage.kt index 5f4eb1d361d0..4195c928e969 100644 --- a/platform/configuration-store-impl/src/FileBasedStorage.kt +++ b/platform/configuration-store-impl/src/FileBasedStorage.kt @@ -13,6 +13,7 @@ import com.intellij.openapi.components.StoragePathMacros import com.intellij.openapi.diagnostic.debug import com.intellij.openapi.diagnostic.debugOrInfoIfTestMode import com.intellij.openapi.fileEditor.impl.LoadTextUtil +import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream import com.intellij.openapi.util.io.FileUtilRt import com.intellij.openapi.vfs.LocalFileSystem @@ -178,7 +179,7 @@ open class FileBasedStorage(file: Path, else { val data = file.readChars() lineSeparator = detectLineSeparators(data, if (isUseXmlProlog) null else LineSeparator.LF) - return loadElement(data) + return JDOMUtil.load(data) } return null } diff --git a/platform/configuration-store-impl/src/ModuleStateStorageManager.kt b/platform/configuration-store-impl/src/ModuleStateStorageManager.kt index d73def44ceef..3ea3c8189c07 100644 --- a/platform/configuration-store-impl/src/ModuleStateStorageManager.kt +++ b/platform/configuration-store-impl/src/ModuleStateStorageManager.kt @@ -9,9 +9,9 @@ import com.intellij.openapi.module.impl.ModuleManagerImpl import com.intellij.openapi.module.impl.getModuleNameByFilePath import com.intellij.openapi.project.ProjectBundle import com.intellij.openapi.project.isExternalStorageEnabled +import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.vfs.newvfs.events.VFileEvent import com.intellij.util.LineSeparator -import com.intellij.util.loadElement import org.jdom.Element import java.io.FileNotFoundException import java.nio.ByteBuffer @@ -100,7 +100,7 @@ internal class ModuleStateStorageManager(macroSubstitutor: TrackingPathMacroSubs runAndHandleExceptions { val charBuffer = StandardCharsets.UTF_8.decode(ByteBuffer.wrap(virtualFile.contentsToByteArray())) lineSeparator = detectLineSeparators(charBuffer, if (isUseXmlProlog) null else LineSeparator.LF) - return loadElement(charBuffer) + return JDOMUtil.load(charBuffer) } } return null diff --git a/platform/configuration-store-impl/src/XmlElementStorage.kt b/platform/configuration-store-impl/src/XmlElementStorage.kt index 7f85ba2a4c11..89a287422097 100644 --- a/platform/configuration-store-impl/src/XmlElementStorage.kt +++ b/platform/configuration-store-impl/src/XmlElementStorage.kt @@ -16,7 +16,6 @@ import com.intellij.util.LineSeparator import com.intellij.util.SmartList import com.intellij.util.containers.SmartHashSet import com.intellij.util.io.delete -import com.intellij.util.loadElement import gnu.trove.THashMap import org.jdom.Attribute import org.jdom.Element @@ -51,7 +50,7 @@ abstract class XmlElementStorage protected constructor(val fileSpec: String, if (useStreamProvider && provider != null) { isLoadLocalData = !provider.read(fileSpec, roamingType) { inputStream -> inputStream?.let { - element = loadElement(inputStream) + element = JDOMUtil.load(inputStream) providerDataStateChanged(createDataWriterForElement(element!!, toString()), DataStateChanged.LOADED) } } diff --git a/platform/configuration-store-impl/testSrc/BinaryXmlOutputterTest.kt b/platform/configuration-store-impl/testSrc/BinaryXmlOutputterTest.kt index 9bcd891d8514..a89b076296ad 100644 --- a/platform/configuration-store-impl/testSrc/BinaryXmlOutputterTest.kt +++ b/platform/configuration-store-impl/testSrc/BinaryXmlOutputterTest.kt @@ -3,7 +3,6 @@ package com.intellij.configurationStore import com.intellij.openapi.util.JDOMUtil import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream -import com.intellij.util.loadElement import org.assertj.core.api.Assertions.assertThat import org.junit.Test @@ -78,7 +77,7 @@ class BinaryXmlOutputterTest { private fun test(xml: String) { val byteOut = BufferExposingByteArrayOutputStream() byteOut.use { - serializeElementToBinary(loadElement(xml), it) + serializeElementToBinary(JDOMUtil.load(xml), it) } val xmlAfter = JDOMUtil.writeElement(byteOut.toByteArray().inputStream().use { deserializeElementFromBinary(it) }) diff --git a/platform/configuration-store-impl/testSrc/CodeStyleTest.kt b/platform/configuration-store-impl/testSrc/CodeStyleTest.kt index 445b9d829ac8..fba0d1f14798 100644 --- a/platform/configuration-store-impl/testSrc/CodeStyleTest.kt +++ b/platform/configuration-store-impl/testSrc/CodeStyleTest.kt @@ -1,3 +1,4 @@ +// 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. package com.intellij.configurationStore import com.intellij.openapi.Disposable @@ -10,7 +11,6 @@ import com.intellij.psi.codeStyle.CustomCodeStyleSettings import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.ProjectRule import com.intellij.util.containers.ContainerUtil -import com.intellij.util.loadElement import org.assertj.core.api.Assertions.assertThat import org.jdom.Element import org.junit.ClassRule @@ -43,7 +43,7 @@ class CodeStyleTest {