MCPcopy Create free account
hub / github.com/getsentry/XcodeBuildMCP / renderNode

Function renderNode

src/utils/renderers/path-tree.ts:104–138  ·  view source on GitHub ↗
(
  node: PathTreeNode,
  prefix: string,
  isLast: boolean,
  parentRawPath: string | undefined,
  formatPath: (path: string) => string,
)

Source from the content-addressed store, hash-verified

102}
103
104function renderNode(
105 node: PathTreeNode,
106 prefix: string,
107 isLast: boolean,
108 parentRawPath: string | undefined,
109 formatPath: (path: string) => string,
110): string[] {
111 const flattened = flattenSingleChildChain(node);
112 const displayName = appendDirectorySlash(
113 parentRawPath === undefined
114 ? formatPath(flattened.rawPath)
115 : relativeRawPath(parentRawPath, flattened.rawPath),
116 flattened.children.size > 0,
117 );
118 const branch = isLast ? '└── ' : '├── ';
119 const lines = [`${prefix}${branch}${formatLeaf(flattened, displayName)}`];
120 const children = [...flattened.children.values()].sort((left, right) =>
121 left.name.localeCompare(right.name),
122 );
123 const childPrefix = `${prefix}${isLast ? ' ' : '│ '}`;
124
125 children.forEach((child, index) => {
126 lines.push(
127 ...renderNode(
128 child,
129 childPrefix,
130 index === children.length - 1,
131 flattened.rawPath,
132 formatPath,
133 ),
134 );
135 });
136
137 return lines;
138}
139
140function topLevelNodes(root: PathTreeNode): PathTreeNode[] {
141 const children = [...root.children.values()];

Callers 1

formatPathTreeFunction · 0.85

Calls 5

flattenSingleChildChainFunction · 0.85
appendDirectorySlashFunction · 0.85
relativeRawPathFunction · 0.85
formatLeafFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected