writeTo method

  1. @override
void writeTo(
  1. Printer printer
)
override

Implements the NestedItem interface.

Implementation

@override
void writeTo(Printer printer) {
  _flush();
  var propagate = false;
  for (var item in _items) {
    if (item is NestedItem) {
      item.writeTo(printer);
    } else if (item is String) {
      printer.add(item, projectMarks: propagate);
      propagate = false;
    } else if (item is SourceLocation || item is SourceSpan) {
      printer.mark(item);
    } else if (item == _original) {
      // we insert booleans when we are about to quote text that was copied
      // from the original source. In such case, we will propagate marks on
      // every new-line.
      propagate = true;
    } else {
      throw UnsupportedError('Unknown item type: $item');
    }
  }
}