getUpdatedSliceIndices method
Computes new slice indices when creating a sub-slice of this reference.
When slicing an already-sliced port reference, this method calculates the
effective indices in the original port coordinate system. The endIndex
and startIndex
are relative to this slice's coordinate system.
Returns a tuple of (newLowerIndex, newUpperIndex) in the original port's coordinate system.
Implementation
@protected
(int newLowerIndex, int newUpperIndex) getUpdatedSliceIndices(
int endIndex, int startIndex) {
final newRangeSize = endIndex - startIndex + 1;
final newLowerIndex = (sliceLowerIndex ?? 0) + startIndex;
final newUpperIndex = newLowerIndex + newRangeSize - 1;
return (newLowerIndex, newUpperIndex);
}