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

Function resolveControllerMethod

src/resolution/frameworks/express.ts:694–720  ·  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

692 * Resolve controller method using name-based lookup
693 */
694function 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

Callers 1

resolveFunction · 0.70

Calls 2

getNodesByNameMethod · 0.65
getNodesInFileMethod · 0.65

Tested by

no test coverage detected