MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / flattenTree

Function flattenTree

graph-ui/src/app/tree-model.ts:283–310  ·  view source on GitHub ↗
(
    levels: ReadonlyMap<string, TreeLevel>,
    expanded: ReadonlySet<string>,
    rootPath = '',
)

Source from the content-addressed store, hash-verified

281 * Pfeil-Zeichen, statt eine leere Ebene als "hier ist nichts" auszugeben.
282 */
283export function flattenTree(
284 levels: ReadonlyMap<string, TreeLevel>,
285 expanded: ReadonlySet<string>,
286 rootPath = '',
287): TreeRow[] {
288 const rows: TreeRow[] = [];
289 const walk = (path: string, depth: number, seen: Set<string>): void => {
290 const level = levels.get(path);
291 if (level === undefined || seen.has(path)) {
292 return;
293 }
294 seen.add(path);
295 for (const child of level.children) {
296 const isExpanded = child.kind === 'dir' && expanded.has(child.path);
297 rows.push({
298 ...child,
299 depth,
300 expanded: isExpanded,
301 loaded: child.kind === 'dir' ? levels.has(child.path) : true,
302 });
303 if (isExpanded) {
304 walk(child.path, depth + 1, seen);
305 }
306 }
307 };
308 walk(rootPath, 0, new Set());
309 return rows;
310}
311
312/** Alle Ordnerpfade einer Ebene, in Anzeigeordnung. */
313export function directoryPaths(level: TreeLevel): string[] {

Callers 2

ProjectWindowViewFunction · 0.90
tree-model.test.tsFile · 0.90

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected