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

Method getImportBindingsResolvedElsewhere

src/db/queries.ts:3869–3901  ·  view source on GitHub ↗

* The import bindings of `filePaths` that resolved some other way than * through their import — `imports` edges out of each file's node named for * the binding, whose `resolvedBy` is a name match or a framework's — with * the source file and language a resurrection needs and the file of eac

(
    filePaths: readonly string[]
  )

Source from the content-addressed store, hash-verified

3867 * an indexed range (idx_edges_source_kind); few of them resolve by name.
3868 */
3869 getImportBindingsResolvedElsewhere(
3870 filePaths: readonly string[]
3871 ): Array<Edge & { edgeId: number; sourceFilePath: string; sourceLanguage: Language; targetFilePath: string }> {
3872 const out: Array<Edge & { edgeId: number; sourceFilePath: string; sourceLanguage: Language; targetFilePath: string }> = [];
3873 const unique = [...new Set(filePaths)].map((filePath) => `file:${filePath}`);
3874 for (let i = 0; i < unique.length; i += SQLITE_PARAM_CHUNK_SIZE) {
3875 const chunk = unique.slice(i, i + SQLITE_PARAM_CHUNK_SIZE);
3876 const placeholders = chunk.map(() => '?').join(',');
3877 const rows = this.db
3878 .prepare(
3879 `SELECT e.*, src.file_path AS source_file_path, src.language AS source_language, tgt.file_path AS target_file_path
3880 FROM edges e
3881 JOIN nodes src ON src.id = e.source
3882 JOIN nodes tgt ON tgt.id = e.target
3883 WHERE e.source IN (${placeholders})
3884 AND e.kind = 'imports'
3885 AND (e.provenance IS NULL OR e.provenance != 'heuristic')
3886 AND json_valid(e.metadata)
3887 AND json_extract(e.metadata, '$.resolvedBy') != 'import'`
3888 )
3889 .all(...chunk) as Array<EdgeRow & { source_file_path: string; source_language: Language; target_file_path: string }>;
3890 for (const row of rows) {
3891 out.push({
3892 ...rowToEdge(row),
3893 edgeId: row.id,
3894 sourceFilePath: row.source_file_path,
3895 sourceLanguage: row.source_language,
3896 targetFilePath: row.target_file_path,
3897 });
3898 }
3899 }
3900 return out;
3901 }
3902
3903 /**
3904 * The resolution edges into `targetIds` — every edge into one of them but

Callers 1

reopenNameMatchedImportsFunction · 0.80

Calls 6

rowToEdgeFunction · 0.85
mapMethod · 0.80
pushMethod · 0.80
allMethod · 0.65
prepareMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected