Make a delombok pretty mode #643

Closed
lombokissues opened this Issue Jul 14, 2015 · 13 comments

Projects

None yet

1 participant

@lombokissues
Collaborator

Migrated from Google Code (issue 608)

@lombokissues
Collaborator

👤 r.spilker   🕗 Nov 20, 2013 at 01:09 UTC

Delombok currently generates code that's great to be processed by other tooling, but not so good for either migrating from lombok or rendering on a website.

Some issues are already logged to make this better, others can be added to this issue:

  • Indentation by tabs or number of spaces (issue #639)
  • Indentation of otherwise empty lines (issue #638)
  • Suppress generation of @ ConstructorProperties (issue #640)
  • Suppress @ SuppressWarnings("all") (issue #214)
  • Suppress generation of delombok header comment
  • Suppress "java.lang." for types in java.lang
  • Have a more readable null-check in @ Cleanup
  • Suppress "final" for generated code except where obviously intended (val, @ Value, ...)
  • Use shorthand for exact import type matches
@lombokissues
Collaborator

👤 r.spilker   🕗 Nov 20, 2013 at 01:31 UTC

Other things to be fixed in the pretty printer, regardless of any switch:

  • In try-with-resources in the list of resources, improve the rendering of multiple declarations, suppress "final" and the trailing semicolon.
  • After case-statements, if it is followed by a block, render the opening brace on the same line
  • Improve the rendering of labeled statements
  • Don't render an empty line for the suppressed "super();" statement in constructors
@lombokissues
Collaborator

👤 reinierz   🕗 Nov 20, 2013 at 19:28 UTC

Done so far (branch: pretty-delombok):

  • Try-with-resources cleaned up.
  • labelled statements cleanup
  • super(); empty line suppression.
  • infrastructure for conveying (via delombok commandline) and referencing format parameters.
  • auto-detect and application of indent-or-blank empty lines behaviour.
  • auto-detect and application of indent string (tabs, 4 spaces, etc) behaviour.
@lombokissues
Collaborator

👤 reinierz   🕗 Nov 21, 2013 at 02:05 UTC

Tricky addition: Can we do some voodoo magic and truly copy-and-paste as many things that are in the original source file as possible? Presumably any node in the tree for which the rule holds nor it, nor any of its children (recursive) are generated or modified, can be copy-pasted straight from the source by using the start/end markers. I'm not sure how reliable the start/end markers are (they mostly aren't, IIRC, only lombok.ast offers start/end positions that are all-inclusive), so this might not be feasible, but would be a nice addition to have delombok's impact reduced to an absolute minimum.

@lombokissues
Collaborator

👤 r.spilker   🕗 Dec 11, 2013 at 20:16 UTC

Issue #640 has been merged into this issue.

@lombokissues
Collaborator

👤 r.spilker   🕗 Dec 11, 2013 at 20:31 UTC

Issue #639 has been merged into this issue.

@lombokissues
Collaborator

👤 r.spilker   🕗 Dec 11, 2013 at 20:32 UTC

Issue #638 has been merged into this issue.

@lombokissues
Collaborator

👤 r.spilker   🕗 Dec 11, 2013 at 20:32 UTC

Issue #214 has been merged into this issue.

@lombokissues
Collaborator

👤 reinierz   🕗 Dec 11, 2013 at 21:47 UTC

... and it's live! At least in edge:

https://projectlombok.org/download-edge.html

give it a spin!

@lombokissues
Collaborator

👤 reinierz   🕗 Jan 15, 2014 at 21:27 UTC

This fix is now part of the latest official release. 1.12.4 was just pushed for download and to maven central.

@lombokissues
Collaborator

👤 cbeams   🕗 Mar 23, 2014 at 17:41 UTC

I've just tried 1.12.4 out, and it's looking really nice. The auto-detection of spaces v. tabs is working as expected, and I now get clean diffs. Thank you!

I'm still seeing lots of @ SuppressWarnings and @ ConstructorParameters, however. Are this indeed able to be shut off now?

@lombokissues
Collaborator

👤 r.spilker   🕗 Mar 26, 2014 at 19:23 UTC

You can turn these off via the prettyprint settings.

run:

java -jar lombok.jar delombok --format-help

for more info. I think you're looking for:

java -jar lombok.jar delombok -f pretty -f constructorProperties:skip

There's a mention of --format-help on the delombok page, which may contain a few other relevant sections. That page is here:

https://projectlombok.org/features/delombok.html

@lombokissues
Collaborator

End of migration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment