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

Method line

atomic-core/src/change/format_v3/semantic/encode.rs:148–207  ·  view source on GitHub ↗
(&mut self, line: &LineOps)

Source from the content-addressed store, hash-verified

146 Ok(())
147 }
148 fn line(&mut self, line: &LineOps) -> FormatResult<()> {
149 self.branch(line.branch_id());
150 for (n, col, state) in [
151 (
152 line.old_line_num(),
153 &mut self.c.old_numbers,
154 &mut self.s.old_number,
155 ),
156 (
157 line.new_line_num(),
158 &mut self.c.new_numbers,
159 &mut self.s.new_number,
160 ),
161 ] {
162 put(&mut self.c.control, u64::from(n.is_some()));
163 if let Some(n) = n {
164 state.write(col, n as u64);
165 }
166 }
167 put(
168 &mut self.c.control,
169 u64::from(line.content_range().is_some()),
170 );
171 if let Some((a, b)) = line.content_range() {
172 self.s.position.write(&mut self.c.positions, a.get());
173 self.s.position.write(&mut self.c.positions, b.get());
174 }
175 match line.operation() {
176 BranchOp::Insert { after, content } => {
177 put(&mut self.c.control, 0);
178 self.optional_branch(*after);
179 self.leaves(content, line.content_range())?;
180 }
181 BranchOp::Delete { branch, content } => {
182 put(&mut self.c.control, 1);
183 self.branch(*branch);
184 self.leaves(content, None)?;
185 }
186 BranchOp::Modify {
187 branch,
188 old_content,
189 new_content,
190 } => {
191 put(&mut self.c.control, 2);
192 self.branch(*branch);
193 self.leaves(old_content, None)?;
194 self.leaves(new_content, line.content_range())?;
195 }
196 BranchOp::Restore { branch } => {
197 put(&mut self.c.control, 3);
198 self.branch(*branch);
199 }
200 BranchOp::Reparent { branch, new_after } => {
201 put(&mut self.c.control, 4);
202 self.branch(*branch);
203 self.optional_branch(*new_after);
204 }
205 }

Callers 1

columnsFunction · 0.45

Calls 11

putFunction · 0.70
getMethod · 0.65
branchMethod · 0.45
branch_idMethod · 0.45
old_line_numMethod · 0.45
new_line_numMethod · 0.45
writeMethod · 0.45
content_rangeMethod · 0.45
operationMethod · 0.45
optional_branchMethod · 0.45
leavesMethod · 0.45

Tested by

no test coverage detected