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

Function cppFunctionAround

src/resolution/cpp-supertypes.ts:125–136  ·  view source on GitHub ↗

* The function a C or C++ class is local to: the one of the scope its * qualified name is in whose lines hold it. Null for a class of a namespace * or of another class.

(cls: Node, context: ResolutionContext)

Source from the content-addressed store, hash-verified

123 * or of another class.
124 */
125function cppFunctionAround(cls: Node, context: ResolutionContext): Node | null {
126 let memo = LOCAL_TO.get(context);
127 if (!memo) LOCAL_TO.set(context, (memo = new Map()));
128 const hit = memo.get(cls.id);
129 if (hit !== undefined) return hit;
130 const scope = cppParentScope(cls.qualifiedName);
131 const fn = (scope ? context.getNodesByQualifiedName(scope) : []).find((f) =>
132 (f.kind === 'function' || f.kind === 'method') && f.filePath === cls.filePath &&
133 f.startLine <= cls.startLine && f.endLine >= cls.startLine) ?? null;
134 memo.set(cls.id, fn);
135 return fn;
136}
137
138/**
139 * The declarations code in `file` can see: a header's, and the file's own —

Callers 1

seenFromFunction · 0.85

Calls 4

cppParentScopeFunction · 0.90
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected