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

Function classNode

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

* The node of the class a lookup found, among the declarations the lookup can * see (`visible`; null: the name names no particular class; undefined: keep * looking).

(named: CppNamedType, site: CppNameSite, context: ResolutionContext, visible: (n: Node) => boolean)

Source from the content-addressed store, hash-verified

374 * looking).
375 */
376function classNode(named: CppNamedType, site: CppNameSite, context: ResolutionContext, visible: (n: Node) => boolean): Node | null | undefined {
377 if (named === null || named === undefined) return named;
378 if (site.declared) return declarationNode(named, site, context, visible);
379 if ('alias' in named) return named.alias;
380 if ('enums' in named) return null;
381 const classes = context
382 .getNodesByQualifiedName(named.cls)
383 .filter((n) => isCFamily(n) && CLASS_KINDS.has(n.kind) && n.id !== site.self?.id);
384 // A lookup that ended on the class itself (its namespace lost) found nothing.
385 if (classes.length === 0) return undefined;
386 const shown = classes.filter(visible);
387 return pick(shown.length > 0 ? shown : classes, site.file);
388}
389
390/**
391 * The declaration a type name found by a lookup stands for, among all that one

Callers 2

lookUpCppClassFunction · 0.85
lookUpFunction · 0.85

Calls 5

declarationNodeFunction · 0.85
hasMethod · 0.80
isCFamilyFunction · 0.70
pickFunction · 0.70

Tested by

no test coverage detected