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

Function synced

__tests__/parameter-flow.test.ts:723–750  ·  view source on GitHub ↗

Index `first`, apply `change`, sync and compare with a fresh index; `looked` says how the pass went.

(first: Record<string, string>, change: (root: string) => void)

Source from the content-addressed store, hash-verified

721
722 /** Index `first`, apply `change`, sync and compare with a fresh index; `looked` says how the pass went. */
723 async function synced(first: Record<string, string>, change: (root: string) => void): Promise<{ cg: CodeGraph; root: string; looked: 'the change' | 'the project'; files: number }> {
724 const project = vi.spyOn(ParameterFlowQueries.prototype, 'getReachedMethods');
725 const { root, cg } = await indexed(first);
726 project.mockClear();
727 const adapter = rubyParameterFlow.adapter.bind(rubyParameterFlow);
728 let files = 0;
729 const made = vi.spyOn(rubyParameterFlow, 'adapter').mockImplementation((...args) => {
730 const flow = adapter(...args);
731 const written = flow.written.bind(flow);
732 flow.written = (names, list) => {
733 files = Math.max(files, list.length);
734 return written(names, list);
735 };
736 return flow;
737 });
738 change(root);
739 await cg.sync();
740 const looked = project.mock.calls.length > 0 ? 'the project' : 'the change';
741 project.mockRestore();
742 made.mockRestore();
743 const fresh = fs.mkdtempSync(path.join(os.tmpdir(), 'cg-parameter-flow-fresh-'));
744 roots.push(fresh);
745 fs.cpSync(root, fresh, { recursive: true, filter: (src) => !src.includes('.codegraph') });
746 const rebuilt = await CodeGraph.init(fresh, { index: true });
747 open.push(rebuilt);
748 expect(graphOf(cg)).toEqual(graphOf(rebuilt));
749 return { cg, root, looked, files };
750 }
751
752 const record = (cg: CodeGraph): string | null => (cg as unknown as { queries: QueryBuilder }).queries.getMetadata('parameter_flow_record_ruby');
753 const setRecord = (cg: CodeGraph, value: string): void => (cg as unknown as { queries: QueryBuilder }).queries.setMetadata('parameter_flow_record_ruby', value);

Callers 1

Calls 9

adapterFunction · 0.85
writtenFunction · 0.85
bindMethod · 0.80
pushMethod · 0.80
indexedFunction · 0.70
graphOfFunction · 0.70
syncMethod · 0.45
joinMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected