diff --git a/src/cfg.js b/src/cfg.js index 23e9aae..d0f4d2e 100644 --- a/src/cfg.js +++ b/src/cfg.js @@ -1046,9 +1046,17 @@ export function buildFunctionCFG(functionNode, langId) { export async function buildCFGData(db, fileSymbols, rootDir, _engineOpts) { // Lazily init WASM parsers if needed let parsers = null; - let extToLang = null; let needsFallback = false; + // Always build ext→langId map so native-only builds (where _langId is unset) + // can still derive the language from the file extension. + const extToLang = new Map(); + for (const entry of LANGUAGE_REGISTRY) { + for (const ext of entry.extensions) { + extToLang.set(ext, entry.id); + } + } + for (const [relPath, symbols] of fileSymbols) { if (!symbols._tree) { const ext = path.extname(relPath).toLowerCase(); @@ -1068,12 +1076,6 @@ export async function buildCFGData(db, fileSymbols, rootDir, _engineOpts) { if (needsFallback) { const { createParsers } = await import('./parser.js'); parsers = await createParsers(); - extToLang = new Map(); - for (const entry of LANGUAGE_REGISTRY) { - for (const ext of entry.extensions) { - extToLang.set(ext, entry.id); - } - } } let getParserFn = null; @@ -1115,7 +1117,7 @@ export async function buildCFGData(db, fileSymbols, rootDir, _engineOpts) { // WASM fallback if no cached tree and not all native if (!tree && !allNative) { - if (!extToLang || !getParserFn) continue; + if (!getParserFn) continue; langId = extToLang.get(ext); if (!langId || !CFG_LANG_IDS.has(langId)) continue; @@ -1138,7 +1140,7 @@ export async function buildCFGData(db, fileSymbols, rootDir, _engineOpts) { } if (!langId) { - langId = extToLang ? extToLang.get(ext) : null; + langId = extToLang.get(ext); if (!langId) continue; } diff --git a/src/dataflow.js b/src/dataflow.js index 08b982f..e5b926d 100644 --- a/src/dataflow.js +++ b/src/dataflow.js @@ -1005,9 +1005,17 @@ function collectIdentifiers(node, out, rules) { export async function buildDataflowEdges(db, fileSymbols, rootDir, _engineOpts) { // Lazily init WASM parsers if needed let parsers = null; - let extToLang = null; let needsFallback = false; + // Always build ext→langId map so native-only builds (where _langId is unset) + // can still derive the language from the file extension. + const extToLang = new Map(); + for (const entry of LANGUAGE_REGISTRY) { + for (const ext of entry.extensions) { + extToLang.set(ext, entry.id); + } + } + for (const [relPath, symbols] of fileSymbols) { if (!symbols._tree && !symbols.dataflow) { const ext = path.extname(relPath).toLowerCase(); @@ -1021,12 +1029,6 @@ export async function buildDataflowEdges(db, fileSymbols, rootDir, _engineOpts) if (needsFallback) { const { createParsers } = await import('./parser.js'); parsers = await createParsers(); - extToLang = new Map(); - for (const entry of LANGUAGE_REGISTRY) { - for (const ext of entry.extensions) { - extToLang.set(ext, entry.id); - } - } } let getParserFn = null; @@ -1069,7 +1071,7 @@ export async function buildDataflowEdges(db, fileSymbols, rootDir, _engineOpts) // WASM fallback if no cached tree if (!tree) { - if (!extToLang || !getParserFn) continue; + if (!getParserFn) continue; langId = extToLang.get(ext); if (!langId || !DATAFLOW_LANG_IDS.has(langId)) continue; @@ -1092,7 +1094,7 @@ export async function buildDataflowEdges(db, fileSymbols, rootDir, _engineOpts) } if (!langId) { - langId = extToLang ? extToLang.get(ext) : null; + langId = extToLang.get(ext); if (!langId) continue; }