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

Move internal code to internal package, fixes #192. #236

Merged
merged 5 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
10 changes: 9 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ lazy val publishSettings = Seq(
"scm:git:git@github.com:scalacenter/scalafix.git"
)
),
mimaPreviousArtifacts := Set(
organization.value % s"${moduleName.value}_${scalaBinaryVersion.value}" % stableVersion.value
),
mimaBinaryIssueFilters ++= Mima.ignoredABIProblems,
pomExtra :=
<developers>
<developer>
Expand All @@ -69,11 +73,14 @@ lazy val noPublish = Seq(
publishLocal := {}
)

lazy val stableVersion =
settingKey[String]("Version of latest release to Maven.")

lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
"stable" -> version.value.replaceAll("\\+.*", ""),
stableVersion,
"nightly" -> version.value,
"scalameta" -> scalametaV,
scalaVersion,
Expand All @@ -88,6 +95,7 @@ lazy val buildInfoSettings: Seq[Def.Setting[_]] = Seq(

lazy val allSettings = List(
version := sys.props.getOrElse("scalafix.version", version.value),
stableVersion := version.value.replaceAll("\\+.*", ""),
resolvers += Resolver.bintrayRepo("scalameta", "maven"),
resolvers += Resolver.sonatypeRepo("releases"),
resolvers ~= { old =>
Expand Down
10 changes: 10 additions & 0 deletions project/Mima.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._

object Mima {
val ignoredABIProblems: Seq[ProblemFilter] = {
Seq(
exclude[MissingClassProblem]("scalafix.package$XtensionRewriteCtx")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not super familiar with MiMa, can you please explain what is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a way to document binary breaking changes. sbt mimaReportBinaryIssues compares the classfiles of the current HEAD with the classfiles of the latest published release to Maven and reports issues such as "missing class/method". It's possible to ignore those issues by acknowledging them like this, to indicate you the breaking change is OK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After the v0.5.0 release, we can run mimaReportBinaryIssues in CI so that PRs will need to document the breaking changes in the public API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks. And what about this specific line?
Why are we ignoring that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It really shouldn't be there, I kept it as an example of how to filter out errors. I'll remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok, got it!

)
}
}
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.4")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.17")
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.6.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value
6 changes: 3 additions & 3 deletions readme/Installation.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
The sbt-plugin is the recommended integration for semantic rewrites.

@hl.scala
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "@V.stable")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "@V.stableVersion")

@ul
@li
Expand All @@ -31,7 +31,7 @@
@sect{scalafix-core}
Scalafix can be used as a library to run custom rewrites.
@hl.scala
libraryDependencies += "ch.epfl.scala" % "scalafix-core" % "@V.stable" cross CrossVersion.full
libraryDependencies += "ch.epfl.scala" % "scalafix-core" % "@V.stableVersion" cross CrossVersion.full


By using scalafix as a library, you have full control of how/when/where
Expand Down Expand Up @@ -64,7 +64,7 @@

@hl.scala
// coursier
coursier bootstrap ch.epfl.scala:scalafix-cli_@(V.scalaVersion):@(V.stable) -f --main scalafix.cli.Cli -o scalafix
coursier bootstrap ch.epfl.scala:scalafix-cli_@(V.scalaVersion):@(V.stableVersion) -f --main scalafix.cli.Cli -o scalafix
./scalafix --help

// homebrew
Expand Down
2 changes: 1 addition & 1 deletion readme/Readme.scalatex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import Main._
@import scalafix.Readme._

