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

Function classes

__tests__/cpp-written-scope-class-names.test.ts:47–58  ·  view source on GitHub ↗

Every class, struct and union node, as `kind qualifiedName`, with the members it contains.

(cg: CodeGraph)

Source from the content-addressed store, hash-verified

45
46/** Every class, struct and union node, as `kind qualifiedName`, with the members it contains. */
47function classes(cg: CodeGraph): Record<string, string[]> {
48 const out: Record<string, string[]> = {};
49 for (const n of [...cg.getNodesByKind('class'), ...cg.getNodesByKind('struct'), ...cg.getNodesByKind('union')]) {
50 const members = cg.getOutgoingEdgesFrom([n.id], ['contains'])
51 .map((e) => cg.getNode(e.target))
52 .filter((m): m is Node => m !== null && (m.kind === 'method' || m.kind === 'field' || m.kind === 'property'))
53 .map((m) => m.qualifiedName)
54 .sort();
55 out[`${n.kind} ${n.qualifiedName}`] = members;
56 }
57 return out;
58}
59
60const SKIPLIST = lines(
61 'namespace leveldb {',

Calls 4

mapMethod · 0.80
getNodeMethod · 0.80
getNodesByKindMethod · 0.65
getOutgoingEdgesFromMethod · 0.45

Tested by

no test coverage detected