writeComment abstract method

void writeComment(
  1. CommentToken? comment, {
  2. String? prefix,
  3. BeforeCommentWrite before = BeforeCommentWrite.nothing,
  4. AfterCommentWrite after = AfterCommentWrite.nothing,
  5. bool indentTrailingNewLine = true,
})

Writes the given comment, if it is not null.

Continues to iterate to the next comment token until there are no more comment tokens or a non-comment token is reached.

The prefix is usually a string of whitespace that represents one level of indentation before the comment.

If indentTrailingNewLine is true, then the trailing new line will be indented to match the prefix plus one level of indentation. Otherwise, the trailing new line will be written with just the prefix.

The before and after parameters control what is written before and after the comment. The after parameter is special in that even with AfterCommentWrite.nothing, a new line will be written if the last comment token is a TokenType.SINGLE_LINE_COMMENT. It mostly controls what will be done if the last comment token is a TokenType.MULTI_LINE_COMMENT.

Implementation

void writeComment(
  CommentToken? comment, {
  String? prefix,
  BeforeCommentWrite before = BeforeCommentWrite.nothing,
  AfterCommentWrite after = AfterCommentWrite.nothing,
  bool indentTrailingNewLine = true,
});