(
context: &SpanRenderContext<'_, T>,
inode: Inode,
retain_content: bool,
)
| 176 | } |
| 177 | |
| 178 | pub(super) fn layout<T: SpanPatchReadTxn>( |
| 179 | context: &SpanRenderContext<'_, T>, |
| 180 | inode: Inode, |
| 181 | retain_content: bool, |
| 182 | ) -> Result<Option<SpanRecordState>> { |
| 183 | let Some(graph) = context.txn.legacy_span_graph(inode, context.visible)? else { |
| 184 | return Ok(None); |
| 185 | }; |
| 186 | let owner = context |
| 187 | .txn |
| 188 | .get_external(graph.position.change)? |
| 189 | .context("legacy file owner hash missing")?; |
| 190 | let creator = context |
| 191 | .changes |
| 192 | .get(&owner) |
| 193 | .context("legacy file creator outside closure")?; |
| 194 | let ordinal = creator |
| 195 | .legacy |
| 196 | .files |
| 197 | .iter() |
| 198 | .position(|pos| *pos == graph.position.pos.get()) |
| 199 | .context("legacy inode has no canonical FileAdd")?; |
| 200 | let ordinal = u32::try_from(ordinal)?; |
| 201 | ensure!( |
| 202 | creator.span.is_none(), |
| 203 | "typed span root index is missing; cannot fall back to legacy graph" |
| 204 | ); |
| 205 | let mut content = Vec::new(); |
| 206 | let mut spans: Vec<VisibleSpan> = Vec::new(); |
| 207 | let mut output_len = 0usize; |
| 208 | for node in graph.nodes { |
| 209 | let hash = context |
| 210 | .txn |
| 211 | .get_external(node.change)? |
| 212 | .context("legacy content owner hash missing")?; |
| 213 | let change = context |
| 214 | .changes |
| 215 | .get(&hash) |
| 216 | .context("legacy content outside closure")?; |
| 217 | let candidates: Vec<_> = change |
| 218 | .legacy |
| 219 | .ranges |
| 220 | .iter() |
| 221 | .filter(|(file_owner, pos, start, end)| { |
| 222 | *file_owner == owner |
| 223 | && *pos == graph.position.pos.get() |
| 224 | && *start <= node.start.get() |
| 225 | && node.end.get() <= *end |
| 226 | }) |
| 227 | .collect(); |
| 228 | ensure!( |
| 229 | candidates.len() == 1, |
| 230 | "legacy vertex has no unique immutable authored range" |
| 231 | ); |
| 232 | let (_, _, start, end) = *candidates[0]; |
| 233 | ensure!( |
| 234 | end <= change.contents.len() as u64, |
| 235 | "legacy declaration is outside verified content" |
no test coverage detected