* 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)
| 583 | * `@HttpCode(204)`, …) and access/async modifiers in between. |
| 584 | */ |
| 585 | function 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) |
no test coverage detected