* 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)
| 739 | * line. Null for any other reference, and when no such method is indexed. |
| 740 | */ |
| 741 | function 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. */ |
| 754 | function resolveByNameAndKind( |
no test coverage detected