MCPcopy
hub / github.com/colbymchenry/codegraph / makeContext

Function makeContext

__tests__/swift-objc-bridge-resolver.test.ts:11–31  ·  view source on GitHub ↗

* Lightweight ResolutionContext mock — implements only the methods the * bridge resolver actually calls. Anything else throws so a leaked call * surfaces loudly in tests.

(nodes: Node[], fileContents: Record<string, string> = {})

Source from the content-addressed store, hash-verified

9 * surfaces loudly in tests.
10 */
11function makeContext(nodes: Node[], fileContents: Record<string, string> = {}): ResolutionContext {
12 const byName = new Map<string, Node[]>();
13 for (const n of nodes) {
14 const arr = byName.get(n.name);
15 if (arr) arr.push(n);
16 else byName.set(n.name, [n]);
17 }
18 const allFiles = new Set(nodes.map((n) => n.filePath));
19 return {
20 getNodesInFile: (fp) => nodes.filter((n) => n.filePath === fp),
21 getNodesByName: (name) => byName.get(name) ?? [],
22 getNodesByQualifiedName: () => { throw new Error('not used'); },
23 getNodesByKind: (kind) => nodes.filter((n) => n.kind === kind),
24 getNodesByLowerName: () => { throw new Error('not used'); },
25 fileExists: (fp) => allFiles.has(fp),
26 readFile: (fp) => fileContents[fp] ?? null,
27 getProjectRoot: () => '/test',
28 getAllFiles: () => Array.from(allFiles),
29 getImportMappings: () => [],
30 };
31}
32
33function method(name: string, language: 'swift' | 'objc', filePath: string, startLine = 10): Node {
34 return {

Calls 3

setMethod · 0.80
hasMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected