Google is committed to advancing racial equity for Black communities. See how.

property method

PropertyMatcher property (String name)

Get a PropertyMatcher for a property on this node.

If the property cannot be found or is not a value type, an invalid PropertyMatcher is returned.

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);
}