getUnion method

SourceRange getUnion(
  1. SourceRange otherRange
)

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

Implementation

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