* The result type, as written, of the function making a call: the routine * the reference comes from, or, for code the graph gives to the file (a * helper's method), the one whose header is above it.
(ref: UnresolvedRef, context: ResolutionContext)
| 1686 | * helper's method), the one whose header is above it. |
| 1687 | */ |
| 1688 | function resultTypeText(ref: UnresolvedRef, context: ResolutionContext): string | undefined { |
| 1689 | const routine = routineNode(ref.fromNodeId, context); |
| 1690 | const signature = routine ? routine.signature ?? '' : (() => { |
| 1691 | const lines = fileLines(ref.filePath!, context); |
| 1692 | const from = routineHeaderAt(ref.filePath!, ref.line, context); |
| 1693 | // A header's parameters may go on over a few lines. |
| 1694 | let text = ''; |
| 1695 | for (let i = from; i <= ref.line && i < from + 6 && i <= lines.length; i++) { |
| 1696 | text += ' ' + lines[i - 1]!.replace(/\/\/.*$|\{[^}]*\}/g, ' '); |
| 1697 | if (/;\s*$/.test(text) && text.split('(').length <= text.split(')').length) break; |
| 1698 | } |
| 1699 | return text.replace(/^\s*(?:class\s+)?function\s+[\w.<>, ]*?(?=[(:])/i, ''); |
| 1700 | })(); |
| 1701 | return routine?.returnType ?? /(?:^|\))\s*:\s*([^;]+?)\s*;?\s*$/.exec(signature.trim())?.[1]; |
| 1702 | } |
| 1703 | |
| 1704 | /** |
| 1705 | * The declared type, as written, of a parameter or a local the calling |
no test coverage detected