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

Function defaultPropertyType

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

What a class's default array property gives (`property Items[I: Integer]: TFoo …; default;`), or null.

(cls: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

1659
1660/** What a class's default array property gives (`property Items[I: Integer]: TFoo …; default;`), or null. */
1661function defaultPropertyType(cls: Node, context: ResolutionContext): Node | null {
1662 const memo = memos(context).defaultProperties;
1663 if (memo.has(cls.id)) return memo.get(cls.id)!;
1664 memo.set(cls.id, null);
1665 let type: Node | null = null;
1666 for (const c of ancestorsOf(cls, context)) {
1667 const owner = c.qualifiedName.toLowerCase();
1668 const property = context.getNodesInFile(c.filePath).find((n) => {
1669 if (n.kind !== 'property' || ownerOf(n) !== owner) return false;
1670 const lines = fileLines(n.filePath, context);
1671 const text = `${lines[n.startLine - 1] ?? ''} ${lines[n.startLine] ?? ''}`.replace(/\/\/.*$|\{[^}]*\}/gm, ' ');
1672 return /\bproperty\s+\w+\s*\[[^\]]*\][^;]*;\s*default\s*;/i.test(text);
1673 });
1674 if (property) {
1675 type = valueTypeOf(property, false, context);
1676 break;
1677 }
1678 }
1679 memo.set(cls.id, type);
1680 return type;
1681}
1682
1683/**
1684 * The result type, as written, of the function making a call: the routine

Callers 1

typeOfTextFunction · 0.85

Calls 9

memosFunction · 0.85
fileLinesFunction · 0.85
valueTypeOfFunction · 0.85
hasMethod · 0.80
ancestorsOfFunction · 0.70
ownerOfFunction · 0.70
getMethod · 0.65
getNodesInFileMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected