* Name the routes whose path is built from a constant — bulletproof-react's * `path: paths.app.discussions.path` under `path: paths.app.root.path` is * `/app/discussions` — by reading the constant's object literal where it is * declared. Idempotent: the parts ride on the node's signature.
(context: ResolutionContext)
| 212 | * declared. Idempotent: the parts ride on the node's signature. |
| 213 | */ |
| 214 | postExtract(context: ResolutionContext): Node[] { |
| 215 | const updates: Node[] = []; |
| 216 | for (const route of context.getNodesByKind('route')) { |
| 217 | if (!route.signature?.startsWith(ROUTE_PARTS_PREFIX)) continue; |
| 218 | let parts: RoutePart[]; |
| 219 | try { |
| 220 | parts = JSON.parse(route.signature.slice(ROUTE_PARTS_PREFIX.length)) as RoutePart[]; |
| 221 | } catch { |
| 222 | continue; |
| 223 | } |
| 224 | const values = parts.map((p) => p.lit ?? (p.expr ? constantPathValue(p.expr, route.filePath, context) : null)); |
| 225 | if (values.some((v) => v === null)) continue; |
| 226 | const name = composeRoutePath(values as string[]); |
| 227 | if (name !== route.name) updates.push({ ...route, name }); |
| 228 | } |
| 229 | return updates; |
| 230 | }, |
| 231 | |
| 232 | /** The routes of tables another file hands the router (`tableRoutes`). */ |
| 233 | crossFileNodes(context: ResolutionContext) { |
nothing calls this directly
no test coverage detected