(
provider: HopResolver,
root: string,
hop: BugPathNode,
opts: ProviderQueryOptions = {},
)
| 672 | * opens nothing rather than opening something plausible. |
| 673 | */ |
| 674 | export async function resolveHop( |
| 675 | provider: HopResolver, |
| 676 | root: string, |
| 677 | hop: BugPathNode, |
| 678 | opts: ProviderQueryOptions = {}, |
| 679 | ): Promise<SymbolRef | undefined> { |
| 680 | if (hop.filePath !== undefined && hop.line !== undefined) { |
| 681 | const resolved = await provider |
| 682 | .resolveSymbolAt(root, hop.filePath, hop.line, opts) |
| 683 | .catch(() => undefined); |
| 684 | if (resolved?.kind === 'ok') { |
| 685 | return resolved.symbol; |
| 686 | } |
| 687 | } |
| 688 | const hits = await provider |
| 689 | .searchSymbols(root, hop.name, WIZARD_SEARCH_LIMIT, opts) |
| 690 | .catch(() => [] as SymbolSearchHit[]); |
| 691 | const match = pickHit(hits, hop); |
| 692 | if (match?.filePath === undefined || match.line === undefined) { |
| 693 | return undefined; |
| 694 | } |
| 695 | const resolved = await provider |
| 696 | .resolveSymbolAt(root, match.filePath, match.line, opts) |
| 697 | .catch(() => undefined); |
| 698 | return resolved?.kind === 'ok' ? resolved.symbol : undefined; |
| 699 | } |
| 700 | |
| 701 | /** |
| 702 | * The candidate that is this hop, out of what the search returned. |
no test coverage detected