getUnion method

SourceRange getUnion(
  1. SourceRange otherRange
)

Return the minimal source range that covers both this and the otherRange.

Implementation

SourceRange getUnion(SourceRange otherRange) {
  int newOffset = math.min(offset, otherRange.offset);
  int newEnd =
      math.max(offset + length, otherRange.offset + otherRange.length);
  return SourceRange(newOffset, newEnd - newOffset);
}