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

Function split_top_level

codegraph-kernel/src/cfnptr.rs:969–986  ·  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

967// ---------- struct field parsing ----------
968
969/// splitTopLevel(body, sep): split on `sep` at brace/paren/bracket depth 0.
970fn split_top_level(body: &[u8], sep: u8) -> Vec<Range> {
971 let mut out = Vec::new();
972 let mut depth = 0i64;
973 let mut start = 0usize;
974 for (i, &c) in body.iter().enumerate() {
975 match c {
976 b'{' | b'(' | b'[' => depth += 1,
977 b'}' | b')' | b']' => depth -= 1,
978 _ if c == sep && depth == 0 => {
979 out.push((start, i));
980 start = i + 1;
981 }
982 _ => {}
983 }
984 }
985 out.push((start, body.len()));
986 out
987}
988
989/// 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