struct EditPlan {
changes: Vec<PlannedChange>,
}Expand description
A validated batch of changes in the exact order in which it must execute.
Planning is deliberately separate from tree mutation. Once an EditPlan
exists, execution does not need to reason about overlaps, dependencies, or
source ordering.
Fields§
§changes: Vec<PlannedChange>Implementations§
Source§impl EditPlan
impl EditPlan
Sourcefn build(
changes: Vec<Change>,
mappings: &SyntaxMapping,
node_depth: impl FnMut(SyntaxNode) -> usize,
) -> Result<Self, InvalidEditPlan>
fn build( changes: Vec<Change>, mappings: &SyntaxMapping, node_depth: impl FnMut(SyntaxNode) -> usize, ) -> Result<Self, InvalidEditPlan>
Validates raw editor changes and turns them into an execution schedule.
The input is first sorted in source order, dependent targets are then rewritten from their input trees into ancestor replacement trees. Finally, discarded changes are removed and the dependency forest is traversed in postorder. Independent roots and sibling changes are prioritized right to left.
Sourcefn execution_priority(
left: &Change,
right: &Change,
node_depth: &mut impl FnMut(SyntaxNode) -> usize,
) -> Ordering
fn execution_priority( left: &Change, right: &Change, node_depth: &mut impl FnMut(SyntaxNode) -> usize, ) -> Ordering
Orders disjoint changes from right to left, with deeper ties first.
Sourcefn append_postorder(
index: usize,
children: &[Vec<usize>],
planned: &mut [Option<PlannedChange>],
ordered: &mut Vec<PlannedChange>,
)
fn append_postorder( index: usize, children: &[Vec<usize>], planned: &mut [Option<PlannedChange>], ordered: &mut Vec<PlannedChange>, )
Appends a dependency subtree in post order fashion.
Sourcefn replacements_are_disjoint(
changes: &[Change],
node_depth: impl FnMut(SyntaxNode) -> usize,
) -> bool
fn replacements_are_disjoint( changes: &[Change], node_depth: impl FnMut(SyntaxNode) -> usize, ) -> bool
Checks that replacement at the same tree depth do not overlap
changes is sorted by range start, so overlap is a single comparison against the
last range at that key, and insert can throw away the range it evicts.
Sourcefn rewrite_dependent_target(
changes: &mut [Change],
parent: usize,
child: usize,
mappings: &SyntaxMapping,
)
fn rewrite_dependent_target( changes: &mut [Change], parent: usize, child: usize, mappings: &SyntaxMapping, )
Maps one dependent change into its ancestor replacement tree.
Auto Trait Implementations§
impl !RefUnwindSafe for EditPlan
impl !Send for EditPlan
impl !Sync for EditPlan
impl !UnwindSafe for EditPlan
impl Freeze for EditPlan
impl Unpin for EditPlan
impl UnsafeUnpin for EditPlan
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more