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

Method validate_for

atomic-core/src/change/semantic_context.rs:108–121  ·  view source on GitHub ↗

Require exactly one declaration for every foreign name, with no unused declarations that could silently expand the operation's context.

(&self, ops: &[FileOps])

Source from the content-addressed store, hash-verified

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.

Callers 2

localizeMethod · 0.80
buildMethod · 0.80

Calls 3

collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected