MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / resolve_context_vertex

Function resolve_context_vertex

atomic-core/src/apply/position.rs:250–267  ·  view source on GitHub ↗

Resolve a context position to a span. Given a position, finds the span that contains it or ends at it. For predecessors, we use `find_block_end` to find the span that ENDS at this position (since predecessors references the end of a predecessor). For successors, we use `find_block` to find the span starting at or containing this position. # Arguments `txn` - Transaction for graph lookups `pos`

(
    txn: &T,
    pos: Position<NodeId>,
    is_predecessor: bool,
)

Source from the content-addressed store, hash-verified

248/// - **Down context**: References the START of a successor span. We use
249/// `find_block` to find a span containing this position.
250pub fn resolve_context_vertex<T: GraphTxnT>(
251 txn: &T,
252 pos: Position<NodeId>,
253 is_predecessor: bool,
254) -> Result<GraphNode<NodeId>, LocalApplyError> {
255 if pos.change.is_root() {
256 return Ok(GraphNode::root());
257 }
258
259 let found = if is_predecessor {
260 txn.find_block_end(pos)
261 } else {
262 txn.find_block(pos)
263 }
264 .map_err(|_| LocalApplyError::BlockNotFound { position: pos })?;
265
266 Ok(adjust_for_mid_span(found, pos, is_predecessor))
267}
268
269// ---------------------------------------------------------------------------
270// Mid-span adjustment

Callers 1

write_new_vertexFunction · 0.85

Calls 4

adjust_for_mid_spanFunction · 0.85
is_rootMethod · 0.45
find_block_endMethod · 0.45
find_blockMethod · 0.45

Tested by

no test coverage detected