debugGetDiagnosticChain method Null safety

List<Element> debugGetDiagnosticChain()

Returns the parent chain from this element back to the root of the tree.

Useful for debug display of a tree of Elements with only nodes in the path from the root to this Element expanded.

Implementation

List<Element> debugGetDiagnosticChain() {
  final List<Element> chain = <Element>[this];
  Element? node = _parent;
  while (node != null) {
    chain.add(node);
    node = node._parent;
  }
  return chain;
}