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

Migrate to 2.13 #1118

Merged
merged 5 commits into from
May 26, 2020
Merged
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
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,37 @@ jobs:
command:
- "ci-211"
- "ci-212"
- "ci-213"
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v7
- run: sbt ${{ matrix.command }}
jdk11:
name: JDK11 tests
jdk11_212:
name: JDK11/scala_2.12 tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v7
with:
java-version: [email protected]
- run: sbt ci-212
windows:
name: Windows tests
jdk11_213:
name: JDK11/scala_2.13 tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v7
with:
java-version: [email protected]
- run: sbt ci-213

windows_213:
name: Windows/scala_2.13 tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v7
- run: sbt ci-212-windows
- run: sbt ci-213-windows
shell: bash
checks:
name: Scalafmt
Expand Down
24 changes: 14 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Dependencies._
inThisBuild(
List(
onLoadMessage := s"Welcome to scalafix ${version.value}",
scalaVersion := scala212,
crossScalaVersions := List(scala212, scala211),
scalaVersion := scala213,
crossScalaVersions := List(scala213, scala212, scala211),
fork := true
)
)
Expand Down Expand Up @@ -31,9 +31,9 @@ lazy val interfaces = project
props.put("scalafixVersion", version.value)
props.put("scalafixStableVersion", stableVersion.value)
props.put("scalametaVersion", scalametaV)
props.put("scala213", scala213)
props.put("scala212", scala212)
props.put("scala211", scala211)
props.put("scala213", scala213)
val out =
managedResourceDirectories.in(Compile).value.head /
"scalafix-interfaces.properties"
Expand All @@ -50,7 +50,7 @@ lazy val interfaces = project
javaHome.in(Compile, doc) := inferJavaHome(),
moduleName := "scalafix-interfaces",
crossVersion := CrossVersion.disabled,
crossScalaVersions := List(scala212),
crossScalaVersions := List(scala213),
autoScalaLibrary := false
)

Expand All @@ -63,7 +63,8 @@ lazy val core = project
scalameta,
googleDiff,
"com.geirsson" %% "metaconfig-typesafe-config" % metaconfigV,
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided,
collectionCompat
)
)
.enablePlugins(BuildInfoPlugin)
Expand All @@ -73,7 +74,10 @@ lazy val rules = project
.settings(
moduleName := "scalafix-rules",
description := "Built-in Scalafix rules",
libraryDependencies += "org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full
libraryDependencies ++= List(
"org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full,
collectionCompat
)
)
.dependsOn(core)

Expand Down Expand Up @@ -131,7 +135,7 @@ lazy val testsInput = project
scalacOptions += warnUnusedImports.value, // For RemoveUnused
scalacOptions += "-Ywarn-unused", // For RemoveUnusedTerms
logLevel := Level.Error, // avoid flood of compiler warnings
libraryDependencies += "com.twitter" %% "bijection-core" % "0.9.6",
libraryDependencies += bijectionCore,
testsInputOutputSetting,
coverageEnabled := false
)
Expand All @@ -147,7 +151,7 @@ lazy val testsOutput = project
),
testsInputOutputSetting,
coverageEnabled := false,
libraryDependencies += "com.twitter" %% "bijection-core" % "0.9.6"
libraryDependencies += bijectionCore
)

