@aroman22/codegraph-vba 1.15.0 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +131 -3
  2. package/dist/bin/daemon-release.d.ts +7 -0
  3. package/dist/db/queries.d.ts +41 -0
  4. package/dist/extraction/access-erd-extractor.d.ts +57 -0
  5. package/dist/extraction/extraction-version.d.ts +1 -1
  6. package/dist/extraction/grammars.d.ts +20 -0
  7. package/dist/extraction/index.d.ts +1 -0
  8. package/dist/extraction/parse-pool.d.ts +8 -3
  9. package/dist/extraction/sql-query-extractor.d.ts +16 -14
  10. package/dist/extraction/sql-table-scan.d.ts +184 -0
  11. package/dist/extraction/tree-sitter.d.ts +10 -1
  12. package/dist/extraction/vba/call-sweep.d.ts +2 -7
  13. package/dist/extraction/vba/calls.d.ts +24 -4
  14. package/dist/extraction/vba/constants.d.ts +7 -14
  15. package/dist/extraction/vba/context.d.ts +443 -7
  16. package/dist/extraction/vba/controls.d.ts +18 -1
  17. package/dist/extraction/vba/declarations.d.ts +1 -6
  18. package/dist/extraction/vba/dims.d.ts +11 -7
  19. package/dist/extraction/vba/docmd.d.ts +29 -2
  20. package/dist/extraction/vba/enums-consts.d.ts +7 -14
  21. package/dist/extraction/vba/error-channel.d.ts +57 -0
  22. package/dist/extraction/vba/errors.d.ts +64 -0
  23. package/dist/extraction/vba/filesystem-statements.d.ts +23 -0
  24. package/dist/extraction/vba/implements.d.ts +1 -6
  25. package/dist/extraction/vba/labels.d.ts +26 -0
  26. package/dist/extraction/vba/module-vars.d.ts +36 -0
  27. package/dist/extraction/vba/options.d.ts +88 -0
  28. package/dist/extraction/vba/parameters.d.ts +35 -0
  29. package/dist/extraction/vba/procedures.d.ts +1 -9
  30. package/dist/extraction/vba/rules.d.ts +10 -5
  31. package/dist/extraction/vba/runtime-objects.d.ts +59 -0
  32. package/dist/extraction/vba/signature.d.ts +57 -0
  33. package/dist/extraction/vba/sql-wrapper.d.ts +76 -3
  34. package/dist/extraction/vba/text-utils.d.ts +62 -2
  35. package/dist/extraction/vba-extractor.d.ts +18 -1
  36. package/dist/extraction/vba-form-extractor.d.ts +28 -14
  37. package/dist/extraction/vba-preprocess.d.ts +89 -3
  38. package/dist/extraction/vba-source.d.ts +0 -10
  39. package/dist/extraction/vba-test-manifest-extractor.d.ts +0 -6
  40. package/dist/graph/behavior-evidence.d.ts +162 -0
  41. package/dist/index.d.ts +22 -0
  42. package/dist/mcp/daemon-paths.d.ts +6 -0
  43. package/dist/mcp/daemon-registry.d.ts +82 -7
  44. package/dist/mcp/daemon-watchdog.d.ts +12 -0
  45. package/dist/mcp/daemon.d.ts +20 -1
  46. package/dist/mcp/proxy.d.ts +32 -0
  47. package/dist/mcp/server-instructions.d.ts +1 -1
  48. package/dist/mcp/tools.d.ts +12 -0
  49. package/dist/project-config.d.ts +43 -2
  50. package/dist/resolution/index.d.ts +47 -2
  51. package/dist/resolution/name-matcher.d.ts +25 -0
  52. package/dist/resolution/vba-runtime-objects.d.ts +11 -11
  53. package/dist/types.d.ts +13 -5
  54. package/dist/utils/backtrace-helpers.d.ts +14 -2
  55. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { VbaExtractorContext, VbaClassifier } from './context';
1
+ import { VbaClassifier } from './context';
2
2
  import { VbaExtractionRule } from './rules';
3
3
  /**
4
4
  * Issue #153: the declarative rule table for the Dim / WithEvents
@@ -34,12 +34,16 @@ export declare const RULES: readonly VbaExtractionRule<unknown>[];
34
34
  * rules are independent: `dim-decl` handles typed declarations
35
35
  * (REJECTED if the line is a `WithEvents` because the prefix
36
36
  * negative-lookahead excludes `WithEvents`), `withevents-decl`
37
- * handles WithEvents. No inter-line state.
37
+ * handles WithEvents.
38
+ *
39
+ * Issue #205: the classifier maintains a closure-local proc stack
40
+ * (parallel to the calls-sweep's `ctx.procStack` in
41
+ * `call-sweep.ts:213`) and writes the top of that stack into
42
+ * `ctx.currentVarTypeProcKey` so `localVarTypeMap` writes are scoped
43
+ * to the procedure whose body the `Dim` is inside (or `'module'`
44
+ * when no procedure is open). The two stacks track the same
45
+ * `PROC_RE` / `PROCEDURE_END_RE` boundaries so they stay in sync at
46
+ * every line.
38
47
  */
39
48
  export declare function createDimsClassifier(): VbaClassifier;
