aboutsummaryrefslogtreecommitdiff
path: root/plugins/scalariform
diff options
context:
space:
mode:
authorNikolay Tatarinov <5min4eq.unity@gmail.com>2016-06-24 02:48:45 +0300
committerJan Christopher Vogt <oss.nsp@cvogt.org>2016-06-23 19:48:45 -0400
commit2cbc42fd0809b60b1ee2116657d18b3f44f8aef1 (patch)
treee894a040137e591c4a7664b7353d709298a44f65 /plugins/scalariform
parent75c32537cd8f29f9d12db37bf06ad942806f0239 (diff)
downloadcbt-2cbc42fd0809b60b1ee2116657d18b3f44f8aef1.tar.gz
cbt-2cbc42fd0809b60b1ee2116657d18b3f44f8aef1.tar.bz2
cbt-2cbc42fd0809b60b1ee2116657d18b3f44f8aef1.zip
Scalafmt plugin implementation (#156)
* scalariform: improve logging, declare tasks final * scalafmt plugin implementation * add scalafmt and scalariform plugins and examples to tests * fix logging guarded logging behaviour * add notes about formatting check to README * fix compilation error in examples
Diffstat (limited to 'plugins/scalariform')
-rw-r--r--plugins/scalariform/Scalariform.scala9
1 files changed, 4 insertions, 5 deletions
diff --git a/plugins/scalariform/Scalariform.scala b/plugins/scalariform/Scalariform.scala
index 1f6e51f..0612469 100644
--- a/plugins/scalariform/Scalariform.scala
+++ b/plugins/scalariform/Scalariform.scala
@@ -4,13 +4,12 @@ import java.io.File
import java.nio.file.FileSystems
import java.nio.file.Files._
-import scala.util.Try
import scalariform.formatter.ScalaFormatter
import scalariform.formatter.preferences.FormattingPreferences
import scalariform.parser.ScalaParserException
trait Scalariform extends BaseBuild {
- def scalariformFormat: ExitCode = {
+ final def scalariformFormat: ExitCode = {
Scalariform.format(sourceFiles, scalariformPreferences, scalaVersion)
ExitCode.Success
}
@@ -35,7 +34,7 @@ object Scalariform {
private val scalaFileMatcher = FileSystems.getDefault.getPathMatcher("glob:**.scala")
- def format(files: Seq[File], preferences: FormattingPreferences, scalaVersion: String) = {
+ def format(files: Seq[File], preferences: FormattingPreferences, scalaVersion: String): Unit = {
var reformattedCount: Int = 0
for (file <- files if file.exists) {
val path = file.toPath
@@ -52,11 +51,11 @@ object Scalariform {
reformattedCount += 1
}
} catch {
- case e: ScalaParserException => System.err.println(s"Scalariform parser error: ${e.getMessage} when formatting source: $file")
+ case e: ScalaParserException => System.err.println(s"Scalariform parser error: ${e.getMessage} when formatting: $file")
}
}
}
- System.err.println(s"Reformatted $reformattedCount Scala sources")
+ if (reformattedCount > 0) System.err.println(s"Formatted $reformattedCount Scala sources")
}
}