Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed

- VBA extractor comments now describe the behavior they guard, and the rule-table invariant also validates the procedure pre-walk so future drift fails loudly. (#215)
- VBA classifiers now share one rule dispatcher with consistent scan modes, structural gates, counting, and declarative terminal behavior, preventing future rule tables from silently bypassing their documented preconditions. (#216)
- VBA extraction now exposes only the classifier factories used by the shared source walker, removing obsolete compatibility entry points and other unused public helpers. (#217)

Expand Down
9 changes: 9 additions & 0 deletions __tests__/extraction-vba-rule-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ describe('VBA rule-table validation', () => {
empty: ['dims'],
});
});

it('validates the procedures pre-walk rule table', () => {
const tables = { ...VBA_RULE_TABLES, procedures: [] };

expect(validateVbaRuleTables(tables)).toEqual({
ok: false,
empty: ['procedures'],
});
});
});
9 changes: 4 additions & 5 deletions src/extraction/vba-extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,12 @@ export const VBA_RULE_TABLES: Readonly<Record<string, readonly VbaExtractionRule
* Issue #153: the canonical list of concern keys `VBA_RULE_TABLES`
* must contain. Order matches the per-line dispatch order in
* `extract()`: events/types/declares → implements → dims → enums/consts
* → calls/sql. The procedures sweep is the only one that runs BEFORE
* the main walk (so `ctx.localProcs` is populated for the call sweep
* to consult) and is therefore referenced in `VBA_RULE_TABLES` but NOT
* in this list — it is intentionally validated as a separate concern
* because the pre-walk contract is different.
* → calls/sql. The procedures sweep runs before the main walk so
* `ctx.localProcs` is populated for the call sweep, but its rule table
* has the same non-empty invariant as every per-line classifier.
*/
const REQUIRED_DISPATCH_TABLES: readonly string[] = [
'procedures',
'declarations',
'implements',
'dims',
Expand Down
4 changes: 3 additions & 1 deletion src/extraction/vba-preprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export function joinLineContinuations(src: string): string {
// 2. stripVbaComments
// -----------------------------------------------------------------------------

const REM_PREFIX = /^Rem(\s|$)/i;
// Leading indentation is still line-start in VBA; recognize it directly
// rather than relying on the mid-line fallback to slice from column zero.
const REM_PREFIX = /^\s*Rem(\s|$)/i;
// Fix 5: handle trailing bare `Rem` at EOL (`\s|$` instead of `\s` alone).
const REM_MIDLINE = /\s+Rem(\s|$)/i;
const OPTION_DIRECTIVE = /^\s*Option\s+\w+/i;
Expand Down