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

Method getModuleImportsUnder

src/db/queries.ts:4005–4027  ·  view source on GitHub ↗

* The module edges (`imports` edges into a file node) into any file under * the folder `dir` (projectRoot-relative, no trailing slash), with the * source file and language a resurrection needs: where an import of a * package by its name can land, whichever file of the package its manifest

(
    dir: string
  )

Source from the content-addressed store, hash-verified

4003 * or the folder's index makes the entry.
4004 */
4005 getModuleImportsUnder(
4006 dir: string
4007 ): Array<Edge & { edgeId: number; targetFilePath: string; sourceFilePath: string; sourceLanguage: Language }> {
4008 // `dir/` up to `dir0` ('0' is the byte after '/').
4009 const rows = this.db
4010 .prepare(
4011 `SELECT e.*, tgt.file_path AS target_file_path, src.file_path AS source_file_path, src.language AS source_language
4012 FROM nodes tgt
4013 JOIN edges e ON e.target = tgt.id AND e.kind = 'imports'
4014 JOIN nodes src ON src.id = e.source
4015 WHERE tgt.kind = 'file' AND tgt.file_path >= ? AND tgt.file_path < ?`
4016 )
4017 .all(`${dir}/`, `${dir}0`) as Array<
4018 EdgeRow & { target_file_path: string; source_file_path: string; source_language: Language }
4019 >;
4020 return rows.map((row) => ({
4021 ...rowToEdge(row),
4022 edgeId: row.id,
4023 targetFilePath: row.target_file_path,
4024 sourceFilePath: row.source_file_path,
4025 sourceLanguage: row.source_language,
4026 }));
4027 }
4028
4029 /**
4030 * The module edges (`imports` edges into a file node) into declaration

Callers 1

outrankedImportsFunction · 0.80

Calls 4

rowToEdgeFunction · 0.85
mapMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65

Tested by

no test coverage detected