diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-27 19:34:20 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-03-28 09:39:16 -0400 |
commit | cf0c79a78924ca15b81494da05af7e0b48fe2c7e (patch) | |
tree | 1aa232fbd9d4e4bdd59d86e0b9e58c28e0a0220b /examples/scalafix-example | |
parent | 2c792df95d36d61c55b07ddfa13387cf79371bdb (diff) | |
download | cbt-cf0c79a78924ca15b81494da05af7e0b48fe2c7e.tar.gz cbt-cf0c79a78924ca15b81494da05af7e0b48fe2c7e.tar.bz2 cbt-cf0c79a78924ca15b81494da05af7e0b48fe2c7e.zip |
add (currently non-working) example how to use it for built-in rewrites
Diffstat (limited to 'examples/scalafix-example')
-rw-r--r-- | examples/scalafix-example/Main.scala | 9 | ||||
-rw-r--r-- | examples/scalafix-example/build/build.scala | 28 | ||||
-rw-r--r-- | examples/scalafix-example/build/build/build.scala | 5 |
3 files changed, 42 insertions, 0 deletions
diff --git a/examples/scalafix-example/Main.scala b/examples/scalafix-example/Main.scala new file mode 100644 index 0000000..c82c77b --- /dev/null +++ b/examples/scalafix-example/Main.scala @@ -0,0 +1,9 @@ +object Main{ + lazy val x = 1 + 1 + + implicit def toString(i :Int) = i.toString + + def main( args: Array[String] ){ + println("Hello world!") + } +} diff --git a/examples/scalafix-example/build/build.scala b/examples/scalafix-example/build/build.scala new file mode 100644 index 0000000..eff4176 --- /dev/null +++ b/examples/scalafix-example/build/build.scala @@ -0,0 +1,28 @@ +import cbt._ + +import scala.meta._ +import scalafix.rewrite._ +import scalafix.util._ +import scalafix.util.TreePatch._ +import scalafix.util.TokenPatch._ + +class Build(val context: Context) extends BaseBuild{ + override def compile = { + new BasicBuild(context) with Scalafix{ + override def scalafix = super.scalafix.copy( + patches = + Seq( + AddGlobalImport( + importer"scala.collection.immutable" + ) + ), + rewrites = Seq( + ProcedureSyntax, + ExplicitImplicit, + VolatileLazyVal + ) + ) + }.scalafix.apply + super.compile // <- as scalafix trigger compile already before re-writing, this will just return the cached compile result before rewriting + } +} diff --git a/examples/scalafix-example/build/build/build.scala b/examples/scalafix-example/build/build/build.scala new file mode 100644 index 0000000..404356f --- /dev/null +++ b/examples/scalafix-example/build/build/build.scala @@ -0,0 +1,5 @@ +import cbt._ + +class Build(val context: Context) extends BuildBuild { + override def dependencies = super.dependencies :+ plugins.scalafix +} |