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

Function methodNameAfter

src/resolution/frameworks/nestjs.ts:585–627  ·  view source on GitHub ↗

* Starting just after a method decorator's `)`, return the name of the method * it decorates. Skips any further stacked decorators (`@UseGuards(...)`, * `@HttpCode(204)`, …) and access/async modifiers in between.

(safe: string, start: number)

Source from the content-addressed store, hash-verified

583 * `@HttpCode(204)`, …) and access/async modifiers in between.
584 */
585function methodNameAfter(safe: string, start: number): string | null {
586 let i = start;
587 const ws = /\s*/y;
588 const decoName = /@[\w.]+/y;
589 const modifier = /(?:public|private|protected|async|static)\b/y;
590 const ident = /([A-Za-z_$][\w$]*)\s*\(/y;
591
592 const eatWs = (): void => {
593 ws.lastIndex = i;
594 if (ws.exec(safe)) i = ws.lastIndex;
595 };
596
597 // Skip stacked decorators.
598 for (;;) {
599 eatWs();
600 if (safe[i] !== '@') break;
601 decoName.lastIndex = i;
602 if (!decoName.exec(safe)) break;
603 i = decoName.lastIndex;
604 eatWs();
605 if (safe[i] === '(') {
606 const parsed = readArgs(safe, i);
607 if (!parsed) return null;
608 i = parsed.end;
609 }
610 }
611
612 // Skip access/async/static modifiers.
613 for (;;) {
614 eatWs();
615 modifier.lastIndex = i;
616 if (modifier.exec(safe) && modifier.lastIndex > i) {
617 i = modifier.lastIndex;
618 continue;
619 }
620 break;
621 }
622
623 eatWs();
624 ident.lastIndex = i;
625 const m = ident.exec(safe);
626 return m ? m[1]! : null;
627}
628
629// ---------------------------------------------------------------------------
630// Class scopes (controller / resolver / gateway boundaries)

Callers 2

extractFunction · 0.70
routeVersionFunction · 0.70

Calls 3

eatWsFunction · 0.85
readArgsFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected