MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / buildTreeNodeIndex

Function buildTreeNodeIndex

packages/web/src/features/tools/listTree.ts:218–230  ·  view source on GitHub ↗
(root: FileTreeNode)

Source from the content-addressed store, hash-verified

216}
217
218const buildTreeNodeIndex = (root: FileTreeNode): Map<string, FileTreeNode> => {
219 const nodeIndex = new Map<string, FileTreeNode>();
220
221 const visit = (node: FileTreeNode, currentPath: string) => {
222 nodeIndex.set(currentPath, node);
223 for (const child of node.children) {
224 visit(child, joinTreePath(currentPath, child.name));
225 }
226 };
227
228 visit(root, '');
229 return nodeIndex;
230}
231
232const sortTreeEntries = (entries: ListTreeEntry[]): ListTreeEntry[] => {
233 const collator = new Intl.Collator(undefined, { sensitivity: 'base' });

Callers 1

listTree.tsFile · 0.85

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected