Interval Collections: Refactor rebase to be based on local references #24867
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the
IntervalCollection
class inpackages/dds/sequence/src/intervalCollection.ts
to improve type safety, streamline interval rebasing logic, and enhance the handling of local metadata. It also updates theIntervalCollectionMapInterfaces
and adjusts test utilities accordingly.Refactoring for Type Safety and Code Simplification:
hasEndpointChanges
function to use a type predicate, ensuring theserialized
parameter is of typeISerializedInterval
when endpoints are defined.rebasePositionWithSegmentSlide
torebaseReferenceWithSegmentSlide
, simplifying its logic and improving readability by usingLocalReferencePosition
instead of raw positions.computeRebasedPositions
method to return aPick<ISerializedInterval, "start" | "end">
type for better specificity and clarity.Enhancements to Interval Rebasing Logic:
rebaseLocalInterval
method to acceptSerializedIntervalDelta
directly instead of relying onoriginal
from metadata, improving flexibility and clarity.computeRebasedPositions
by leveragingLocalReferencePosition
for calculating rebased start and end positions.Updates to Metadata Handling:
original
withinterval
in metadata interfaces (IntervalAddLocalMetadata
andIntervalChangeLocalMetadata
) for better alignment with interval operations.Pick<ISerializedInterval, "start" | "end">
, enhancing type specificity.Test Utility Adjustments:
start
andend
in test operations (removeRange
andannotateRange
) to ensure valid interval positions during fuzz testing.