Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Migrate to 2.13 #3475

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ val scala212CompilerOptions = List(
logo := Welcome.logo
usefulTasks := Welcome.tasks

ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value

inThisBuild(
List(
version ~= { dynVer =>
if (isCI) dynVer
else localSnapshotVersion // only for local publishing
},
// note bucket created by @tgodzik
scalaVersion := V.scala212,
scalaVersion := V.scala213,
crossScalaVersions := List(V.scala212),
scalacOptions ++= List(
"-target:jvm-1.8",
Expand Down Expand Up @@ -219,10 +221,10 @@ lazy val V = new {
val ammonite213Version = scala213

val ammonite = "2.4.1"
val bloop = "1.4.11-30-75fb3441"
val bloop = "1.4.11-40-39ec23e0"
val bloopNightly = bloop
val bsp = "2.0.0-M15"
val coursier = "2.0.16"
val coursier = "2.1.0-M2"
val coursierInterfaces = "1.0.6"
val debugAdapter = "2.0.12"
val genyVersion = "0.7.0"
Expand Down Expand Up @@ -487,7 +489,7 @@ lazy val metals = project
// for BSP
"org.scala-sbt.ipcsocket" % "ipcsocket" % "1.4.0",
"ch.epfl.scala" % "bsp4j" % V.bsp,
"ch.epfl.scala" %% "bloop-launcher" % V.bloopNightly,
"ch.epfl.scala" %% "bloop-launcher-core" % V.bloopNightly,
// for LSP
V.lsp4j,
// for DAP
Expand Down Expand Up @@ -534,7 +536,8 @@ lazy val metals = project
"org.scalameta" %% "scalameta" % V.scalameta,
"org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full,
// For starting Ammonite
"io.github.alexarchambault.ammonite" %% "ammonite-runner" % "0.3.2"
"io.github.alexarchambault.ammonite" %% "ammonite-runner" % "0.3.2",
"org.scala-lang.modules" %% "scala-xml" % "2.0.1"
),
buildInfoPackage := "scala.meta.internal.metals",
buildInfoKeys := Seq[BuildInfoKey](
Expand Down Expand Up @@ -582,6 +585,7 @@ lazy val `sbt-metals` = project
"semanticdbVersion" -> V.semanticdb,
"supportedScala2Versions" -> V.scala2Versions
),
scalaVersion := V.scala212,
scriptedLaunchOpts ++= Seq(s"-Dplugin.version=${version.value}")
)
.enablePlugins(BuildInfoPlugin, SbtPlugin)
Expand All @@ -595,12 +599,9 @@ lazy val input = project
libraryDependencies ++= List(
// these projects have macro annotations
"org.scalameta" %% "scalameta" % V.scalameta,
"io.circe" %% "circe-derivation-annotations" % "0.9.0-M5"
"io.circe" %% "circe-derivation-annotations" % "0.13.0-M5"
),
scalacOptions += "-P:semanticdb:synthetics:on",
addCompilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full
)
scalacOptions += "-P:semanticdb:synthetics:on"
)
.disablePlugins(ScalafixPlugin)

Expand Down Expand Up @@ -791,10 +792,6 @@ lazy val bench = project
run / fork := true,
publish / skip := true,
moduleName := "metals-bench",
libraryDependencies ++= List(
// for measuring memory usage
"org.spire-math" %% "clouseau" % "0.2.2"
),
buildInfoKeys := Seq[BuildInfoKey](scalaVersion),
buildInfoPackage := "bench",
Jmh / bspEnabled := false
Expand Down
28 changes: 16 additions & 12 deletions metals-docs/src/main/scala/docs/Snapshot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,23 @@ object Snapshot {
// maven-metadata.xml is consistently outdated so we scrape the "Last modified" column
// of the HTML page that lists all snapshot releases instead.
val doc = Jsoup.connect(url).get
val snapshots: Seq[Snapshot] = doc.select("tr").asScala.flatMap { tr =>
val lastModified =
tr.select("td:nth-child(2)").text()
val version =
tr.select("td:nth-child(1)").text().stripSuffix("/")
if (lastModified.nonEmpty && !version.contains("maven-metadata")) {
val date: ZonedDateTime =
ZonedDateTime.parse(lastModified, zdtFormatter)
List(Snapshot(version, date.toLocalDateTime))
} else {
List()
val snapshots: Seq[Snapshot] = doc
.select("tr")
.asScala
.flatMap { tr =>
val lastModified =
tr.select("td:nth-child(2)").text()
val version =
tr.select("td:nth-child(1)").text().stripSuffix("/")
if (lastModified.nonEmpty && !version.contains("maven-metadata")) {
val date: ZonedDateTime =
ZonedDateTime.parse(lastModified, zdtFormatter)
List(Snapshot(version, date.toLocalDateTime))
} else {
List()
}
}
}
.toSeq
if (snapshots.isEmpty) {
val doc = Jsoup.connect(url + "maven-metadata.xml").get
val latest = doc.select("latest").text().trim
Expand Down
5 changes: 3 additions & 2 deletions metals/src/main/scala/scala/meta/internal/builds/Digest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.security.MessageDigest

import scala.jdk.CollectionConverters._
import scala.util.control.NonFatal
import scala.xml.Node

Expand Down Expand Up @@ -116,9 +117,9 @@ object Digest {
value <- attr.value
} digest.update(value.toString().getBytes())

val chldrenSuccessful: Seq[Boolean] = for {
val chldrenSuccessful: Seq[Boolean] = (for {
child <- node.child
} yield digestElement(child)
} yield digestElement(child)).toSeq
chldrenSuccessful.forall(p => p)
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.io.File

import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters._
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was usually added via MetalsEnrichments and the DecorateAsScala/DecorateAsJava traits, I think we can just switch to AsJavaExtensions and AsScalaExtensions instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I started out with that, but then I realized there was a lot of places that only brought in MetalsEnrichments just to use those instead of just using them directly. Do you still think we should do this?

import scala.util.Try
import scala.util.matching.Regex

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scala.meta.internal.builds

import scala.concurrent.Future
import scala.concurrent.Promise
import scala.jdk.CollectionConverters._
import scala.util.Properties

import scala.meta.internal.metals.Cancelable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue

import scala.collection.mutable
import scala.jdk.CollectionConverters._
import scala.util.control.NonFatal

import scala.meta.internal.metals.Buffers
Expand Down Expand Up @@ -287,7 +288,7 @@ final class ImplementationProvider(
classContext,
source.toNIO
)
file <- locationsByFile.keySet.toArray.par
file <- locationsByFile.keySet.toArray // TODO replcae .par
locations = locationsByFile(file)
implPath = AbsolutePath(file)
implDocument <- findSemanticdb(implPath).toIterable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package scala.meta.internal.implementation

import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters._

import scala.meta.internal.implementation.Supermethods.formatMethodSymbolForQuickPick
import scala.meta.internal.metals.ClientCommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package scala.meta.internal.metals

import java.util.concurrent.ConcurrentLinkedQueue

import scala.meta.internal.metals.MetalsEnrichments._
import scala.jdk.CollectionConverters._

import scala.meta.io.AbsolutePath

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package scala.meta.internal.metals

import java.{util => ju}

import scala.jdk.CollectionConverters._

import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.pc.AutoImportsResult

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ final class BloopServers(
override def write(byte: Int): Unit = byte.toChar match {
case c => b.append(c)
}
def logs = b.lines.toList
def logs = b.result.linesIterator
}

val launcher =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import scala.concurrent.ExecutionContext
import scala.concurrent.ExecutionContextExecutorService
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.jdk.CollectionConverters._
import scala.reflect.ClassTag
import scala.util.Try

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import scala.annotation.tailrec
import scala.collection.concurrent.TrieMap
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.jdk.CollectionConverters._
import scala.util.control.NonFatal

import scala.meta.internal.io.PathIO
Expand Down Expand Up @@ -176,7 +177,8 @@ final class BuildTargets(
scalac <- scalacTargetInfo.get(target.getId)
scalaTarget <- target.asScalaBuildTarget
} yield {
val autoImports = target.asSbtBuildTarget.map(_.getAutoImports.asScala)
val autoImports =
target.asSbtBuildTarget.map(_.getAutoImports.asScala.toSeq)
ScalaTarget(
target,
scalaTarget,
Expand Down Expand Up @@ -538,7 +540,11 @@ final class BuildTargets(
query: BuildTargetIdentifier,
roots: List[BuildTargetIdentifier]
): Boolean = {
BuildTargets.isInverseDependency(query, roots, inverseDependencies.get)
BuildTargets.isInverseDependency(
query,
roots,
inverseDependencies.get(_).map(_.toSeq)
)
}
def inverseDependencyLeaves(
target: BuildTargetIdentifier
Expand All @@ -553,7 +559,10 @@ final class BuildTargets(
private def computeInverseDependencies(
target: BuildTargetIdentifier
): BuildTargets.InverseDependencies = {
BuildTargets.inverseDependencies(List(target), inverseDependencies.get)
BuildTargets.inverseDependencies(
List(target),
inverseDependencies.get(_).map(_.toSeq)
)
}

def addDependencySource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package scala.meta.internal.metals

import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters._

import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.pc.CancelToken

import org.eclipse.{lsp4j => l}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package scala.meta.internal.metals

import scala.jdk.CollectionConverters._
import scala.reflect.ClassTag
import scala.util.matching.Regex

import scala.meta.internal.metals.JsonParser._
import scala.meta.internal.metals.MetalsEnrichments._

import org.eclipse.{lsp4j => l}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scala.meta.internal.metals
import scala.collection.concurrent.TrieMap
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters._
import scala.util.Failure
import scala.util.Success
import scala.util.Try
Expand Down Expand Up @@ -141,6 +142,8 @@ final class Compilations(

val groupedTargetIds = buildTargets.allBuildTargetIds
.groupBy(buildTargets.buildServerOf(_))
.toSeq

Future
.traverse(groupedTargetIds) { case (connectionOpt, targetIds) =>
clean(connectionOpt, targetIds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.{util => ju}

import scala.concurrent.ExecutionContextExecutorService
import scala.concurrent.Future
import scala.jdk.CollectionConverters._
import scala.util.Try

import scala.meta.inputs.Input
Expand Down Expand Up @@ -298,7 +299,7 @@ class Compilers(
.complete(offsetParams)
.asScala
.map(list =>
list.getItems.asScala
list.getItems.asScala.toSeq
.map(
toDebugCompletionItem(
_,
Expand Down Expand Up @@ -715,7 +716,7 @@ class Compilers(
): PresentationCompiler = {
newCompiler(
mtags,
scalac.getOptions().asScala,
scalac.getOptions().asScala.toSeq,
classpath,
search,
scalac.getTarget.getUri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.{util => ju}

import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters._

import scala.meta.inputs.Input
import scala.meta.internal.metals.MetalsEnrichments._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.{util => ju}

import scala.collection.concurrent.TrieMap
import scala.collection.mutable
import scala.jdk.CollectionConverters._

import scala.meta.inputs.Input
import scala.meta.internal.metals.MetalsEnrichments._
Expand Down Expand Up @@ -118,7 +119,7 @@ final class Diagnostics(
val path = params.getTextDocument.getUri.toAbsolutePath
onPublishDiagnostics(
path,
params.getDiagnostics().asScala.map(_.toLSP),
params.getDiagnostics().asScala.map(_.toLSP).toSeq,
params.getReset()
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.meta.internal.metals

import scala.jdk.CollectionConverters._

import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.mtags.DefinitionAlternatives.GlobalSymbol
import scala.meta.internal.mtags.Semanticdbs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import java.nio.file.Path
import java.util.ServiceLoader

import scala.collection.concurrent.TrieMap
import scala.jdk.CollectionConverters._

import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.pc.ScalaPresentationCompiler
import scala.meta.internal.worksheets.MdocClassLoader
import scala.meta.io.Classpath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import javax.annotation.Nullable
import scala.annotation.tailrec
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.jdk.CollectionConverters._
import scala.util.Failure
import scala.util.Properties
import scala.util.Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import java.util.concurrent.atomic.AtomicReference
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.jdk.CollectionConverters._
import scala.util.Failure
import scala.util.Success

Expand Down
Loading