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

Function readChain

src/resolution/frameworks/angular-router.ts:508–519  ·  view source on GitHub ↗
(open: number, links: readonly string[])

Source from the content-addressed store, hash-verified

506 if (content && root && chain.length > 0) {
507 const safe = stripCommentsForRegex(content, 'typescript');
508 const readChain = (open: number, links: readonly string[]): string | null => {
509 let start = open;
510 let end = matchBracket(safe, start);
511 for (let i = 0; i < links.length && end > start; i++) {
512 const field = readFields(safe, start, end).get(links[i]!);
513 if (!field) return null;
514 if (i === links.length - 1) return field.text.trim();
515 start = safe.indexOf('{', field.at);
516 end = start < 0 ? -1 : matchBracket(safe, start);
517 }
518 return null;
519 };
520 const decl = new RegExp(String.raw`\b(?:const|let)\s+${escapeRegExp(root)}\s*(?::[^=]+)?=\s*\{`).exec(safe);
521 const enumDecl = decl ? null : new RegExp(String.raw`\benum\s+${escapeRegExp(root)}\s*\{`).exec(safe);
522 const classDecl = decl || enumDecl ? null : new RegExp(String.raw`\bclass\s+${escapeRegExp(root)}\b[^{]*\{`).exec(safe);

Callers 1

constantTextFunction · 0.85

Calls 3

matchBracketFunction · 0.90
readFieldsFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected