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

Function create_insertion_tokens

atomic-core/src/diff/semantic/diff_impl.rs:237–251  ·  view source on GitHub ↗

Create token changes for a line that was entirely added.

(line: &SemanticLine<'a>)

Source from the content-addressed store, hash-verified

235
236/// Create token changes for a line that was entirely added.
237pub(super) fn create_insertion_tokens<'a>(line: &SemanticLine<'a>) -> Vec<TokenChange<'a>> {
238 let mut offset = 0;
239 line.tokens()
240 .iter()
241 .map(|token| {
242 let start = offset;
243 let end = start + token.content().len();
244 offset = end;
245 TokenChange::Inserted {
246 token: token.clone(),
247 new_range: start..end,
248 }
249 })
250 .collect()
251}
252
253/// Create token changes for a line that was entirely deleted.
254pub(super) fn create_deletion_tokens<'a>(line: &SemanticLine<'a>) -> Vec<TokenChange<'a>> {

Callers 4

test_line_change_addedFunction · 0.85
test_line_change_summaryFunction · 0.85

Calls 5

iterMethod · 0.45
tokensMethod · 0.45
lenMethod · 0.45
contentMethod · 0.45
cloneMethod · 0.45

Tested by 3

test_line_change_addedFunction · 0.68
test_line_change_summaryFunction · 0.68