Skip to content

Fixes ScalaCaseClassRenderer for #110#111

Merged
dwijnand merged 1 commit intosbt:masterfrom
damdev:fix-caseclassrenderer-issue110
Aug 2, 2018
Merged

Fixes ScalaCaseClassRenderer for #110#111
dwijnand merged 1 commit intosbt:masterfrom
damdev:fix-caseclassrenderer-issue110

Conversation

@damdev
Copy link
Copy Markdown

@damdev damdev commented Dec 24, 2017

Fixes #110

Copy link
Copy Markdown
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!

s"package $pkg",
"",
"import scala.Predef._",
"import scala.Any",
Copy link
Copy Markdown
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
Copy Markdown
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


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
Copy Markdown
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
Copy Markdown
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 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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


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
Copy Markdown
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
Copy Markdown
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