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

Method getPythonImporterClosure

src/db/queries.ts:5605–5632  ·  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

5603 * directly or within `depth` hops, and the touched files themselves.
5604 */
5605 getPythonImporterClosure(filePaths: string[], depth: number = 6): string[] {
5606 const closure = new Set<string>(filePaths);
5607 let frontier = [...filePaths];
5608 for (let hop = 0; hop < depth && frontier.length > 0; hop++) {
5609 const next: string[] = [];
5610 for (let i = 0; i < frontier.length; i += SQLITE_PARAM_CHUNK_SIZE) {
5611 const chunk = frontier.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
5612 const placeholders = chunk.map(() => '?').join(',');
5613 const rows = this.db
5614 .prepare(
5615 `SELECT DISTINCT src.file_path AS file_path
5616 FROM edges e
5617 JOIN nodes tgt ON tgt.id = e.target
5618 JOIN nodes src ON src.id = e.source
5619 WHERE e.kind = 'imports' AND tgt.file_path IN (${placeholders}) AND src.language = 'python'`
5620 )
5621 .all(...chunk) as Array<{ file_path: string }>;
5622 for (const row of rows) {
5623 if (!closure.has(row.file_path)) {
5624 closure.add(row.file_path);
5625 next.push(row.file_path);
5626 }
5627 }
5628 }
5629 frontier = next;
5630 }
5631 return [...closure];
5632 }
5633
5634 /**
5635 * 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