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

Function resolveControllerMethod

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

706 * Resolve controller method using name-based lookup
707 */
708function 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

Callers 1

resolveFunction · 0.70

Calls 2

getNodesByNameMethod · 0.65
getNodesInFileMethod · 0.65

Tested by

no test coverage detected