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

Function valueTypeOf

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

* The class a member's value is of: a field's, a variable's or a property's * declared type, a function's result; indexed, the element of an array or a * generic list, or what an array property gives.

(member: Node, indexed: boolean, context: ResolutionContext)

Source from the content-addressed store, hash-verified

1620 * generic list, or what an array property gives.
1621 */
1622function valueTypeOf(member: Node, indexed: boolean, context: ResolutionContext): Node | null {
1623 if (isRoutine(member)) {
1624 const result = member.returnType ?? /(?:^|\))\s*:\s*([^;]+?)\s*;?\s*$/.exec(member.signature ?? '')?.[1];
1625 return result ? typeOfText(result, member.filePath, indexed, context) : null;
1626 }
1627 // An array property's declared type is its element's: `property Items[I: Integer]: TItem`.
1628 const arrayProperty = indexed && member.kind === 'property' &&
1629 new RegExp(`\\bproperty\\s+${escapeRegExp(member.name)}\\s*\\[`, 'i').test(fileLines(member.filePath, context)[member.startLine - 1] ?? '');
1630 return typeOfText(declaredTypeText(member, context), member.filePath, indexed && !arrayProperty, context);
1631}
1632
1633/**
1634 * The class a written type names (through its aliases, see classNamed); for

Callers 3

typeOfLinksFunction · 0.85
valueOfDeclarationFunction · 0.85
defaultPropertyTypeFunction · 0.85

Calls 6

isRoutineFunction · 0.85
typeOfTextFunction · 0.85
fileLinesFunction · 0.85
declaredTypeTextFunction · 0.85
escapeRegExpFunction · 0.70
execMethod · 0.65

Tested by

no test coverage detected