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

Function attachSeeLinkSymbolsFromSourceFile

packages/tools/jsdocs/src/Jsdocs.ts:1812–1848  ·  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

1810}
1811
1812function attachSeeLinkSymbolsFromSourceFile<
1813 T extends ParsedModuleTags | ParsedDeclarationTags | ParsedNamespaceTags | ParsedMemberTags
1814>(
1815 tags: T,
1816 sourceFile: ts.SourceFile,
1817 block: JSDocBlock,
1818 linkContext: { readonly checker: ts.TypeChecker; readonly entry: ProgramCacheEntry; readonly cwd: string }
1819): T {
1820 const resolved = new Map<
1821 string,
1822 Array<{ readonly range: readonly [number, number]; readonly symbol?: ParsedInlineLinkSymbol }>
1823 >()
1824 for (const link of collectJSDocLinks(sourceFile, block)) {
1825 const text = link.getText(sourceFile)
1826 const target = extractInlineLinkTarget(text)
1827 if (target === "" || urlRegex.test(target)) continue
1828 const symbol = resolveJSDocLinkSymbol(link, linkContext.checker)
1829 const info = symbol === undefined ? undefined : inlineLinkSymbol(symbol, linkContext.cwd, linkContext.checker)
1830 const items = resolved.get(text) ?? []
1831 items.push(info === undefined ? { range: [link.pos, link.end] } : { range: [link.pos, link.end], symbol: info })
1832 resolved.set(text, items)
1833 }
1834 return {
1835 ...tags,
1836 see: tags.see.map((tag) => ({
1837 ...tag,
1838 links: tag.links.map((link) => {
1839 const items = resolved.get(link.raw)
1840 const info = items?.shift()
1841 if (info === undefined) return link
1842 return info.symbol === undefined
1843 ? { ...link, range: info.range }
1844 : { ...link, range: info.range, symbol: info.symbol }
1845 })
1846 }))
1847 }
1848}
1849
1850function attachSeeLinkSymbols<T extends ParsedDeclarationTags | ParsedNamespaceTags | ParsedMemberTags>(
1851 tags: T,

Callers 2

attachSeeLinkSymbolsFunction · 0.85
moduleSeeTagsFunction · 0.85

Calls 8

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

Tested by

no test coverage detected