What a class's default array property gives (`property Items[I: Integer]: TFoo …; default;`), or null.
(cls: Node, context: ResolutionContext)
| 1659 | |
| 1660 | /** What a class's default array property gives (`property Items[I: Integer]: TFoo …; default;`), or null. */ |
| 1661 | function 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 |
no test coverage detected