(
index: BugPathIndex,
project: string,
filePaths: readonly string[],
)
| 403 | * asked about it. |
| 404 | */ |
| 405 | export async function declarationNames( |
| 406 | index: BugPathIndex, |
| 407 | project: string, |
| 408 | filePaths: readonly string[], |
| 409 | ): Promise<Map<string, { qualifiedName?: string; line?: number }>> { |
| 410 | const found = new Map<string, { qualifiedName?: string; line?: number }>(); |
| 411 | const files = [...new Set(filePaths.filter((path) => path.length > 0))].sort(compareText); |
| 412 | if (files.length === 0) { |
| 413 | return found; |
| 414 | } |
| 415 | for (const label of CALLABLE_LABELS) { |
| 416 | const query = declarationsInFiles(label, files); |
| 417 | if (query === undefined) { |
| 418 | continue; |
| 419 | } |
| 420 | let rows: Record<string, string>[]; |
| 421 | try { |
| 422 | rows = await index.queryRows(project, query); |
| 423 | } catch { |
| 424 | continue; |
| 425 | } |
| 426 | for (const row of rows) { |
| 427 | const name = row[COLUMNS.declarations[0]] ?? ''; |
| 428 | const filePath = row[COLUMNS.declarations[2]] ?? ''; |
| 429 | if (name.length === 0) { |
| 430 | continue; |
| 431 | } |
| 432 | const key = nodeKey({ name, filePath }); |
| 433 | if (found.has(key)) { |
| 434 | continue; |
| 435 | } |
| 436 | const qualifiedName = row[COLUMNS.declarations[1]] ?? ''; |
| 437 | const line = toOptionalNumber(row[COLUMNS.declarations[3]]); |
| 438 | found.set(key, { |
| 439 | ...(qualifiedName.length > 0 ? { qualifiedName } : {}), |
| 440 | ...(line === undefined ? {} : { line }), |
| 441 | }); |
| 442 | } |
| 443 | } |
| 444 | return found; |
| 445 | } |
| 446 | |
| 447 | /** |
| 448 | * Whether the index records one named call. |
no test coverage detected