MCPcopy Create free account
hub / github.com/davidblewett/rure-python / notate_line

Method notate_line

regex/regex-syntax/src/error.rs:234–256  ·  view source on GitHub ↗

Return notes for the line indexed at `i` (zero-based). If there are no spans for the given line, then `None` is returned. Otherwise, an appropriately space padded string with correctly positioned `^` is returned, accounting for line numbers.

(&self, i: usize)

Source from the content-addressed store, hash-verified

232 /// appropriately space padded string with correctly positioned `^` is
233 /// returned, accounting for line numbers.
234 fn notate_line(&self, i: usize) -> Option<String> {
235 let spans = &self.by_line[i];
236 if spans.is_empty() {
237 return None;
238 }
239 let mut notes = String::new();
240 for _ in 0..self.line_number_padding() {
241 notes.push(' ');
242 }
243 let mut pos = 0;
244 for span in spans {
245 for _ in pos..(span.start.column - 1) {
246 notes.push(' ');
247 pos += 1;
248 }
249 let note_len = span.end.column.saturating_sub(span.start.column);
250 for _ in 0..cmp::max(1, note_len) {
251 notes.push('^');
252 pos += 1;
253 }
254 }
255 Some(notes)
256 }
257
258 /// Left pad the given line number with spaces such that it is aligned with
259 /// other line numbers.

Callers 1

notateMethod · 0.80

Calls 3

line_number_paddingMethod · 0.80
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected