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

Function balancedArgs

src/resolution/frameworks/python.ts:612–630  ·  view source on GitHub ↗

The text between an opening `(` at `open` and its matching `)`, or null. Strings are skipped.

(text: string, open: number)

Source from the content-addressed store, hash-verified

610
611/** The text between an opening `(` at `open` and its matching `)`, or null. Strings are skipped. */
612function balancedArgs(text: string, open: number): string | null {
613 let depth = 1;
614 let quote = '';
615 for (let i = open; i < text.length && i < open + 4000; i++) {
616 const ch = text[i]!;
617 if (quote) {
618 if (ch === '\\') i++;
619 else if (ch === quote) quote = '';
620 continue;
621 }
622 if (ch === '"' || ch === "'") quote = ch;
623 else if (ch === '(' || ch === '[' || ch === '{') depth++;
624 else if (ch === ')' || ch === ']' || ch === '}') {
625 depth--;
626 if (depth === 0) return text.slice(open, i);
627 }
628 }
629 return null;
630}
631
632// Directory patterns
633const MODEL_DIRS = ['models', 'app/models', 'src/models'];

Callers 1

extractFlaskUrlRulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected