at method

*<Null safety>*

NodeMatcher at (List<String> path)

Implementation

NodeMatcher at(List<String> path) {
  if (!_valid) {
    // No error, it was already recorded by the creation of this.
    return NodeMatcher._invalid(_parent);
  }

  int curIndex = _index;
  for (var p in path) {
    int next = _parent._findNamedValue(p, curIndex);
    if (next == 0) {
      _parent._addError('Cannot find node $p in $path');
      return NodeMatcher._invalid(_parent);
    } else if (Block.read(_parent._holder, next).type !=
        BlockType.nodeValue) {
      _parent._addError('Value $p in $path found, but it is not a node');
      return NodeMatcher._invalid(_parent);
    }

    curIndex = next;
  }
  return NodeMatcher._valid(_parent, curIndex);
}