lazy val testkit = project
Expand Down Expand Up @@ -256,9 +260,9 @@ lazy val docs = project
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
skip in publish := true,
moduleName := "scalafix-docs",
scalaVersion := scala212,
scalaVersion := scala213,
mdoc := run.in(Compile).evaluated,
crossScalaVersions := List(scala212),
crossScalaVersions := List(scala213),
libraryDependencies ++= List(
"com.geirsson" %% "metaconfig-docs" % metaconfigV,
"org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full
Expand Down
3 changes: 0 additions & 3 deletions docs/developers/symbol-information.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ of length greater than 1.
```scala mdoc
printMethodParameters(Symbol("example/Main#curried()."))
printMethodParameters(Symbol("scala/Option#fold()."))
printMethodParameters(Symbol("scala/collection/LinearSeqOptimized#foldLeft()."))
```

### Test if method is nullary
Expand Down Expand Up @@ -243,9 +242,7 @@ def getParentSymbols(symbol: Symbol): Set[Symbol] =
case TypeRef(_, symbol, _) => getParentSymbols(symbol)
}
}
getParentSymbols(Symbol("scala/Some#"))
getParentSymbols(Symbol("java/lang/String#"))
getParentSymbols(Symbol("scala/collection/immutable/List#")).take(5)
```

### Lookup class methods
Expand Down
4 changes: 3 additions & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object Dependencies {
def scala212 = "2.12.11"
def scala213 = "2.13.2"
def coursierV = "2.0.0-RC5-6"
val currentScalaVersion = scala212
val currentScalaVersion = scala213

val jgit = "org.eclipse.jgit" % "org.eclipse.jgit" % "5.7.0.202003110725-r"

Expand All @@ -22,7 +22,9 @@ object Dependencies {
def semanticdbPluginLibrary = "org.scalameta" % "semanticdb-scalac-core" % scalametaV cross CrossVersion.full
def scalameta = "org.scalameta" %% "scalameta" % scalametaV
def scalatest = "org.scalatest" %% "scalatest" % "3.0.8"
def bijectionCore = "com.twitter" %% "bijection-core" % "0.9.7"
def scalacheck = "org.scalacheck" %% "scalacheck" % "1.14.3"
def collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6"

def testsDeps = List(
// integration property tests
Expand Down
12 changes: 6 additions & 6 deletions project/ScalafixBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
lazy val noPublish = Seq(
skip in publish := true
) ++ noMima
lazy val supportedScalaVersions = List(scala211, scala212)
lazy val supportedScalaVersions = List(scala213, scala211, scala212)
lazy val isFullCrossVersion = Seq(
crossVersion := CrossVersion.full
)
lazy val isScala213 = Def.setting { scalaVersion.value.startsWith("2.13") }
lazy val warnUnusedImports = Def.setting {
if (isScala213.value) "-Ywarn-unused:imports"
if (isScala213.value) "-Wunused:imports"
else "-Ywarn-unused-import"
}
lazy val scaladocOptions = Seq(
Expand Down Expand Up @@ -187,22 +187,22 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
commands += Command.command("ci-213") { s =>
s"++$scala213" ::
"unit/test" ::
"docs/run" ::
"interfaces/doc" ::
s
},
commands += Command.command("ci-212") { s =>
s"++$scala212" ::
"unit/test" ::
"docs/run" ::
"interfaces/doc" ::
s
},
commands += Command.command("ci-211") { s =>
s"++$scala211" ::
"unit/test" ::
s
},
commands += Command.command("ci-212-windows") { s =>
s"++$scala212" ::
commands += Command.command("ci-213-windows") { s =>
s"++$scala213" ::
s"unit/testOnly -- -l scalafix.internal.tests.utils.SkipWindows" ::
s
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util
import java.util.Optional
import metaconfig.Conf
import metaconfig.Configured
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.meta.io.AbsolutePath
import scala.meta.io.Classpath
import scala.util.control.NoStackTrace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.eclipse.jgit.treewalk.FileTreeIterator
import org.eclipse.jgit.util.io.NullOutputStream
import org.eclipse.jgit.lib.Constants.DOT_GIT

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

import metaconfig.{ConfError, Configured}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import metaconfig.internal.ConfGet
import metaconfig.typesafeconfig.typesafeConfigMetaconfigParser
import pprint.TPrint
import scala.annotation.StaticAnnotation
import scala.language.higherKinds
import scala.meta.internal.io.PathIO
import scala.meta.internal.symtab.SymbolTable
import scala.meta.io.AbsolutePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object CompletionsOps {
if (setting.isHidden) Nil
else setting.name :: setting.alternativeNames.filter(_.length == 1)

private def toZshOption(setting: Setting): scala.Seq[String] = {
private def toZshOption(setting: Setting): scala.collection.Seq[String] = {
if (setting.isHidden) Nil
else {
// See https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#writing-completion-functions-using-_arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ import metaconfig.generic.Settings
import metaconfig.internal.Case
import org.typelevel.paiges.{Doc => D}
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.ListBuffer
import scala.meta.Tree
import scala.meta.inputs.Input
import scala.meta.internal.semanticdb.TextDocument
import scala.meta.internal.tokenizers.PlatformTokenizerCache
import scala.meta.io.AbsolutePath
import scala.meta.parsers.ParseException
import scala.util.control.NoStackTrace
Expand Down Expand Up @@ -81,7 +79,7 @@ object MainOps {
def files(args: ValidatedArgs): collection.Seq[AbsolutePath] =
args.args.ls match {
case Ls.Find =>
val buf = ArrayBuffer.empty[AbsolutePath]
val buf = Vector.newBuilder[AbsolutePath]
val visitor = new SimpleFileVisitor[Path] {
override def visitFile(
file: Path,
Expand Down Expand Up @@ -273,7 +271,6 @@ object MainOps {

def handleFile(args: ValidatedArgs, file: AbsolutePath): ExitStatus = {
try {
PlatformTokenizerCache.megaCache.clear()
unsafeHandleFile(args, file)
} catch {
case e: ParseException =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import scala.collection.immutable.IndexedSeq
object Compat {
type View[T] = collection.SeqView[T, IndexedSeq[T]]
type SeqView[T] = collection.SeqView[T, IndexedSeq[T]]

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import scala.collection.immutable.IndexedSeq
object Compat {
type View[T] = collection.SeqView[T, IndexedSeq[T]]
type SeqView[T] = collection.Seq[T]

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package scalafix.util
object Compat {
type View[T] = collection.View[T]
type SeqView[T] = collection.SeqView[T]

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package scala.meta.internal

import scala.compat.Platform.EOL
import scala.meta._
import scala.meta.internal.semanticdb.Scala.Descriptor
import scala.meta.internal.semanticdb.Scala.DescriptorParser
import scala.meta.internal.trees.Origin
import scala.meta.internal.{semanticdb => s}

object ScalametaInternals {
private val EOL = System.lineSeparator()

def symbolOwnerAndDescriptor(symbol: String): (String, Descriptor) = {
val (desc, owner) = DescriptorParser(symbol)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scalafix.internal.diff

import difflib.{DiffUtils => DU}
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

object DiffUtils {
def unifiedDiff(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import scalafix.patch.Patch.internal._
import scalafix.rule.RuleName
import scalafix.util.TreeExtractors.Mods
import scalafix.v0._
import scala.collection.compat._ // used for cross-compilation.

/** EscapeHatch is an algorithm to selectively disable rules. There
* are two mechanisms to do so: anchored comments and the
Expand Down Expand Up @@ -171,7 +172,7 @@ object EscapeHatch {
if (isEmpty) (true, None)
else {
val escapesUpToPos =
escapeTree.to(EscapeOffset(position)).valuesIterator.flatten
escapeTree.rangeTo(EscapeOffset(position)).valuesIterator.flatten
escapesUpToPos
.collectFirst {
case f @ EscapeFilter(_, _, _, Some(end))
Expand Down Expand Up @@ -316,7 +317,7 @@ object EscapeHatch {
if (disabling.isEmpty) (true, None)
else {
val disables =
disabling.to(EscapeOffset(position)).valuesIterator.flatten
disabling.rangeTo(EscapeOffset(position)).valuesIterator.flatten
loop(disables.toList, None)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ object ImportPatchOps {
.sortBy(_.ref.syntax)
.map(is => ctx.addRight(editToken, s"\nimport ${is.syntax}"))
val isRemovedImporter =
allImporters.toIterator
allImporters.iterator
.filter(_.importees.forall(isRemovedImportee))
.toSet
def removeSpaces(tokens: Iterable[Token]): Patch = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ trait LegacyPatchOps extends PatchOps {
Patch.replaceSymbols(toReplace: _*)
@deprecated(DeprecationMessage, "0.6.0")
final def replaceSymbols(
toReplace: Seq[(String, String)]
toReplace: scala.collection.Seq[(String, String)]
)(implicit noop: DummyImplicit, index: SemanticdbIndex): Patch =
Patch.replaceSymbols(toReplace: _*)
Patch.replaceSymbols(toReplace.toSeq: _*)
@deprecated(DeprecationMessage, "0.6.0")
final def renameSymbol(fromSymbol: Symbol.Global, toName: String)(
implicit index: SemanticdbIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ object PatchInternals {
val patchMap = patches
.groupBy(x => TokenOps.hash(x.tok))
.mapValues(_.reduce(merge).newTok)
ctx.tokens.toIterator
ctx.tokens.iterator
.map(tok => patchMap.getOrElse(TokenOps.hash(tok), tok.syntax))
.mkString
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object ReplaceSymbolOps {
)(implicit ctx: RuleCtx, index: SemanticdbIndex): Patch = {
if (moveSymbols.isEmpty) return Patch.empty
val moves: Map[String, Symbol.Global] =
moveSymbols.toIterator.flatMap {
moveSymbols.iterator.flatMap {
case ReplaceSymbol(
term @ Symbol.Global(_, Signature.Method(_, _)),
to
Expand Down Expand Up @@ -67,7 +67,7 @@ object ReplaceSymbolOps {
}
object Move {
def unapply(name: Name): Option[Symbol.Global] = {
val result = name.symbol.toIterator
val result = name.symbol.iterator
.flatMap {
case Symbol.Multi(syms) => syms
case els => els :: Nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object FileOps {
} else {
def listFilesIter(s: File): Iterable[String] = {
val (dirs, files) = Option(s.listFiles()).toIterable
.flatMap(_.toIterator)
.flatMap(_.iterator)
.partition(_.isDirectory)
files.map(_.getPath) ++ dirs.flatMap(listFilesIter)
}
Expand Down
Loading