@@ -44,6 +44,7 @@ func (l *LanguageService) ProvideSignatureHelp(
4444 position lsproto.Position ,
4545 context * lsproto.SignatureHelpContext ,
4646 clientOptions * lsproto.SignatureHelpClientCapabilities ,
47+ docFormat lsproto.MarkupKind ,
4748) (lsproto.SignatureHelpResponse , error ) {
4849 program , sourceFile := l .getProgramAndFile (documentURI )
4950 items := l .GetSignatureHelpItems (
@@ -52,7 +53,8 @@ func (l *LanguageService) ProvideSignatureHelp(
5253 program ,
5354 sourceFile ,
5455 context ,
55- clientOptions )
56+ clientOptions ,
57+ docFormat )
5658 return lsproto.SignatureHelpOrNull {SignatureHelp : items }, nil
5759}
5860
@@ -63,6 +65,7 @@ func (l *LanguageService) GetSignatureHelpItems(
6365 sourceFile * ast.SourceFile ,
6466 context * lsproto.SignatureHelpContext ,
6567 clientOptions * lsproto.SignatureHelpClientCapabilities ,
68+ docFormat lsproto.MarkupKind ,
6669) * lsproto.SignatureHelp {
6770 typeChecker , done := program .GetTypeCheckerForFile (ctx , sourceFile )
6871 defer done ()
@@ -140,7 +143,7 @@ func (l *LanguageService) GetSignatureHelpItems(
140143
141144 // return typeChecker.runWithCancellationToken(cancellationToken, typeChecker =>
142145 if candidateInfo .candidateInfo != nil {
143- return createSignatureHelpItems (candidateInfo .candidateInfo .candidates , candidateInfo .candidateInfo .resolvedSignature , argumentInfo , sourceFile , typeChecker , onlyUseSyntacticOwners , clientOptions )
146+ return l . createSignatureHelpItems (candidateInfo .candidateInfo .candidates , candidateInfo .candidateInfo .resolvedSignature , argumentInfo , sourceFile , typeChecker , onlyUseSyntacticOwners , clientOptions , docFormat )
144147 }
145148 return createTypeHelpItems (candidateInfo .typeInfo , argumentInfo , sourceFile , clientOptions , typeChecker )
146149}
@@ -202,7 +205,7 @@ func getTypeHelpItem(symbol *ast.Symbol, typeParameter []*checker.Type, enclosin
202205 }
203206}
204207
205- func createSignatureHelpItems (candidates []* checker.Signature , resolvedSignature * checker.Signature , argumentInfo * argumentListInfo , sourceFile * ast.SourceFile , c * checker.Checker , useFullPrefix bool , clientOptions * lsproto.SignatureHelpClientCapabilities ) * lsproto.SignatureHelp {
208+ func ( l * LanguageService ) createSignatureHelpItems (candidates []* checker.Signature , resolvedSignature * checker.Signature , argumentInfo * argumentListInfo , sourceFile * ast.SourceFile , c * checker.Checker , useFullPrefix bool , clientOptions * lsproto.SignatureHelpClientCapabilities , docFormat lsproto. MarkupKind ) * lsproto.SignatureHelp {
206209 enclosingDeclaration := getEnclosingDeclarationFromInvocation (argumentInfo .invocation )
207210 if enclosingDeclaration == nil {
208211 return nil
@@ -223,7 +226,7 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature
223226 }
224227 items := make ([][]signatureInformation , len (candidates ))
225228 for i , candidateSignature := range candidates {
226- items [i ] = getSignatureHelpItem (candidateSignature , argumentInfo .isTypeParameterList , callTargetDisplayParts .String (), enclosingDeclaration , sourceFile , c )
229+ items [i ] = l . getSignatureHelpItem (candidateSignature , argumentInfo .isTypeParameterList , callTargetDisplayParts .String (), enclosingDeclaration , sourceFile , c , docFormat )
227230 }
228231
229232 selectedItemIndex := 0
@@ -262,9 +265,18 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature
262265 for j , param := range item .Parameters {
263266 parameters [j ] = param .parameterInfo
264267 }
268+ var documentation * lsproto.StringOrMarkupContent
269+ if item .Documentation != nil {
270+ documentation = & lsproto.StringOrMarkupContent {
271+ MarkupContent : & lsproto.MarkupContent {
272+ Kind : docFormat ,
273+ Value : * item .Documentation ,
274+ },
275+ }
276+ }
265277 signatureInformation [i ] = & lsproto.SignatureInformation {
266278 Label : item .Label ,
267- Documentation : nil ,
279+ Documentation : documentation ,
268280 Parameters : & parameters ,
269281 }
270282 }
@@ -291,7 +303,7 @@ func createSignatureHelpItems(candidates []*checker.Signature, resolvedSignature
291303 return help
292304}
293305
294- func getSignatureHelpItem (candidate * checker.Signature , isTypeParameterList bool , callTargetSymbol string , enclosingDeclaration * ast.Node , sourceFile * ast.SourceFile , c * checker.Checker ) []signatureInformation {
306+ func ( l * LanguageService ) getSignatureHelpItem (candidate * checker.Signature , isTypeParameterList bool , callTargetSymbol string , enclosingDeclaration * ast.Node , sourceFile * ast.SourceFile , c * checker.Checker , docFormat lsproto. MarkupKind ) []signatureInformation {
295307 var infos []* signatureHelpItemInfo
296308 if isTypeParameterList {
297309 infos = itemInfoForTypeParameters (candidate , c , enclosingDeclaration , sourceFile )
@@ -301,6 +313,15 @@ func getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool
301313
302314 suffixDisplayParts := returnTypeToDisplayParts (candidate , c )
303315
316+ // Generate documentation from the signature's declaration
317+ var documentation * string
318+ if declaration := candidate .Declaration (); declaration != nil {
319+ doc := l .getDocumentationFromDeclaration (c , declaration , docFormat )
320+ if doc != "" {
321+ documentation = & doc
322+ }
323+ }
324+
304325 result := make ([]signatureInformation , len (infos ))
305326 for i , info := range infos {
306327 var display strings.Builder
@@ -309,7 +330,7 @@ func getSignatureHelpItem(candidate *checker.Signature, isTypeParameterList bool
309330 display .WriteString (suffixDisplayParts )
310331 result [i ] = signatureInformation {
311332 Label : display .String (),
312- Documentation : nil ,
333+ Documentation : documentation ,
313334 Parameters : info .parameters ,
314335 IsVariadic : info .isVariadic ,
315336 }
0 commit comments