matches method

bool matches(
  1. XPathStep other
)

Like ==, but a name test also matches *. Port of XPathStep.matches.

Implementation

bool matches(XPathStep other) {
  final nameVsWildcard =
      (test == StepTest.name && other.test == StepTest.nameWildcard) ||
      (test == StepTest.nameWildcard && other.test == StepTest.name);
  if (axis != other.axis ||
      (test != other.test && !nameVsWildcard) ||
      predicates.length != other.predicates.length) {
    return false;
  }
  if (test == StepTest.name &&
      other.test != StepTest.nameWildcard &&
      name != other.name) {
    return false;
  }
  if (test != StepTest.name && !_sameTestDetail(other)) return false;
  return const ListEquality<XPathExpression>().equals(
    predicates,
    other.predicates,
  );
}