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

Method getModuleImportsUnder

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

3892 * or the folder's index makes the entry.
3893 */
3894 getModuleImportsUnder(
3895 dir: string
3896 ): Array<Edge & { edgeId: number; targetFilePath: string; sourceFilePath: string; sourceLanguage: Language }> {
3897 // `dir/` up to `dir0` ('0' is the byte after '/').
3898 const rows = this.db
3899 .prepare(
3900 `SELECT e.*, tgt.file_path AS target_file_path, src.file_path AS source_file_path, src.language AS source_language
3901 FROM nodes tgt
3902 JOIN edges e ON e.target = tgt.id AND e.kind = 'imports'
3903 JOIN nodes src ON src.id = e.source
3904 WHERE tgt.kind = 'file' AND tgt.file_path >= ? AND tgt.file_path < ?`
3905 )
3906 .all(`${dir}/`, `${dir}0`) as Array<
3907 EdgeRow & { target_file_path: string; source_file_path: string; source_language: Language }
3908 >;
3909 return rows.map((row) => ({
3910 ...rowToEdge(row),
3911 edgeId: row.id,
3912 targetFilePath: row.target_file_path,
3913 sourceFilePath: row.source_file_path,
3914 sourceLanguage: row.source_language,
3915 }));
3916 }
3917
3918 /**
3919 * 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