-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improvement: Automatically calculate last supported versions for sema…
…nticdb Previously, we would fail if our version of semanticdb was not supported for a sepcific scala version. Now, we calculate last supported version for each scala version when compiling. Potentially this means we could get a new semanticdb version automatically, but that should not be an issue as semanticdb is well tested in scalameta itself
- Loading branch information
Showing
8 changed files
with
100 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import scala.jdk.CollectionConverters._ | ||
|
||
object SemanticDbSupport { | ||
|
||
private val Scala211Versions = getVersions(2, 11, 12 to 12) | ||
private val last212 = V.scala212.split('.').last.toInt | ||
private val Scala212Versions = getVersions(2, 12, 9 to last212) | ||
private val last213 = V.scala213.split('.').last.toInt | ||
private val Scala213Versions = getVersions(2, 13, 1 to last213) | ||
|
||
private val AllScalaVersions = | ||
Scala213Versions ++ Scala212Versions ++ Scala211Versions | ||
|
||
val last: Map[String, String] = AllScalaVersions.flatMap { scalaVersion => | ||
coursierapi.Complete | ||
.create() | ||
.withScalaVersion(scalaVersion) | ||
.withScalaBinaryVersion(scalaVersion.split('.').take(2).mkString(".")) | ||
.withInput(s"org.scalameta:semanticdb-scalac_$scalaVersion:") | ||
.complete() | ||
.getCompletions() | ||
.asScala | ||
.lastOption | ||
.map(scalaVersion -> _) | ||
}.toMap | ||
|
||
// returns versions from newest to oldest | ||
private def getVersions(major: Int, minor: Int, range: Range) = { | ||
val desc = if (range.step > 0) range.reverse else range | ||
desc.map { x => s"$major.$minor.$x" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters