MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resultTypeText

Function resultTypeText

src/resolution/pascal-scope.ts:1688–1702  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

1686 * helper's method), the one whose header is above it.
1687 */
1688function 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

Callers 1

typeOfLinksFunction · 0.85

Calls 4

routineNodeFunction · 0.85
fileLinesFunction · 0.85
routineHeaderAtFunction · 0.85
execMethod · 0.65

Tested by

no test coverage detected