@aroman22/codegraph-vba-darwin-arm64 1.10.0 → 1.11.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.
- package/lib/dist/db/queries.d.ts +37 -0
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +33 -0
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/extraction/frameworks/dysflow-export.d.ts +37 -0
- package/lib/dist/extraction/frameworks/dysflow-export.d.ts.map +1 -0
- package/lib/dist/extraction/frameworks/dysflow-export.js +121 -0
- package/lib/dist/extraction/frameworks/dysflow-export.js.map +1 -0
- package/lib/dist/extraction/frameworks/index.d.ts +20 -0
- package/lib/dist/extraction/frameworks/index.d.ts.map +1 -0
- package/lib/dist/extraction/frameworks/index.js +24 -0
- package/lib/dist/extraction/frameworks/index.js.map +1 -0
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +25 -5
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/parse-pool.d.ts +10 -0
- package/lib/dist/extraction/parse-pool.d.ts.map +1 -1
- package/lib/dist/extraction/parse-pool.js +2 -0
- package/lib/dist/extraction/parse-pool.js.map +1 -1
- package/lib/dist/extraction/parse-worker.js +6 -2
- package/lib/dist/extraction/parse-worker.js.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +9 -1
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +58 -5
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vba/call-sweep.d.ts +43 -0
- package/lib/dist/extraction/vba/call-sweep.d.ts.map +1 -1
- package/lib/dist/extraction/vba/call-sweep.js +155 -66
- package/lib/dist/extraction/vba/call-sweep.js.map +1 -1
- package/lib/dist/extraction/vba/calls.d.ts.map +1 -1
- package/lib/dist/extraction/vba/calls.js +6 -0
- package/lib/dist/extraction/vba/calls.js.map +1 -1
- package/lib/dist/extraction/vba/context.d.ts +109 -1
- package/lib/dist/extraction/vba/context.d.ts.map +1 -1
- package/lib/dist/extraction/vba/context.js +155 -2
- package/lib/dist/extraction/vba/context.js.map +1 -1
- package/lib/dist/extraction/vba/declarations.d.ts +38 -2
- package/lib/dist/extraction/vba/declarations.d.ts.map +1 -1
- package/lib/dist/extraction/vba/declarations.js +217 -129
- package/lib/dist/extraction/vba/declarations.js.map +1 -1
- package/lib/dist/extraction/vba/dims.d.ts +35 -1
- package/lib/dist/extraction/vba/dims.d.ts.map +1 -1
- package/lib/dist/extraction/vba/dims.js +185 -109
- package/lib/dist/extraction/vba/dims.js.map +1 -1
- package/lib/dist/extraction/vba/enums-consts.d.ts +47 -7
- package/lib/dist/extraction/vba/enums-consts.d.ts.map +1 -1
- package/lib/dist/extraction/vba/enums-consts.js +212 -139
- package/lib/dist/extraction/vba/enums-consts.js.map +1 -1
- package/lib/dist/extraction/vba/event-synth.d.ts +3 -0
- package/lib/dist/extraction/vba/event-synth.d.ts.map +1 -0
- package/lib/dist/extraction/vba/event-synth.js +176 -0
- package/lib/dist/extraction/vba/event-synth.js.map +1 -0
- package/lib/dist/extraction/vba/implements.d.ts +16 -0
- package/lib/dist/extraction/vba/implements.d.ts.map +1 -1
- package/lib/dist/extraction/vba/implements.js +43 -12
- package/lib/dist/extraction/vba/implements.js.map +1 -1
- package/lib/dist/extraction/vba/procedures.d.ts +20 -0
- package/lib/dist/extraction/vba/procedures.d.ts.map +1 -1
- package/lib/dist/extraction/vba/procedures.js +48 -13
- package/lib/dist/extraction/vba/procedures.js.map +1 -1
- package/lib/dist/extraction/vba/rules.d.ts +125 -0
- package/lib/dist/extraction/vba/rules.d.ts.map +1 -0
- package/lib/dist/extraction/vba/rules.js +49 -0
- package/lib/dist/extraction/vba/rules.js.map +1 -0
- package/lib/dist/extraction/vba-extractor.d.ts +77 -1
- package/lib/dist/extraction/vba-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vba-extractor.js +177 -15
- package/lib/dist/extraction/vba-extractor.js.map +1 -1
- package/lib/dist/extraction/vba-preprocess.d.ts +11 -1
- package/lib/dist/extraction/vba-preprocess.d.ts.map +1 -1
- package/lib/dist/extraction/vba-preprocess.js +45 -16
- package/lib/dist/extraction/vba-preprocess.js.map +1 -1
- package/lib/dist/extraction/vba-timing.d.ts +38 -0
- package/lib/dist/extraction/vba-timing.d.ts.map +1 -0
- package/lib/dist/extraction/vba-timing.js +203 -0
- package/lib/dist/extraction/vba-timing.js.map +1 -0
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +22 -0
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/project-config.d.ts +31 -0
- package/lib/dist/project-config.d.ts.map +1 -1
- package/lib/dist/project-config.js +75 -22
- package/lib/dist/project-config.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +7 -0
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/node_modules/.modules.yaml +1 -1
- package/lib/node_modules/.pnpm-workspace-state-v1.json +1 -1
- package/lib/package.json +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { VbaExtractorContext, VbaClassifier } from './context';
|
|
2
|
+
import { VbaExtractionRule } from './rules';
|
|
3
|
+
/**
|
|
4
|
+
* Issue #153: the declarative rule table for the implements concern.
|
|
5
|
+
* One rule — `implements` — matching a leading `Implements <Name>`
|
|
6
|
+
* declaration. The body has no inter-line state to track, so the
|
|
7
|
+
* orchestrator walks the table and bumps `this.count` on every
|
|
8
|
+
* non-null emit. Keeps the inline `classifyLine` below honest: any
|
|
9
|
+
* branch not represented in this table is dead code.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RULES: readonly VbaExtractionRule<unknown>[];
|
|
2
12
|
/**
|
|
3
13
|
* Issue #83: factory for the `Implements` classifier. Stateless per-line.
|
|
14
|
+
*
|
|
15
|
+
* The body walks the declarative `RULES` table — the inline regex
|
|
16
|
+
* match that lived here before #153 is now a single entry in
|
|
17
|
+
* `RULES`. This is the canonical pattern every classifier will
|
|
18
|
+
* converge on as part of the refactor; the legacy "one giant
|
|
19
|
+
* if/else cascade" is gone.
|
|
4
20
|
*/
|
|
5
21
|
export declare function createImplementsClassifier(): VbaClassifier;
|
|
6
22
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implements.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/implements.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"implements.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/implements.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAyB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKnE;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,iBAAiB,CAAC,OAAO,CAAC,EAyCtD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,aAAa,CAgB1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7E"}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULES = void 0;
|
|
3
4
|
exports.createImplementsClassifier = createImplementsClassifier;
|
|
4
5
|
exports.sweepImplements = sweepImplements;
|
|
5
6
|
const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
|
|
7
|
+
const rules_1 = require("./rules");
|
|
6
8
|
/** Implements regex. */
|
|
7
9
|
const IMPLEMENTS_RE = /^\s*Implements\s+(\p{L}[\p{L}\p{N}_]*)/iu;
|
|
8
10
|
/**
|
|
9
|
-
* Issue #
|
|
11
|
+
* Issue #153: the declarative rule table for the implements concern.
|
|
12
|
+
* One rule — `implements` — matching a leading `Implements <Name>`
|
|
13
|
+
* declaration. The body has no inter-line state to track, so the
|
|
14
|
+
* orchestrator walks the table and bumps `this.count` on every
|
|
15
|
+
* non-null emit. Keeps the inline `classifyLine` below honest: any
|
|
16
|
+
* branch not represented in this table is dead code.
|
|
10
17
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!m)
|
|
18
|
-
return;
|
|
18
|
+
exports.RULES = [
|
|
19
|
+
(0, rules_1.defineRule)({
|
|
20
|
+
id: 'implements',
|
|
21
|
+
description: 'Match a leading `Implements <Name>` declaration; emit an `interface` node + a pending `implements` edge.',
|
|
22
|
+
pattern: IMPLEMENTS_RE,
|
|
23
|
+
emit: (m, ctx, line, lineNum) => {
|
|
19
24
|
const name = m[1] ?? '';
|
|
20
25
|
if (!name)
|
|
21
|
-
return;
|
|
22
|
-
const lineNum = i + 1;
|
|
26
|
+
return null;
|
|
23
27
|
const targetId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'interface', name, lineNum);
|
|
24
28
|
ctx.nodes.push({
|
|
25
29
|
id: targetId,
|
|
@@ -49,7 +53,34 @@ function createImplementsClassifier() {
|
|
|
49
53
|
};
|
|
50
54
|
ctx.edges.push(edge);
|
|
51
55
|
ctx.pendingModuleOrClassSource.push(edge);
|
|
52
|
-
|
|
56
|
+
return { name };
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* Issue #83: factory for the `Implements` classifier. Stateless per-line.
|
|
62
|
+
*
|
|
63
|
+
* The body walks the declarative `RULES` table — the inline regex
|
|
64
|
+
* match that lived here before #153 is now a single entry in
|
|
65
|
+
* `RULES`. This is the canonical pattern every classifier will
|
|
66
|
+
* converge on as part of the refactor; the legacy "one giant
|
|
67
|
+
* if/else cascade" is gone.
|
|
68
|
+
*/
|
|
69
|
+
function createImplementsClassifier() {
|
|
70
|
+
return {
|
|
71
|
+
name: 'implements',
|
|
72
|
+
count: 0,
|
|
73
|
+
classifyLine(line, i, ctx) {
|
|
74
|
+
const lineNum = i + 1;
|
|
75
|
+
for (const rule of exports.RULES) {
|
|
76
|
+
const m = (0, rules_1.matchRule)(rule.pattern, line);
|
|
77
|
+
if (!m)
|
|
78
|
+
continue;
|
|
79
|
+
const result = rule.emit(m, ctx, line, lineNum);
|
|
80
|
+
if (result !== null && result !== undefined) {
|
|
81
|
+
this.count += rule.count ? rule.count(result) : 1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
53
84
|
},
|
|
54
85
|
};
|
|
55
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implements.js","sourceRoot":"","sources":["../../../src/extraction/vba/implements.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"implements.js","sourceRoot":"","sources":["../../../src/extraction/vba/implements.ts"],"names":[],"mappings":";;;AAyEA,gEAgBC;AAMD,0CAOC;AAhGD,gEAAwD;AAExD,mCAAmE;AAEnE,wBAAwB;AACxB,MAAM,aAAa,GAAG,0CAA0C,CAAC;AAEjE;;;;;;;GAOG;AACU,QAAA,KAAK,GAA0C;IAC1D,IAAA,kBAAU,EAAC;QACT,EAAE,EAAE,YAAY;QAChB,WAAW,EACT,0GAA0G;QAC5G,OAAO,EAAE,aAAa;QACtB,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;YAC9B,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YACvB,MAAM,QAAQ,GAAG,IAAA,oCAAc,EAAC,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;YAC1E,GAAG,CA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AAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBAChD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC5C,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,eAAe,CAAC,GAAwB,EAAE,GAAW;IACnE,MAAM,GAAG,GAAG,0BAA0B,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC;AACnB,CAAC"}
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { VbaExtractorContext, ProcInfo, VbaClassifier } from './context';
|
|
2
|
+
import { VbaExtractionRule } from './rules';
|
|
3
|
+
/**
|
|
4
|
+
* Issue #153: the declarative rule table for the procedures concern.
|
|
5
|
+
* One rule — `procedure` — matches a `Sub` / `Function` /
|
|
6
|
+
* `Property Get|Let|Set` declaration and emits the function node,
|
|
7
|
+
* the `localProcs` / `functionNodeByName` / `functionNodeByStartLine`
|
|
8
|
+
* / `functionReturnTypes` registration, and (for form code-behind)
|
|
9
|
+
* the synthesized `event-handler` edge.
|
|
10
|
+
*
|
|
11
|
+
* The emit body is intentionally not split across multiple rules —
|
|
12
|
+
* these are 5+ small operations that all fire on the same declaration
|
|
13
|
+
* line. Splitting them would force the orchestrator to know they
|
|
14
|
+
* always co-occur, which is more coupling than the original cascade
|
|
15
|
+
* had. The pattern is the discriminating surface; everything past
|
|
16
|
+
* `match` is one emit.
|
|
17
|
+
*/
|
|
18
|
+
export declare const RULES: readonly VbaExtractionRule<unknown>[];
|
|
2
19
|
/**
|
|
3
20
|
* Issue #83: factory for the procedures classifier. Closure state: none
|
|
4
21
|
* beyond `count` (the per-concern accumulators live on `ctx`).
|
|
22
|
+
*
|
|
23
|
+
* The body walks the declarative `RULES` table (Issue #153). The
|
|
24
|
+
* inline cascade that used to live here is now one entry in `RULES`.
|
|
5
25
|
*/
|
|
6
26
|
export declare function createProceduresClassifier(): VbaClassifier;
|
|
7
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/procedures.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"procedures.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/procedures.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAyB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAmBnE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,iBAAiB,CAAC,OAAO,CAAC,EAoNtD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,aAAa,CAgB1D;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,CAOjF"}
|
|
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RULES = void 0;
|
|
36
37
|
exports.createProceduresClassifier = createProceduresClassifier;
|
|
37
38
|
exports.sweepProcedures = sweepProcedures;
|
|
38
39
|
/**
|
|
@@ -45,6 +46,7 @@ const path = __importStar(require("path"));
|
|
|
45
46
|
const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
|
|
46
47
|
const constants_1 = require("./constants");
|
|
47
48
|
const text_utils_1 = require("./text-utils");
|
|
49
|
+
const rules_1 = require("./rules");
|
|
48
50
|
/**
|
|
49
51
|
* Parse a `Function`/`Property Get` declaration's return type — the `As
|
|
50
52
|
* <Type>` that follows the parameter list (or the name, for a paren-less
|
|
@@ -63,23 +65,31 @@ function parseReturnType(line) {
|
|
|
63
65
|
return m[1] ?? m[2] ?? null;
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
|
-
* Issue #
|
|
67
|
-
*
|
|
68
|
+
* Issue #153: the declarative rule table for the procedures concern.
|
|
69
|
+
* One rule — `procedure` — matches a `Sub` / `Function` /
|
|
70
|
+
* `Property Get|Let|Set` declaration and emits the function node,
|
|
71
|
+
* the `localProcs` / `functionNodeByName` / `functionNodeByStartLine`
|
|
72
|
+
* / `functionReturnTypes` registration, and (for form code-behind)
|
|
73
|
+
* the synthesized `event-handler` edge.
|
|
74
|
+
*
|
|
75
|
+
* The emit body is intentionally not split across multiple rules —
|
|
76
|
+
* these are 5+ small operations that all fire on the same declaration
|
|
77
|
+
* line. Splitting them would force the orchestrator to know they
|
|
78
|
+
* always co-occur, which is more coupling than the original cascade
|
|
79
|
+
* had. The pattern is the discriminating surface; everything past
|
|
80
|
+
* `match` is one emit.
|
|
68
81
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!m)
|
|
76
|
-
return;
|
|
82
|
+
exports.RULES = [
|
|
83
|
+
(0, rules_1.defineRule)({
|
|
84
|
+
id: 'procedure',
|
|
85
|
+
description: 'Match a `Sub` / `Function` / `Property Get|Let|Set <Name>(...) [As <Type>]` declaration; emit a function node, register the proc in `localProcs` / `functionNodeByName` / `functionNodeByStartLine` / `functionReturnTypes`, and (for `Form_*.cls` / `Report_*.cls`) synthesize a `form-instance-control` stub + `event-handler` edge.',
|
|
86
|
+
pattern: constants_1.PROC_RE,
|
|
87
|
+
emit: (m, ctx, line, lineNum) => {
|
|
77
88
|
const visibilityRaw = (m[1] ?? '').trim();
|
|
78
89
|
const kindRaw = (m[2] ?? '').trim().toLowerCase();
|
|
79
90
|
const name = m[3] ?? '';
|
|
80
91
|
if (!name)
|
|
81
|
-
return;
|
|
82
|
-
const lineNum = i + 1;
|
|
92
|
+
return null;
|
|
83
93
|
// Normalize the visibility. VBA's "Static" keyword is a storage
|
|
84
94
|
// specifier, not visibility, so we treat bare-static declarations as
|
|
85
95
|
// 'Public' (the default) per spec R1. "Friend" is not in the Node
|
|
@@ -269,7 +279,32 @@ function createProceduresClassifier() {
|
|
|
269
279
|
ctx.edges.push(edge);
|
|
270
280
|
ctx.pendingModuleOrClassSource.push(edge);
|
|
271
281
|
}
|
|
272
|
-
|
|
282
|
+
return { name };
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
];
|
|
286
|
+
/**
|
|
287
|
+
* Issue #83: factory for the procedures classifier. Closure state: none
|
|
288
|
+
* beyond `count` (the per-concern accumulators live on `ctx`).
|
|
289
|
+
*
|
|
290
|
+
* The body walks the declarative `RULES` table (Issue #153). The
|
|
291
|
+
* inline cascade that used to live here is now one entry in `RULES`.
|
|
292
|
+
*/
|
|
293
|
+
function createProceduresClassifier() {
|
|
294
|
+
return {
|
|
295
|
+
name: 'procedures',
|
|
296
|
+
count: 0,
|
|
297
|
+
classifyLine(line, i, ctx) {
|
|
298
|
+
const lineNum = i + 1;
|
|
299
|
+
for (const rule of exports.RULES) {
|
|
300
|
+
const m = (0, rules_1.matchRule)(rule.pattern, line);
|
|
301
|
+
if (!m)
|
|
302
|
+
continue;
|
|
303
|
+
const result = rule.emit(m, ctx, line, lineNum);
|
|
304
|
+
if (result !== null && result !== undefined) {
|
|
305
|
+
this.count += rule.count ? rule.count(result) : 1;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
273
308
|
},
|
|
274
309
|
};
|
|
275
310
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedures.js","sourceRoot":"","sources":["../../../src/extraction/vba/procedures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"procedures.js","sourceRoot":"","sources":["../../../src/extraction/vba/procedures.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2QA,gEAgBC;AASD,0CAOC;AA3SD;;;;;GAKG;AACH,2CAA6B;AAE7B,gEAAwD;AACxD,2CAAuD;AACvD,6CAAqD;AAErD,mCAAmE;AAEnE;;;;;;;GAOG;AACH,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QACpC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC,CAAC,IAAI,CAAC;IACT,MAAM,CAAC,GAAG,4DAA4D,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzF,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACU,QAAA,KAAK,GAA0C;IAC1D,IAAA,kBAAU,EAAC;QACT,EAAE,EAAE,WAAW;QACf,WAAW,EACT,wUAAwU;QAC1U,OAAO,EAAE,mBAAO;QAChB,IAAI,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAA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BAChD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;oBAC5C,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7D,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,GAAwB,EAAE,GAAW;IACnE,MAAM,GAAG,GAAG,0BAA0B,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC;IACD,OAAO,GAAG,CAAC,UAAU,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VbaExtractionRule — the declarative rule shape every VBA classifier
|
|
3
|
+
* exports as a `RULES: VbaExtractionRule[]` constant. Issue #153.
|
|
4
|
+
*
|
|
5
|
+
* Before this refactor the per-concern sweepers under `src/extraction/vba/`
|
|
6
|
+
* encoded their rules as inline `if (RE.test(line)) { ... }` branches
|
|
7
|
+
* inside `classifyLine`. Each branch was hard to enumerate, impossible
|
|
8
|
+
* to unit-test in isolation, and easy to silently drop when refactoring
|
|
9
|
+
* the body of a sweep. The rule table here promotes the pattern →
|
|
10
|
+
* emit-mapping to a typed object so:
|
|
11
|
+
*
|
|
12
|
+
* 1. Every rule has a stable `id` (used in error messages, logs, and
|
|
13
|
+
* as a stable handle for tools that consume the rule table).
|
|
14
|
+
* 2. The pattern is explicit (single RegExp or RegExp[]) — the
|
|
15
|
+
* dispatcher knows exactly what to test, no "branched control flow
|
|
16
|
+
* around the regex".
|
|
17
|
+
* 3. The emit function is the ONLY side effect for the rule — pure
|
|
18
|
+
* given (match, ctx, line, lineNum) → T | null. That makes the
|
|
19
|
+
* rule trivially testable in isolation.
|
|
20
|
+
* 4. The `count?` hook lets a rule report "N symbols emitted" without
|
|
21
|
+
* sharing an accumulator with the orchestrator (each rule owns
|
|
22
|
+
* its own count semantics).
|
|
23
|
+
*
|
|
24
|
+
* Inter-line state (procedure stack, With stack, SQL variables) STILL
|
|
25
|
+
* lives on `VbaExtractorContext` — the rule table is per-line. The
|
|
26
|
+
* `classifyLine` orchestrator inside each classifier is the "shell"
|
|
27
|
+
* that maintains the state machine and walks the rule table.
|
|
28
|
+
*/
|
|
29
|
+
import type { VbaExtractorContext } from './context';
|
|
30
|
+
/**
|
|
31
|
+
* A single per-line rule the orchestrator dispatches.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The shape `emit` returns. Most rules return
|
|
34
|
+
* `void | null` because they push directly onto `ctx.nodes` /
|
|
35
|
+
* `ctx.edges` (the canonical VBA sweep idiom). Rules that
|
|
36
|
+
* synthesize a specific symbol can narrow `T` to the symbol's
|
|
37
|
+
* shape so `count?` and downstream consumers get a typed handle.
|
|
38
|
+
*
|
|
39
|
+
* Fields:
|
|
40
|
+
*
|
|
41
|
+
* - `id` Stable, human-readable identifier (e.g. `'implements'`,
|
|
42
|
+
* `'procedure'`, `'dim'`, `'sql-in-strings'`). The rule
|
|
43
|
+
* table's primary key — every id within one file must be
|
|
44
|
+
* unique. Used in error messages and in the test suite
|
|
45
|
+
* that pins the table's shape.
|
|
46
|
+
* - `description` One-line plain-English summary. Surfaced in tooling
|
|
47
|
+
* that introspects the table.
|
|
48
|
+
* - `pattern` The regex (or regex alternatives) the dispatcher tests
|
|
49
|
+
* against the per-line source. Either a single `RegExp`
|
|
50
|
+
* or a non-empty `RegExp[]` (a rule is matched when ANY
|
|
51
|
+
* of the alternatives matches). The dispatcher runs
|
|
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
|
|
57
|
+
* expected to honour this — keeping the gate declarative
|
|
58
|
+
* lets the rule own its own preconditions instead of
|
|
59
|
+
* scattering `if` checks into the rule body.
|
|
60
|
+
* - `scan?` `'masked'` = run on the string-literal-masked line
|
|
61
|
+
* (so call patterns inside `"..."` are ignored), the
|
|
62
|
+
* default. `'unmasked'` = run on the original line (so
|
|
63
|
+
* SQL patterns inside `"..."` are caught). `'both'` =
|
|
64
|
+
* dispatcher calls the rule twice, once with each line.
|
|
65
|
+
* - `emit` The per-match side effect. Receives the
|
|
66
|
+
* `RegExpExecArray` from the pattern, the shared
|
|
67
|
+
* `VbaExtractorContext`, the original (or masked) line,
|
|
68
|
+
* and the 1-based line number. Returns the symbol it
|
|
69
|
+
* emitted (used by `count?`) or `null` when the match
|
|
70
|
+
* didn't apply (the caller is expected to skip
|
|
71
|
+
* `count?` in that case).
|
|
72
|
+
* - `count?` Optional counter. When the rule emits exactly one
|
|
73
|
+
* symbol per successful match the orchestrator can
|
|
74
|
+
* treat `1` as the implicit count; the hook is for
|
|
75
|
+
* rules whose emit can fan out (e.g. a multi-variable
|
|
76
|
+
* `Dim a As Foo, b As Bar` line that produces two
|
|
77
|
+
* `references` edges from one match).
|
|
78
|
+
*
|
|
79
|
+
* The `count` parameter is typed as `unknown` to keep the
|
|
80
|
+
* `VbaExtractionRule<T>` shape covariant in `T` — narrowing `T`
|
|
81
|
+
* (e.g. to `{ edges: number }` for the dim-decl fan-out rule) does
|
|
82
|
+
* NOT then force `count` to take that narrower type, which would
|
|
83
|
+
* break the `VbaExtractionRule<unknown>[]` aggregate. Rule
|
|
84
|
+
* authors cast inside their `count` body.
|
|
85
|
+
*/
|
|
86
|
+
export interface VbaExtractionRule<T = unknown> {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly description: string;
|
|
89
|
+
readonly pattern: RegExp | RegExp[];
|
|
90
|
+
readonly requires?: 'class' | 'module' | 'inside-procedure' | string;
|
|
91
|
+
readonly scan?: 'masked' | 'unmasked' | 'both';
|
|
92
|
+
readonly emit: (match: RegExpMatchArray, ctx: VbaExtractorContext, line: string, lineNum: number) => T | null;
|
|
93
|
+
readonly count?: (result: unknown) => number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Helper to build a `VbaExtractionRule<T>` with a single RegExp.
|
|
97
|
+
* Most rules are 1-line declarations; this collapses the boilerplate
|
|
98
|
+
* to one place.
|
|
99
|
+
*/
|
|
100
|
+
export declare function defineRule<T = unknown>(spec: Omit<VbaExtractionRule<T>, 'pattern'> & {
|
|
101
|
+
pattern: RegExp;
|
|
102
|
+
}): VbaExtractionRule<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Helper to build a `VbaExtractionRule<T>` whose `pattern` is an array
|
|
105
|
+
* of alternative regexes. The dispatcher treats the rule as matched
|
|
106
|
+
* when ANY alternative matches; it runs the alternatives in order and
|
|
107
|
+
* uses the first match's `RegExpExecArray` for `emit`.
|
|
108
|
+
*/
|
|
109
|
+
export declare function defineRuleAlternatives<T = unknown>(spec: Omit<VbaExtractionRule<T>, 'pattern'> & {
|
|
110
|
+
pattern: RegExp[];
|
|
111
|
+
}): VbaExtractionRule<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Run a single rule's `pattern` against `line` and return the first
|
|
114
|
+
* match's `RegExpMatchArray`, or `null` when no alternative matches.
|
|
115
|
+
* `pattern` is `RegExp | RegExp[]` (an array means "match any of
|
|
116
|
+
* these alternatives"); this helper normalizes both into the same
|
|
117
|
+
* `RegExpMatchArray | null` shape the dispatcher's `emit` expects.
|
|
118
|
+
*
|
|
119
|
+
* Every classifier's `classifyLine` walks the declarative `RULES`
|
|
120
|
+
* table via this helper. Centralizing the RegExp/RegExp[] branching
|
|
121
|
+
* here keeps the per-classifier dispatcher loops trivial and avoids
|
|
122
|
+
* each classifier re-implementing the same boilerplate.
|
|
123
|
+
*/
|
|
124
|
+
export declare function matchRule(pattern: RegExp | RegExp[], line: string): RegExpMatchArray | null;
|
|
125
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,kBAAkB,GAAG,MAAM,CAAC;IACrE,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,CACb,KAAK,EAAE,gBAAgB,EACvB,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,KACZ,CAAC,GAAG,IAAI,CAAC;IACd,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;CAC9C;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EACpC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAChE,iBAAiB,CAAC,CAAC,CAAC,CAEtB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,OAAO,EAChD,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAClE,iBAAiB,CAAC,CAAC,CAAC,CAOtB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,IAAI,EAAE,MAAM,GACX,gBAAgB,GAAG,IAAI,CASzB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineRule = defineRule;
|
|
4
|
+
exports.defineRuleAlternatives = defineRuleAlternatives;
|
|
5
|
+
exports.matchRule = matchRule;
|
|
6
|
+
/**
|
|
7
|
+
* Helper to build a `VbaExtractionRule<T>` with a single RegExp.
|
|
8
|
+
* Most rules are 1-line declarations; this collapses the boilerplate
|
|
9
|
+
* to one place.
|
|
10
|
+
*/
|
|
11
|
+
function defineRule(spec) {
|
|
12
|
+
return spec;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Helper to build a `VbaExtractionRule<T>` whose `pattern` is an array
|
|
16
|
+
* of alternative regexes. The dispatcher treats the rule as matched
|
|
17
|
+
* when ANY alternative matches; it runs the alternatives in order and
|
|
18
|
+
* uses the first match's `RegExpExecArray` for `emit`.
|
|
19
|
+
*/
|
|
20
|
+
function defineRuleAlternatives(spec) {
|
|
21
|
+
if (spec.pattern.length === 0) {
|
|
22
|
+
throw new Error(`defineRuleAlternatives: rule "${spec.id}" has an empty pattern[]`);
|
|
23
|
+
}
|
|
24
|
+
return spec;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Run a single rule's `pattern` against `line` and return the first
|
|
28
|
+
* match's `RegExpMatchArray`, or `null` when no alternative matches.
|
|
29
|
+
* `pattern` is `RegExp | RegExp[]` (an array means "match any of
|
|
30
|
+
* these alternatives"); this helper normalizes both into the same
|
|
31
|
+
* `RegExpMatchArray | null` shape the dispatcher's `emit` expects.
|
|
32
|
+
*
|
|
33
|
+
* Every classifier's `classifyLine` walks the declarative `RULES`
|
|
34
|
+
* table via this helper. Centralizing the RegExp/RegExp[] branching
|
|
35
|
+
* here keeps the per-classifier dispatcher loops trivial and avoids
|
|
36
|
+
* each classifier re-implementing the same boilerplate.
|
|
37
|
+
*/
|
|
38
|
+
function matchRule(pattern, line) {
|
|
39
|
+
if (Array.isArray(pattern)) {
|
|
40
|
+
for (const re of pattern) {
|
|
41
|
+
const m = re.exec(line);
|
|
42
|
+
if (m)
|
|
43
|
+
return m;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return pattern.exec(line);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/extraction/vba/rules.ts"],"names":[],"mappings":";;AA0GA,gCAIC;AAQD,wDASC;AAcD,8BAYC;AApDD;;;;GAIG;AACH,SAAgB,UAAU,CACxB,IAAiE;IAEjE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CACpC,IAAmE;IAEnE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,EAAE,0BAA0B,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,SAAS,CACvB,OAA0B,EAC1B,IAAY;IAEZ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACxB,IAAI,CAAC;gBAAE,OAAO,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,11 +1,87 @@
|
|
|
1
1
|
import { ExtractionResult } from '../types';
|
|
2
|
+
import type { VbaExtractionRule } from './vba/rules';
|
|
3
|
+
/**
|
|
4
|
+
* Issue #152: per-file fanout cap for `RaiseEvent <EventName>` edges. An
|
|
5
|
+
* event raised from more than this many sites in a single file is
|
|
6
|
+
* flagged `metadata.highFanout: true` and ALL `raises-event` edges to it
|
|
7
|
+
* are dropped — the gate suppresses graph noise from events with generic
|
|
8
|
+
* names (`Change`, `Click`, `AfterUpdate`, …) that would otherwise
|
|
9
|
+
* produce hundreds of edges per file. Mirrors the upstream
|
|
10
|
+
* `EVENT_FANOUT_CAP` discipline in
|
|
11
|
+
* `src/resolution/callback-synthesizer.ts:43`. Configurable via
|
|
12
|
+
* `codegraph.json` → `vba.maxRaiseFanout`. Pass `Number.POSITIVE_INFINITY`
|
|
13
|
+
* (or any value `>=` the largest expected count) to disable the gate.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_MAX_RAISE_FANOUT = 50;
|
|
16
|
+
/**
|
|
17
|
+
* Issue #153: the orchestrator's aggregated view of every VBA
|
|
18
|
+
* classifier's declarative `RULES` table. Each entry is the
|
|
19
|
+
* `readonly VbaExtractionRule[]` constant exported by the
|
|
20
|
+
* corresponding classifier file. Exposed at module scope so:
|
|
21
|
+
*
|
|
22
|
+
* 1. Tests can pin the table shape and assert that the orchestrator
|
|
23
|
+
* still references each table (a deleted import would
|
|
24
|
+
* accidentally break a whole concern and the test would catch
|
|
25
|
+
* the missing reference).
|
|
26
|
+
* 2. Tooling can introspect every rule the orchestrator
|
|
27
|
+
* dispatches — useful for `codegraph stats` style UIs that
|
|
28
|
+
* show "what kinds of VBA symbols does codegraph know about".
|
|
29
|
+
* 3. The `validateVbaRuleTables` invariant runs on this aggregate
|
|
30
|
+
* so a refactor that empties one concern's `RULES` array
|
|
31
|
+
* (e.g. by deleting the `defineRule` calls during a partial
|
|
32
|
+
* migration) fails loudly at module load instead of silently
|
|
33
|
+
* dropping a whole concern.
|
|
34
|
+
*
|
|
35
|
+
* The keys are the FILE BASENAMES of the classifier modules (no
|
|
36
|
+
* `.ts` extension, kebab-case) — the same naming convention the
|
|
37
|
+
* per-classifier export comments use. Stable identifier for
|
|
38
|
+
* `validateVbaRuleTables` consumers.
|
|
39
|
+
*/
|
|
40
|
+
export declare const VBA_RULE_TABLES: Readonly<Record<string, readonly VbaExtractionRule[]>>;
|
|
41
|
+
/**
|
|
42
|
+
* Issue #153: validate that every per-concern rule table the
|
|
43
|
+
* orchestrator dispatches is non-empty. Called once at module load
|
|
44
|
+
* (see the IIFE at the bottom of this file) so an accidentally-
|
|
45
|
+
* emptied `RULES` array fails loudly when the extractor is first
|
|
46
|
+
* imported, NOT at the first `extract()` call.
|
|
47
|
+
*
|
|
48
|
+
* The result is `{ ok, empty }`:
|
|
49
|
+
* - `ok: true` — every required table has at least one rule.
|
|
50
|
+
* - `ok: false` — at least one table is empty; `empty` lists the
|
|
51
|
+
* concern keys that need attention.
|
|
52
|
+
*
|
|
53
|
+
* The function accepts an optional `tables` argument so the unit
|
|
54
|
+
* test in `__tests__/extraction-vba-rule-table.test.ts` can verify
|
|
55
|
+
* the validator's contract independently of the live data.
|
|
56
|
+
*/
|
|
57
|
+
export declare function validateVbaRuleTables(tables?: Readonly<Record<string, readonly VbaExtractionRule[]>>): {
|
|
58
|
+
ok: boolean;
|
|
59
|
+
empty: string[];
|
|
60
|
+
};
|
|
2
61
|
export declare class VbaExtractor {
|
|
3
62
|
private filePath;
|
|
4
63
|
private source;
|
|
5
64
|
private ctx;
|
|
6
65
|
private vbaTargets?;
|
|
7
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Issue #152: per-file fanout cap for `RaiseEvent <EventName>` edges.
|
|
68
|
+
* When a single event is raised more than this many times in one file,
|
|
69
|
+
* the event node is flagged `metadata.highFanout: true` and ALL
|
|
70
|
+
* `raises-event` edges to it are dropped. Pass `undefined` to disable
|
|
71
|
+
* the gate (the legacy, uncapped behaviour). The 50 default lives in
|
|
72
|
+
* the orchestrator: callers that don't pass a value get the default.
|
|
73
|
+
*/
|
|
74
|
+
private maxRaiseFanout;
|
|
75
|
+
constructor(filePath: string, source: string, vbaTargets?: Record<string, boolean>, maxRaiseFanout?: number);
|
|
8
76
|
extract(): ExtractionResult;
|
|
77
|
+
/**
|
|
78
|
+
* Issue #156: emit the per-file timing block (mode `1` or `2`) and
|
|
79
|
+
* — in mode `2` — append the running aggregate. No-op when
|
|
80
|
+
* `mode === 'off'`. In aggregate mode we flush after every extract()
|
|
81
|
+
* call so the line is visible per-file even without a graceful
|
|
82
|
+
* shutdown (crash-on-file-3 still shows files 1-3 in the aggregate).
|
|
83
|
+
*/
|
|
84
|
+
private maybeEmitTimings;
|
|
9
85
|
private result;
|
|
10
86
|
private isFormOrReportFile;
|
|
11
87
|
private createFileNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vba-extractor.d.ts","sourceRoot":"","sources":["../../src/extraction/vba-extractor.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"vba-extractor.d.ts","sourceRoot":"","sources":["../../src/extraction/vba-extractor.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAQ,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQlD,OAAO,KAAK,EAAE,iBAAiB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