* Resolve controller method using name-based lookup
( controller: string, method: string, context: ResolutionContext )
| 692 | * Resolve controller method using name-based lookup |
| 693 | */ |
| 694 | function resolveControllerMethod( |
| 695 | controller: string, |
| 696 | method: string, |
| 697 | context: ResolutionContext |
| 698 | ): string | null { |
| 699 | // Look for the method name directly |
| 700 | const methodCandidates = context.getNodesByName(method); |
| 701 | const methodNodes = methodCandidates.filter( |
| 702 | (n) => (n.kind === 'method' || n.kind === 'function') && |
| 703 | n.filePath.toLowerCase().includes(controller.toLowerCase()) |
| 704 | ); |
| 705 | |
| 706 | if (methodNodes.length > 0) return methodNodes[0]!.id; |
| 707 | |
| 708 | // Fall back: look for controller class, then find the method in its file |
| 709 | const controllerName = controller + 'Controller'; |
| 710 | const controllerCandidates = context.getNodesByName(controllerName); |
| 711 | for (const ctrl of controllerCandidates) { |
| 712 | const nodesInFile = context.getNodesInFile(ctrl.filePath); |
| 713 | const methodNode = nodesInFile.find( |
| 714 | (n) => (n.kind === 'method' || n.kind === 'function') && n.name === method |
| 715 | ); |
| 716 | if (methodNode) return methodNode.id; |
| 717 | } |
| 718 | |
| 719 | return null; |
| 720 | } |
| 721 | |
| 722 | /** |
| 723 | * Resolve service/helper method using name-based lookup |
no test coverage detected