* Whether the project declares a class's whole hierarchy, so a name its * classes don't declare isn't its member (save TObject's): no ancestor is * outside the project — for a helper, nor the type it helps — and it is no * old-style object or interface with an ancestor of its own, whose * ancest
(cls: Node, context: ResolutionContext)
| 1750 | * ancestors aren't read. |
| 1751 | */ |
| 1752 | function hierarchyInProject(cls: Node, context: ResolutionContext): boolean { |
| 1753 | const memo = memos(context).wholeHierarchies; |
| 1754 | const hit = memo.get(cls.id); |
| 1755 | if (hit !== undefined) return hit; |
| 1756 | let whole = true; |
| 1757 | for (const c of ancestorsOf(cls, context)) { |
| 1758 | if (helperHead(c)) { |
| 1759 | if (supertypesOf(c, context).some((name) => !visibleClassNamed(name, c.filePath, context))) { |
| 1760 | whole = false; |
| 1761 | break; |
| 1762 | } |
| 1763 | continue; |
| 1764 | } |
| 1765 | const head = fileLines(c.filePath, context).slice(c.startLine - 1, c.startLine + 1).join(' ').replace(/\{[^}]*\}|\/\/.*$/gm, ' '); |
| 1766 | const parentInterface = /=\s*(?:disp)?interface\s*\(\s*&?([A-Za-z_][\w.]*)/i.exec(head)?.[1]?.split('.').pop()!.toLowerCase(); |
| 1767 | if (/=\s*(?:packed\s+)?object\s*\(/i.test(head) || |
| 1768 | (parentInterface !== undefined && !IMPLICIT_ROOTS.has(parentInterface))) { |
| 1769 | whole = false; |
| 1770 | break; |
| 1771 | } |
| 1772 | // A class's first supertype is its ancestor; the others are interfaces it implements. |
| 1773 | const base = declaredSupertypes(c, context)[0]; |
| 1774 | if (base && !/^I[A-Z]/.test(base) && !IMPLICIT_ROOTS.has(base.toLowerCase()) && !classNamed(base, c.filePath, context)) { |
| 1775 | whole = false; |
| 1776 | break; |
| 1777 | } |
| 1778 | } |
| 1779 | memo.set(cls.id, whole); |
| 1780 | return whole; |
| 1781 | } |
| 1782 | |
| 1783 | // --------------------------------------------------------------------------- |
| 1784 | // Classes, units and declarations |
no test coverage detected