| 378 | } |
| 379 | |
| 380 | function routeDrafts(routes: readonly RouteRef[], rank: number): Draft[] { |
| 381 | return routes.map((route) => { |
| 382 | const method = route.method ?? 'ANY'; |
| 383 | const handler = route.handler === undefined ? '' : ` handled by ${route.handler}`; |
| 384 | const source: CardSource = { name: `${method} ${route.path}` }; |
| 385 | if (route.filePath !== undefined) { |
| 386 | source.filePath = route.filePath; |
| 387 | } |
| 388 | if (route.line !== undefined) { |
| 389 | source.line = route.line; |
| 390 | } |
| 391 | return { |
| 392 | kind: 'route' as const, |
| 393 | lines: [ |
| 394 | `The route ${method} ${route.path} is registered in ` |
| 395 | + `${route.filePath ?? 'an unnamed file'}` |
| 396 | + `${route.line === undefined ? '' : `:${route.line}`}${handler}.`, |
| 397 | route.origin === 'source' |
| 398 | ? 'It was read off the source text, not out of the index.' |
| 399 | : 'The index reports it.', |
| 400 | ], |
| 401 | source, |
| 402 | rank, |
| 403 | }; |
| 404 | }); |
| 405 | } |
| 406 | |
| 407 | function entryDraft(entryPoints: readonly SymbolSearchHit[], rank: number): Draft[] { |
| 408 | if (entryPoints.length === 0) { |