@sect("Scalafix - a Scala rewrite tool", scalafix.Versions.stable)
@sect("Scalafix - a Scala rewrite tool", scalafix.Versions.stableVersion)
@scalatex.Intro()
@scalatex.Installation()
@scalatex.Configuration()
Expand Down
2 changes: 1 addition & 1 deletion readme/Testkit.scalatex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
lazy val tests = project
.in(file("scalafix/tests"))
.settings(
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % "@V.stable" % Test cross CrossVersion.full,
libraryDependencies += "ch.epfl.scala" % "scalafix-testkit" % "@V.stableVersion" % Test cross CrossVersion.full,
buildInfoPackage := "myproject.scalafix.tests",
buildInfoKeys := Seq[BuildInfoKey](
"inputSourceroot" ->
Expand Down
6 changes: 3 additions & 3 deletions readme/src/main/scala/scalafix/Readme.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scalafix
import metaconfig._, typesafeconfig._
import scala.meta.inputs.Input
import scalafix.config.ScalafixMetaconfigReaders
import scalafix.reflect.ScalafixCompilerDecoder
import scalafix.reflect.ScalafixReflect
import scalatags.Text.TypedTag
import scalatags.Text.all._
import scalatex.site.Highlighter
Expand All @@ -28,13 +28,13 @@ object Readme {
def config(str: String): TypedTag[String] = {
// assert that config listings in docs is free of typos.
ScalafixMetaconfigReaders
.scalafixConfigConfDecoder(ScalafixCompilerDecoder.syntactic)
.scalafixConfigConfDecoder(ScalafixReflect.syntactic)
.read(Input.String(str).toConf.get)
.get
highlight.scala(str)
}
def githubSyntax(path: String) =
reflect.ScalafixCompilerDecoder.GitHubUrlRewrite
internal.reflect.ScalafixCompilerDecoder.GitHubUrlRewrite
.unapply(Conf.Str(s"github:$path"))
.get
}
4 changes: 3 additions & 1 deletion scalafix-cli/src/main/scala/scalafix/cli/Cli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import scala.meta.Database
import scala.meta.io.AbsolutePath
import scalafix.cli.CliCommand.PrintAndExit
import scalafix.cli.CliCommand.RunScalafix
import scalafix.internal.cli.CommonOptions
import scalafix.internal.cli.ScalafixOptions
import scalafix.rewrite.ScalafixRewrites
import caseapp.Name
import caseapp.core.Arg
Expand All @@ -16,7 +18,7 @@ import metaconfig.Configured.NotOk
import metaconfig.Configured.Ok

object Cli {
import ArgParserImplicits._
import scalafix.internal.cli.ArgParserImplicits._
private val withHelp: Messages[WithHelp[ScalafixOptions]] =
OptionsMessages.copy(optionsDesc = "[options] [<file>...]").withHelp
val helpMessage: String = withHelp.helpMessage +
Expand Down
10 changes: 7 additions & 3 deletions scalafix-cli/src/main/scala/scalafix/cli/CliRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import scala.meta.internal.semantic.vfs
import scala.meta.io.AbsolutePath
import scala.util.Try
import scala.util.control.NonFatal
import scalafix.cli.termdisplay.TermDisplay
import scalafix.config.Class2Hocon
import scalafix.config.FilterMatcher
import scalafix.config.LazyMirror
Expand All @@ -31,7 +30,12 @@ import scalafix.config.PrintStreamReporter
import scalafix.config.RewriteKind
import scalafix.config.ScalafixConfig
import scalafix.config.ScalafixReporter
import scalafix.reflect.ScalafixCompilerDecoder
import scalafix.internal.cli.CommonOptions
import scalafix.internal.cli.FixFile
import scalafix.internal.cli.ScalafixOptions
import scalafix.internal.cli.TermDisplay
import scalafix.internal.cli.WriteMode
import scalafix.reflect.ScalafixReflect
import scalafix.syntax._
import metaconfig.Configured.NotOk
import metaconfig.Configured.Ok
Expand Down Expand Up @@ -351,7 +355,7 @@ object CliRunner {
// - .scalafix.conf in working directory
// - ScalafixConfig.default
val resolvedRewriteAndConfig: Configured[(Rewrite, ScalafixConfig)] = {
val decoder = ScalafixCompilerDecoder.fromMirror(lazyMirror)
val decoder = ScalafixReflect.fromLazyMirror(lazyMirror)
for {
inputs <- fixFiles
configuration <- {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package scalafix
package cli
package scalafix.internal.cli

import java.io.InputStream
import java.io.PrintStream

import caseapp.core.ArgParser
import caseapp.core.Messages
import caseapp.core.Parser
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scalafix.cli
package scalafix.internal.cli

import java.io.File

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scalafix.cli
package scalafix.internal.cli

import java.io.File
import scala.meta.Input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package scalafix
package cli
package scalafix.internal.cli

import java.io.File
import java.io.InputStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
* which in turn was copy/pasted from (MIT licence)
* https://github.com/lihaoyi/Ammonite/blob/10854e3b8b454a74198058ba258734a17af32023/terminal/src/main/scala/ammonite/terminal/Utils.scala
*/
package scalafix.cli.termdisplay

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.util.Try
package scalafix.internal.cli

import java.io.File
import java.io.Writer
import java.sql.Timestamp
import java.util.concurrent._
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.util.Try

object Terminal {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scalafix.cli
package scalafix.internal.cli

sealed abstract class WriteMode {
def isWriteFile: Boolean = this == WriteMode.WriteFile
Expand All @@ -7,4 +7,4 @@ sealed abstract class WriteMode {
object WriteMode {
case object WriteFile extends WriteMode
case object Stdout extends WriteMode
}
}
4 changes: 3 additions & 1 deletion scalafix-cli/src/test/scala/scalafix/cli/CliTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import scala.collection.immutable.Seq
import scala.meta.io.AbsolutePath
import scalafix.cli.CliCommand.PrintAndExit
import scalafix.cli.CliCommand.RunScalafix
import scalafix.internal.cli.CommonOptions
import scalafix.internal.cli.ScalafixOptions
import scalafix.internal.util.FileOps
import scalafix.rewrite.ExplicitReturnTypes
import scalafix.rewrite.ProcedureSyntax
import scalafix.testkit.DiffAssertions
import scalafix.util.FileOps
import org.scalatest.FunSuite

trait ScalafixCliTest extends FunSuite with DiffAssertions {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package scalafix.config

import scalafix.util.Severity
import scala.meta.Position
import scala.meta.internal.inputs.XtensionPointFormatMessage

import java.io.PrintStream

import scalafix.internal.util.Severity
import metaconfig.Recurse
import metaconfig._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.util.Try
import scala.util.matching.Regex
import scalafix.patch.TreePatch._
import scalafix.rewrite.ScalafixRewrites
import scalafix.util.ClassloadRewrite
import scalafix.internal.util.ClassloadRewrite
import java.io.OutputStream
import java.io.PrintStream
import java.net.URI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package scalafix.config

import scala.meta.Position
import scalafix.util.Severity

import scalafix.internal.util.Severity
import metaconfig.ConfDecoder

trait ScalafixReporter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package scalafix.patch
package scalafix.internal.patch

import scala.collection.immutable.Seq
import scala.collection.mutable
import scala.meta._
import scala.meta.tokens.Token.Comment
import scala.meta.tokens.Token.KwImport
import scalafix.config.FilterMatcher
import scalafix.patch.Patch
import scalafix.patch.TokenPatch
import scalafix.patch.TreePatch
import scalafix.patch.TreePatch.ImportPatch
import scalafix.rewrite.RewriteCtx
import scalafix.syntax._
import scalafix.util.Newline
import scalafix.util.Whitespace
import org.scalameta.logger

object ImportPatchOps {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package scalafix.patch
package scalafix.internal.patch

import scalafix.syntax._
import scala.meta._
import scala.collection.immutable.Seq
import scalafix.patch.TreePatch._
import scala.meta._
import scalafix.patch.Patch
import scalafix.patch.TokenPatch
import scalafix.patch.TokenPatch._
import scala.util.Try
import scalafix.rewrite.RewriteCtx
import scalafix.patch.TreePatch.AddGlobalImport

import org.scalameta.logger
import scalafix.patch.TreePatch._
import scalafix.rewrite.RewriteCtx
import scalafix.syntax._

private[this] class Replacer(implicit ctx: RewriteCtx, mirror: Mirror) {
object `:withSymbol:` {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package scalafix
package util
package scalafix.internal.util

import java.lang.reflect.InvocationTargetException
import scala.meta.semantic.Mirror
import scala.reflect.ClassTag
import scala.util.Failure
import scala.util.Success
import scala.util.Try

import java.lang.reflect.InvocationTargetException

import scalafix.Rewrite
import metaconfig.ConfError
import metaconfig.Configured

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package scalafix.util
package scalafix.internal.util

import scala.collection.immutable.Seq
object CollectionOps {
def partition[A, B](coll: Seq[A])(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scalafix.util
package scalafix.internal.util

import java.io.BufferedReader
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package scalafix.util
package scalafix.internal.util

import scalafix.config.ReaderUtil

import metaconfig.ConfDecoder

sealed abstract class Severity(color: String, val order: Int)(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scalafix.util
package scalafix.internal.util

import scala.meta.Token

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import scalafix.patch.TokenPatch.Remove
import scalafix.patch.TreePatch.ImportPatch
import scalafix.patch.TreePatch.RenamePatch
import scalafix.patch.TreePatch.Replace
import scalafix.util.TokenOps
import scalafix.diff.DiffUtils
import scalafix.internal.patch.ImportPatchOps
import scalafix.internal.patch.Renamer
import scalafix.internal.patch.Replacer
import scalafix.internal.util.TokenOps

/** A data structure that can produce a .patch file.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scalafix.util

import scala.meta._
import scalafix.util.TokenOps._
import scalafix.internal.util.TokenOps._
import tokens.Token._

sealed abstract class MatchingParens(map: Map[TokenHash, Token]) {
Expand Down

This file was deleted.

Loading