Fix version parser for versions without status "1.4-M1-42-IJ2020.1-1".
This commit is contained in:
@@ -9,7 +9,6 @@ import com.intellij.openapi.application.ApplicationInfo
|
|||||||
import com.intellij.openapi.ui.Messages
|
import com.intellij.openapi.ui.Messages
|
||||||
import com.intellij.util.PlatformUtils
|
import com.intellij.util.PlatformUtils
|
||||||
import com.intellij.util.text.nullize
|
import com.intellij.util.text.nullize
|
||||||
import org.intellij.lang.annotations.RegExp
|
|
||||||
|
|
||||||
object KotlinPluginCompatibilityVerifier {
|
object KotlinPluginCompatibilityVerifier {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -29,7 +28,7 @@ object KotlinPluginCompatibilityVerifier {
|
|||||||
data class KotlinPluginVersion(
|
data class KotlinPluginVersion(
|
||||||
val kotlinVersion: String, // 1.2.3
|
val kotlinVersion: String, // 1.2.3
|
||||||
val milestone: String?, // M1
|
val milestone: String?, // M1
|
||||||
val status: String, // release, eap, rc
|
val status: String?, // release, eap, rc
|
||||||
val buildNumber: String?, // 53
|
val buildNumber: String?, // 53
|
||||||
val platformVersion: PlatformVersion,
|
val platformVersion: PlatformVersion,
|
||||||
val patchNumber: String // usually '1'
|
val patchNumber: String // usually '1'
|
||||||
@@ -38,7 +37,7 @@ data class KotlinPluginVersion(
|
|||||||
private const val KOTLIN_VERSION_REGEX_STRING =
|
private const val KOTLIN_VERSION_REGEX_STRING =
|
||||||
"^([\\d.]+)" + // Version number, like 1.3.50
|
"^([\\d.]+)" + // Version number, like 1.3.50
|
||||||
"(?:-(M\\d+))?" + // (Optional) M-release, like M2
|
"(?:-(M\\d+))?" + // (Optional) M-release, like M2
|
||||||
"-([A-Za-z]+)" + // status, like 'eap/dev/release'
|
"(?:-([A-Za-z]+))?" + // (Optional) status, like 'eap/dev/release'
|
||||||
"(?:-(\\d+))?" + // (Optional) buildNumber (absent for 'release')
|
"(?:-(\\d+))?" + // (Optional) buildNumber (absent for 'release')
|
||||||
"-([A-Za-z0-9.]+)" + // Platform version, like Studio4.0.1
|
"-([A-Za-z0-9.]+)" + // Platform version, like Studio4.0.1
|
||||||
"-(\\d+)$" // Tooling update, like '-1'
|
"-(\\d+)$" // Tooling update, like '-1'
|
||||||
|
|||||||
@@ -43,6 +43,23 @@ class CompatibilityVerifierVersionComparisonTest : LightPlatformTestCase() {
|
|||||||
assertEquals("1", version.patchNumber)
|
assertEquals("1", version.patchNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testMilestoneVersionWithoutStatus() {
|
||||||
|
val version = KotlinPluginVersion.parse("1.4-M1-42-IJ2020.1-1") ?: throw AssertionError("Version should not be null")
|
||||||
|
|
||||||
|
assertEquals("1.4", version.kotlinVersion)
|
||||||
|
assertEquals("M1", version.milestone)
|
||||||
|
assertEquals("42", version.buildNumber)
|
||||||
|
assertEquals(PlatformVersion.Platform.IDEA, version.platformVersion.platform)
|
||||||
|
assertEquals("2020.1", version.platformVersion.version)
|
||||||
|
assertEquals("1", version.patchNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testInvalidVersion() {
|
||||||
|
val version = KotlinPluginVersion.parse("1.4-release-M5-IJ2020.1-1")
|
||||||
|
|
||||||
|
assertNull(version)
|
||||||
|
}
|
||||||
|
|
||||||
fun testPlatformVersionParsing() {
|
fun testPlatformVersionParsing() {
|
||||||
PlatformVersion.getCurrent() ?: throw AssertionError("Version should not be null")
|
PlatformVersion.getCurrent() ?: throw AssertionError("Version should not be null")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user