copyComments method Null safety

  1. @override
CommentToken? copyComments(
  1. CommentToken? token
)
inherited

Copy a linked list of comment tokens identical to the given comment tokens.

Implementation

@override
CommentToken? copyComments(CommentToken? token) {
  if (token == null) {
    return null;
  }
  CommentToken head = token.copy();
  Token tail = head;
  token = token.next as CommentToken?;
  while (token != null) {
    tail = tail.setNext(token.copy());
    token = token.next as CommentToken?;
  }
  return head;
}