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

Function routeHandlerAt

src/resolution/frameworks/java.ts:741–751  ·  view source on GitHub ↗

* The method a Spring route's handler reference names, found where the * route's mapping annotation is written: the innermost method of that name * whose span — which starts at its first annotation — holds the annotation's * line. Null for any other reference, and when no such method is indexed.

(ref: UnresolvedRef, context: ResolutionContext)

Source from the content-addressed store, hash-verified

739 * line. Null for any other reference, and when no such method is indexed.
740 */
741function routeHandlerAt(ref: UnresolvedRef, context: ResolutionContext): Node | null {
742 if (ref.referenceKind !== 'references' || (ref.language !== 'java' && ref.language !== 'kotlin')) return null;
743 if (!ref.fromNodeId.startsWith(`route:${ref.filePath}:${ref.line}:`)) return null;
744 let handler: Node | null = null;
745 for (const node of context.getNodesInFile(ref.filePath)) {
746 if ((node.kind !== 'method' && node.kind !== 'function') || node.name !== ref.referenceName) continue;
747 if (node.startLine > ref.line || node.endLine < ref.line) continue;
748 if (!handler || node.startLine > handler.startLine) handler = node;
749 }
750 return handler;
751}
752
753/** A framework name heuristic's pick (see name-heuristic.ts), preferring these folders. */
754function resolveByNameAndKind(

Callers 1

resolveFunction · 0.85

Calls 1

getNodesInFileMethod · 0.65

Tested by

no test coverage detected