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

Function memberInHierarchy

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

* The member a name reaches in a class or, failing that, in its ancestors, * nearest first; a parameterless overload before the others. Null when no * class of the hierarchy declares it.

(cls: Node, lower: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

770 * class of the hierarchy declares it.
771 */
772function memberInHierarchy(cls: Node, lower: string, context: ResolutionContext): Node | null {
773 const memo = memos(context).hierarchy;
774 const key = `${cls.id}|${lower}`;
775 if (memo.has(key)) return memo.get(key)!;
776 let found: Node | null = null;
777 const candidates = pascalNamed(lower, context).filter((n) => MEMBER_KINDS.has(n.kind));
778 if (candidates.length > 0) {
779 for (const c of ancestorsOf(cls, context)) {
780 const owner = c.qualifiedName.toLowerCase();
781 const members = candidates.filter((n) => n.filePath === c.filePath && ownerOf(n) === owner);
782 if (members.length > 0) {
783 found = members.find((n) => !needsArguments(n)) ?? members[0]!;
784 break;
785 }
786 }
787 }
788 memo.set(key, found);
789 return found;
790}
791
792/**
793 * A unit's top-level declaration of a name (its enum values included), as

Callers 3

declarationInScopeFunction · 0.85
memberAtPathFunction · 0.85
headOfFunction · 0.85

Calls 8

memosFunction · 0.85
pascalNamedFunction · 0.85
needsArgumentsFunction · 0.85
hasMethod · 0.80
ancestorsOfFunction · 0.70
ownerOfFunction · 0.70
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected