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

Method finish

atomic-cli/src/commands/git/span_compiler.rs:181–265  ·  view source on GitHub ↗
(
        &mut self,
        hash: ContentHash,
        pending: &[PendingLineIndexUpdate],
        roots: &[NewRoot],
    )

Source from the content-addressed store, hash-verified

179 }
180
181 pub(super) fn finish(
182 &mut self,
183 hash: ContentHash,
184 pending: &[PendingLineIndexUpdate],
185 roots: &[NewRoot],
186 ) -> CliResult<()> {
187 for update in pending {
188 match update {
189 PendingLineIndexUpdate::Add {
190 path, new_ranges, ..
191 } => {
192 let root = roots
193 .iter()
194 .find(|root| &root.path == path)
195 .ok_or_else(|| git_error("span root missing after compilation"))?;
196 let span = ExternalSpan {
197 owner: hash,
198 start: root.start,
199 end: root.end,
200 };
201 let lines = new_ranges
202 .iter()
203 .map(|(start, end)| SpanLine {
204 span: span.clone(),
205 start: start.get(),
206 end: end.get(),
207 })
208 .collect();
209 self.files.insert(
210 path.clone(),
211 SpanFile {
212 file: ExternalFile {
213 owner: hash,
214 ordinal: root.ordinal,
215 },
216 root: span,
217 lines,
218 },
219 );
220 }
221 PendingLineIndexUpdate::Modify { path, replacements } => {
222 let file = self
223 .files
224 .get_mut(path)
225 .ok_or_else(|| git_error("span file vanished"))?;
226 for replacement in replacements.iter().rev() {
227 let start = replacement.start_idx;
228 let end = start + replacement.old_len;
229 let lines = if let (Some(first), Some(last)) = (
230 replacement.new_ranges.first(),
231 replacement.new_ranges.last(),
232 ) {
233 let span = ExternalSpan {
234 owner: hash,
235 start: first.0.get(),
236 end: last.1.get(),
237 };
238 replacement

Callers

nothing calls this directly

Calls 9

get_mutMethod · 0.80
lastMethod · 0.80
git_errorFunction · 0.70
getMethod · 0.65
removeMethod · 0.65
iterMethod · 0.45
collectMethod · 0.45
cloneMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected