Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes ScalaCaseClassRenderer for #110 #111

Merged
merged 1 commit into from
Aug 2, 2018

Conversation

damdev
Copy link

@damdev damdev commented Dec 24, 2017

Fixes #110

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @damdev! I have a couple of finicky questions about the fix, but by-and-large it looks good!

@@ -17,6 +17,7 @@ case class ScalaCaseClassRenderer(options: Seq[BuildInfoOption], pkg: String, ob
s"package $pkg",
"",
"import scala.Predef._",
"import scala.Any",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is necessary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@@ -5,7 +5,7 @@ case class ScalaCaseClassRenderer(options: Seq[BuildInfoOption], pkg: String, ob
override def extension = "scala"

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 ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this as it, to avoid trailing spaces when there are no traits to mix in.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I understand this change now. (How did I misunderstand??)

private def caseClassEnd = List("}")

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(",")})",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you want to switch to using named parameters here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just see the generated code more clear than a whole line with the values.

@damdev
Copy link
Author

damdev commented Aug 2, 2018

Hi, what do you think about this PR? @dwijnand
I can change the named params if you don't like, it will be really useful to fix this bug, we are using a fork of this plugin waiting for this PR.
Thanks!

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! LGTM

@@ -5,7 +5,7 @@ case class ScalaCaseClassRenderer(options: Seq[BuildInfoOption], pkg: String, ob
override def extension = "scala"

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 ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I understand this change now. (How did I misunderstand??)

@dwijnand dwijnand merged commit 21b33ec into sbt:master Aug 2, 2018
@dwijnand
Copy link
Member

dwijnand commented Aug 2, 2018

I won't have time to publish the plugin for a while, though. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation error using ScalaCaseClassRenderer and traits
2 participants