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

Function declaredTypeText

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

* The text of the type a field, variable, constant or property declares, * from its declaration on: `TFoo; // the foo` for `FFoo: TFoo; // the foo`. * A name in a comma list (`FOnLoad,` above `FOnSave: TSaveEvent;`) takes the * type the list ends with, a few lines down. Empty when none is written

(node: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

2650 * for a published `property OnClick;`.
2651 */
2652function declaredTypeText(node: Node, context: ResolutionContext): string {
2653 const lines = fileLines(node.filePath, context);
2654 const name = escapeRegExp(node.name);
2655 const re = node.kind === 'property'
2656 ? new RegExp(`\\bproperty\\s+${name}\\s*(?:\\[[^\\]]*\\])?\\s*:\\s*(.*)$`, 'i')
2657 : new RegExp(`\\b${name}\\b(?:\\s*,\\s*[A-Za-z_]\\w*)*\\s*,?\\s*:(?!=)\\s*(.*)$`, 'i');
2658 let text = '';
2659 for (let i = node.startLine - 1; i < node.startLine + 5 && i < lines.length; i++) {
2660 text += ' ' + lines[i]!.replace(/\/\/.*$|\{[^}]*\}|\(\*.*?\*\)/g, ' ');
2661 const m = re.exec(text);
2662 if (m) return m[1]!.trim();
2663 // A list goes on only after a comma.
2664 if (node.kind === 'property' || !/,\s*$/.test(text)) break;
2665 }
2666 return '';
2667}
2668
2669/**
2670 * Whether data holds a routine, by its declared type: one written in place

Callers 4

assignedRoutineTypeFunction · 0.85
valueTypeOfFunction · 0.85
typeOfMemberFunction · 0.85
isProceduralDataFunction · 0.85

Calls 3

fileLinesFunction · 0.85
escapeRegExpFunction · 0.70
execMethod · 0.65

Tested by

no test coverage detected