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,
)
| 248 | /// - **Down context**: References the START of a successor span. We use |
| 249 | /// `find_block` to find a span containing this position. |
| 250 | pub 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 |
no test coverage detected