equals method

  1. @override
bool equals(
  1. FluentNode other, {
  2. bool ignoreSpans = true,
})
override

Structural equality.

When ignoreSpans is true (the default), two ASTs from differently- positioned sources compare equal as long as their structure matches — useful for testing parser output against expected shapes regardless of whitespace placement. Set false for a strict, position-aware comparison that requires every Span to match.

Implementation

@override
bool equals(FluentNode other, {bool ignoreSpans = true}) {
  if (other is! TermReference) return false;
  if (!id.equals(other.id, ignoreSpans: ignoreSpans)) return false;
  if ((attribute == null) != (other.attribute == null)) return false;
  if (attribute != null &&
      !attribute!.equals(other.attribute!, ignoreSpans: ignoreSpans)) {
    return false;
  }
  if ((arguments == null) != (other.arguments == null)) return false;
  if (arguments != null &&
      !arguments!.equals(other.arguments!, ignoreSpans: ignoreSpans)) {
    return false;
  }
  return _spansEqual(span, other.span, ignoreSpans: ignoreSpans);
}