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

Function targets

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

What a function's or method's `kind` edges reach, as `qualifiedName @confidence`.

(cg: CodeGraph, qualifiedName: string, kind: 'calls' | 'instantiates')

Source from the content-addressed store, hash-verified

193
194/** What a function's or method's `kind` edges reach, as `qualifiedName @confidence`. */
195function targets(cg: CodeGraph, qualifiedName: string, kind: 'calls' | 'instantiates'): string[] {
196 const from = [...cg.getNodesByKind('method'), ...cg.getNodesByKind('function')].find((n) => n.qualifiedName === qualifiedName)!;
197 return cg.getOutgoingEdgesFrom([from.id], [kind])
198 .map((e) => `${cg.getNode(e.target)?.qualifiedName} @${(e.metadata as { confidence?: number } | undefined)?.confidence}`)
199 .sort();
200}
201
202describe('C++ constructions of a type a class shares its name with', () => {
203 // leveldb's db_impl.cc constructs `log::Writer`s and, as `Writer w(…)`, the

Calls 4

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

Tested by

no test coverage detected