Skip to content

Commit 800c7c5

Browse files
authored
fix(documentation): correctly show T? type (#380)
Fixes #375
1 parent dfd52fb commit 800c7c5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

server/src/e2e/suite/testcases/documentation/functions.test

+9
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,12 @@ Some interesting list
181181
- Point 1
182182
with other line
183183
- Point 2
184+
185+
========================================================================
186+
Function documentation with T? type
187+
========================================================================
188+
fun <caret>foo(): Int? {}
189+
------------------------------------------------------------------------
190+
```tact
191+
fun foo(): Int?
192+
```

server/src/psi/Decls.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ export class Fun extends NamedNode {
337337
if (!parametersNode) return ""
338338

339339
const result = this.returnType()
340-
return parametersNode.text + (result ? `: ${result.node.text}` : "")
340+
const suffix = result?.node.nextSibling?.text === "?" ? "?" : ""
341+
342+
return parametersNode.text + (result ? `: ${result.node.text}${suffix}` : "")
341343
}
342344

343345
public isOverride(): boolean {

0 commit comments

Comments
 (0)