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

Method GetSymbolDocumentationComment

internal/ls/jsdoc.go:27–45  ·  view source on GitHub ↗

GetSymbolDocumentationComment renders a symbol's documentation comment as plain text. It backs the API's Symbol.getDocumentationComment and mirrors Strada's getJsDocCommentsFromDeclarations: comments are gathered from each unique declaration, deduplicated, and joined with line breaks. Like Strada, i

(c *checker.Checker, symbol *ast.Symbol)

Source from the content-addressed store, hash-verified

25// deduplicated, and joined with line breaks. Like Strada, it does not resolve aliases —
26// consumers resolve aliases themselves (via getAliasedSymbol) and re-query if desired.
27func (l *LanguageService) GetSymbolDocumentationComment(c *checker.Checker, symbol *ast.Symbol) string {
28 if symbol == nil {
29 return ""
30 }
31 var parts []string
32 var seen collections.Set[*ast.Node]
33 for _, decl := range symbol.Declarations {
34 if decl == nil {
35 continue
36 }
37 if !seen.AddIfAbsent(decl) {
38 continue
39 }
40 if doc := l.getDocumentationFromDeclaration(c, symbol, decl, decl, lsproto.MarkupKindPlainText, true /*commentOnly*/); doc != "" && !slices.Contains(parts, doc) {
41 parts = append(parts, doc)
42 }
43 }
44 return strings.Join(parts, "\n")
45}
46
47// GetSymbolJSDocTags collects a symbol's JSDoc tags. It backs the API's Symbol.getJsDocTags
48// and mirrors Strada's getJsDocTagsFromDeclarations, except each tag's text is rendered as a

Callers 1

Calls 4

ContainsMethod · 0.65
appendFunction · 0.50
AddIfAbsentMethod · 0.45

Tested by

no test coverage detected