flushCharacters method

void flushCharacters()

Implementation

void flushCharacters() {
  if (characterTokens.isEmpty) return;

  // TODO(sigmund,jmesserly): remove '' (dartbug.com/8480)
  final data = characterTokens.map((t) => t.data).join('');
  FileSpan? span;

  if (parser.generateSpans) {
    span = characterTokens[0].span!.expand(characterTokens.last.span!);
  }

  if (!allWhitespace(data)) {
    parser._inTablePhase.insertText(CharactersToken(data)..span = span);
  } else if (data.isNotEmpty) {
    tree.insertText(data, span);
  }
  characterTokens = <StringToken>[];
}