Every existing node these operations name — the changes that created the file, lines and tokens they touch. Ids this change creates carry the placeholder `NodeId::ROOT` until it is applied, and are left out. These ids are applied as they are, so whoever applies a change it did not record checks them (a remote sandbox's change may name only its own view's nodes).
(&self)
| 268 | /// not record checks them (a remote sandbox's change may name only its |
| 269 | /// own view's nodes). |
| 270 | pub fn referenced_node_ids(&self) -> std::collections::BTreeSet<crate::types::NodeId> { |
| 271 | let mut ids = std::collections::BTreeSet::new(); |
| 272 | let leaf = |op: &LeafOp, ids: &mut std::collections::BTreeSet<_>| match op { |
| 273 | LeafOp::Insert { after, .. } => ids.extend(after.map(|l| l.change_id())), |
| 274 | LeafOp::Delete { leaf } | LeafOp::Replace { leaf, .. } | LeafOp::Restore { leaf } => { |
| 275 | ids.insert(leaf.change_id()); |
| 276 | } |
| 277 | }; |
| 278 | ids.insert(self.trunk_id.change_id()); |
| 279 | match &self.trunk_op { |
| 280 | Some(TrunkOp::Delete { trunk }) |
| 281 | | Some(TrunkOp::Move { trunk, .. }) |
| 282 | | Some(TrunkOp::Undelete { trunk }) |
| 283 | | Some(TrunkOp::SetMode { trunk, .. }) |
| 284 | | Some(TrunkOp::SetKind { trunk, .. }) => { |
| 285 | ids.insert(trunk.change_id()); |
| 286 | } |
| 287 | Some(TrunkOp::Create { .. } | TrunkOp::ProjectedSpanEdit { .. }) | None => {} |
| 288 | } |
| 289 | for line in &self.line_ops { |
| 290 | ids.insert(line.branch_id().change_id()); |
| 291 | match line.operation() { |
| 292 | BranchOp::Insert { after, content } => { |
| 293 | ids.extend(after.map(|b| b.change_id())); |
| 294 | content.iter().for_each(|op| leaf(op, &mut ids)); |
| 295 | } |
| 296 | BranchOp::Delete { branch, content } => { |
| 297 | ids.insert(branch.change_id()); |
| 298 | content.iter().for_each(|op| leaf(op, &mut ids)); |
| 299 | } |
| 300 | BranchOp::Modify { |
| 301 | branch, |
| 302 | old_content, |
| 303 | new_content, |
| 304 | } => { |
| 305 | ids.insert(branch.change_id()); |
| 306 | old_content |
| 307 | .iter() |
| 308 | .chain(new_content) |
| 309 | .for_each(|op| leaf(op, &mut ids)); |
| 310 | } |
| 311 | BranchOp::Restore { branch } => { |
| 312 | ids.insert(branch.change_id()); |
| 313 | } |
| 314 | BranchOp::Reparent { branch, new_after } => { |
| 315 | ids.insert(branch.change_id()); |
| 316 | ids.extend(new_after.map(|b| b.change_id())); |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | ids.remove(&crate::types::NodeId::ROOT); |
| 321 | ids |
| 322 | } |
| 323 | |
| 324 | /// Translate existing semantic identities while preserving ROOT placeholders. |
| 325 | pub fn remap_referenced_node_ids<E>( |
no test coverage detected