* Resolve controller method using name-based lookup
( controller: string, method: string, context: ResolutionContext )
| 706 | * Resolve controller method using name-based lookup |
| 707 | */ |
| 708 | function resolveControllerMethod( |
| 709 | controller: string, |
| 710 | method: string, |
| 711 | context: ResolutionContext |
| 712 | ): string | null { |
| 713 | // Look for the method name directly |
| 714 | const methodCandidates = context.getNodesByName(method); |
| 715 | const methodNodes = methodCandidates.filter( |
| 716 | (n) => (n.kind === 'method' || n.kind === 'function') && |
| 717 | n.filePath.toLowerCase().includes(controller.toLowerCase()) |
| 718 | ); |
| 719 | |
| 720 | if (methodNodes.length > 0) return methodNodes[0]!.id; |
| 721 | |
| 722 | // Fall back: look for controller class, then find the method in its file |
| 723 | const controllerName = controller + 'Controller'; |
| 724 | const controllerCandidates = context.getNodesByName(controllerName); |
| 725 | for (const ctrl of controllerCandidates) { |
| 726 | const nodesInFile = context.getNodesInFile(ctrl.filePath); |
| 727 | const methodNode = nodesInFile.find( |
| 728 | (n) => (n.kind === 'method' || n.kind === 'function') && n.name === method |
| 729 | ); |
| 730 | if (methodNode) return methodNode.id; |
| 731 | } |
| 732 | |
| 733 | return null; |
| 734 | } |
| 735 | |
| 736 | /** |
| 737 | * Resolve service/helper method using name-based lookup |
no test coverage detected