property method

*<Null safety>*

PropertyMatcher property (String name)

Implementation

PropertyMatcher property(String name) {
  if (!_valid) {
    // No error, it would have been added creating the node itself.
    return PropertyMatcher._invalid(_parent);
  }

  int valueIndex = _parent._findNamedValue(name, _index);
  if (valueIndex == 0) {
    _parent._addError('Cannot find property $name');
    return PropertyMatcher._invalid(_parent);
  } else if ([
    BlockType.nodeValue,
    BlockType.tombstone,
    BlockType.nameUtf8,
    BlockType.extent
  ].contains(Block.read(_parent._holder, valueIndex).type)) {
    _parent._addError('Value $name found, but it is not a property type');
    return PropertyMatcher._invalid(_parent);
  }

  return PropertyMatcher._valid(_parent, valueIndex);
}