diff options
author | Stewart Stewart <stewinsalot@gmail.com> | 2017-02-23 13:58:00 -0500 |
---|---|---|
committer | Stewart Stewart <stewinsalot@gmail.com> | 2017-02-23 13:58:00 -0500 |
commit | fc53279b51f4be08b4bed7dca7bf427b116874ea (patch) | |
tree | adb5935de0b9b77574fd4d93eb55f0f2f3549d25 | |
parent | 9d25f129826b4fced8726c27f1be8c3aa6387a4b (diff) | |
download | slick-codegen-plugin-fc53279b51f4be08b4bed7dca7bf427b116874ea.tar.gz slick-codegen-plugin-fc53279b51f4be08b4bed7dca7bf427b116874ea.tar.bz2 slick-codegen-plugin-fc53279b51f4be08b4bed7dca7bf427b116874ea.zip |
scalafmt
-rw-r--r-- | src/main/scala/NamespacedCodegen.scala | 158 |
1 files changed, 81 insertions, 77 deletions
diff --git a/src/main/scala/NamespacedCodegen.scala b/src/main/scala/NamespacedCodegen.scala index 7dd99cc..bdb9fc6 100644 --- a/src/main/scala/NamespacedCodegen.scala +++ b/src/main/scala/NamespacedCodegen.scala @@ -5,10 +5,7 @@ import scala.concurrent.Await import scala.concurrent.duration.Duration import scala.concurrent.ExecutionContext.Implicits.global import slick.backend.DatabaseConfig -import slick.codegen.{ - SourceCodeGenerator, - StringGeneratorHelpers -} +import slick.codegen.{SourceCodeGenerator, StringGeneratorHelpers} import slick.dbio.DBIO import slick.driver.JdbcProfile import slick.jdbc.meta.MTable @@ -50,35 +47,35 @@ object Generator { Duration.Inf) val tableGenerator = new TableGenerator(pkg, - dbModel, - schemaOnlyModel, - manualForeignKeys, - parentType, - idType, - header, - schemaImports, - typeReplacements, - schemaName) + dbModel, + schemaOnlyModel, + manualForeignKeys, + parentType, + idType, + header, + schemaImports, + typeReplacements, + schemaName) tableGenerator.writeToFile(profile = profile, - folder = outputPath, - pkg = pkg, - container = schemaName, - fileName = s"${schemaName}.scala") + folder = outputPath, + pkg = pkg, + container = schemaName, + fileName = s"${schemaName}.scala") val rowGenerator = new RowGenerator(pkg, - dbModel, - schemaOnlyModel, - manualForeignKeys, - parentType, - idType, - header, - schemaImports, - typeReplacements) - rowGenerator.writeToFile( - schemaName = schemaName, - folder = outputPath, - pkg = pkg, - fileName = s"${schemaName.capitalize}Rows.scala") + dbModel, + schemaOnlyModel, + manualForeignKeys, + parentType, + idType, + header, + schemaImports, + typeReplacements) + rowGenerator.writeToFile(schemaName = schemaName, + folder = outputPath, + pkg = pkg, + fileName = + s"${schemaName.capitalize}Rows.scala") } } finally { dc.db.close() @@ -87,15 +84,16 @@ object Generator { } -abstract class Generator(pkg: String, - fullDatabaseModel: Model, - schemaOnlyModel: Model, - manualForeignKeys: Map[(String, String), (String, String)], - override val parentType: Option[String], - idType: Option[String], - override val headerComment: String, - schemaImports: List[String], - typeReplacements: Map[String, String]) +abstract class Generator( + pkg: String, + fullDatabaseModel: Model, + schemaOnlyModel: Model, + manualForeignKeys: Map[(String, String), (String, String)], + override val parentType: Option[String], + idType: Option[String], + override val headerComment: String, + schemaImports: List[String], + typeReplacements: Map[String, String]) extends SourceCodeGenerator(schemaOnlyModel) with OutputHelpers { @@ -116,7 +114,7 @@ abstract class Generator(pkg: String, // TODO: fix upstream override def Table = new TableO(_) - + class TableO(model: sModel.Table) extends this.Table(model) { table => override def TableClass = new TableClass() { @@ -280,23 +278,23 @@ object SchemaParser { } class RowGenerator(pkg: String, - fullDatabaseModel: Model, - schemaOnlyModel: Model, - manualForeignKeys: Map[(String, String), (String, String)], - override val parentType: Option[String], - idType: Option[String], - override val headerComment: String, - schemaImports: List[String], - typeReplacements: Map[String, String]) + fullDatabaseModel: Model, + schemaOnlyModel: Model, + manualForeignKeys: Map[(String, String), (String, String)], + override val parentType: Option[String], + idType: Option[String], + override val headerComment: String, + schemaImports: List[String], + typeReplacements: Map[String, String]) extends Generator(pkg, - fullDatabaseModel, - schemaOnlyModel, - manualForeignKeys, - parentType, - idType, - headerComment, - schemaImports, - typeReplacements) { + fullDatabaseModel, + schemaOnlyModel, + manualForeignKeys, + parentType, + idType, + headerComment, + schemaImports, + typeReplacements) { override def Table = new TableO(_) { //override def Column = new IdColumn(_){ } @@ -305,8 +303,14 @@ class RowGenerator(pkg: String, override def code = tables.map(_.code.mkString("\n")).mkString("\n\n") - def writeToFile(schemaName: String, folder: String, pkg: String, fileName: String) = { - writeStringToFile(packageCode(pkg, schemaName), folder = folder, pkg = pkg, fileName = fileName) + def writeToFile(schemaName: String, + folder: String, + pkg: String, + fileName: String) = { + writeStringToFile(packageCode(pkg, schemaName), + folder = folder, + pkg = pkg, + fileName = fileName) } override val imports = schemaImports.map("import " + _).mkString("\n") @@ -326,26 +330,26 @@ class RowGenerator(pkg: String, //override def writeToFile(profile: String, folder: String, pkg: String, container: String, fileName: String) = ??? } -class TableGenerator(pkg: String, - fullDatabaseModel: Model, - schemaOnlyModel: Model, - manualForeignKeys: Map[(String, String), (String, String)], - override val parentType: Option[String], - idType: Option[String], - override val headerComment: String, - schemaImports: List[String], - typeReplacements: Map[String, String], - schemaName: String -) +class TableGenerator( + pkg: String, + fullDatabaseModel: Model, + schemaOnlyModel: Model, + manualForeignKeys: Map[(String, String), (String, String)], + override val parentType: Option[String], + idType: Option[String], + override val headerComment: String, + schemaImports: List[String], + typeReplacements: Map[String, String], + schemaName: String) extends Generator(pkg, - fullDatabaseModel, - schemaOnlyModel, - manualForeignKeys, - parentType, - idType, - headerComment, - schemaImports, - typeReplacements) { + fullDatabaseModel, + schemaOnlyModel, + manualForeignKeys, + parentType, + idType, + headerComment, + schemaImports, + typeReplacements) { override def Table = new TableO(_) { override def EntityType = new EntityType { |