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

Function declaredTypeText

src/resolution/pascal-scope.ts:1116–1131  ·  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

1114 * for a published `property OnClick;`.
1115 */
1116function declaredTypeText(node: Node, context: ResolutionContext): string {
1117 const lines = fileLines(node.filePath, context);
1118 const name = escapeRegExp(node.name);
1119 const re = node.kind === 'property'
1120 ? new RegExp(`\\bproperty\\s+${name}\\s*(?:\\[[^\\]]*\\])?\\s*:\\s*(.*)$`, 'i')
1121 : new RegExp(`\\b${name}\\b(?:\\s*,\\s*[A-Za-z_]\\w*)*\\s*,?\\s*:(?!=)\\s*(.*)$`, 'i');
1122 let text = '';
1123 for (let i = node.startLine - 1; i < node.startLine + 5 && i < lines.length; i++) {
1124 text += ' ' + lines[i]!.replace(/\/\/.*$|\{[^}]*\}|\(\*.*?\*\)/g, ' ');
1125 const m = re.exec(text);
1126 if (m) return m[1]!.trim();
1127 // A list goes on only after a comma.
1128 if (node.kind === 'property' || !/,\s*$/.test(text)) break;
1129 }
1130 return '';
1131}
1132
1133/**
1134 * Whether data holds a routine, by its declared type: one written in place

Callers 3

assignedRoutineTypeFunction · 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