MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / namespace_head

Function namespace_head

codegraph-kernel/src/ccpp/brace_scopes.rs:200–234  ·  view source on GitHub ↗

namespaceHead: after the `namespace` keyword ending at `from`, the name as written and the offset of the body's `{`.

(src: &str, from: usize)

Source from the content-addressed store, hash-verified

198/// namespaceHead: after the `namespace` keyword ending at `from`, the name as
199/// written and the offset of the body's `{`.
200fn namespace_head(src: &str, from: usize) -> Option<(String, usize)> {
201 let s = src.as_bytes();
202 let mut i = skip_blank(src, from);
203 while src.get(i..).is_some_and(|r| r.starts_with("[[")) {
204 let end = find(src, i + 2, "]]")?;
205 i = skip_blank(src, end + 2);
206 }
207 let mut name: Option<(usize, usize)> = None;
208 while let Some(end) = word_end(s, i) {
209 name = Some((name.map_or(i, |(start, _)| start), end));
210 i = skip_blank(src, end);
211 if !src.get(i..).is_some_and(|r| r.starts_with("::")) {
212 break;
213 }
214 i = skip_blank(src, i + 2);
215 if let Some(inline) = word_end(s, i) {
216 if &src[i..inline] == "inline" {
217 i = skip_blank(src, inline);
218 }
219 }
220 }
221 if name.is_some() {
222 while let Some(end) = word_end(s, i) {
223 let paren = skip_blank(src, end);
224 if at(s, paren) != b'(' {
225 return None;
226 }
227 i = skip_blank(src, paren_group_end(s, paren)?);
228 }
229 }
230 if at(s, i) != b'{' {
231 return None;
232 }
233 Some((name.map_or(String::new(), |(start, end)| src[start..end].to_string()), i))
234}
235
236fn is_raw_delimiter(d: &[u8]) -> bool {
237 d.len() <= 16 && d.iter().all(|&b| (0x21..=0x7e).contains(&b) && !matches!(b, b'"' | b'(' | b')' | b'\\'))

Callers 1

scanFunction · 0.85

Calls 6

skip_blankFunction · 0.85
paren_group_endFunction · 0.85
findFunction · 0.70
word_endFunction · 0.70
atFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected