in src/main/scala/kotlin/KotlinVersion.scala [32:64]
def apply(versionString: String): KotlinVersion = versionString match {
case kotlinVersionRegex(majorStr, minorStr, patchStr, kindSuffixStr, buildNumberStr) =>
val majorValue = majorStr.parseVersionComponent("major")
val minorValue = minorStr.parseVersionComponent("minor")
val patchValue = patchStr.parseVersionComponent("patch")
val kindSuffixOpt = Option(kindSuffixStr).map(_.toLowerCase) match {
case None | Some("release") =>
Some(Kind.Release)
case Some("dev") =>
Some(Kind.Dev)
case Some("snapshot") | Some("local") =>
Some(Kind.Snapshot)
case Some(suffix) if suffix.startsWith("rc") =>
parseKind(suffix, "rc")(Kind.ReleaseCandidate)
case Some(suffix) if suffix.startsWith("beta") =>
parseKind(suffix, "beta")(Kind.Beta)
case Some(suffix) if suffix.startsWith("eap") =>
parseKind(suffix, "eap")(Kind.Eap)
case Some(suffix) if suffix.startsWith("m") =>
parseKind(suffix, "m")(Kind.Milestone)
case Some(suffix) if suffix.matches(IdeBuildRegex.regex) =>
val parts = suffix.stripPrefix("ij").split('.').toSeq.map(_.toInt)
Some(Kind.ForIde(suffix, parts))
case _ => None
}
val kindSuffix = kindSuffixOpt.getOrElse(throw new IllegalArgumentException(s"""Unsupported version kind suffix: "$kindSuffixStr" ($versionString)"""))
val buildNumber = Option(buildNumberStr).filterNot(_.isEmpty)
new KotlinVersion(majorValue, minorValue, patchValue, kindSuffix, buildNumber)
case _ => throw new IllegalArgumentException(s"Unsupported Kotlin version: $versionString")
}