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

Function balancedArgs

src/resolution/frameworks/python.ts:613–631  ·  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

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

Callers 1

extractFlaskUrlRulesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected