This comment processor is used to parse and format comments spanning multiple lines. It is a low-level class that can be used to implement higher order comment formatting strategies.
Comments may be a sequence of single line comments, or a multi line comment. When processing a sequence of single line comments, everything in the passed region to format must be comment text or whitespace - input in this example:
# comment a = 10 # comment b = 20 # comment
will result in something like:
# comment # a = 10 # comment # b = 20 # comment # comment
Usage: An instance of the class is created with an ICommentContext that describes how the comment should be parsed. This context includes the relative starting position of the comment sequence. One of the classes implementing this interface may be used as a convenience. As an example, given the text:
{@code a = 10 / * comment starts here * and continues here, * but is not aligned ok and some lines do not start with the repeating character ∗/}
Is processed by providing the starting line offset 7. When formatting with the same context, the result is:
{@code a = 10 / * comment starts here * and continues here * but is not aligned ok * and some lines do not start with the repeating character ∗/ }
To relocate the comment, or output it in a different style, use a second {@link ICommentContainerInformation} in the format call.The same input example as before can be output to look like this:
{@code a = 10 # # comment starts here # and continues here # but is not aligned ok # and some lines do not start with the repeating character # }
The comment processor has special processing of comment lines that consists of the same repeated character. All such lines are formatted without a left margin, and such lines longer than 5 characters are truncated instead of folded/wrapped when not fitting within the max constraints.
It is possible to constrain trailing empty lines min/max.
Note that the result will contain leading whitespace up to the position passed as the starting position. When appending the text to an existing flow already at this position, the method {@link CharSequences#trimLeft(CharSequence)} can be used to adjust the text to this position.
TODO: Needs to know about the ICommentFormatterAdvice !