mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-11 03:38:07 +00:00
test(cfg): validate cfg/visitors literals + drop 3 dead TS node types
Extend the grammar-literal CI gate (test/helpers/literal-collectors.ts) to scan cfg/visitors/*.ts, mapping each visitor file to its grammar via the existing basename rule (c-cpp -> C/C++, csharp -> C#, java -> Java, go -> Go, typescript -> TS). Closes the gap where the gate never validated CFG visitor node-type literals -- the prerequisite for adding C-family visitors safely (#2195 U1). The newly-scanned TS visitor surfaced 3 dead literals absent from every grammar it serves (typescript/javascript/tsx all = 0): for_of_statement (for-of parses as for_in_statement), async_function_declaration and async_arrow_function (async functions are function_declaration / arrow_function + an async child). Removed them; behavior-preserving -- the cases never matched, bench --check fingerprints unchanged, TS visitor unit tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1967512211
commit
5439c363de
2 changed files with 8 additions and 5 deletions
|
|
@ -76,8 +76,6 @@ const TS_FUNCTION_TYPES = new Set([
|
|||
'method_definition',
|
||||
'generator_function_declaration',
|
||||
'generator_function',
|
||||
'async_function_declaration',
|
||||
'async_arrow_function',
|
||||
]);
|
||||
|
||||
/** Statement node types that break a basic block (everything else coalesces). */
|
||||
|
|
@ -87,7 +85,6 @@ const CONTROL_FLOW_TYPES = new Set([
|
|||
'do_statement',
|
||||
'for_statement',
|
||||
'for_in_statement',
|
||||
'for_of_statement',
|
||||
'switch_statement',
|
||||
'try_statement',
|
||||
'return_statement',
|
||||
|
|
@ -103,7 +100,6 @@ const LOOP_OR_SWITCH_TYPES = new Set([
|
|||
'do_statement',
|
||||
'for_statement',
|
||||
'for_in_statement',
|
||||
'for_of_statement',
|
||||
'switch_statement',
|
||||
]);
|
||||
|
||||
|
|
@ -206,7 +202,6 @@ class TsCfgWalk {
|
|||
case 'for_statement':
|
||||
return this.visitFor(stmt);
|
||||
case 'for_in_statement':
|
||||
case 'for_of_statement':
|
||||
return this.visitForIn(stmt);
|
||||
case 'switch_statement':
|
||||
return this.visitSwitch(stmt);
|
||||
|
|
|
|||
|
|
@ -183,6 +183,14 @@ function mode2Files(): string[] {
|
|||
if (existsSync(cap)) files.push(cap);
|
||||
}
|
||||
}
|
||||
// CFG visitors (cfg/visitors/<lang>.ts) hard-code tree-sitter node-type and
|
||||
// field literals directly; include them so the gate validates per-language
|
||||
// CFG literals against the right grammar (basename → grammar via
|
||||
// `fileLanguages`: c-cpp → C+C++, csharp → C#, java → Java, go → Go,
|
||||
// typescript[-harvest] → TS). Without this, the gate stays green on dead
|
||||
// literals in a new visitor — the exact failure KTD5 warns about.
|
||||
const cfgVisitorsDir = join(INGESTION_DIR, 'cfg', 'visitors');
|
||||
if (existsSync(cfgVisitorsDir)) walkTs(cfgVisitorsDir, files);
|
||||
const exportDetection = join(INGESTION_DIR, 'export-detection.ts');
|
||||
if (existsSync(exportDetection)) files.push(exportDetection);
|
||||
return files;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue