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

Function scan_inline_structs

codegraph-kernel/src/cfnptr.rs:432–468  ·  view source on GitHub ↗
(s: &[u8])

Source from the content-addressed store, hash-verified

430 tags: Vec<String>,
431}
432
433fn scan_inline_structs(s: &[u8]) -> InlineScan {
434 let mut out = InlineScan { ptr: false, types: Vec::new(), tags: Vec::new() };
435 let mut last = 0;
436 while let Some(t) = find_word(s, b"struct", last) {
437 let after_kw = t + 6;
438 let ws = skip_jsws(s, after_kw);
439 if ws == after_kw || !is_word_at(s, ws) {
440 last = t + 1;
441 continue;
442 }
443 let te = word_end(s, ws);
444 let open = skip_jsws(s, te);
445 if s.get(open) != Some(&b'{') {
446 last = t + 1;
447 continue;
448 }
449 last = open + 1; // lastIndex = end of match (after `{`)
450 let Some(close) = match_brace(s, open) else { continue };
451 // vm: /^\s*(\w+)…/ on the text after `}` — only vm[1] matters here.
452 let v = skip_jsws(s, close + 1);
453 if !is_word_at(s, v) {
454 continue;
455 }
456 push_str(&mut out.tags, &s[ws..te]);
457 for f in parse_struct_fields_raw(&s[open + 1..close]) {
458 if f.name.is_empty() {
459 continue;
460 }
461 if f.ptr {
462 out.ptr = true;
463 } else if !f.ty.is_empty() {
464 out.types.push(f.ty);
465 }
466 }
467 }
468 out
469}
470
471/// matchBrace: index of the `}` matching the `{` at `open`, or None.

Callers 1

scan_fileFunction · 0.85

Calls 8

find_wordFunction · 0.85
skip_jswsFunction · 0.85
is_word_atFunction · 0.85
word_endFunction · 0.85
match_braceFunction · 0.85
push_strFunction · 0.85
parse_struct_fields_rawFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected