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

Function splitRustTopLevel

src/resolution/rust-scopes.ts:830–845  ·  view source on GitHub ↗
(text: string, sep: string)

Source from the content-addressed store, hash-verified

828
829/** `text` parted at its top-level `sep`s, outside `()`, `[]`, `{}` and `<>` (`->` closes nothing). */
830export function splitRustTopLevel(text: string, sep: string): string[] {
831 const parts: string[] = [];
832 let depth = 0;
833 let start = 0;
834 for (let i = 0; i < text.length; i++) {
835 const c = text[i]!;
836 if (c === '(' || c === '[' || c === '{' || c === '<') depth++;
837 else if (c === ')' || c === ']' || c === '}' || (c === '>' && text[i - 1] !== '-' && text[i - 1] !== '=')) depth--;
838 else if (c === sep && depth === 0) {
839 parts.push(text.slice(start, i));
840 start = i + 1;
841 }
842 }
843 parts.push(text.slice(start));
844 return parts.map((p) => p.trim()).filter((p) => p !== '');
845}
846
847/**
848 * The bounds a generic parameter `name` is declared with, read from the

Callers 2

takeFunction · 0.85
rustBoundsOfFunction · 0.85

Calls 2

pushMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected