I noticed the eclipse indenter has support for the latest version of java, and it would be nice if I could use that class to indent generated java source code. Is there a way of integrating it ?
EDIT: I need to be able to include the code formatter in my code. No external calls.
EDIT2: I’ve managed to get it working. You can read the story here. Thanks VonC !
You can try running the formatter as a standalone application (also detailed here).
Try first to define formatting settings with eclipse IDE in order to achieve the right result, then export those settings, and use that configuration file in the eclipse.exe parameters.
Or see also “Generating a Config File for the Formatter Application”
In a java program, you can try to directly format by:
CodeFormatterformat(aString)on this instance to format aString. It will return the formatted string.Thanks to Geo himself and his report in his blog entry, I now know you need to use
DefaultCodeFormatterAgain, full details in the blog entry. Thank you Geo for that feedback!
Thorbjørn Ravn Andersen mentions in the comments: