MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / parse_body_loc_start

Function parse_body_loc_start

parser/src/parsing/source.rs:23–48  ·  view source on GitHub ↗

Parse the line and column number of function block. A function block is wrapped in a pair of braces, i.e. `{ ... }`

(block: &syn::Block)

Source from the content-addressed store, hash-verified

21///
22/// A function block is wrapped in a pair of braces, i.e. `{ ... }`
23pub(crate) fn parse_body_loc_start(block: &syn::Block) -> LineColumn {
24 // Given a function like... the `loc.column` will be at
25 // - `fn func<T>(i: T) -> T where T: Into<u64> { `
26 // ^
27 // - `fn func<T>(i: T) -> T where T: Into<u64>{ `
28 // ^
29 // - `fn func() { `
30 // ^
31 // - `fn func(){ `
32 // ^
33 // However, we want the `loc.column` to be one character after `{`, i.e.
34 // - `fn func<T>(i: T) -> T where T: Into<u64> { `
35 // ^
36 // - `fn func<T>(i: T) -> T where T: Into<u64>{ `
37 // ^
38 // - `fn func() { `
39 // ^
40 // - `fn func(){ `
41 // ^
42 let mut loc: LineColumn = block.span().start().into_loc();
43 // Hence, `loc.column + 2`
44 if let Some(col) = loc.column.as_mut() {
45 *col += 2;
46 }
47 loc
48}
49
50/// Parse the line and column number of function block.
51///

Callers 2

parse_body_locFunction · 0.85
parse_body_loc_endFunction · 0.85

Calls 3

into_locMethod · 0.80
startMethod · 0.80
spanMethod · 0.80

Tested by

no test coverage detected