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

Function makeContext

__tests__/react-native-bridge.test.ts:13–37  ·  view source on GitHub ↗

* Mock ResolutionContext for the React Native bridge resolver.

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

Source from the content-addressed store, hash-verified

11 * Mock ResolutionContext for the React Native bridge resolver.
12 */
13function makeContext(nodes: Node[], fileContents: Record<string, string> = {}): ResolutionContext {
14 const byName = new Map<string, Node[]>();
15 for (const n of nodes) {
16 const arr = byName.get(n.name);
17 if (arr) arr.push(n);
18 else byName.set(n.name, [n]);
19 }
20 // Files = union of node files + any extra fileContents keys (for files that
21 // have content like .mm bridge declarations but no extracted nodes yet).
22 const allFiles = new Set<string>(
23 [...nodes.map((n) => n.filePath), ...Object.keys(fileContents)]
24 );
25 return {
26 getNodesInFile: (fp) => nodes.filter((n) => n.filePath === fp),
27 getNodesByName: (name) => byName.get(name) ?? [],
28 getNodesByQualifiedName: () => { throw new Error('not used'); },
29 getNodesByKind: (kind) => nodes.filter((n) => n.kind === kind),
30 getNodesByLowerName: () => { throw new Error('not used'); },
31 fileExists: (fp) => allFiles.has(fp),
32 readFile: (fp) => fileContents[fp] ?? null,
33 getProjectRoot: () => '/test',
34 getAllFiles: () => Array.from(allFiles),
35 getImportMappings: () => [],
36 };
37}
38
39function method(
40 name: string,

Callers 1

Calls 3

setMethod · 0.80
hasMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected