diff options
author | rockjam <rockjam@actor.im> | 2016-10-02 19:34:10 +0300 |
---|---|---|
committer | rockjam <rockjam@actor.im> | 2016-10-02 23:56:34 +0300 |
commit | aea470195de6cb8f0111e5908917d64889f3c753 (patch) | |
tree | 18d537835d16e08afb23706b8546045da4da9f9f /examples | |
parent | 3e35d0809240a3379dd3d71d42655e00b9cff421 (diff) | |
download | cbt-aea470195de6cb8f0111e5908917d64889f3c753.tar.gz cbt-aea470195de6cb8f0111e5908917d64889f3c753.tar.bz2 cbt-aea470195de6cb8f0111e5908917d64889f3c753.zip |
upgrade scalafmt 0.3.1 -> 0.4.2; load scalafmt config from config file
Diffstat (limited to 'examples')
-rw-r--r-- | examples/scalafmt-example/.scalafmt.conf | 11 | ||||
-rw-r--r-- | examples/scalafmt-example/build/build.scala | 9 | ||||
-rw-r--r-- | examples/scalafmt-example/src/Main.scala | 12 |
3 files changed, 22 insertions, 10 deletions
diff --git a/examples/scalafmt-example/.scalafmt.conf b/examples/scalafmt-example/.scalafmt.conf new file mode 100644 index 0000000..4fc0088 --- /dev/null +++ b/examples/scalafmt-example/.scalafmt.conf @@ -0,0 +1,11 @@ +style: defaultWithAlign +danglingParentheses: true + +spaces { + inImportCurlyBraces: true +} + +rewriteTokens { + "->": "→" + "=>": "⇒" +} diff --git a/examples/scalafmt-example/build/build.scala b/examples/scalafmt-example/build/build.scala index b8a819b..4f5545e 100644 --- a/examples/scalafmt-example/build/build.scala +++ b/examples/scalafmt-example/build/build.scala @@ -1,5 +1,4 @@ import cbt._ -import org.scalafmt.ScalafmtStyle class Build(val context: Context) extends BaseBuild with Scalafmt { override def compile = { @@ -7,8 +6,6 @@ class Build(val context: Context) extends BaseBuild with Scalafmt { super.compile } - override def scalafmtConfig: ScalafmtStyle = ScalafmtStyle.defaultWithAlign - def breakFormatting = { import java.nio.file._ import java.nio.charset.Charset @@ -17,7 +14,11 @@ class Build(val context: Context) extends BaseBuild with Scalafmt { sourceFiles foreach { file => val path = file.toPath val fileLines = Files.readAllLines(path, utf8).asScala - val brokenLines = fileLines map (_.dropWhile(_ == ' ')) + val brokenLines = fileLines map (l => + l.dropWhile(_ == ' ') + .replaceAll("⇒", "=>") + .replaceAll("→", "->") + ) Files.write(path, brokenLines.asJava, utf8) } System.err.println("Done breaking formatting") diff --git a/examples/scalafmt-example/src/Main.scala b/examples/scalafmt-example/src/Main.scala index 595cede..465e27a 100644 --- a/examples/scalafmt-example/src/Main.scala +++ b/examples/scalafmt-example/src/Main.scala @@ -1,16 +1,16 @@ -import scala.concurrent.{Await, Future} +import scala.concurrent.{ Await, Future } import scala.concurrent.duration._ object Main extends App { println("fooo") val futureRes = Await.result(Future.successful(1), 5.seconds) List(1, 2, 4, 5, 6) match { - case h :: _ => println("not empty list") - case Nil => println("empty list") + case h :: _ ⇒ println("not empty list") + case Nil ⇒ println("empty list") } - List(1 -> 2, 2 -> 3, 3 -> 4) match { - case (1, 2) :: _ => 90 -> 1 - case (22, 44) :: _ => 1 -> 150 + List(1 → 2, 2 → 3, 3 → 4) match { + case (1, 2) :: _ ⇒ 90 → 1 + case (22, 44) :: _ ⇒ 1 → 150 } } |