getMaxDepth method

  1. @override
int getMaxDepth()
override

Retrieve the maximum depth of this DartBlockFunction.

If it has no child nodes, its depth is 0. Otherwise, retrieve the maximum depth from its child nodes (statements of its body).

Implementation

@override
int getMaxDepth() {
  if (children.isEmpty) {
    return 0;
  } else {
    List<int> depths = List.generate(children.length, (index) => 0);
    for (var (index, child) in children.indexed) {
      depths[index] += child.getMaxDepth();
    }
    return depths.max;
  }
}