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

Function findDecorators

src/resolution/frameworks/nestjs.ts:308–326  ·  view source on GitHub ↗

* Find every `@Name(...)` decorator whose name is in `names`. Uses a * string-aware balanced-paren reader for the argument list so type thunks * like `@Query(() => [User])` are captured whole rather than truncated at the * inner `()`.

(safe: string, names: string[])

Source from the content-addressed store, hash-verified

306 * inner `()`.
307 */
308function findDecorators(safe: string, names: string[]): DecoratorHit[] {
309 const hits: DecoratorHit[] = [];
310 const re = new RegExp(`@(${names.join('|')})\\s*\\(`, 'g');
311 let m: RegExpExecArray | null;
312 while ((m = re.exec(safe)) !== null) {
313 const openIndex = m.index + m[0].length - 1; // position of '('
314 const parsed = readArgs(safe, openIndex);
315 if (!parsed) continue;
316 hits.push({
317 name: m[1]!,
318 args: parsed.args,
319 index: m.index,
320 end: parsed.end,
321 length: parsed.end - m.index,
322 });
323 re.lastIndex = parsed.end; // resume past the args so nested text isn't re-scanned
324 }
325 return hits;
326}
327
328/**
329 * Read a balanced `(...)` starting at `openIndex` (which must point at `(`).

Callers 3

extractFunction · 0.85
buildClassScopesFunction · 0.85
collectModuleControllersFunction · 0.85

Calls 3

readArgsFunction · 0.85
execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected