printTreeAtLevel static method

String printTreeAtLevel(
  1. NodeV2 tree,
  2. int level
)

Implementation

static String printTreeAtLevel(NodeV2 tree, int level) {
  String result = "${getSpaced(level)} ${tree.prettyTag}";

  result +=
      "(${tree.nodeIndexStart}/${tree.textIndexStart} - ${tree.textIndexEnd}/${tree.nodeIndexEnd}): ";

  if (tree is SimpleNode) {
    result += " ${tree.body}";
  }

  result += "\n";

  for (NodeV2 child in tree.children) {
    result += printTreeAtLevel(child, level + 2);
  }

  return result;
}