diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt index 5c0e3905d82..c51ea05ffb8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt @@ -217,33 +217,6 @@ enum class LibraryJarDescriptor(val jarName: String, fun bundledRuntimeVersion(): String = KotlinCompilerVersion.VERSION -private val PLUGIN_VERSIONS_SEPARATORS = arrayOf("Idea", "IJ", "release", "dev", "Studio") - -// TODO: Used only in tests, can be removed -fun pluginRuntimeVersion(pluginVersion: String): String { - var placeToSplit = -1 - - for (separator in PLUGIN_VERSIONS_SEPARATORS) { - val ideaPatternIndex = StringUtil.indexOf(pluginVersion, separator) - if (ideaPatternIndex >= 2 && Character.isDigit(pluginVersion[ideaPatternIndex - 2])) { - placeToSplit = ideaPatternIndex - 1 - break - } - } - - if (placeToSplit == -1) { - for (i in 1..pluginVersion.length - 1) { - val ch = pluginVersion[i] - if (Character.isLetter(ch) && pluginVersion[i - 1] == '.') { - placeToSplit = i - 1 - break - } - } - } - - return if (placeToSplit != -1) pluginVersion.substring(0, placeToSplit) else pluginVersion -} - fun getLocalJar(kotlinRuntimeJar: VirtualFile?): VirtualFile? { if (kotlinRuntimeJar == null) return null diff --git a/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt index 79bed1da3ee..de01ecc0bb7 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/OutdatedKotlinRuntimeNotificationTest.kt @@ -18,93 +18,47 @@ package org.jetbrains.kotlin.idea import junit.framework.TestCase import org.jetbrains.kotlin.idea.versions.isRuntimeOutdated -import org.jetbrains.kotlin.idea.versions.pluginRuntimeVersion import org.junit.Assert class KotlinRuntimeLibraryUtilTest : TestCase() { - fun testKotlinLibraryRelevantVersion() { - test("0.10.2013", "0.10.2013") - test("0.10.M.2013", "0.10") - test("0.10.2.Idea140.2013", "0.10.2") - test("0.11.1995.1.M.Idea140.2013", "0.11.1995.1") - test("Some.0.10.2", "Some.0.10.2") - test("@snapshot@", "@snapshot@") - test("snapshot", "snapshot") - test("internal-0.1.2", "internal-0.1.2") - test(".0.1.2", ".0.1.2") - test("0.1.2.", "0.1.2.") - - test("1.0.0-beta1-001-Idea141-12", "1.0.0-beta1-001") - test("1.0.1-beta5-013-Idea143-1", "1.0.1-beta5-013") - test("1.0.1-beta1-2-Idea143-1", "1.0.1-beta1-2") - test("1.0.3-beta1-2", "1.0.3-beta1-2") - - test("1.0.0-beta1-001-IJ143-12", "1.0.0-beta1-001") - test("1.0.1-beta5-013-IJ142-1", "1.0.1-beta5-013") - test("1.0.1-beta1-2-IJ-2-1", "1.0.1-beta1-2") - test("1.0.3-beta1-2-IJ", "1.0.3-beta1-2") - - test("1.0.3-beta-1020", "1.0.3-beta-1020") - test("1.2.3-beta-2059-Idea141-1", "1.2.3-beta-2059") - test("1.0.3-beta-4000-IJ-1", "1.0.3-beta-4000") - - test("2.15.789-Idea147-14", "2.15.789") - - test("1.0.0-alpha", "1.0.0-alpha") - test("1.2.2123-alpha-023", "1.2.2123-alpha-023") - test("1.0.0-release-IJ143-75", "1.0.0") - test("1.0.2-eap-10-IJ141-10", "1.0.2-eap-10") - test("1.0.2-dev-825", "1.0.2") - test("1.0.1-rc-5-IJ143-7", "1.0.1-rc-5") - - test("1.1-M01-Studio2.2-9", "1.1-M01") - } fun testOutdatedRuntime() { - outdated("1.0.0-beta1-001-Idea141-12", "0.12.15") - outdated("1.0.0-beta1-001-Idea141-1", "0.152.16") - outdated("1.0.0-beta1-001-Idea141-1", "0.152.16") + outdated("1.0.0-beta1-001", "0.12.15") + outdated("1.0.0-beta1-001", "0.152.16") - outdated("1.0.0-beta-1001-Idea141-12", "0.12.15") - outdated("1.0.0-beta-1000-Idea141-1", "0.152.16") + outdated("1.0.0-beta-1001", "0.12.15") + outdated("1.0.0-beta-1000", "0.152.16") - notOutdated("1.0.0-beta1-001-Idea141-12", "1.0.0-beta1-001") - notOutdated("1.0.0-beta1-001-Idea143-14", "1.0.0-beta1-001") notOutdated("1.0.0-beta1-001", "1.0.0-beta1-001") - notOutdated("1.0.0-beta1-001-Idea3-1", "1.0.0-beta1-001") - notOutdated("1.0.0-beta1-001-Idea3-(1)", "1.0.0-beta1-001") - notOutdated("1.0.0-release-IJ143-12", "1.0.0") - notOutdated("1.0.1-release-IJ143-75", "1.0.1") + notOutdated("1.0.0", "1.0.0") + notOutdated("1.0.1", "1.0.1") - outdated("1.0.0-beta1-002-Idea141-1", "1.0.0-beta1-001") - outdated("1.0.0-beta1-010-Idea141-1", "1.0.0-beta1-009") - outdated("1.0.0-beta1-100-Idea141-1", "1.0.0-beta1-099") - outdated("1.0.0-beta2-000-Idea141-1", "1.0.0-beta1-999") - outdated("1.1.0-beta1-000-Idea141-1", "1.0.9-beta9-999") - outdated("2.0.0-beta1-000-Idea141-1", "1.9.9-beta9-999") + outdated("1.0.0-beta1-002", "1.0.0-beta1-001") + outdated("1.0.0-beta1-010", "1.0.0-beta1-009") + outdated("1.0.0-beta1-100", "1.0.0-beta1-099") + outdated("1.0.0-beta2-000", "1.0.0-beta1-999") + outdated("1.1.0-beta1-000", "1.0.9-beta9-999") + outdated("2.0.0-beta1-000", "1.9.9-beta9-999") - outdated("1.0.0-beta-1001-Idea141-12", "1.0.0-beta-1000") - outdated("1.0.0-beta-1010-Idea141-12", "1.0.0-beta-1009") - outdated("1.0.0-beta-1100-Idea141-12", "1.0.0-beta-1099") - outdated("1.0.0-beta-2000-Idea141-12", "1.0.0-beta-1999") - outdated("1.0.1-beta-1001-Idea141-12", "1.0.0-beta-9999") - outdated("1.1.0-beta-1001-Idea141-12", "1.0.9-beta-9999") - outdated("2.0.0-beta-1001-Idea141-12", "1.9.9-beta-9999") + outdated("1.0.0-beta-1001", "1.0.0-beta-1000") + outdated("1.0.0-beta-1010", "1.0.0-beta-1009") + outdated("1.0.0-beta-1100", "1.0.0-beta-1099") + outdated("1.0.0-beta-2000", "1.0.0-beta-1999") + outdated("1.0.1-beta-1001", "1.0.0-beta-9999") + outdated("1.1.0-beta-1001", "1.0.9-beta-9999") + outdated("2.0.0-beta-1001", "1.9.9-beta-9999") } - private fun outdated(plugin: String, library: String) { - Assert.assertTrue("Should be outdated: plugin=$plugin, library=$library", - isRuntimeOutdated(library, pluginRuntimeVersion(plugin))) + private fun outdated(bundledRuntime: String, library: String) { + Assert.assertTrue("Should be outdated: bundled=$bundledRuntime, library=$library", + isRuntimeOutdated(library, bundledRuntime)) } - private fun notOutdated(plugin: String, library: String) { - Assert.assertFalse("Should NOT be outdated: plugin=$plugin, library=$library", - isRuntimeOutdated(library, pluginRuntimeVersion(plugin))) + private fun notOutdated(bundledRuntime: String, library: String) { + Assert.assertFalse("Should NOT be outdated: bundled=$bundledRuntime, library=$library", + isRuntimeOutdated(library, bundledRuntime)) } - private fun test(version: String, expected: String) { - Assert.assertEquals(expected, pluginRuntimeVersion(version)) - } } \ No newline at end of file