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

Update Scala to 2.13 #1522

Merged
merged 18 commits into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@ jobs:
- env: TEST="2.12"
jdk: openjdk8
script: sbt ci-test
- env: TEST="2.13"
jdk: openjdk8
script: sbt ci-test
- env: TEST="2.11"
jdk: openjdk11
script: sbt ci-test
- env: TEST="2.12"
jdk: openjdk11
script: sbt ci-test
- env: TEST="2.13"
jdk: openjdk11
script: sbt ci-test
- stage: release
jdk: openjdk8
script: sbt ci-release docs/docusaurusPublishGhpages
Expand Down
26 changes: 19 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sbtcrossproject.CrossPlugin.autoImport.crossProject

def scala211 = "2.11.12"
def scala212 = "2.12.8"
def scala213 = "2.13.1"

inThisBuild(
List(
Expand All @@ -19,8 +20,8 @@ inThisBuild(
url("https://geirsson.com")
)
),
scalaVersion := scala212,
crossScalaVersions := List(scala212, scala211),
scalaVersion := scala213,
crossScalaVersions := List(scala213, scala212, scala211),
resolvers += Resolver.sonatypeRepo("releases"),
libraryDependencies ++= List(
scalatest.value % Test,
Expand All @@ -36,7 +37,8 @@ skip in publish := true
commands += Command.command("ci-test") { s =>
val scalaVersion = sys.env.get("TEST") match {
case Some("2.11") => scala211
case _ => scala212
case Some("2.12") => scala212
case _ => scala213
}
val docsTest = if (scalaVersion == scala212) "docs/run" else "version"
s"++$scalaVersion" ::
Expand Down Expand Up @@ -89,17 +91,26 @@ lazy val core = crossProject(JVMPlatform)
.in(file("scalafmt-core"))
.settings(
moduleName := "scalafmt-core",
addCompilerPlugin(
poslegm marked this conversation as resolved.
Show resolved Hide resolved
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
),
buildInfoSettings,
scalacOptions ++= scalacJvmOptions.value,
libraryDependencies ++= Seq(
metaconfig.value,
scalameta.value,
// scala-reflect is an undeclared dependency of fansi, see #1252.
// Scalafmt itself does not require scala-reflect.
"org.scala-lang" % "scala-reflect" % scalaVersion.value
)
),
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 13)) => Seq.empty
case _ =>
Seq(
compilerPlugin(
"org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full
)
)
}
}
)
// .jsSettings(
// libraryDependencies ++= List(
Expand All @@ -122,6 +133,7 @@ import sbtassembly.AssemblyPlugin.defaultUniversalScript
val scalacJvmOptions = Def.setting {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq("-target:jvm-1.8")
case Some((2, 13)) => Seq("-Ymacro-annotations")
case _ => Seq.empty
}
}
Expand Down
6 changes: 3 additions & 3 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import org.portablescala.sbtplatformdeps.PlatformDepsPlugin.autoImport._
// scalafmt: { maxColumn = 120, style = defaultWithAlign }

object Dependencies {
val metaconfigV = "0.8.3"
val metaconfigV = "0.9.4"
val scalametaV = "4.2.3"
val scalatestV = "3.2.0-SNAP10"
val scalacheckV = "1.13.5"
val scalatestV = "3.0.8"
val scalacheckV = "1.14.2"
val coursier = "1.0.3"

val scalapb = Def.setting {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.6
sbt.version=1.3.2
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ object ScalafmtCoreRunner extends ScalafmtRunner {
val termDisplay =
newTermDisplay(options, inputMethods, termDisplayMessage)
val exitCode = new AtomicReference(ExitCode.Ok)
inputMethods.par.foreach { inputMethod =>
// TODO add parallel collections
poslegm marked this conversation as resolved.
Show resolved Hide resolved
inputMethods.foreach { inputMethod =>
val code = handleFile(inputMethod, options, scalafmtConf)
exitCode.getAndUpdate(new UnaryOperator[ExitCode] {
override def apply(t: ExitCode): ExitCode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object Terminal {
None

implicit class Ansi(val output: Writer) extends AnyVal {
private def control(n: Int, c: Char) = output.write(s"\033[" + n + c)
private def control(n: Int, c: Char) = output.write(s"\\033[" + n + c)

/**
* Move up `n` squares
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ScalafmtConfDecoders {
implicit lazy val eventReader: ConfDecoder[FormatEvent => Unit] =
ConfDecoder.instance[FormatEvent => Unit] {
case _ =>
Configured.Ok((_: FormatEvent) => Unit)
Configured.Ok((_: FormatEvent) => ())
}
implicit lazy val parseReader: ConfDecoder[MetaParser] = {
ReaderUtil.oneOf[MetaParser](parseSource, parseStat, parseCase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.meta.parsers.Parse
*/
case class ScalafmtRunner(
debug: Boolean = false,
eventCallback: FormatEvent => Unit = _ => Unit,
eventCallback: FormatEvent => Unit = _ => (),
parser: Parse[_ <: Tree] = Parse.parseSource,
optimizer: ScalafmtOptimizer = ScalafmtOptimizer.default,
maxStateVisits: Int = 1000000,
Expand Down Expand Up @@ -84,7 +84,7 @@ object ScalafmtRunner {
*/
val default = ScalafmtRunner(
debug = false,
eventCallback = _ => Unit,
eventCallback = _ => (),
parser = scala.meta.parsers.Parse.parseSource,
optimizer = ScalafmtOptimizer.default,
maxStateVisits = 1000000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.meta.Tree
import scala.meta.Type
import scala.meta.prettyprinters.Structure
import scala.meta.tokens.Token
import scala.meta.tokens.Token._
import scala.meta.tokens.Token.{Space => _, _}
poslegm marked this conversation as resolved.
Show resolved Hide resolved
import org.scalafmt.Error.CaseMissingArrow
import org.scalafmt.config.{
DanglingExclude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.meta.Tree
import scala.meta.Type
import scala.meta.prettyprinters.Syntax
import scala.meta.tokens.Token
import scala.meta.tokens.Token._
import scala.meta.tokens.Token.{Space => _, _}
import java.util.regex.Pattern

import org.scalafmt.internal.FormatWriter.FormatLocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import scala.meta.{
}

// Too many to import individually.
import scala.meta.tokens.Token._
import scala.meta.tokens.Token.{Space => _, _}
poslegm marked this conversation as resolved.
Show resolved Hide resolved

object Constants {
val ShouldBeNewline = 100000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ object Patch {
(tokenPatches)
.groupBy(t => t.tok.start -> t.tok.end)
.mapValues(_.reduce(merge).newTok)
.toMap
input.toIterator
.map(x => patchMap.getOrElse(x.start -> x.end, x.syntax))
.mkString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Rewrite {
)

private def nameMap[T](t: sourcecode.Text[T]*): Map[String, T] = {
t.map(x => x.source -> x.value)(scala.collection.breakOut)
t.view.map(x => x.source -> x.value).toMap
}

val name2rewrite: Map[String, Rewrite] = nameMap[Rewrite](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GitOpsImpl(private[util] val workingDirectory: AbsoluteFile)
private[util] def exec(cmd: Seq[String]): Try[Seq[String]] = {
val gitRes: Try[String] = Try {
val lastError = new StringBuilder
val swallowStderr = ProcessLogger(_ => Unit, err => lastError.append(err))
val swallowStderr = ProcessLogger(_ => (), err => lastError.append(err))
try {
sys.process
.Process(cmd, workingDirectory.jfile)
Expand Down