Skip to content

Commit

Permalink
Merge branch 'main' into update/cats-core-2.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-center-steward[bot] committed Aug 25, 2023
2 parents d59d207 + 9fe1e5d commit fac4df9
Show file tree
Hide file tree
Showing 26 changed files with 558 additions and 432 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ It proposes an incremental approach that can be described as follows:
# Requirements
- sbt 1.5 or higher
- java 8 or 11
- scala 2.13, preferred 2.13.5
- scala 2.13, preferred 2.13.11

# Installation
```
Expand Down Expand Up @@ -227,7 +227,7 @@ This command goal is to find the necessary types to add in order to make you cod

# What to do next ?
You can start again with another module `MODULE2`. If `MODULE2` depends on the last module migrated, you need
either to add `-Ytasty-reader` to `MODULE2` scalacOptions, or `reload` or `set MODULE-MIGRATED/scalaVersion := "2.13.5"`
either to add `-Ytasty-reader` to `MODULE2` scalacOptions, or `reload` or `set MODULE-MIGRATED/scalaVersion := "2.13.11"`

Once you're done, you can remove `scala3-migrate` from your plugins.

Expand Down
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,19 @@ addCommandAlias("compileScalafixOutputinScala3", s"""set `scalafix-output`/scala
def isCI = System.getenv("CI") != null

lazy val V = new {
val scala213 = "2.13.8"
val scala213 = "2.13.11"
val scala213BinaryVersion = "2.13"
val scala212 = "2.12.15"
val scalatest = "3.2.11"
val scala3 = "3.1.1"
val scalafix = "0.9.34"
val scalatest = "3.2.13"
val scala3 = "3.3.0"
val scalafix = "0.11.0"
val scribe = "3.8.2"
val organizeImports = "0.4.3"
val catsCore = "2.7.0"
val kindProjector = "0.13.2"
val coursierApi = "2.0.16"
val coursierInterface = "1.0.7"
val scalameta = "4.4.32"
val scalameta = "4.8.8"
val localSnapshotVersion = "0.5.0-SNAPSHOT"
val zio = "1.0.14"
}
13 changes: 0 additions & 13 deletions input/src/main/scala/migrate/Incompat1.scala

This file was deleted.

18 changes: 0 additions & 18 deletions input/src/main/scala/migrate/Incompat7.scala

This file was deleted.

17 changes: 8 additions & 9 deletions migrate/src/main/scala/migrate/Scala3Migrate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import migrate.interfaces.Lib
import migrate.interfaces.MigratedLibsImpl
import migrate.interfaces.MigratedScalacOptions
import migrate.internal.ScalaMigrateLogger
import migrate.internal.ScalacOption.PluginSpecific
import migrate.internal._
import migrate.utils.FileUtils
import migrate.utils.ScalaExtensions._
Expand Down Expand Up @@ -174,16 +173,16 @@ class Scala3Migrate(scalafixSrv: ScalafixService) {

object Scala3Migrate {
def migrateScalacOptions(scalacOptions: Seq[String]): MigratedScalacOptions = {
val sanitized = ScalacOption.sanitizeScalacOption(scalacOptions)
val scalaSettings = sanitized.map(ScalacOption.from)
val notParsed: Seq[ScalacOption.NotParsed] = scalaSettings.collect { case x: ScalacOption.NotParsed => x }
val scala3cOption: Seq[Scala3cOption] = scalaSettings.collect {
case x: ScalacOption.Specific3 => x;
val sanitized = ScalacOption.sanitize(scalacOptions)
val scalaSettings = sanitized.map(ScalacOption.from)
val notParsed = scalaSettings.collect { case x: ScalacOption.NotParsed => x }
val scala3cOption = scalaSettings.collect {
case x: ScalacOption.Specific3 => x
case x: ScalacOption.Shared => x
}
val pluginsSettings: Seq[PluginSpecific] = scalaSettings.collect { case x: ScalacOption.PluginSpecific => x }
val renamed = scalaSettings.collect { case x: ScalacOption.Renamed => x }
val specific2 = scalaSettings.collect { case x: ScalacOption.Specific2 => x }
val pluginsSettings = scalaSettings.collect { case x: ScalacOption.PluginSpecific => x }
val renamed = scalaSettings.collect { case x: ScalacOption.Renamed => x }
val specific2 = scalaSettings.collect { case x: ScalacOption.Specific2 => x }
MigratedScalacOptions(notParsed, specific2, scala3cOption, renamed, pluginsSettings)
}

Expand Down
2 changes: 1 addition & 1 deletion migrate/src/main/scala/migrate/internal/AbsolutePath.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ case class AbsolutePath private (value: String) {
}

object AbsolutePath {
def from(value: String): Try[AbsolutePath] = Try(AbsolutePath(value))
def from(value: String): Try[AbsolutePath] = from(Paths.get(value))
def from(path: Path): Try[AbsolutePath] = Try(AbsolutePath(path.toString))
def from(file: File): AbsolutePath = AbsolutePath(file.toString)
}
116 changes: 116 additions & 0 deletions migrate/src/main/scala/migrate/internal/CommandLineParser.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

package migrate.internal

import scala.annotation.tailrec

/**
* A simple enough command line parser.
*
* Copied from scala/scala
*/
private[migrate] object CommandLineParser {
final private val DQ = '"'
final private val SQ = '\''

/**
* Split the line into tokens separated by whitespace or quotes.
*
* @return
* either an error message or reverse list of tokens
*/
private def tokens(in: String) = {
import Character.isWhitespace
import java.lang.{StringBuilder => Builder}
import collection.mutable.ArrayBuffer

var accum: List[String] = Nil
var pos = 0
var start = 0
val qpos = new ArrayBuffer[Int](16) // positions of paired quotes

def cur: Int = if (done) -1 else in.charAt(pos)
def bump() = pos += 1
def done = pos >= in.length

def skipToQuote(q: Int) = {
var escaped = false
def terminal = in.charAt(pos) match {
case _ if escaped => escaped = false; false
case '\\' => escaped = true; false
case `q` => true
case _ => false
}
while (!done && !terminal) pos += 1
!done
}
@tailrec
def skipToDelim(): Boolean =
cur match {
case q @ (DQ | SQ) => { qpos += pos; bump(); skipToQuote(q) } && { qpos += pos; bump(); skipToDelim() }
case -1 => true
case c if isWhitespace(c) => true
case _ => bump(); skipToDelim()
}
def skipWhitespace() = while (isWhitespace(cur)) pos += 1
def copyText() = {
val buf = new Builder
var p = start
var i = 0
while (p < pos)
if (i >= qpos.size) {
buf.append(in, p, pos)
p = pos
} else if (p == qpos(i)) {
buf.append(in, qpos(i) + 1, qpos(i + 1))
p = qpos(i + 1) + 1
i += 2
} else {
buf.append(in, p, qpos(i))
p = qpos(i)
}
buf.toString
}
def text() = {
val res =
if (qpos.isEmpty) in.substring(start, pos)
else if (qpos(0) == start && qpos(1) == pos) in.substring(start + 1, pos - 1)
else copyText()
qpos.clear()
res
}
def badquote = Left("Unmatched quote")

@tailrec def loop(): Either[String, List[String]] = {
skipWhitespace()
start = pos
if (done) Right(accum)
else if (!skipToDelim()) badquote
else {
accum = text() :: accum
loop()
}
}
loop()
}

class ParseException(msg: String) extends RuntimeException(msg)

def tokenize(line: String, errorFn: String => Unit): List[String] =
tokens(line) match {
case Right(args) => args.reverse
case Left(msg) => errorFn(msg); Nil
}

def tokenize(line: String): List[String] = tokenize(line, x => throw new ParseException(x))
}
22 changes: 6 additions & 16 deletions migrate/src/main/scala/migrate/internal/InitialLib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import migrate.interfaces.MigratedLibImp
import migrate.interfaces.MigratedLibImp._
import migrate.internal.InitialLib.macroLibs
import migrate.internal.MigratedLib._
import migrate.internal.ScalacOption.Specific3
import migrate.internal.ScalacOption.CoverageOut
import migrate.internal.ScalacOption.KindProjector
import migrate.internal.ScalacOption.SemanticDB
import migrate.utils.CoursierHelper
import migrate.utils.ScalaExtensions._

Expand Down Expand Up @@ -152,8 +154,9 @@ object InitialLib {

val compilerPluginToScalacOption: Map[(Organization, Name), Scala3cOption] =
Map(
(Organization("org.typelevel"), Name("kind-projector")) -> Specific3.KindProjector,
(Organization("org.scalameta"), Name("semanticdb-scalac")) -> Specific3.SemanticDB
(Organization("org.typelevel"), Name("kind-projector")) -> KindProjector,
(Organization("org.scalameta"), Name("semanticdb-scalac")) -> SemanticDB,
(Organization("org.scoverage"), Name("scalac-scoverage-plugin")) -> CoverageOut(":.")
)

val macroLibs: Set[(Organization, Name)] =
Expand All @@ -162,34 +165,21 @@ object InitialLib {
Set(
Organization("com.softwaremill.scalamacrodebug") -> Name("macros"),
Organization("com.github.ajozwik") -> Name("macro"),
Organization("io.argonaut") -> Name("argonaut"),
Organization("eu.timepit") -> Name("refined"),
Organization("org.backuity") -> Name("ansi-interpolator"),
Organization("org.typelevel") -> Name("log4cats-slf4j"),
Organization("org.typelevel") -> Name("log4cats-core"),
Organization("com.github.dmytromitin") -> Name("auxify-macros"),
Organization("biz.enef") -> Name("slogging"),
Organization("io.getquill") -> Name("quill-jdbc"),
Organization("com.phylage") -> Name("refuel-container"),
Organization("com.typesafe.scala-logging") -> Name("scala-logging"),
Organization("com.lihaoyi") -> Name("macro"),
Organization("com.lihaoyi") -> Name("fastparse"),
Organization("com.github.kmizu") -> Name("macro_peg"),
Organization("com.michaelpollmeier") -> Name("macros"),
Organization("me.lyh") -> Name("parquet-avro-extra"),
Organization("org.spire-math") -> Name("imp"),
Organization("com.typesafe.play") -> Name("play-json"),
Organization("com.github.plokhotnyuk.expression-evaluator") -> Name("expression-evaluator"),
Organization("com.github.plokhotnyuk.fsi") -> Name("fsi-macros"),
Organization("com.propensive") -> Name("magnolia"),
Organization("org.wvlet.airframe") -> Name("airframe"),
Organization("com.wix") -> Name("accord-api"),
Organization("org.typelevel") -> Name("spire"),
Organization("org.typelevel") -> Name("claimant"),
Organization("com.softwaremill.macwire") -> Name("util"),
Organization("com.typesafe.slick") -> Name("slick"),
Organization("io.bullet") -> Name("borer-core"),
Organization("org.parboiled") -> Name("parboiled"),
Organization("com.github.pureconfig") -> Name("pureconfig"),
Organization("com.geirsson") -> Name("metaconfig-typesafe-config"),
Organization("com.thoughtworks.each") -> Name("each"),
Expand Down
Loading

0 comments on commit fac4df9

Please sign in to comment.