40
- /**
41
- * Backward-compat wrapper (see procedures.ts). Returns the classifier's
42
- * `count` so the orchestrator can decide `hasAnySymbols`.
43
- */
44
- export declare function sweepDimsAndWithEvents(ctx: VbaExtractorContext, src: string): number;
45
49
  //# sourceMappingURL=dims.d.ts.map
@@ -5,12 +5,39 @@ import { VbaExtractorContext, ProcInfo } from './context';
5
5
  * a cached stub node (form-layout / report-layout) and an
6
6
  * `opens-form` / `opens-report` heuristic edge from the calling Sub.
7
7
  */
8
- export declare function scanDoCmdOpenCalls(ctx: VbaExtractorContext, line: string, caller: ProcInfo, lineNum: number): void;
8
+ export declare function scanDoCmdOpenCalls(ctx: VbaExtractorContext, line: string, maskedLine: string, caller: ProcInfo, lineNum: number): void;
9
9
  /**
10
10
  * Issue #48: scan one line of VBA source for `DoCmd.OpenQuery "X"` calls.
11
11
  * Each match emits ONE `UnresolvedReference` (NOT a stub + edge) so the
12
12
  * resolver binds to the REAL `query` node that `SqlQueryExtractor`
13
13
  * produces for `queries/<Name>.sql`, tagged `synthesizedBy: 'vba-opens-query'`.
14
14
  */
15
- export declare function scanDoCmdOpenQuery(ctx: VbaExtractorContext, line: string, caller: ProcInfo, lineNum: number): void;
15
+ export declare function scanDoCmdOpenQuery(ctx: VbaExtractorContext, line: string, maskedLine: string, caller: ProcInfo, lineNum: number): void;
16
+ /**
17
+ * Issue #246 (task T4): scan one line of VBA source for
18
+ * `DoCmd.Close acForm|acReport, "<Name>"`.
19
+ *
20
+ * Each match emits ONE `references` edge -- not a new edge kind -- from the
21
+ * calling procedure to the very same `form-layout` / `report-layout` stub
22
+ * that `opens-form` / `opens-report` already point at, by reusing
23
+ * `resolveOpensStubId`'s cache. A form that is both opened and closed
24
+ * therefore ends up with ONE node carrying two distinct edges.
25
+ *
26
+ * The edge carries `synthesizedBy: 'vba-closes-form'` for both object types
27
+ * (one tag for the whole verb keeps every close edge queryable as a set) and
28
+ * `targetFormName` as its single name key, for the same reason. If a
29
+ * first-class `closes-form` edge kind is ever wanted, that tag is the seam.
30
+ */
31
+ export declare function scanDoCmdCloseCalls(ctx: VbaExtractorContext, line: string, maskedLine: string, caller: ProcInfo, lineNum: number): void;
32
+ /**
33
+ * Issue #254: scan one line of VBA source for every `DoCmd` verb in
34
+ * `DOCMD_OBJECT_DISPATCH`. Each match whose object argument resolves to a
35
+ * static name emits ONE `UnresolvedReference` — no node, ever.
36
+ *
37
+ * `maskedLine` has string CONTENT blanked out, so the `docmd` prefix check
38
+ * rejects a verb name that only appears inside a string literal. The object
39
+ * name itself lives inside a literal, which is why the split runs on the
40
+ * original `line`.
41
+ */
42
+ export declare function scanDoCmdObjectCalls(ctx: VbaExtractorContext, line: string, maskedLine: string, caller: ProcInfo, lineNum: number): void;
16
43
  //# sourceMappingURL=docmd.d.ts.map
@@ -1,4 +1,4 @@
1
- import { VbaExtractorContext, VbaClassifier } from './context';
1
+ import { VbaClassifier } from './context';
2
2
  import { VbaExtractionRule } from './rules';
3
3
  /**
4
4
  * Issue #153: the declarative rule table for the enum / const concern.
@@ -26,8 +26,9 @@ import { VbaExtractionRule } from './rules';
26
26
  * + `contains` edge ONLY when not inside a proc
27
27
  * (proc-local Consts are not module symbols).
28
28
  *
29
- * The inter-line `ctx.procStack` / `ctx.currentProcKey` state is
30
- * SHARED with the calls/SQL classifier (issue #52 protocol). The
29
+ * This classifier exclusively owns the inter-line `ctx.procStack` /
30
+ * `ctx.currentProcKey` state. The calls/SQL classifier keeps its own
31
+ * `ProcInfo` stack and only reads the shared current-scope key. The
31
32
  * `ctx.vbaEnumBlock` state is local to this concern and lives on
32
33
  * `ctx` for the same RULES-table-friendliness reason as
33
34
  * `vbaDeclTypeBlock`.
@@ -42,17 +43,9 @@ export declare const RULES: readonly VbaExtractionRule<unknown>[];
42
43
  * `ctx.vbaEnumBlock` — lives on `ctx` so the RULES table's `emit`
43
44
  * functions can read/write it without taking a closure reference.
44
45
  *
45
- * Issue #52: the first invocation also resets the shared proc-stack
46
- * + lookup key so leftover state from a previous `extract()` (only
47
- * possible in tests that construct a fresh extractor and run twice)
48
- * never leaks across sweeps. The walk below updates both every
49
- * iteration; `sweepCallsAndSql` resets again at its own start, so
50
- * the protocol stays consistent across both classifiers.
46
+ * A fresh `VbaExtractorContext` owns fresh stack state; classifiers never
47
+ * lazily reset it. This makes the result independent of whether a procedure
48
+ * begins on the first or a later physical line.
51
49
  */
52
50
  export declare function createEnumsConstsClassifier(): VbaClassifier;
53
- /**
54
- * Backward-compat wrapper (see procedures.ts). Returns the classifier's
55
- * `count` so the orchestrator can decide `hasAnySymbols`.
56
- */
57
- export declare function sweepEnumsAndConsts(ctx: VbaExtractorContext, src: string): number;
58
51
  //# sourceMappingURL=enums-consts.d.ts.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The channel names used when `codegraph.json` → `vba.errorChannel` is absent.
3
+ *
4
+ * `m_Error` / `p_Error` are the private module-variable spellings, `g_Error`
5
+ * the global one, and `Error` the public field a caller reads off the object
6
+ * (`m_ObjRiesgoActivo.Error`). Identical to the probe's
7
+ * `DEFAULT_ERROR_CHANNEL_NAMES` — `scripts/vba-coverage-probe.mjs` measured
8
+ * the census this task is accepted against, so the two lists must agree.
9
+ */
10
+ export declare const DEFAULT_ERROR_CHANNEL_NAMES: readonly string[];
11
+ /** A channel entry is a bare VBA identifier — nothing qualified, no regex. */
12
+ export declare const ERROR_CHANNEL_ENTRY_RE: RegExp;
13
+ /**
14
+ * The per-extractor compiled channel. Built ONCE per `VbaExtractor` and parked
15
+ * on `VbaExtractorContext`, for the same reason `CompiledSqlWrappers` is: the
16
+ * name lookup runs per identifier per line, and the write matcher per statement
17
+ * per line, so neither may be rebuilt inside the line loop.
18
+ *
19
+ * NOT structured-cloneable (it holds a `Set` and `RegExp`s) — which is exactly
20
+ * why `VbaExtractionOptions.errorChannel` carries plain strings across the
21
+ * worker boundary and the compilation happens on the far side.
22
+ */
23
+ export interface CompiledErrorChannel {
24
+ /** The channel names, defaults first, project entries appended. Display form. */
25
+ readonly names: readonly string[];
26
+ /** Lowercased `names`, for the per-identifier membership test. VBA is case-insensitive. */
27
+ readonly lookup: ReadonlySet<string>;
28
+ /**
29
+ * One anchored regex per name: the channel in the assignment-TARGET position
30
+ * of a statement — bare (`p_Error = …`), `Me.`-qualified (`Me.Error = …`) or
31
+ * object-qualified (`obj.Error = …`).
32
+ *
33
+ * Anchoring at the start of the statement is the whole precision of this
34
+ * matcher: it is what separates a WRITE from a READ, so the house guard
35
+ * `If m_Error <> "" Then` and the copy `x = m_Error` both correctly miss.
36
+ * Kept identical to the probe's `buildChannelWriteMatcher`.
37
+ */
38
+ readonly writeRes: readonly RegExp[];
39
+ }
40
+ /**
41
+ * Compile the channel from the plain-string config entries.
42
+ *
43
+ * `configured` entries are APPENDED to {@link DEFAULT_ERROR_CHANNEL_NAMES},
44
+ * never substituted for them — same contract as `vba.sqlWrappers`: a project
45
+ * that names its own `lastFailure` field must not lose `m_Error` in the trade,
46
+ * because in a codebase this size the two conventions coexist. Blank, dotted
47
+ * and otherwise non-identifier entries are dropped here; `project-config.ts`
48
+ * has already warned about them at load time.
49
+ */
50
+ export declare function compileErrorChannel(configured?: readonly string[]): CompiledErrorChannel;
51
+ export declare function defaultErrorChannel(): CompiledErrorChannel;
52
+ /**
53
+ * Is `name` the error channel? A WHOLE-name, case-insensitive test — the
54
+ * single reason `ErrorCount` does not match `Error`, pinned by a test.
55
+ */
56
+ export declare function isErrorChannelName(channel: CompiledErrorChannel, name: string): boolean;
57
+ //# sourceMappingURL=error-channel.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { VbaClassifier, VbaExtractorContext, VbaErrorPolicyState } from './context';
2
+ import { VbaExtractionRule } from './rules';
3
+ /**
4
+ * The error-propagation channel this corpus actually uses: a module-level or
5
+ * object field the failing procedure writes and the caller reads. §2.3 of the
6
+ * plan measures 3,602 handlers touching it against 16 that re-raise — VBA's
7
+ * own error mechanism unwinds one frame, the MESSAGE travels through one of
8
+ * these variables.
9
+ *
10
+ * Names only, never substrings, so `ErrorCount` cannot match `Error`.
11
+ *
12
+ * Issue #261 (task E4) moved this list — and the write matcher built from it —
13
+ * into `./error-channel`, so the two consumers can no longer fork: this
14
+ * classifier asks "is this statement a channel WRITE?", `module-vars.ts` asks
15
+ * "is this variable the channel?", and both now read one compiled object that
16
+ * `codegraph.json` → `vba.errorChannel` extends. Re-exported from here because
17
+ * this module was its home and the probe-agreement suite imports it.
18
+ */
19
+ export { DEFAULT_ERROR_CHANNEL_NAMES } from './error-channel';
20
+ /**
21
+ * Calls that make an error visible to a human. `MsgBox` is the form-code
22
+ * shape, `Debug.Print` the developer-only one; §2.3 counts both as "display",
23
+ * so this list — identical to the probe's `DEFAULT_DISPLAY_CALLS` — does too.
24
+ */
25
+ export declare const DEFAULT_DISPLAY_CALLS: readonly string[];
26
+ /** A fresh accumulator for a procedure body opening at `startLine`. */
27
+ export declare function newErrorPolicyState(startLine: number, edgeMark: number, refMark: number): VbaErrorPolicyState;
28
+ /**
29
+ * Issue #259: the declarative rule table for the error-policy concern. All
30
+ * four rules are `scan: 'masked'` and `requires: 'inside-procedure'`.
31
+ *
32
+ * `masked` is the #209 discipline: `s = "On Error GoTo errores"` is a string
33
+ * assignment, and a classifier that reads it as a handler would report a
34
+ * protected procedure that is not protected. `inside-procedure` is what keeps
35
+ * module-level noise out — there is no error policy without a procedure to
36
+ * attach it to.
37
+ *
38
+ * The three `On Error` rules re-scan their own line globally instead of
39
+ * acting on the dispatcher's single match, so a colon-separated single-line
40
+ * procedure carrying two `On Error GoTo` statements counts two.
41
+ */
42
+ export declare const RULES: readonly VbaExtractionRule<unknown>[];
43
+ /**
44
+ * Fold the open accumulator into the procedure's `metadata.errorPolicy` and
45
+ * clear it. `endLine` is the procedure's terminating `End` line — the handler
46
+ * region's closing boundary.
47
+ *
48
+ * Called from three places: the `End Sub` boundary (the normal path), a new
49
+ * procedure declaration while a body is somehow still open (malformed VBA
50
+ * with no `End`), and end-of-file. All three converge on the same shape, so a
51
+ * truncated module still records a policy instead of silently dropping it.
52
+ */
53
+ export declare function closeErrorPolicy(ctx: VbaExtractorContext, endLine: number): void;
54
+ /**
55
+ * Issue #259: factory for the error-policy classifier.
56
+ *
57
+ * `count` stays at 0 for the life of the classifier, deliberately. The
58
+ * orchestrator derives `hasAnySymbols` from the sum of every classifier's
59
+ * `count`, and this one emits no symbols at all — it only annotates nodes the
60
+ * procedures sweep already created. Letting it count would make a file whose
61
+ * only content is an `On Error` line look like a file with symbols.
62
+ */
63
+ export declare function createErrorPolicyClassifier(): VbaClassifier;
64
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,23 @@
1
+ import type { ProcInfo, VbaExtractorContext } from './context';
2
+ export declare const VBA_FILESYSTEM_STATEMENT_SYNTHESIZED_BY: "vba-filesystem-statement";
3
+ export type VbaFilesystemOperation = 'kill' | 'open' | 'close';
4
+ /**
5
+ * Parse only the intrinsic grammar-shaped statement forms. The input must be a
6
+ * single string-masked statement clause, so quoted keywords remain opaque while
7
+ * valid string operands retain their token shape.
8
+ */
9
+ export declare function detectVbaFilesystemStatement(statement: string): VbaFilesystemOperation | null;
10
+ /**
11
+ * The shared provenance gate used by both resolution and runtime
12
+ * classification. Name, kind, language, family, and operation must agree; a
13
+ * copied or partially forged metadata stamp is rejected.
14
+ */
15
+ export declare function isExactVbaFilesystemStatementReference(ref: {
16
+ language?: string | null;
17
+ referenceKind?: string | null;
18
+ referenceName?: string | null;
19
+ metadata?: Record<string, unknown> | null;
20
+ }): boolean;
21
+ /** Emit one typed unresolved runtime reference from the containing procedure. */
22
+ export declare function emitVbaFilesystemStatementReference(ctx: VbaExtractorContext, caller: ProcInfo, statement: string, lineNum: number): boolean;
23
+ //# sourceMappingURL=filesystem-statements.d.ts.map
@@ -1,4 +1,4 @@
1
- import { VbaExtractorContext, VbaClassifier } from './context';
1
+ import { VbaClassifier } from './context';
2
2
  import { VbaExtractionRule } from './rules';
3
3
  /**
4
4
  * Issue #153: the declarative rule table for the implements concern.
@@ -19,9 +19,4 @@ export declare const RULES: readonly VbaExtractionRule<unknown>[];
19
19
  * if/else cascade" is gone.
20
20
  */
21
21
  export declare function createImplementsClassifier(): VbaClassifier;
22
- /**
23
- * Backward-compat wrapper (see procedures.ts). Returns the classifier's
24
- * `count` so the orchestrator can decide `hasAnySymbols`.
25
- */
26
- export declare function sweepImplements(ctx: VbaExtractorContext, src: string): number;
27
22
  //# sourceMappingURL=implements.d.ts.map
@@ -0,0 +1,26 @@
1
+ import type { VbaErrorPolicy, VbaErrorPolicyState, VbaExtractorContext } from './context';
2
+ /** `handles-error` edges and their unresolved twin carry this provenance. */
3
+ export declare const ERROR_HANDLER_SYNTHESIZED_BY = "vba-error-handler";
4
+ /** A plain `GoTo <label>` jump — a generic `references` edge. */
5
+ export declare const GOTO_SYNTHESIZED_BY = "vba-goto";
6
+ /**
7
+ * A `GoTo` (plain or `On Error`) naming a label the procedure never defines.
8
+ * One shared tag for both, because from a consumer's point of view they are
9
+ * the same defect: a jump with no landing site.
10
+ */
11
+ export declare const GOTO_UNRESOLVED_SYNTHESIZED_BY = "vba-goto-unresolved";
12
+ /**
13
+ * Emit this procedure's `label` nodes and the three edge shapes that reach
14
+ * them, then hand control back to `closeErrorPolicy`.
15
+ *
16
+ * `policy` is the object that was just folded from `state`; it is read, never
17
+ * recomputed. `endLine` is the procedure's terminating `End` line.
18
+ *
19
+ * Ordering matters and is the caller's responsibility: this runs BEFORE
20
+ * #260's `markErrorHandlerRegion`, so a `GoTo` or a second `On Error GoTo`
21
+ * written inside the handler region is stamped `metadata.inErrorHandler` by
22
+ * that single stamping point like every other edge, instead of quietly
23
+ * becoming the one emitter that opted out of it.
24
+ */
25
+ export declare function emitLabelNodes(ctx: VbaExtractorContext, state: VbaErrorPolicyState, policy: VbaErrorPolicy, endLine: number): void;
26
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Module-level variable read/write sweep (issue #251).
3
+ *
4
+ * The dims classifier emits one `variable` node per module-level
5
+ * declaration and registers the name on `ctx.moduleVariables`. A node
6
+ * nobody points at answers nothing, so this sweep supplies the other
7
+ * half: for every procedure body line, an identifier that matches one of
8
+ * THIS FILE's module-level variable names becomes an
9
+ * `UnresolvedReference` tagged `synthesizedBy: 'vba-module-var'`, with
10
+ * `referenceKind: 'property-get'` for a read and `'property-set'` for a
11
+ * write.
12
+ *
13
+ * The gate is the whole design. The sweep never looks for "identifiers
14
+ * that might be variables"; it only ever asks whether a name is already
15
+ * registered as a module-level variable of the module being extracted.
16
+ * Any looser rule turns a codebase-wide sweep into thousands of
17
+ * references to names that merely collide.
18
+ *
19
+ * Issue #261 adds ONE field on top: when the matched variable is the project's
20
+ * error channel (`m_Error`, `p_Error`, … — see `./error-channel`), the
21
+ * reference also carries `metadata.errorChannel: true`. No new node kind, no
22
+ * new edge kind and not a single extra row: the propagation chain
23
+ * `inner procedure --property-set--> m_Error --property-get--> caller` is the
24
+ * one this sweep already emits, and the flag is what makes it identifiable as
25
+ * error flow instead of ordinary module state.
26
+ */
27
+ import { VbaExtractorContext, ProcInfo } from './context';
28
+ /**
29
+ * Scan one procedure-body line for reads and writes of this module's
30
+ * module-level variables.
31
+ *
32
+ * `line` must be the string-literal-masked line: a variable name that
33
+ * appears inside `"…"` is prose, not an access.
34
+ */
35
+ export declare function scanModuleVariableReferences(ctx: VbaExtractorContext, line: string, from: ProcInfo, lineNum: number): void;
36
+ //# sourceMappingURL=module-vars.d.ts.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * `VbaExtractionOptions` — the single object that carries every VBA
3
+ * extraction knob from `codegraph.json` down to `VbaExtractor` (issue #243).
4
+ *
5
+ * ## Why this module exists
6
+ *
7
+ * The knobs used to travel as positional parameters through five files:
8
+ *
9
+ * ```
10
+ * project-config.ts loadVbaConfig()
11
+ * -> extraction/index.ts reads vbaConfig
12
+ * -> extraction/parse-pool.ts ParseTask fields
13
+ * -> extraction/parse-worker.ts message shape
14
+ * -> extraction/tree-sitter.ts extractFromSource(..., vbaTargets, maxRaiseFanout, ...)
15
+ * -> new VbaExtractor(filePath, source, vbaTargets, maxRaiseFanout)
16
+ * ```
17
+ *
18
+ * Every new knob meant editing all five signatures and every call site. One
19
+ * object collapses that to "add a field here, read it in the extractor".
20
+ *
21
+ * ## Worker-boundary constraint — READ BEFORE ADDING A FIELD
22
+ *
23
+ * This object crosses the `parse-pool` -> `parse-worker` boundary through
24
+ * `worker.postMessage`, which is `structuredClone`-based. Every field MUST be
25
+ * plain, structured-cloneable data: primitives, plain objects, and arrays of
26
+ * those. NO functions, NO `RegExp`, NO `Map`/`Set`, NO class instances — a
27
+ * function throws `DataCloneError` at the boundary and a `RegExp` silently
28
+ * loses its `lastIndex`/identity semantics.
29
+ *
30
+ * A derived value that is not cloneable (a compiled wrapper `RegExp`, a
31
+ * lookup `Map`) belongs on the extractor context, built inside the extractor
32
+ * from the plain data in this object.
33
+ *
34
+ * This module is a LEAF: it imports nothing, so the config layer, the pool,
35
+ * the worker, and the extractor can all depend on it without a cycle.
36
+ */
37
+ /**
38
+ * Every VBA-specific extraction knob, in one structured-cloneable object.
39
+ *
40
+ * All fields are optional; `{}` is the zero-config default and must behave
41
+ * exactly like the pre-#243 "caller passed nothing" path.
42
+ */
43
+ export interface VbaExtractionOptions {
44
+ /**
45
+ * Conditional-compilation targets — the `#Const` name -> truth map used to
46
+ * decide which `#If` branches stay active. Sourced from `codegraph.json` ->
47
+ * `vba.targets`. Undefined means "no project overrides"; the preprocessor
48
+ * falls back to its built-in defaults.
49
+ */
50
+ targets?: Record<string, boolean>;
51
+ /**
52
+ * Issue #152: per-file fanout cap for `RaiseEvent <EventName>` edges. An
53
+ * event raised from more than this many sites in one file is flagged
54
+ * `metadata.highFanout: true` and ALL its `raises-event` edges are dropped.
55
+ * Undefined means the caller did not choose, so `VbaExtractor` applies
56
+ * `DEFAULT_MAX_RAISE_FANOUT` (50). Sourced from `codegraph.json` ->
57
+ * `vba.maxRaiseFanout`.
58
+ */
59
+ maxRaiseFanout?: number;
60
+ /**
61
+ * Names of project-specific procedures that wrap a SQL execution call
62
+ * (e.g. a shared `EjecutarSQL(sql)` helper), so a call to one of them is
63
+ * treated as a SQL execution site instead of an ordinary call.
64
+ *
65
+ * Declared here now and threaded end-to-end by #243; the SQL-wrapper task
66
+ * is the consumer. Kept as a `readonly string[]` of plain strings — the
67
+ * compiled matcher built from these names is NOT cloneable and therefore
68
+ * belongs on the extractor context, never in this object.
69
+ */
70
+ sqlWrappers?: readonly string[];
71
+ /**
72
+ * Issue #261 — the module-level variable names this project uses to carry
73
+ * an error message from where it happened to where the user sees it
74
+ * (`m_Error`, `p_Error`, a project's own `lastFailure`). A read or write of
75
+ * one of them is flagged `metadata.errorChannel: true`, and a handler that
76
+ * writes one is classified `behavior: 'channel'`.
77
+ *
78
+ * Bare VBA identifiers, matched as WHOLE names — never substrings, never
79
+ * user-supplied regex (this runs per identifier per line, the same reasoning
80
+ * `sqlWrappers` was built on). Sourced from `codegraph.json` →
81
+ * `vba.errorChannel`, and EXTENDS the built-in list rather than replacing
82
+ * it. Kept as plain strings for the same reason `sqlWrappers` is: the
83
+ * compiled `Set`/`RegExp` form cannot cross the `structuredClone` worker
84
+ * boundary, so it is built on the extractor context instead.
85
+ */
86
+ errorChannel?: readonly string[];
87
+ }
88
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Issue #257 (task T16, half A): turn a procedure's already-parsed signature
3
+ * into `parameter` nodes.
4
+ *
5
+ * This module is EMISSION ONLY. The signature was parsed once by
6
+ * `signature.ts` — after the preprocessor joined `_` line continuations — and
7
+ * stamped onto the `function` node's `metadata.params` by `procedures.ts`.
8
+ * The same `VbaParameterInfo[]` is handed here, so a continued signature and
9
+ * its one-line equivalent produce byte-identical nodes by construction. Never
10
+ * re-parse the declaration line here; that is how the two views drift.
11
+ */
12
+ import { Node } from '../../types';
13
+ import { VbaExtractorContext } from './context';
14
+ import type { VbaParameterInfo } from './signature';
15
+ /**
16
+ * Emit one `parameter` node per declared parameter of `procedureNode`, the
17
+ * `contains` edge that binds it to its procedure, and — for a non-primitive
18
+ * declared type — a `type_of` edge onto the type's node.
19
+ *
20
+ * Parameters have no line of their own: VBA writes them inside the procedure
21
+ * header, and after continuation joining even the physical line is a fiction.
22
+ * So `startLine` / `endLine` are the procedure's declaration line, and the id
23
+ * is disambiguated by `<Procedure>.<param>` rather than by position — two
24
+ * accessors of the same property (`Property Get X` / `Property Let X`) sit on
25
+ * different lines and therefore still get distinct ids.
26
+ *
27
+ * `qualifiedName` is `<ModuleOrClass>.<Procedure>.<param>`, using
28
+ * `ctx.moduleName` (the resolved `Attribute VB_Name`, or the basename) rather
29
+ * than `ctx.classNamePrefix` — the latter is `null` for a `.bas`, and a
30
+ * parameter of a module-level Sub wants the module prefix just as much as a
31
+ * class method's does. Same choice the module-level `variable` nodes made in
32
+ * issue #251.
33
+ */
34
+ export declare function emitParameterNodes(ctx: VbaExtractorContext, procedureNode: Node, params: readonly VbaParameterInfo[], lineNum: number, line: string): void;
35
+ //# sourceMappingURL=parameters.d.ts.map
@@ -1,4 +1,4 @@
1
- import { VbaExtractorContext, ProcInfo, VbaClassifier } from './context';
1
+ import { VbaClassifier } from './context';
2
2
  import { VbaExtractionRule } from './rules';
3
3
  /**
4
4
  * Issue #153: the declarative rule table for the procedures concern.
@@ -17,12 +17,4 @@ import { VbaExtractionRule } from './rules';
17
17
  */
18
18
  export declare const RULES: readonly VbaExtractionRule<unknown>[];
19
19
  export declare function createProceduresClassifier(): VbaClassifier;
20
- /**
21
- * Backward-compat wrapper: pre-#83 callers (e.g. legacy test fixtures)
22
- * used `sweepProcedures(ctx, src)` and got back the ProcInfo[].
23
- * Now it returns `ctx.procedures` (the same flat list the factory
24
- * appends to). The implementation still calls the classifier once per
25
- * pre-split line, so the count is identical to the new walker path.
26
- */
27
- export declare function sweepProcedures(ctx: VbaExtractorContext, src: string): ProcInfo[];
28
20
  //# sourceMappingURL=procedures.d.ts.map
@@ -50,10 +50,8 @@ import type { VbaExtractorContext } from './context';
50
50
  * or a non-empty `RegExp[]` (a rule is matched when ANY
51
51
  * of the alternatives matches). The dispatcher runs
52
52
  * `.exec()` for single regexes and iterates for arrays.
53
- * - `requires?` Optional structural gate. `'class'` means the rule
54
- * only fires inside a `.cls` file; `'module'` only in
55
- * `.bas`/`.frm`/`.dsr`; `'inside-procedure'` only when
56
- * `ctx.procStack.length > 0`. The orchestrator is
53
+ * - `requires?` Optional structural gate from the closed
54
+ * `VbaRuleRequirement` union. The orchestrator is
57
55
  * expected to honour this — keeping the gate declarative
58
56
  * lets the rule own its own preconditions instead of
59
57
  * scattering `if` checks into the rule body.
@@ -75,6 +73,8 @@ import type { VbaExtractorContext } from './context';
75
73
  * rules whose emit can fan out (e.g. a multi-variable
76
74
  * `Dim a As Foo, b As Bar` line that produces two
77
75
  * `references` edges from one match).
76
+ * - `terminal?` Stop dispatch after this rule matches, without coupling
77
+ * dispatcher control flow to a rule id.
78
78
  *
79
79
  * The `count` parameter is typed as `unknown` to keep the
80
80
  * `VbaExtractionRule<T>` shape covariant in `T` — narrowing `T`
@@ -87,11 +87,14 @@ export interface VbaExtractionRule<T = unknown> {
87
87
  readonly id: string;
88
88
  readonly description: string;
89
89
  readonly pattern: RegExp | RegExp[];
90
- readonly requires?: 'class' | 'module' | 'inside-procedure' | string;
90
+ readonly requires?: VbaRuleRequirement;
91
91
  readonly scan?: 'masked' | 'unmasked' | 'both';
92
+ readonly terminal?: boolean;
92
93
  readonly emit: (match: RegExpMatchArray, ctx: VbaExtractorContext, line: string, lineNum: number) => T | null;
93
94
  readonly count?: (result: unknown) => number;
94
95
  }
96
+ export type VbaRuleRequirement = 'inside-procedure' | 'inside-type-block' | 'outside-type-block' | 'inside-enum-block' | 'outside-enum-block';
97
+ export type VbaRuleGates = Partial<Record<VbaRuleRequirement, boolean>>;
95
98
  /**
96
99
  * Helper to build a `VbaExtractionRule<T>` with a single RegExp.
97
100
  * Most rules are 1-line declarations; this collapses the boilerplate
@@ -126,4 +129,6 @@ export declare function matchRuleForScan(rule: VbaExtractionRule, line: string,
126
129
  match: RegExpMatchArray;
127
130
  line: string;
128
131
  } | null;
132
+ /** Dispatch a rule table with consistent scan, gate, count, and terminal semantics. */
133
+ export declare function runRules(rules: readonly VbaExtractionRule[], ctx: VbaExtractorContext, line: string, maskedLine: string, lineNum: number, gates: VbaRuleGates): number;
129
134
  //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Canonical list of VBA/Access runtime objects and singletons whose
3
+ * `Receiver.Member` calls are NEVER user-defined code — DAO, FileSystemObject
4
+ * (`fso`), intrinsic collections, error/debug intrinsics, late-binding
5
+ * factories, and Access application singletons.
6
+ *
7
+ * Issue #245: this used to be TWO literal sets written at different times.
8
+ * `RUNTIME_OBJECTS` (formerly in `src/resolution/vba-runtime-objects.ts`)
9
+ * decided whether a synthetic call EDGE was stamped `declined-runtime`;
10
+ * `RUNTIME_RECEIVER_BLACKLIST` (formerly a second literal in
11
+ * `./constants.ts`) decided whether the call-site scan looked at a receiver
12
+ * at all. Because the second list omitted `VBA`, `fso`, `Collection`,
13
+ * `ListBox` and friends, the extractor still synthesized a `function` NODE
14
+ * for every one of those calls — 6,132 stub nodes against 3,840 real
15
+ * procedures on the reference corpus. Edge consumers can filter on
16
+ * `repointDecision`; symbol search and node counts cannot.
17
+ *
18
+ * The two sets are now one literal (`RUNTIME_OBJECT_DEFS`) with two derived
19
+ * views, so they can never drift apart again:
20
+ *
21
+ * - `RUNTIME_OBJECTS` — every canonical name, lowercased, for the
22
+ * case-insensitive `isRuntimeObject` predicate. Consumed by the
23
+ * post-extraction stub resolver (`ReferenceResolver.resolveVbaCallStubTarget`)
24
+ * to DECLINE repointing a stub whose receiver is a runtime object, and by
25
+ * the extractor's stub-NODE gate in `./calls.ts`.
26
+ * - `RUNTIME_RECEIVER_BLACKLIST` — the case-sensitive PascalCase subset
27
+ * flagged `blocksCallScan`. These receivers/members are dropped by the
28
+ * call-site scans BEFORE any reference is surfaced, so the set is
29
+ * deliberately narrow: widening it would silently delete
30
+ * `unresolved_refs` rows. Widening the canonical set is safe; promoting
31
+ * an entry to `blocksCallScan` is not.
32
+ *
33
+ * A user class or module that happens to share a runtime-object name (a
34
+ * "shadow" declaration, e.g. a user `.cls` literally named `DAO`) is still
35
+ * linked by the resolver: it runs its normal two-step name resolution FIRST
36
+ * and only falls back to this list when no real target exists (FR-2.1).
37
+ *
38
+ * This module is a LEAF: it imports nothing. `src/extraction/` must not
39
+ * depend on `src/resolution/`, so the canonical set lives here and
40
+ * `src/resolution/vba-runtime-objects.ts` re-exports it — every existing
41
+ * resolver import keeps working unchanged.
42
+ */
43
+ /**
44
+ * Every canonical runtime-object name, lowercased so matching is
45
+ * case-insensitive against a receiver as it appears in source.
46
+ */
47
+ export declare const RUNTIME_OBJECTS: ReadonlySet<string>;
48
+ /**
49
+ * Derived view: the case-sensitive receivers/members the call-site scans drop
50
+ * before surfacing anything. NOT a second literal — see `blocksCallScan`.
51
+ */
52
+ export declare const RUNTIME_RECEIVER_BLACKLIST: ReadonlySet<string>;
53
+ /**
54
+ * True iff `receiver` (any case) names a known VBA/Access runtime object.
55
+ * Leading/trailing brackets and surrounding whitespace are stripped
56
+ * defensively so a bracketed receiver (`[DAO]`) still matches.
57
+ */
58
+ export declare function isRuntimeObject(receiver: string | null | undefined): boolean;
59
+ //# sourceMappingURL=runtime-objects.d.ts.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Issue #250 (task T8): parse a VBA procedure's parameter list off its
3
+ * declaration line.
4
+ *
5
+ * The line handed in here has already been through the preprocessor, so a
6
+ * signature split with `_` continuations arrives as ONE logical line and a
7
+ * trailing `'` comment is already gone. This module must never re-implement
8
+ * continuation joining — see `vba-preprocess.ts` and issue #202.
9
+ */
10
+ /** One declared parameter of a `Sub` / `Function` / `Property` signature. */
11
+ export interface VbaParameterInfo {
12
+ /** Declared name, original casing, brackets unwrapped. */
13
+ name: string;
14
+ /** The `As <Type>` type, or `null` for an implicitly-`Variant` parameter. */
15
+ type: string | null;
16
+ /**
17
+ * `true` unless the declaration says `ByVal`. VBA passes by reference by
18
+ * default, so an unqualified parameter really is a `ByRef` one.
19
+ */
20
+ byRef: boolean;
21
+ /** The literal `Optional` keyword was present. */
22
+ optional: boolean;
23
+ /** Declared as an array — `name()`. */
24
+ isArray: boolean;
25
+ /** An `= <default>` clause was present. */
26
+ hasDefault: boolean;
27
+ }
28
+ /**
29
+ * Declared arity. `total` is `null` — not `Infinity` — when the signature ends
30
+ * in a `ParamArray`, because this value is serialised into node metadata and
31
+ * crosses the parse-worker boundary, and JSON has no `Infinity`.
32
+ */
33
+ export interface VbaArity {
34
+ required: number;
35
+ total: number | null;
36
+ }
37
+ /** The parsed shape of one procedure signature. */
38
+ export interface VbaSignatureInfo {
39
+ params: VbaParameterInfo[];
40
+ arity: VbaArity;
41
+ }
42
+ /**
43
+ * Split a parameter-list body on its top-level commas. Depth- and
44
+ * string-aware, so `Optional s As String = "a,b"` stays one entry.
45
+ */
46
+ export declare function splitParameterList(body: string): string[];
47
+ /**
48
+ * Parse the signature of the procedure whose name ends at `nameEndIndex`.
49
+ *
50
+ * A `ParamArray` tail is excluded from `arity.required` (it accepts zero
51
+ * arguments) and forces `arity.total` to `null` (it accepts any number). The
52
+ * `ParamArray` parameter itself is still reported in `params` with
53
+ * `optional: false`, because that flag mirrors the literal `Optional` keyword
54
+ * — which VBA forbids on a `ParamArray`.
55
+ */
56
+ export declare function parseSignature(line: string, nameEndIndex: number): VbaSignatureInfo;
57
+ //# sourceMappingURL=signature.d.ts.map