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

Function buildClassScopes

src/resolution/frameworks/nestjs.ts:649–673  ·  view source on GitHub ↗

* Build the list of class-level decorator scopes, sorted by position. Each * scope runs from its decorator up to the next class decorator (of any kind), * which lets a method decorator find its enclosing class regardless of how * many classes share a file.

(safe: string)

Source from the content-addressed store, hash-verified

647 * many classes share a file.
648 */
649function buildClassScopes(safe: string): ClassScope[] {
650 const defs: Array<{ kind: ClassKind; name: string; prefixOf: (a: string) => string }> = [
651 { kind: 'controller', name: 'Controller', prefixOf: parseControllerPrefix },
652 { kind: 'resolver', name: 'Resolver', prefixOf: () => '' },
653 { kind: 'gateway', name: 'WebSocketGateway', prefixOf: parseGatewayNamespace },
654 { kind: 'other', name: 'Injectable', prefixOf: () => '' },
655 { kind: 'other', name: 'Module', prefixOf: () => '' },
656 { kind: 'other', name: 'Catch', prefixOf: () => '' },
657 ];
658
659 const raw: Array<{ kind: ClassKind; prefix: string; index: number }> = [];
660 for (const def of defs) {
661 for (const hit of findDecorators(safe, [def.name])) {
662 raw.push({ kind: def.kind, prefix: def.prefixOf(hit.args), index: hit.index });
663 }
664 }
665 raw.sort((a, b) => a.index - b.index);
666
667 return raw.map((r, i) => ({
668 kind: r.kind,
669 prefix: r.prefix,
670 start: r.index,
671 end: i + 1 < raw.length ? raw[i + 1]!.index : safe.length,
672 }));
673}
674
675function scopeFor(scopes: ClassScope[], index: number): ClassScope | null {
676 for (const s of scopes) {

Callers 2

extractFunction · 0.85
postExtractFunction · 0.85

Calls 4

findDecoratorsFunction · 0.85
pushMethod · 0.80
prefixOfMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected