(filePath: string, content: string)
| 60 | }, |
| 61 | |
| 62 | extract(filePath: string, content: string): { nodes: Node[]; references: UnresolvedRef[] } { |
| 63 | if (!isPlayRoutesFile(filePath)) return { nodes: [], references: [] }; |
| 64 | const nodes: Node[] = []; |
| 65 | const references: UnresolvedRef[] = []; |
| 66 | const now = Date.now(); |
| 67 | |
| 68 | const lines = content.split('\n'); |
| 69 | for (let i = 0; i < lines.length; i++) { |
| 70 | const line = lines[i]!.trim(); |
| 71 | // Skip comments and `->` route includes (a sub-router mount, not an action). |
| 72 | if (!line || line.startsWith('#') || line.startsWith('->')) continue; |
| 73 | const m = line.match(ROUTE_LINE); |
| 74 | if (!m) continue; |
| 75 | const [, method, routePath, action] = m; |
| 76 | |
| 77 | // action: `controllers.Application.list(p: Int ?= 0)` → drop args, keep the |
| 78 | // last `Controller.method` segment (package prefix is irrelevant for lookup). |
| 79 | const fqn = action!.split('(')[0]!.trim(); |
| 80 | const parts = fqn.split('.').filter(Boolean); |
| 81 | if (parts.length < 2) continue; |
| 82 | const handlerRef = parts.slice(-2).join('.'); // Application.list |
| 83 | |
| 84 | const lineNum = i + 1; |
| 85 | const routeNode: Node = { |
| 86 | id: `route:${filePath}:${lineNum}:${method}:${routePath}`, |
| 87 | kind: 'route', |
| 88 | name: `${method} ${routePath}`, |
| 89 | qualifiedName: `${filePath}::${method}:${routePath}`, |
| 90 | filePath, |
| 91 | startLine: lineNum, |
| 92 | endLine: lineNum, |
| 93 | startColumn: 0, |
| 94 | endColumn: 0, |
| 95 | language: 'scala', |
| 96 | updatedAt: now, |
| 97 | }; |
| 98 | nodes.push(routeNode); |
| 99 | references.push({ |
| 100 | fromNodeId: routeNode.id, |
| 101 | referenceName: handlerRef, |
| 102 | referenceKind: 'references', |
| 103 | line: lineNum, |
| 104 | column: 0, |
| 105 | filePath, |
| 106 | language: 'scala', |
| 107 | }); |
| 108 | } |
| 109 | |
| 110 | return { nodes, references }; |
| 111 | }, |
| 112 | }; |
nothing calls this directly
no test coverage detected