MCPcopy Create free account
hub / github.com/Effect-TS/effect / attachSeeLinkSymbolsFromSourceFile

Function attachSeeLinkSymbolsFromSourceFile

packages/tools/jsdocs/src/Jsdocs.ts:1761–1797  ·  view source on GitHub ↗
(
  tags: T,
  sourceFile: ts.SourceFile,
  block: JSDocBlock,
  linkContext: { readonly checker: ts.TypeChecker; readonly entry: ProgramCacheEntry; readonly cwd: string }
)

Source from the content-addressed store, hash-verified

1759}
1760
1761function attachSeeLinkSymbolsFromSourceFile<
1762 T extends ParsedModuleTags | ParsedDeclarationTags | ParsedNamespaceTags | ParsedMemberTags
1763>(
1764 tags: T,
1765 sourceFile: ts.SourceFile,
1766 block: JSDocBlock,
1767 linkContext: { readonly checker: ts.TypeChecker; readonly entry: ProgramCacheEntry; readonly cwd: string }
1768): T {
1769 const resolved = new Map<
1770 string,
1771 Array<{ readonly range: readonly [number, number]; readonly symbol?: ParsedInlineLinkSymbol }>
1772 >()
1773 for (const link of collectJSDocLinks(sourceFile, block)) {
1774 const text = link.getText(sourceFile)
1775 const target = extractInlineLinkTarget(text)
1776 if (target === "" || urlRegex.test(target)) continue
1777 const symbol = resolveJSDocLinkSymbol(link, linkContext.checker)
1778 const info = symbol === undefined ? undefined : inlineLinkSymbol(symbol, linkContext.cwd, linkContext.checker)
1779 const items = resolved.get(text) ?? []
1780 items.push(info === undefined ? { range: [link.pos, link.end] } : { range: [link.pos, link.end], symbol: info })
1781 resolved.set(text, items)
1782 }
1783 return {
1784 ...tags,
1785 see: tags.see.map((tag) => ({
1786 ...tag,
1787 links: tag.links.map((link) => {
1788 const items = resolved.get(link.raw)
1789 const info = items?.shift()
1790 if (info === undefined) return link
1791 return info.symbol === undefined
1792 ? { ...link, range: info.range }
1793 : { ...link, range: info.range, symbol: info.symbol }
1794 })
1795 }))
1796 }
1797}
1798
1799function attachSeeLinkSymbols<T extends ParsedDeclarationTags | ParsedNamespaceTags | ParsedMemberTags>(
1800 tags: T,

Callers 2

attachSeeLinkSymbolsFunction · 0.85
moduleSeeTagsFunction · 0.85

Calls 8

collectJSDocLinksFunction · 0.85
extractInlineLinkTargetFunction · 0.85
resolveJSDocLinkSymbolFunction · 0.85
inlineLinkSymbolFunction · 0.85
pushMethod · 0.80
getMethod · 0.65
setMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected