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

Function hierarchyInProject

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

* 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)

Source from the content-addressed store, hash-verified

1750 * ancestors aren't read.
1751 */
1752function 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

Callers 1

withSubjectMemberFunction · 0.85

Calls 13

memosFunction · 0.85
helperHeadFunction · 0.85
visibleClassNamedFunction · 0.85
fileLinesFunction · 0.85
declaredSupertypesFunction · 0.85
hasMethod · 0.80
ancestorsOfFunction · 0.70
supertypesOfFunction · 0.70
classNamedFunction · 0.70
getMethod · 0.65
execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected