(b *strings.Builder, c *checker.Checker, name *ast.Node, text string, quote bool, isMarkdown bool)
| 1056 | } |
| 1057 | |
| 1058 | func (l *LanguageService) writeNameLink(b *strings.Builder, c *checker.Checker, name *ast.Node, text string, quote bool, isMarkdown bool) { |
| 1059 | declarations := getDeclarationsFromLocation(c, name) |
| 1060 | if len(declarations) != 0 { |
| 1061 | declaration := declarations[0] |
| 1062 | file := ast.GetSourceFileOfNode(declaration) |
| 1063 | node := core.OrElse(ast.GetNameOfDeclaration(declaration), declaration) |
| 1064 | loc := l.getMappedLocation(file.FileName(), createRangeFromNode(node, file)) |
| 1065 | prefixLen := core.IfElse(strings.HasPrefix(text, "()"), 2, 0) |
| 1066 | linkText := trimCommentPrefix(text[prefixLen:]) |
| 1067 | if linkText == "" { |
| 1068 | linkText = getEntityNameString(name) + text[:prefixLen] |
| 1069 | } |
| 1070 | if isMarkdown { |
| 1071 | linkUri := fmt.Sprintf("%s#%d,%d-%d,%d", loc.Uri, loc.Range.Start.Line+1, loc.Range.Start.Character+1, loc.Range.End.Line+1, loc.Range.End.Character+1) |
| 1072 | writeMarkdownLink(b, linkText, linkUri, quote) |
| 1073 | } else { |
| 1074 | writeQuotedString(b, linkText, false) |
| 1075 | } |
| 1076 | return |
| 1077 | } |
| 1078 | writeQuotedString(b, getEntityNameString(name)+core.IfElse(len(text) != 0, " ", "")+text, quote && isMarkdown) |
| 1079 | } |
| 1080 | |
| 1081 | func trimCommentPrefix(text string) string { |
| 1082 | return strings.TrimLeft(strings.TrimPrefix(strings.TrimLeft(text, " "), "|"), " ") |
no test coverage detected