Fixes ScalaCaseClassRenderer for #110#111
Conversation
| s"package $pkg", | ||
| "", | ||
| "import scala.Predef._", | ||
| "import scala.Any", |
There was a problem hiding this comment.
Can you explain why this is necessary?
There was a problem hiding this comment.
When running the scripted test I was having this error /tmp/sbt_4647108f/caseclassrenderer/target/scala-2.11/src_managed/main/sbt-buildinfo/BuildInfo.scala:8: not found: type Any
Searching into this I found this may be related bug sbt/sbt#2572
|
|
||
| val traitNames = options.collect{case BuildInfoOption.Traits(ts @ _*) => ts}.flatten | ||
| val objTraits = if (traitNames.isEmpty) "" else " extends " ++ traitNames.mkString(" with ") | ||
| val objTraits = if (traitNames.isEmpty) "" else "extends " ++ traitNames.mkString(" with ") |
There was a problem hiding this comment.
I think we should keep this as it, to avoid trailing spaces when there are no traits to mix in.
There was a problem hiding this comment.
Ah I understand this change now. (How did I misunderstand??)
| private def caseObjectLine(buildInfoResults: Seq[BuildInfoResult]) = List( | ||
| s"case object $obj {", | ||
| s" def apply(): $obj = new $obj(${buildInfoResults.map(_.value).map(quote).mkString(",")})", | ||
| s" def apply(): $obj = new $obj(${buildInfoResults.map(r => s"\n ${r.identifier} = ${quote(r.value)}").mkString(",")})", |
There was a problem hiding this comment.
Could you explain why you want to switch to using named parameters here?
There was a problem hiding this comment.
I just see the generated code more clear than a whole line with the values.
|
Hi, what do you think about this PR? @dwijnand |
|
|
||
| val traitNames = options.collect{case BuildInfoOption.Traits(ts @ _*) => ts}.flatten | ||
| val objTraits = if (traitNames.isEmpty) "" else " extends " ++ traitNames.mkString(" with ") | ||
| val objTraits = if (traitNames.isEmpty) "" else "extends " ++ traitNames.mkString(" with ") |
There was a problem hiding this comment.
Ah I understand this change now. (How did I misunderstand??)
|
I won't have time to publish the plugin for a while, though. Sorry. |
Fixes #110