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

Function routeHandlerAt

src/resolution/frameworks/java.ts:743–753  ·  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

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

Callers 1

resolveFunction · 0.85

Calls 1

nodesAroundLineFunction · 0.90

Tested by

no test coverage detected