Require exactly one declaration for every foreign name, with no unused declarations that could silently expand the operation's context.
(&self, ops: &[FileOps])
| 106 | /// Require exactly one declaration for every foreign name, with no unused |
| 107 | /// declarations that could silently expand the operation's context. |
| 108 | pub fn validate_for(&self, ops: &[FileOps]) -> Result<(), SemanticContextError> { |
| 109 | let used: BTreeSet<_> = ops.iter().flat_map(FileOps::referenced_node_ids).collect(); |
| 110 | let declared: BTreeSet<_> = self |
| 111 | .owners |
| 112 | .iter() |
| 113 | .map(|entry| NodeId::new(entry.authored_id)) |
| 114 | .collect(); |
| 115 | let missing = used.difference(&declared).copied().collect::<Vec<_>>(); |
| 116 | let unused = declared.difference(&used).copied().collect::<Vec<_>>(); |
| 117 | if !missing.is_empty() || !unused.is_empty() { |
| 118 | return Err(SemanticContextError::IncompleteMapping { missing, unused }); |
| 119 | } |
| 120 | Ok(()) |
| 121 | } |
| 122 | |
| 123 | /// Transport a copy into a receiver's numeric encoding frame, using only |
| 124 | /// hash owners visible through the explicit patch dependency closure. |