def compareIdeaVersions()

in ideaSupport/src/main/scala/org/jetbrains/sbtidea/download/plugin/RepoPluginInstaller.scala [131:149]


  def compareIdeaVersions(a: String, b: String): Int = {
    val SNAPSHOT        = "SNAPSHOT"
    val SNAPSHOT_VALUE  = Int.MaxValue

    val c1 = a.replaceAll(SNAPSHOT, SNAPSHOT_VALUE.toString).replaceAll("\\*", SNAPSHOT_VALUE.toString).split('.')
    val c2 = b.replaceAll(SNAPSHOT, SNAPSHOT_VALUE.toString).replaceAll("\\*", SNAPSHOT_VALUE.toString).split('.')
    val pairs = c1
      .zipAll(c2, "0", "0")
      .map(x => x._1.toInt -> x._2.toInt)

    for ((a_i, b_i) <- pairs) {
      if (a_i == b_i && a_i == SNAPSHOT_VALUE) return 0
      if (a_i == SNAPSHOT_VALUE) return 1
      if (b_i == SNAPSHOT_VALUE) return -1
      val res = a_i - b_i
      if (res != 0) return res
    }
    c1.length - c2.length
  }