(filePath: string, content: string)
| 93 | }, |
| 94 | |
| 95 | extract(filePath: string, content: string): { nodes: Node[]; references: UnresolvedRef[] } { |
| 96 | if (!isPlayRoutesFile(filePath)) return { nodes: [], references: [] }; |
| 97 | const nodes: Node[] = []; |
| 98 | const references: UnresolvedRef[] = []; |
| 99 | const now = Date.now(); |
| 100 | |
| 101 | const lines = content.split('\n'); |
| 102 | for (let i = 0; i < lines.length; i++) { |
| 103 | const line = lines[i]!.trim(); |
| 104 | // Skip comments and `->` route includes (a sub-router mount, not an action). |
| 105 | if (!line || line.startsWith('#') || line.startsWith('->')) continue; |
| 106 | const m = line.match(ROUTE_LINE); |
| 107 | if (!m) continue; |
| 108 | const [, method, routePath, action] = m; |
| 109 | |
| 110 | // action: `controllers.Application.list(p: Int ?= 0)` → drop args, keep the |
| 111 | // last `Controller.method` segment (package prefix is irrelevant for lookup). |
| 112 | const fqn = action!.split('(')[0]!.trim(); |
| 113 | const parts = fqn.split('.').filter(Boolean); |
| 114 | if (parts.length < 2) continue; |
| 115 | const handlerRef = parts.slice(-2).join('.'); // Application.list |
| 116 | |
| 117 | const lineNum = i + 1; |
| 118 | const routeNode: Node = { |
| 119 | id: `route:${filePath}:${lineNum}:${method}:${routePath}`, |
| 120 | kind: 'route', |
| 121 | name: `${method} ${routePath}`, |
| 122 | qualifiedName: `${filePath}::${method}:${routePath}`, |
| 123 | filePath, |
| 124 | startLine: lineNum, |
| 125 | endLine: lineNum, |
| 126 | startColumn: 0, |
| 127 | endColumn: 0, |
| 128 | language: 'scala', |
| 129 | updatedAt: now, |
| 130 | }; |
| 131 | nodes.push(routeNode); |
| 132 | references.push({ |
| 133 | fromNodeId: routeNode.id, |
| 134 | referenceName: handlerRef, |
| 135 | referenceKind: 'references', |
| 136 | line: lineNum, |
| 137 | column: 0, |
| 138 | filePath, |
| 139 | language: 'scala', |
| 140 | }); |
| 141 | } |
| 142 | |
| 143 | return { nodes, references }; |
| 144 | }, |
| 145 | }; |
nothing calls this directly
no test coverage detected