Skip to content

Commit

Permalink
Upgrade to scalafmt 0.6.2 (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg authored Mar 13, 2017
1 parent cf1cec9 commit dccc042
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 42 deletions.
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ lazy val gitPushTag = taskKey[Unit]("Push to git tag")
lazy val release = Command.command("release") { s =>
"clean" ::
"very publishSigned" ::
"sonatypeRelease" ::
"gitPushTag" ::
s
"sonatypeRelease" ::
"gitPushTag" ::
s
}

commands += release
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scalafix/rewrite/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import scalafix.util.Patch

package object rewrite {
type ScalafixRewrite = Rewrite[ScalafixMirror]
val ScalafixRewrite: (RewriteCtx[ScalafixMirror] => Seq[Patch]) => Rewrite[
ScalafixMirror] =
val ScalafixRewrite
: (RewriteCtx[ScalafixMirror] => Seq[Patch]) => Rewrite[ScalafixMirror] =
Rewrite.apply[ScalafixMirror]
type ScalafixCtx = RewriteCtx[ScalafixMirror]
type SyntaxRewrite = Rewrite[Any]
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scalafix/util/CanonicalImport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object CanonicalImport {
renames,
leadingComments = ctx.comments.leading(ownerImport),
trailingComments = ctx.comments.trailing(ownerImport) ++
(wildcard +: unimports).flatMap(ctx.comments.trailing),
(wildcard +: unimports).flatMap(ctx.comments.trailing),
None
) {}
def fromImportee(ref: Term.Ref, importee: Importee)(
Expand All @@ -36,7 +36,7 @@ object CanonicalImport {
Nil,
leadingComments = ctx.comments.leading(ownerImport),
trailingComments = ctx.comments.trailing(ownerImport) ++
ctx.comments.trailing(importee),
ctx.comments.trailing(importee),
None
) {}
}
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/scala/scalafix/util/Replacer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ private[this] class Replacer(implicit ctx: RewriteCtx[Mirror]) {
x.from == symbol
}
.toList
.flatMap(replace =>
TokenPatch.AddLeft(ref.tokens.head, replace.to.syntax) +:
(ref.tokens.map(TokenPatch.Remove.apply) ++
.flatMap(
replace =>
TokenPatch.AddLeft(ref.tokens.head, replace.to.syntax) +:
(ref.tokens.map(TokenPatch.Remove.apply) ++
replace.additionalImports.map(x => AddGlobalImport(x))))
case imp: Import => // Do nothing
case _ => super.apply(tree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import scala.language.higherKinds
import scala.tools.nsc.typechecker.Contexts

trait HijackImportInfos { self: ReflectToolkit =>
val allUsedSelectors: NonRemovableMap[g.analyzer.ImportInfo,
Set[g.ImportSelector]] =
val allUsedSelectors
: NonRemovableMap[g.analyzer.ImportInfo, Set[g.ImportSelector]] =
new NonRemovableMap[g.analyzer.ImportInfo, Set[g.ImportSelector]](Set())
val allImportInfos: NonRemovableMap[g.CompilationUnit,
List[g.analyzer.ImportInfo]] =
val allImportInfos
: NonRemovableMap[g.CompilationUnit, List[g.analyzer.ImportInfo]] =
new NonRemovableMap[g.CompilationUnit, List[g.analyzer.ImportInfo]](Nil)

/** overrides private lazy maps in g.analyzer's Contexts with custom maps */
Expand Down
6 changes: 3 additions & 3 deletions scalafix-sbt/src/main/scala/scalafix/sbt/ScalafixPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ object ScalafixPlugin extends AutoPlugin with ScalafixKeys {
val scalafix: Command = Command.command("scalafix") { state =>
s"set scalafixEnabled in Global := true" ::
"clean" ::
"test:compile" ::
s"set scalafixEnabled in Global := false" ::
state
"test:compile" ::
s"set scalafixEnabled in Global := false" ::
state
}

override def globalSettings: Seq[Def.Setting[_]] = Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ object ScalafixTestUtility {
private def calcDiff(expected: String, obtained: String): Option[String] = {
import scala.collection.JavaConverters._

if (expected == obtained) None else {
if (expected == obtained) None
else {
def jLinesOf(s: String) = s.lines.toSeq.asJava

val expectedLines = jLinesOf(expected)
val obtainedLines = jLinesOf(obtained)

val diff = DiffUtils.diff(expectedLines, obtainedLines)
val unifiedDiff = DiffUtils.generateUnifiedDiff("expected", "obtained", expectedLines, diff, 1)
val unifiedDiff = DiffUtils.generateUnifiedDiff("expected",
"obtained",
expectedLines,
diff,
1)

Some(unifiedDiff.asScala.drop(3).mkString("\n"))
}
Expand All @@ -33,25 +38,27 @@ object ScalafixTestUtility {
))
).trim

calcDiff(expected, obtained).map { diff =>
val msg =
s"""File: $file
|Obtained output:
|----------------
|$obtained
|Expected:
|---------
|$expected
|Diff:
|-----
|$diff""".stripMargin

streams.log.error(file)
streams.log.error(msg)
false
}.getOrElse {
streams.log.success(file)
true
}
calcDiff(expected, obtained)
.map { diff =>
val msg =
s"""File: $file
|Obtained output:
|----------------
|$obtained
|Expected:
|---------
|$expected
|Diff:
|-----
|$diff""".stripMargin

streams.log.error(file)
streams.log.error(msg)
false
}
.getOrElse {
streams.log.success(file)
true
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ abstract class IntegrationPropertyTest(t: ItTest, skip: Boolean = false)
val id = s"${t.name}/$cmd"
logger.info(s"Running $id")
val args = Seq(
"sbt",
"++2.11.8"
) ++ cmds.map(_.toString)
"sbt",
"++2.11.8"
) ++ cmds.map(_.toString)
failAfter(maxTime) {
import sys.process._
val status = Process(args, cwd = t.workingPath.toIO).!
Expand Down
Binary file modified scalafmt
Binary file not shown.

0 comments on commit dccc042

Please sign in to comment.