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

Function classOfRoutine

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

The class a method belongs to: its qualified name's owner, declared in the method's own file.

(routine: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

724
725/** The class a method belongs to: its qualified name's owner, declared in the method's own file. */
726function classOfRoutine(routine: Node, context: ResolutionContext): Node | null {
727 if (routine.kind !== 'method') return null;
728 const memo = memos(context).classOfRoutine;
729 if (memo.has(routine.id)) return memo.get(routine.id)!;
730 const owner = routine.qualifiedName.slice(0, Math.max(0, routine.qualifiedName.lastIndexOf('::')));
731 const candidates = owner ? context.getNodesByQualifiedName(owner).filter((n) => n.language === 'pascal' && CLASS_KINDS.has(n.kind)) : [];
732 const cls = declarationOf(candidates.filter((n) => n.filePath === routine.filePath)) ?? declarationOf(candidates);
733 memo.set(routine.id, cls);
734 return cls;
735}
736
737/** A class and its ancestors the project declares, nearest first. */
738function ancestorsOf(cls: Node, context: ResolutionContext): Node[] {

Callers 2

matchPascalParenlessRefFunction · 0.85
classOfCallFunction · 0.85

Calls 6

memosFunction · 0.85
declarationOfFunction · 0.85
hasMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected