aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Stewart <stewinsalot@gmail.com>2017-02-24 08:13:45 -0500
committerStewart Stewart <stewinsalot@gmail.com>2017-02-24 08:13:45 -0500
commit73ff2c2e532436d691d7ba169be0482e3dae5851 (patch)
treeb2ecae6cf18eea2d6115d9db1f2897e0fe75c2fa
parent8be11dc3a5920d7a97831c688c06999dd09bfd1b (diff)
downloadslick-codegen-plugin-73ff2c2e532436d691d7ba169be0482e3dae5851.tar.gz
slick-codegen-plugin-73ff2c2e532436d691d7ba169be0482e3dae5851.tar.bz2
slick-codegen-plugin-73ff2c2e532436d691d7ba169be0482e3dae5851.zip
strip out unnecessary parts of table generator
-rw-r--r--src/main/scala/NamespacedCodegen.scala52
-rw-r--r--src/main/scala/OutputHelpers.scala29
2 files changed, 6 insertions, 75 deletions
diff --git a/src/main/scala/NamespacedCodegen.scala b/src/main/scala/NamespacedCodegen.scala
index 16ab383..3f8034e 100644
--- a/src/main/scala/NamespacedCodegen.scala
+++ b/src/main/scala/NamespacedCodegen.scala
@@ -81,20 +81,15 @@ object Generator {
}
-abstract class Generator(
+class TableSourceCodeGenerator(
pkg: String,
fullDatabaseModel: Model,
schemaOnlyModel: Model,
manualForeignKeys: Map[(String, String), (String, String)],
- override val parentType: Option[String],
+ parentType: Option[String],
idType: Option[String],
- override val headerComment: String,
- schemaImports: List[String],
typeReplacements: Map[String, String])
- extends TypedIdSourceCodeGenerator(fullDatabaseModel, idType, manualForeignKeys)
- with OOutputHelpers {
-
- override val imports = schemaImports.map("import " + _).mkString("\n")
+ extends TypedIdSourceCodeGenerator(fullDatabaseModel, idType, manualForeignKeys) {
val defaultIdImplementation =
"""|final case class Id[T](v: Int)
@@ -110,10 +105,7 @@ abstract class Generator(
// Alias to ForeignKeyAction is in profile.api
// TODO: fix upstream
- override def Table = new TableO(_)
-
- class TableO(model: sModel.Table) extends this.TypedIdTable(model) { table =>
-
+ override def Table = new this.TypedIdTable(_) { table =>
override def TableClass = new TableClass() {
// We disable the option mapping, as it is a bit more complex to support and we don't appear to need it
override def optionEnabled = false
@@ -145,13 +137,8 @@ abstract class Generator(
.map("a." + _.name)
.mkString("::") + ":: HNil)"
- override def EntityType = new EntityTypeDef {
- override def code: String =
- // Wartremover wants `final`
- // But can't have the final case class inside the trait
- // TODO: Fix by putting case classes in package or object
- // TODO: Upstream default should be false.
- (if (classEnabled) "final " else "") + super.code
+ override def EntityType = new EntityType {
+ override def enabled = false
}
override def Column = new TypedIdColumn(_) {
@@ -239,30 +226,3 @@ object SchemaParser {
jdbcProfile.createModel(filteredTables)
}
}
-
-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])
- extends Generator(pkg,
- fullDatabaseModel,
- schemaOnlyModel,
- manualForeignKeys,
- parentType,
- idType,
- headerComment,
- schemaImports,
- typeReplacements) {
-
- override def Table = new TableO(_) {
- override def EntityType = new EntityType {
- override def enabled = false
- }
- }
-}
diff --git a/src/main/scala/OutputHelpers.scala b/src/main/scala/OutputHelpers.scala
index c3c5e0d..9e6dd0f 100644
--- a/src/main/scala/OutputHelpers.scala
+++ b/src/main/scala/OutputHelpers.scala
@@ -1,31 +1,3 @@
-trait OOutputHelpers extends slick.codegen.OutputHelpers {
-
- def imports: String
-
- def headerComment: String = ""
-
- override def packageCode(profile: String,
- pkg: String,
- container: String,
- parentType: Option[String]): String = {
- s"""|${headerComment.trim().lines.map("// " + _).mkString("\n")}
- |package $pkg
- |
- |$imports
- |
- |/** Stand-alone Slick data model for immediate use */
- |package object $container extends {
- | val profile = $profile
- |} with Tables
- |
- |/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
- |trait Tables${parentType.fold("")(" extends " + _)} {
- | import profile.api._
- | ${indent(code)}
- |}""".stripMargin.trim()
- }
-}
-
import slick.codegen.{SourceCodeGenerator, OutputHelpers}
trait TableFileGenerator { self: SourceCodeGenerator =>
@@ -36,7 +8,6 @@ trait RowFileGenerator { self: SourceCodeGenerator =>
def writeRowsToFile(folder:String, pkg: String, fileName: String): Unit
}
-// Dirty work to hide OutputHelpers
trait TableOutputHelpers extends TableFileGenerator with OutputHelpers { self: SourceCodeGenerator =>
def headerComment: String