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

Method getPythonImporterClosure

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

6042 * directly or within `depth` hops, and the touched files themselves.
6043 */
6044 getPythonImporterClosure(filePaths: string[], depth: number = 6): string[] {
6045 const closure = new Set<string>(filePaths);
6046 let frontier = [...filePaths];
6047 for (let hop = 0; hop < depth && frontier.length > 0; hop++) {
6048 const next: string[] = [];
6049 for (let i = 0; i < frontier.length; i += SQLITE_PARAM_CHUNK_SIZE) {
6050 const chunk = frontier.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
6051 const placeholders = chunk.map(() => '?').join(',');
6052 const rows = this.db
6053 .prepare(
6054 `SELECT DISTINCT src.file_path AS file_path
6055 FROM edges e
6056 JOIN nodes tgt ON tgt.id = e.target
6057 JOIN nodes src ON src.id = e.source
6058 WHERE e.kind = 'imports' AND tgt.file_path IN (${placeholders}) AND src.language = 'python'`
6059 )
6060 .all(...chunk) as Array<{ file_path: string }>;
6061 for (const row of rows) {
6062 if (!closure.has(row.file_path)) {
6063 closure.add(row.file_path);
6064 next.push(row.file_path);
6065 }
6066 }
6067 }
6068 frontier = next;
6069 }
6070 return [...closure];
6071 }
6072
6073 /**
6074 * 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