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

Function resolveControllerMethod

src/resolution/frameworks/express.ts:709–735  ·  view source on GitHub ↗

* Resolve controller method using name-based lookup

(
  controller: string,
  method: string,
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

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

Callers 1

resolveFunction · 0.70

Calls 2

getNodesByNameMethod · 0.65
getNodesInFileMethod · 0.65

Tested by

no test coverage detected