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

Method getPythonImporterClosure

src/db/queries.ts:5716–5743  ·  view source on GitHub ↗

* The python files whose failed attribute-chain refs (`self.client.send`, * `make().send`) an edit to `filePaths` can affect. Such an answer is read * only from files reached through imports — the owner class, its bases, a * factory and the class it returns are each looked up through the im

(filePaths: string[], depth: number = 6)

Source from the content-addressed store, hash-verified

5714 * directly or within `depth` hops, and the touched files themselves.
5715 */
5716 getPythonImporterClosure(filePaths: string[], depth: number = 6): string[] {
5717 const closure = new Set<string>(filePaths);
5718 let frontier = [...filePaths];
5719 for (let hop = 0; hop < depth && frontier.length > 0; hop++) {
5720 const next: string[] = [];
5721 for (let i = 0; i < frontier.length; i += SQLITE_PARAM_CHUNK_SIZE) {
5722 const chunk = frontier.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
5723 const placeholders = chunk.map(() => '?').join(',');
5724 const rows = this.db
5725 .prepare(
5726 `SELECT DISTINCT src.file_path AS file_path
5727 FROM edges e
5728 JOIN nodes tgt ON tgt.id = e.target
5729 JOIN nodes src ON src.id = e.source
5730 WHERE e.kind = 'imports' AND tgt.file_path IN (${placeholders}) AND src.language = 'python'`
5731 )
5732 .all(...chunk) as Array<{ file_path: string }>;
5733 for (const row of rows) {
5734 if (!closure.has(row.file_path)) {
5735 closure.add(row.file_path);
5736 next.push(row.file_path);
5737 }
5738 }
5739 }
5740 frontier = next;
5741 }
5742 return [...closure];
5743 }
5744
5745 /**
5746 * The failed python attribute-chain refs — one attribute hop

Callers 1

Calls 7

mapMethod · 0.80
hasMethod · 0.80
pushMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected