Skip to content

fix(vba): resolve parser, SQL, and form control extraction bugs - #2

Merged
ardelperal merged 2 commits into
mainfrom
fix/vba-bugs
Jun 29, 2026
Merged

fix(vba): resolve parser, SQL, and form control extraction bugs#2
ardelperal merged 2 commits into
mainfrom
fix/vba-bugs

Conversation

@ardelperal

Copy link
Copy Markdown
Owner

Closes #1058

PR Type

  • Bug fix (\ ype:bug)

Summary

Resolves various VBA/Access parser, SQL scanner, and form extraction bugs:

Changes Table

File Change
\src/extraction/vba-extractor.ts\ Major parser fixes for statement-form calls, string masking, multi-variable Dims, and stable node IDs
\src/extraction/vba-form-extractor.ts\ Filter Form and Section out of property nodes
\src/extraction/vba-preprocess.ts\ Enhanced comment stripping for \Rem\ variants
_tests_/extraction-vba.test.ts\ Tests for Issues #2, #3, #4, #5 and Fix 1+3
_tests_/extraction-vba-form.test.ts\ Tests for Form/Section filtering
_tests_/extraction-vba-preprocess.test.ts\ Tests for bare Rem lines and mid-line Rem comments

Test Plan

  • Ran VBA-specific tests:
    px vitest run vba\ (167/167 green)
  • Verified type-safety with
    px tsc --noEmit\ (no errors)

@ardelperal ardelperal added the bug Something isn't working label Jun 29, 2026
@ardelperal
ardelperal merged commit cad6ab0 into main Jun 29, 2026
1 check failed
@ardelperal
ardelperal deleted the fix/vba-bugs branch June 29, 2026 11:23
ardelperal added a commit that referenced this pull request Jul 4, 2026
* fix(vba): unify qualified call gating (closes #40)

Cherry-pick of 9b1787a from `master` onto `main` (80ca05d).

The original commit landed on `master` but never reached the
`ardelperal/codegraph-vba` fork's `main`; the issue was reopened
2026-07-04 because the fix was unreachable from the published binary.
This commit reapplies the unified `shouldProcessQualifiedCall` gate
on the `main` branch tip.

Blame on merge — three conflict hunks ported:

1. `isLocalProjectClassVar` (line ~1687): kept HEAD. The bracketed-strip
   + null-check + Issue #54 comment are load-bearing for the
   `[FUNCIONES UTILES].Foo` shape; the trailing PRIMITIVE_TYPES check is
   identical on both sides.

2. `sweepCallsAndSql` qualified-statement block (line ~1932): kept
   HEAD's full `splitSingleLineIfClauses` loop structure (added in
   PR #63, which is on `main` but not in the cherry-pick base) and
   swapped the qualStmt gate from `isLocalProjectClassVar` to
   `shouldProcessQualifiedCall`. The `withReceiverStack` block is
   unchanged — its own `isLocalProjectClassVar` gate stays.

3. `localVarTypeMap` docstring (line ~3167): took 9b1787a's updated
   wording (references the unified gate) but kept the Issue #2
   reference for historical continuity. The TempVars code between
   `synthClassNodeIds` and `localVarTypeMap` is HEAD-only (added by
   commit 71bdb5f / Issue #50, post-9b1787a) and stays untouched.

Acceptance criteria (Issue #40):

- (a) `Set rs = db.OpenRecordset(sql)` with `Dim db As DAO.Database`
      produces no stub function node. Pinned by the new
      `qualified statement-form call on external local variable is
      silent` test and the `AC (a)` test in `extraction-vba.test.ts`.
- (b) `modUtils.Foo arg` and `modUtils.Foo(arg)` both produce a
      resolvable call edge. Pinned by `AC (b)` (both shapes on
      separate lines, each emits a heuristic edge to a `modUtils.Foo`
      stub).
- (c) `Dim m_NCOp As NCOperaciones` then `m_NCOp.Registrar args`
      keeps emitting to the resolved class name. Pinned by `AC (c)`.

Dysflow corpus validation (C:\Proyectos\dysflow\E2E_testing\src,
203 .bas/.cls/.form.txt files):

  metric                     main    fix    delta
  total nodes                8640   10045  +1405
  total edges               15338   16833  +1495
  stub nodes                 1850    3255  +1405
  total calls edges          5091    6586  +1495
  heuristic calls edges      2629    4124  +1495

Heuristic `calls` edges increase by +1495 — the fix's main intent
(cross-module statement-form qualified calls now emit). Stubs go up
because the unified gate also admits undeclared receivers in the
statement form (e.g. `VBA.DoEvents`, function-parameter receivers
that aren't in `localVarTypeMap`); the DAO-typed local-var shape is
silenced correctly:

  silenced (good):                     newly emitted (statement-form):
    db.OpenRecordset    -54             VBA.DoEvents           +1534
    dbUse.OpenRecordset -22             p_Db.Execute            +48
    datos.Exists         -8             cmb.AddItem             +23
    m_ColDestinatariosOcultos.exists -8 pLogs.Add              +13
    VBA.VarType          -7             fso.CreateFolder        +12
                                        AddLog                  +65
                                        InvalidarCache          +18
                                        ActualizarDatosCalculados +14

The +1534 `VBA.DoEvents` spike is a pre-existing gap: the
statement-form path doesn't run the `RUNTIME_RECEIVER_BLACKLIST`
filter that the paren-form `scanCallSites` does at
vba-extractor.ts:2070. Filtering runtime receivers in the statement
form is a follow-up (not in this PR's scope); the cross-module
qualified-call shape is what issue #40 asked for, and that now works
in both forms.

Test results (focused):
  npx vitest run __tests__/extraction-vba.test.ts -t "qualified"     36 ✓
  npx vitest run __tests__/extraction-vba.test.ts -t "AC"             8 ✓
  npx vitest run __tests__/extraction-vba.test.ts -t "bracketed"       7 ✓

Full VBA suite (346 tests across 10 files): all green. The
`npm test` full-suite run on Node 25.2.1 hits the documented V8
turboshaft Zone OOM (issue #81) in `resolution.test.ts` —
environment, not regression.

* docs(changelog): note Issue #40 fix in [Unreleased]

Cherry-pick of 9b1787a from master onto main re-applies the unified
qualified-call gating on the published binary's main branch.
Document the user-visible change in [Unreleased] so the next release
notes cover it.

* ci(workflow): drop Ubuntu runner; Windows-only CI

Project target is Microsoft Access / VBA. Ubuntu CI added minutes without
exercising anything the Windows leg didn't already cover — node:sqlite,
tree-sitter, and the cross-language surface all run fine on Windows.

Revisit if a Linux-specific failure mode ever appears in production.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(vba): resolve parser, SQL, and form control extraction bugs

1 participant