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

Function walk

__tests__/ui-steps-api-servers.test.ts:291–307  ·  view source on GitHub ↗
(block: WireBlock, indent: string)

Source from the content-addressed store, hash-verified

289 const label = (id: string) => p.steps.find((s) => s.id === id)?.label ?? id;
290 const out: string[] = [];
291 const walk = (block: WireBlock, indent: string): void => {
292 for (const item of block) {
293 if (item.kind === 'step') {
294 out.push(`${indent}${label(item.step)}${item.again ? ' (again)' : ''}`);
295 if (item.body) walk(item.body, `${indent} `);
296 } else if (item.kind === 'fork') {
297 out.push(`${indent}${item.form} ${item.on}`);
298 for (const arm of item.arms) {
299 out.push(`${indent} ${arm.when}${arm.ends ? ` → ${arm.ends}` : ''}`);
300 walk(arm.body, `${indent} `);
301 }
302 } else if (item.kind === 'block') {
303 out.push(`${indent}${item.block} ${item.via?.name ?? item.by ?? ''}`.trimEnd());
304 walk(item.body, `${indent} `);
305 } else out.push(`${indent}cut ${item.why}`);
306 }
307 };
308 if (p.program) walk(p.program.root, '');
309 return out;
310}

Callers 1

inOrderFunction · 0.70

Calls 2

pushMethod · 0.80
labelFunction · 0.70

Tested by

no test coverage detected