public class PoorMansCStyleSourceFormatter
extends java.lang.Object
Cleans up C style source code generated by a string template engine.
Ideally, we prefer to use a grammar aware formatter for all target languages.
For C Style languages where we can't find something something good, we'll use these basic
heuristics:
- To sanitize whitespace, collapse consecutive empty lines to a single empty line.
- To keep doc strings and annotations directly above class and field definitions, collapse any
empty lines after a line starting with '*' or '@'.
- Auto-indent '{', '}' delimited code blocks correctly so long as '{' is always the last and '}'
is always the first non-whitespace char on a line.
- Removes any tailing whitespace from the ends of lines.
- Treat all lines starting with a '*' as a continuation of a doc string and indents them
one additional space.
This routine only modifies whitespace that is either on an empty line or that precedes or trails
the code on any particular line. The code from the fist non-whitespace character to the last on
each line of code is left unmodified.