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

fix rendering of field names with backticks #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fwbrasil
Copy link

@fwbrasil fwbrasil commented Dec 30, 2023

Problem

I've been using PPrint with case classes that contain text field names using backticks, which are currently rendered incorrectly:

case class Test(`with backticks`: Boolean, withoutBackticks: Boolean)
println(pprint(Test(true, false)).plainText)

Outputs both field names without backticks:

Test(with backticks = true, withoutBackticks = false)

It should print:

Test(`with backticks` = true, withoutBackticks = false)

Solution

Change ProductSupport to add backticks in case the field name isn't a regular identifier.

Notes

  • The identifier check is based on the implementation in Scala 3. I believe it hasn't changed from Scala 2.
  • The ProductSupport class seems identical in Scala 2 and 3. Should change it to use a single implementation for both?
  • I wasn't able to run the build locally. What command should I use? ./mill and sbt compile both fail.

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.

1 participant