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

Function classOfRoutine

src/resolution/pascal-scope.ts:1904–1913  ·  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

1902
1903/** The class a method belongs to: its qualified name's owner, declared in the method's own file. */
1904function classOfRoutine(routine: Node, context: ResolutionContext): Node | null {
1905 if (routine.kind !== 'method') return null;
1906 const memo = memos(context).classOfRoutine;
1907 if (memo.has(routine.id)) return memo.get(routine.id)!;
1908 const owner = routine.qualifiedName.slice(0, Math.max(0, routine.qualifiedName.lastIndexOf('::')));
1909 const candidates = owner ? context.getNodesByQualifiedName(owner).filter((n) => n.language === 'pascal' && CLASS_KINDS.has(n.kind)) : [];
1910 const cls = declarationOf(candidates.filter((n) => n.filePath === routine.filePath)) ?? declarationOf(candidates);
1911 memo.set(routine.id, cls);
1912 return cls;
1913}
1914
1915/**
1916 * A class and its ancestors the project declares, nearest first. A helper's

Callers 4

matchPascalParenlessRefFunction · 0.85
gatePascalCallFunction · 0.85
helperOwnedFunction · 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