Wrap

Controls the wrapping behavior of comments.

Single-line comments

When enabled, Jalopy tries to ensure that single-line comments do not exceed the maximal line length.

Since 1.0.3

Example 2.762. A long single-line comment

                            |
// this is a long comment so I would like it to wrap
                            |

Example 2.763. A long single-line comment that was wrapped

                            |
// this is a long comment so|
// I would like it to wrap  |
                            |

Reflow

By default, wrapping happens on a line-by-line basis, i.e. every line that would exceed the maximal length will be split and the resulting chunks will be each printed on a line of its own. To put it in another way: all existing line breaks are kept. This is no problem with a single comment, but when there are multiple comments in row, wrapping may leave annoying artifacts like in the example below.

Since 1.0.3

Example 2.764. Wrapped single-line comments

// when comments are reflowed (both single and multi-line), empty  |
// comment lines are kept to allow some                            |
// sort of control how things are broke up                         |
//                                                                 |
// otherwise it might be very dangerous to use this feature.       |
// The choice is yours                                             |

A better strategy might be to ignore existing line breaks and have the comments reflowed.

Example 2.765. Reflowed single-line comments

// when comments are reflowed (both single and multi-line), empty  |
// comment lines are kept to allow some sort of control how things |
// are broke up                                                    |
//                                                                 |
// otherwise it might be very dangerous to use this feature. The   |
// choice is yours                                                 |

Please note that existing blank lines are always kept!

Multi-line comments

When enabled, ensures that multi-line comments do not exceed the maximal line length.

Since 1.0.3

Example 2.766. A long multi-line comment

                            |
/* A multi-line comment that spans multiple lines but exceeds the max.
 * line length              |
 */                         |
                            |

Example 2.767. A long multi-line comment that was wrapped

                            |
/* A multi-line comment that|
 * spans multiple lines but |
 * exceeds the max.         |
 * line length              |
 */                         |
                            |

Please note that as of Jalopy 1.6 you can disable wrapping of individual comments using the special /*- delimiter.

Example 2.768. Multi-line comment that keeps its style

/*- Comment that
* should NOT
* be wrapped
*/

Reflow

Works similar to single-line comments (see Reflow single-line comments).

Since 1.0.3

Example 2.769. A long multi-line comment that was reflowed

                            |
/* A multi-line comment that|
 * spans multiple lines but |
 * exceeds the max. line    |
 * length                   |
 */                         |
                            |

Compare this to the result of Example 2.767, “A long multi-line comment that was wrapped” and see how the last two lines differ.

Wrap comments when line length greater than

Lets you define the maximal column width that comments are allowed to use. Jalopy keeps the comments within this range. This option is only available with either “Wrap single-line comments” or “Wrap multi-line comments” enabled. Please note that this setting only covers non-Javadoc comments. Javadoc comments are controlled independently, see “Javadoc line length”.

Since 1.6

Only wrap when space greater than

Lets you define the minimal amount of horizontal space that is required to let wrapping occur. This is the space between the current line offset and the maximal line length as defined above (see “Comment Line Length”). If the difference between these two boundaries is greater than the specified lower bound, wrapping occurs. In contrast, if the difference between current offset and maximal line length is smaller or equal to the specified lower bound, no wrapping will occur.

Please note that this option is only available with either “Wrap single-line comments” or “Wrap multi-line comments” enabled.

Since 1.0.3

Example 2.770. Insufficient space, wrapping impossible

                            |                              |    |
System.out.println("Hello");|// quite a long endline comment that
                            |// appears after the statement     |
                            |                              |    |
                            O                              M    

In the above example the space between the current column offset [O] and the maximal line length [M] is smaller than the specified minimal width (space between [O] and [S]), therefore wrapping is not possible.

Example 2.771. Sufficient space, wrapping possible

                            |                         |    |
System.out.println("Hello");|// quite a long endline  |    |
                            |// comment that appears after |
                            |// the statement         |    |
                            |                         |    |
                            O                         S    

In the above example the space between the current column offset [O] and the maximal line length [M] is greater than the specified minimal width (space between [O] and [S]), therefore wrapping is performed.