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

Function split_top_level

codegraph-kernel/src/cfnptr.rs:987–1004  ·  view source on GitHub ↗

splitTopLevel(body, sep): split on `sep` at brace/paren/bracket depth 0.

(body: &[u8], sep: u8)

Source from the content-addressed store, hash-verified

985// ---------- struct field parsing ----------
986
987/// splitTopLevel(body, sep): split on `sep` at brace/paren/bracket depth 0.
988fn split_top_level(body: &[u8], sep: u8) -> Vec<Range> {
989 let mut out = Vec::new();
990 let mut depth = 0i64;
991 let mut start = 0usize;
992 for (i, &c) in body.iter().enumerate() {
993 match c {
994 b'{' | b'(' | b'[' => depth += 1,
995 b'}' | b')' | b']' => depth -= 1,
996 _ if c == sep && depth == 0 => {
997 out.push((start, i));
998 start = i + 1;
999 }
1000 _ => {}
1001 }
1002 }
1003 out.push((start, body.len()));
1004 out
1005}
1006
1007/// JS String.prototype.trim over bytes (the JS set == our jsws set).

Callers 1

parse_struct_fields_rawFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected