(link: ParsedInlineLink)
| 2267 | } |
| 2268 | } |
| 2269 | const resolveSymbol = (link: ParsedInlineLink): JSDocApiSeeLinkResolution | undefined => { |
| 2270 | if (link.symbol === undefined) return undefined |
| 2271 | const symbol = link.symbol |
| 2272 | const exact = bySourceRange.get(sourceRangeKey(symbol.file, symbol.range)) |
| 2273 | if (exact !== undefined) return { _tag: "Resolved", apiId: exact.id, apiFqn: exact.apiFqn } |
| 2274 | const names = seeTargetNames(link) |
| 2275 | const candidates = (bySourceFile.get(symbol.file) ?? []).filter((api) => |
| 2276 | apiMatchesSeeTarget(api, names) && |
| 2277 | (rangeContains(symbol.range, api.source.range) || |
| 2278 | rangeContains(api.source.range, symbol.range) || |
| 2279 | rangeOverlaps(symbol.range, api.source.range)) |
| 2280 | ).sort((self, that) => rangeWidth(self.source.range) - rangeWidth(that.source.range)) |
| 2281 | const unique = Array.from(new Map(candidates.map((candidate) => [candidate.id, candidate])).values()) |
| 2282 | if (unique.length === 1) return { _tag: "Resolved", apiId: unique[0].id, apiFqn: unique[0].apiFqn } |
| 2283 | if (unique.length > 1) { |
| 2284 | return { _tag: "Unresolved", reason: "ambiguous", candidates: unique.map((candidate) => candidate.id) } |
| 2285 | } |
| 2286 | const sameFileByName = (bySourceFile.get(symbol.file) ?? []).filter((api) => apiMatchesSeeTarget(api, names)) |
| 2287 | const uniqueByName = Array.from(new Map(sameFileByName.map((candidate) => [candidate.id, candidate])).values()) |
| 2288 | if (uniqueByName.length === 1) { |
| 2289 | return { _tag: "Resolved", apiId: uniqueByName[0].id, apiFqn: uniqueByName[0].apiFqn } |
| 2290 | } |
| 2291 | if (uniqueByName.length > 1) { |
| 2292 | return { _tag: "Unresolved", reason: "ambiguous", candidates: uniqueByName.map((candidate) => candidate.id) } |
| 2293 | } |
| 2294 | return undefined |
| 2295 | } |
| 2296 | return ( |
| 2297 | context: { readonly moduleName: string; readonly namespacePath: ReadonlyArray<string> }, |
| 2298 | link: ParsedInlineLink |
no test coverage detected