Skip to content

Commit

Permalink
chore: migrate Metals to 2.13
Browse files Browse the repository at this point in the history
  • Loading branch information
ckipp01 committed Mar 5, 2022
1 parent e8a5a8d commit 8173f1f
Show file tree
Hide file tree
Showing 110 changed files with 495 additions and 465 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = "3.4.0"
runner.dialect = scala212
runner.dialect = scala213
project.git = true
align.preset = none
align.stripMargin = true
Expand Down
2 changes: 1 addition & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ touch ~/.bloop/.jvmopts
echo "-Xss16m" >> ~/.bloop/.jvmopts
echo "-Xmx1G" >> ~/.bloop/.jvmopts
curl -Lo coursier https://git.io/coursier-cli && chmod +x coursier
./coursier launch ch.epfl.scala:bloopgun-core_2.12:$(bloop_version) -- about
./coursier launch ch.epfl.scala:bloopgun-core_2.13:$(bloop_version) -- about

rm .jvmopts
touch .jvmopts
Expand Down
26 changes: 12 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,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
},
scalaVersion := V.scala212,
crossScalaVersions := List(V.scala212),
scalaVersion := V.scala213,
crossScalaVersions := List(V.scala213),
scalacOptions ++= List(
"-target:jvm-1.8",
"-Yrangepos"
Expand Down Expand Up @@ -143,7 +145,7 @@ commands ++= Seq(
val publishMtags = V.quickPublishScalaVersions.foldLeft(s) { case (st, v) =>
runMtagsPublishLocal(st, v, localSnapshotVersion)
}
"interfaces/publishLocal" :: s"++${V.scala212} metals/publishLocal" :: publishMtags
"interfaces/publishLocal" :: s"++${V.scala213} metals/publishLocal" :: publishMtags
},
Command.command("cross-test-latest-nightly") { s =>
val max =
Expand Down Expand Up @@ -177,7 +179,7 @@ lazy val V = new {
val bloop = "1.4.13"
val bloopNightly = bloop
val bsp = "2.0.0-M15"
val coursier = "2.0.16"
val coursier = "2.1.0-M5"
val coursierInterfaces = "1.0.6"
val debugAdapter = "2.0.13"
val genyVersion = "0.7.1"
Expand Down Expand Up @@ -491,7 +493,9 @@ 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",
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
),
buildInfoPackage := "scala.meta.internal.metals",
buildInfoKeys := Seq[BuildInfoKey](
Expand Down Expand Up @@ -538,6 +542,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 @@ -551,12 +556,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 ++= Seq("-P:semanticdb:synthetics:on", "-Ymacro-annotations")
)
.disablePlugins(ScalafixPlugin)

Expand Down Expand Up @@ -747,10 +749,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
2 changes: 1 addition & 1 deletion metals-docs/src/main/scala/docs/Docs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Docs {
"SBT_BLOOP_VERSION" -> V.sbtBloopVersion,
"SCALAMETA_VERSION" -> V.scalametaVersion,
"SCALA211_VERSION" -> V.scala211,
"SCALA_VERSION" -> V.scala212
"SCALA_VERSION" -> V.scala213
)
)
.withOut(docsOut)
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
4 changes: 2 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 @@ -116,9 +116,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 @@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentLinkedQueue

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

import scala.meta.internal.metals.Buffers
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 @@ -260,7 +260,7 @@ final class BuildTargets(
info(scalac.getTarget()).foreach { info =>
info.asScalaBuildTarget.foreach { scalaBuildTarget =>
val sbtTarget = info.asSbtBuildTarget
val autoImports = sbtTarget.map(_.getAutoImports.asScala)
val autoImports = sbtTarget.map(_.getAutoImports.asScala.toSeq)
scalaTargetInfo(scalac.getTarget) = ScalaTarget(
info,
scalaBuildTarget,
Expand Down Expand Up @@ -500,7 +500,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 @@ -515,7 +519,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 @@ -142,6 +142,7 @@ 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 @@ -301,7 +301,7 @@ class Compilers(
.complete(offsetParams)
.asScala
.map(list =>
list.getItems.asScala
list.getItems.asScala.toSeq
.map(
toDebugCompletionItem(
_,
Expand Down Expand Up @@ -725,7 +725,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 @@ -118,7 +118,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
Expand Up @@ -132,7 +132,7 @@ final class ForwardingMetalsBuildClient(
}

if (otherChanges.nonEmpty)
onBuildChanged(otherChanges)
onBuildChanged(otherChanges.toSeq)
}

def onBuildTargetCompileReport(params: b.CompileReport): Unit = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException

import scala.annotation.tailrec
import scala.collection.convert.DecorateAsJava
import scala.collection.convert.DecorateAsScala
import scala.collection.convert.AsJavaExtensions
import scala.collection.convert.AsScalaExtensions
import scala.collection.mutable
import scala.compat.java8.FutureConverters
import scala.concurrent.Await
Expand Down Expand Up @@ -70,8 +70,8 @@ import org.eclipse.{lsp4j => l}
* remember only one import.
*/
object MetalsEnrichments
extends DecorateAsJava
with DecorateAsScala
extends AsJavaExtensions
with AsScalaExtensions
with MtagsEnrichments {

implicit class XtensionBuildTarget(buildTarget: b.BuildTarget) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import java.{util => ju}
import scala.collection.immutable.Nil
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.collection.parallel.CollectionConverters._
import scala.collection.parallel.ForkJoinTaskSupport
import scala.concurrent.Await
import scala.concurrent.ExecutionContextExecutorService
Expand Down Expand Up @@ -49,6 +50,7 @@ import scala.meta.internal.decorations.SyntheticsDecorationProvider
import scala.meta.internal.implementation.ImplementationProvider
import scala.meta.internal.implementation.Supermethods
import scala.meta.internal.io.FileIO
import scala.meta.internal.metals.BuildInfo
import scala.meta.internal.metals.Messages.AmmoniteJvmParametersChange
import scala.meta.internal.metals.Messages.IncompatibleBloopVersion
import scala.meta.internal.metals.MetalsEnrichments._
Expand Down Expand Up @@ -1801,7 +1803,7 @@ class MetalsLanguageServer(
)
}.asJavaObject
case ServerCommands.StartDebugAdapter() =>
val args = params.getArguments.asScala
val args = params.getArguments.asScala.toSeq
import DebugProvider.DebugParametersJsonParsers._
val debugSessionParams: Future[b.DebugSessionParams] = args match {
case Seq(debugSessionParamsParser.Jsonized(params))
Expand Down Expand Up @@ -2189,7 +2191,7 @@ class MetalsLanguageServer(
def compileAllOpenFiles: BuildChange => Future[BuildChange] = {
case change if !change.isFailed =>
Future
.sequence[Unit, List](
.sequence(
compilations
.cascadeCompileFiles(buffers.open.toSeq)
.ignoreValue ::
Expand Down Expand Up @@ -2305,7 +2307,7 @@ class MetalsLanguageServer(
}
)
try {
val parSourcesToIndex = sourcesToIndex.par
val parSourcesToIndex = sourcesToIndex.toSeq.par
parSourcesToIndex.tasksupport = new ForkJoinTaskSupport(threadPool)
parSourcesToIndex.foreach(f =>
indexSourceFile(f.source, Some(f.sourceItem), f.targets.headOption)
Expand Down Expand Up @@ -2383,7 +2385,7 @@ class MetalsLanguageServer(
)
}
}
workspaceSymbols.didChange(source, symbols)
workspaceSymbols.didChange(source, symbols.toSeq)

// Since the `symbols` here are toplevel symbols,
// we cannot use `symbols` for expiring the cache for all symbols in the source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class WorkspaceSearchVisitor(
)
)
}
result.asScala
result.asScala.toSeq
}
private val byNameLength = new ju.Comparator[l.SymbolInformation] {
def compare(x: l.SymbolInformation, y: l.SymbolInformation): Int = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ final class Ammonite(
}
_ <- indexWorkspace()
toCompile = buffers.open.toSeq.filter(_.isAmmoniteScript)
_ <- Future.sequence[Unit, List](
_ <- Future.sequence(
compilations
.cascadeCompileFiles(toCompile) ::
compilers.load(toCompile) ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ImplementAbstractMembers(compilers: Compilers) extends CodeAction {
.getContext()
.getDiagnostics()
.asScala
.toSeq
.collect {
case d @ ScalacDiagnostic.ObjectCreationImpossible(_)
if params.getRange().overlapsWith(d.getRange()) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ImportMissingSymbol(compilers: Compilers) extends CodeAction {
codeAction.setEdit(edit)

codeAction
}
}.toSeq
}
}

Expand Down Expand Up @@ -106,7 +106,7 @@ class ImportMissingSymbol(compilers: Compilers) extends CodeAction {
val mainAction = actions.head
val allDiagnostics =
actions.flatMap(_.getDiagnostics().asScala).asJava
val edits = joinActionEdits(actions)
val edits = joinActionEdits(actions.toSeq)
mainAction.setDiagnostics(allDiagnostics)
mainAction
.setEdit(new l.WorkspaceEdit(Map(uri -> edits.asJava).asJava))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class BuildTargetClasses(
): Future[Unit] = {
val distinctTargets = targets.distinct
Future
.traverse(distinctTargets.groupBy(buildTargets.buildServerOf)) {
.traverse(distinctTargets.groupBy(buildTargets.buildServerOf).toSeq) {
case (None, _) =>
Future.successful(())
case (Some(connection), targets0) =>
Expand Down
Loading

0 comments on commit 8173f1f

Please sign in to comment.