MCPcopy Create free account
hub / github.com/microsoft/typescript-go / writeJSDocLink

Method writeJSDocLink

internal/ls/hover.go:1026–1056  ·  view source on GitHub ↗
(b *strings.Builder, c *checker.Checker, link *ast.Node, quote bool, isMarkdown bool)

Source from the content-addressed store, hash-verified

1024}
1025
1026func (l *LanguageService) writeJSDocLink(b *strings.Builder, c *checker.Checker, link *ast.Node, quote bool, isMarkdown bool) {
1027 name := link.Name()
1028 text := strings.Trim(link.Text(), " ")
1029 if name == nil {
1030 writeQuotedString(b, text, quote && isMarkdown)
1031 return
1032 }
1033 if ast.IsIdentifier(name) && (name.Text() == "http" || name.Text() == "https") && strings.HasPrefix(text, "://") {
1034 linkText := name.Text() + text
1035 linkUri := linkText
1036 if commentPos := strings.IndexFunc(linkText, func(ch rune) bool { return ch == ' ' || ch == '|' }); commentPos >= 0 {
1037 linkUri = linkText[:commentPos]
1038 linkText = trimCommentPrefix(linkText[commentPos:])
1039 if linkText == "" {
1040 linkText = linkUri
1041 }
1042 }
1043 if isMarkdown {
1044 writeMarkdownLink(b, linkText, linkUri, quote)
1045 } else {
1046 writeQuotedString(b, linkText, false)
1047 if linkText != linkUri {
1048 b.WriteString(" (")
1049 b.WriteString(linkUri)
1050 b.WriteString(")")
1051 }
1052 }
1053 return
1054 }
1055 l.writeNameLink(b, c, name, text, quote, isMarkdown)
1056}
1057
1058func (l *LanguageService) writeNameLink(b *strings.Builder, c *checker.Checker, name *ast.Node, text string, quote bool, isMarkdown bool) {
1059 declarations := getDeclarationsFromLocation(c, name)

Callers 1

writeCommentsMethod · 0.95

Calls 7

writeNameLinkMethod · 0.95
IsIdentifierFunction · 0.92
writeQuotedStringFunction · 0.85
trimCommentPrefixFunction · 0.85
writeMarkdownLinkFunction · 0.85
NameMethod · 0.65
TextMethod · 0.65

Tested by

no test coverage detected