dump method

DumpedCollection dump(
  1. ConcreteNode<Map<Object?, Object?>> mapEntries,
  2. int indent
)

Dumps a sequence of mapEntries with the provided indent of the map.

Implementation

DumpedCollection dump(
  ConcreteNode<Map<Object?, Object?>> mapEntries,
  int indent,
) {
  initialize();
  final ConcreteNode(:dumpable, :tag, :anchor) = mapEntries;
  _reset(iterator: dumpable.entries.iterator, indent: indent);

  do {
    if (_current != null) {
      _dumpCurrent();
      continue;
    } else if (_isRoot) {
      break;
    }

    final mapBefore = _states.removeLast();
    final nested = _dumpedMap.toString();
    final nestedIsExplicit = _preferExplicit(nested);

    _reset(
      iterator: mapBefore.iterator,
      indent: mapBefore.mapIndent,
      isRoot: mapBefore.isRoot,
      isExplicit: mapBefore.preferExplicit,
      lastHadTrailing: mapBefore.lastHadTrailingComments,
    );

    _entryStore.reset(
      newKey: mapBefore.currentKey,
      newValue: mapBefore.currentValue,
      indent: mapBefore.entryIndent,
      count: mapBefore.entriesFormatted,
    );

    _dumpedMap.write(mapBefore.mapState);
    mapBefore.onMapDone(nestedIsExplicit, nested);
  } while (true);

  final dumped = _dumpedMap.toString();

  final dumpedMap = (
    preferExplicit:
        !_entryStore.isFlow || _isExplicit || dumped.length > 1024,
    node: _onMapDumped(asLocalTag(tag), anchor, _mapIndent, dumped),
    applyTrailingComments: canApplyTrailingComments,
  );

  _reset();
  return dumpedMap;
}