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

Function executableFiles

src/ui-server/api/entrypoints.ts:243–274  ·  view source on GitHub ↗

* Files that do something on the way down, most first. * * Over-fetched before filtering, because the two things that shrink the list — * tests and the per-directory cap — are only knowable after the rows come back, * and a project whose noisiest module-level callers are all test files would *

(cg: CodeGraph, limit: number)

Source from the content-addressed store, hash-verified

241 * otherwise answer with an empty list.
242 */
243function executableFiles(cg: CodeGraph, limit: number): WireList<WireEntryFile> {
244 const ranked = withoutPreviews(cg, cg.getTopCallingFiles(SCAN_ROWS));
245
246 const kept: Array<{ node: Node; calls: number; reaches: number }> = [];
247 const perDir = new Map<string, number>();
248 let eligible = 0;
249
250 for (const row of ranked) {
251 if (isTestFile(row.filePath)) continue;
252 eligible += 1;
253 if (kept.length >= limit) continue;
254 const dir = directoryOf(row.filePath);
255 const taken = perDir.get(dir) ?? 0;
256 if (taken >= MAX_FILES_PER_DIR) continue;
257 const node = cg.getNode(row.nodeId);
258 if (!node) continue;
259 perDir.set(dir, taken + 1);
260 kept.push({ node, calls: row.calls, reaches: row.reaches });
261 }
262
263 const dependents = cg.getFileDependentCounts(kept.map((k) => k.node.filePath));
264 const items: WireEntryFile[] = kept.map(({ node, calls, reaches }) => ({
265 ...toNodeRef(node),
266 calls,
267 reaches,
268 dependents: dependents.get(node.filePath) ?? 0,
269 }));
270
271 // `eligible` counts every non-test file the scan saw: a floor, never an
272 // overstatement.
273 return wireList(items, Math.max(eligible, items.length));
274}
275
276/** A Swift file read for its `#Preview` blocks, at most. */
277const MAX_PREVIEW_SCAN = 1024 * 1024;

Callers 1

buildEntryPointsFunction · 0.85

Calls 12

isTestFileFunction · 0.90
toNodeRefFunction · 0.90
wireListFunction · 0.90
withoutPreviewsFunction · 0.85
getNodeMethod · 0.80
pushMethod · 0.80
mapMethod · 0.80
directoryOfFunction · 0.70
getMethod · 0.65
getTopCallingFilesMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected