@aroman22/codegraph-vba-darwin-arm64 1.6.1 → 1.6.3
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/migrations.d.ts +1 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +14 -1
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +8 -2
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +1 -0
- package/lib/dist/extraction/grammars.d.ts +32 -0
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +61 -0
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +24 -0
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vba/call-sweep.d.ts +13 -1
- package/lib/dist/extraction/vba/call-sweep.d.ts.map +1 -1
- package/lib/dist/extraction/vba/call-sweep.js +229 -151
- package/lib/dist/extraction/vba/call-sweep.js.map +1 -1
- package/lib/dist/extraction/vba/context.d.ts +52 -2
- package/lib/dist/extraction/vba/context.d.ts.map +1 -1
- package/lib/dist/extraction/vba/context.js +29 -2
- package/lib/dist/extraction/vba/context.js.map +1 -1
- package/lib/dist/extraction/vba/declarations.d.ts +10 -1
- package/lib/dist/extraction/vba/declarations.d.ts.map +1 -1
- package/lib/dist/extraction/vba/declarations.js +141 -123
- package/lib/dist/extraction/vba/declarations.js.map +1 -1
- package/lib/dist/extraction/vba/dims.d.ts +9 -1
- package/lib/dist/extraction/vba/dims.d.ts.map +1 -1
- package/lib/dist/extraction/vba/dims.js +125 -109
- package/lib/dist/extraction/vba/dims.js.map +1 -1
- package/lib/dist/extraction/vba/enums-consts.d.ts +13 -10
- package/lib/dist/extraction/vba/enums-consts.d.ts.map +1 -1
- package/lib/dist/extraction/vba/enums-consts.js +153 -131
- package/lib/dist/extraction/vba/enums-consts.js.map +1 -1
- package/lib/dist/extraction/vba/implements.d.ts +9 -1
- package/lib/dist/extraction/vba/implements.d.ts.map +1 -1
- package/lib/dist/extraction/vba/implements.js +56 -40
- package/lib/dist/extraction/vba/implements.js.map +1 -1
- package/lib/dist/extraction/vba/procedures.d.ts +13 -1
- package/lib/dist/extraction/vba/procedures.d.ts.map +1 -1
- package/lib/dist/extraction/vba/procedures.js +238 -186
- package/lib/dist/extraction/vba/procedures.js.map +1 -1
- package/lib/dist/extraction/vba/sql-wrapper.d.ts.map +1 -1
- package/lib/dist/extraction/vba/sql-wrapper.js +20 -3
- package/lib/dist/extraction/vba/sql-wrapper.js.map +1 -1
- package/lib/dist/extraction/vba-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vba-extractor.js +47 -38
- package/lib/dist/extraction/vba-extractor.js.map +1 -1
- package/lib/dist/extraction/vba-form-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vba-form-extractor.js +6 -1
- package/lib/dist/extraction/vba-form-extractor.js.map +1 -1
- package/lib/dist/extraction/vba-preprocess.d.ts.map +1 -1
- package/lib/dist/extraction/vba-preprocess.js +23 -2
- package/lib/dist/extraction/vba-preprocess.js.map +1 -1
- package/lib/dist/extraction/vba-test-manifest-extractor.d.ts +26 -0
- package/lib/dist/extraction/vba-test-manifest-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/vba-test-manifest-extractor.js +173 -0
- package/lib/dist/extraction/vba-test-manifest-extractor.js.map +1 -0
- package/lib/dist/extraction/vba-test-sequence-extractor.d.ts +29 -0
- package/lib/dist/extraction/vba-test-sequence-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/vba-test-sequence-extractor.js +180 -0
- package/lib/dist/extraction/vba-test-sequence-extractor.js.map +1 -0
- package/lib/dist/installer/index.js +2 -2
- package/lib/dist/mcp/server-instructions.d.ts +1 -1
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +5 -0
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +30 -0
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/types.d.ts +7 -0
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/upgrade/index.d.ts +1 -1
- package/lib/dist/upgrade/index.d.ts.map +1 -1
- package/lib/dist/upgrade/index.js +1 -1
- package/lib/dist/upgrade/index.js.map +1 -1
- package/lib/node_modules/.modules.yaml +1 -1
- package/lib/node_modules/.pnpm/lock.yaml +4 -0
- package/lib/node_modules/.pnpm-workspace-state-v1.json +1 -1
- package/lib/package.json +8 -2
- package/package.json +1 -1
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import { VbaExtractorContext } from './context';
|
|
1
|
+
import { VbaExtractorContext, VbaClassifier } from './context';
|
|
2
|
+
/**
|
|
3
|
+
* Issue #83: factory for the calls/SQL classifier. The factory takes the
|
|
4
|
+
* pre-split `lines` array (so `trackSqlVariableAssignment` can do its
|
|
5
|
+
* multi-line look-ahead for `&`-accumulate semantics) and closes over the
|
|
6
|
+
* per-file state the legacy `sweepCallsAndSql` declared locally.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCallsAndSqlClassifier(lines: readonly string[]): VbaClassifier;
|
|
9
|
+
/**
|
|
10
|
+
* Backward-compat wrapper (see procedures.ts). Returns void — the calls
|
|
11
|
+
* sweep never contributed to `hasAnySymbols` directly (every other
|
|
12
|
+
* concern's `count` is the signal the orchestrator reads).
|
|
13
|
+
*/
|
|
2
14
|
export declare function sweepCallsAndSql(ctx: VbaExtractorContext, src: string): void;
|
|
3
15
|
//# sourceMappingURL=call-sweep.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-sweep.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/call-sweep.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAY,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"call-sweep.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/call-sweep.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,mBAAmB,EAAY,aAAa,EAAE,MAAM,WAAW,CAAC;AA0CzE;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,aAAa,CA4Of;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAO5E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCallsAndSqlClassifier = createCallsAndSqlClassifier;
|
|
3
4
|
exports.sweepCallsAndSql = sweepCallsAndSql;
|
|
4
5
|
/**
|
|
5
6
|
* Call/SQL sweep orchestrator (REQ-CODE-4, REQ-CODE-8). Walks the
|
|
@@ -22,21 +23,28 @@ const sql_wrapper_1 = require("./sql-wrapper");
|
|
|
22
23
|
* never matches.
|
|
23
24
|
*/
|
|
24
25
|
const SET_NEW_RE = /\bSet\s+(\p{L}[\p{L}\p{N}_]*)\s*=\s*New\s+(\p{L}[\p{L}\p{N}_]*)(?:\.(\p{L}[\p{L}\p{N}_]*))?/iu;
|
|
26
|
+
/**
|
|
27
|
+
* Factory-return inference: `Set <var> = <Factory>(...)` or `Set <var> =
|
|
28
|
+
* <Factory>` where <Factory> is a bare same-file function. Groups: (1)
|
|
29
|
+
* variable, (2) factory name. The trailing `(?:\(|$)` requires the factory
|
|
30
|
+
* name to be followed by `(` or end-of-expression, so a qualified
|
|
31
|
+
* `Set x = obj.Member` (the `.` breaks the match) and the `New` form
|
|
32
|
+
* (`New Foo` — `New` is followed by a space + type, not `(`/end) never match.
|
|
33
|
+
* Runs on the MASKED line so a string literal never triggers it.
|
|
34
|
+
*/
|
|
35
|
+
const SET_CALL_RE = /\bSet\s+(\p{L}[\p{L}\p{N}_]*)\s*=\s*(\p{L}[\p{L}\p{N}_]*)\s*(?:\(|$)/iu;
|
|
25
36
|
/** Issue #43: track the receiver for `With <expr>` / `End With` blocks. */
|
|
26
37
|
const WITH_START_RE = /^\s*With\b\s+(.+?)\s*$/iu;
|
|
27
38
|
const WITH_END_RE = /^\s*End\s+With\b/iu;
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Issue #83: factory for the calls/SQL classifier. The factory takes the
|
|
41
|
+
* pre-split `lines` array (so `trackSqlVariableAssignment` can do its
|
|
42
|
+
* multi-line look-ahead for `&`-accumulate semantics) and closes over the
|
|
43
|
+
* per-file state the legacy `sweepCallsAndSql` declared locally.
|
|
44
|
+
*/
|
|
45
|
+
function createCallsAndSqlClassifier(lines) {
|
|
30
46
|
const procedureStartLines = new Set();
|
|
31
47
|
const sqlTargetsThisFile = new Set();
|
|
32
|
-
// Issue #52: reset the shared scope state before the per-line walk
|
|
33
|
-
// begins. `sweepEnumsAndConsts` already populated `procStack` /
|
|
34
|
-
// `currentProcKey` during its own walk; clearing here guarantees the
|
|
35
|
-
// `scanDoCmdOpenCalls` / `scanDoCmdOpenQuery` reads (which consult
|
|
36
|
-
// `currentProcKey` per call-site) start in module scope and follow
|
|
37
|
-
// the same push/pop discipline as the existing `stack` array below.
|
|
38
|
-
ctx.procStack.length = 0;
|
|
39
|
-
ctx.currentProcKey = 'module';
|
|
40
48
|
// Walk the source once, emitting call edges and SQL edges per line and
|
|
41
49
|
// tracking the current procedure stack.
|
|
42
50
|
const stack = [];
|
|
@@ -48,159 +56,229 @@ function sweepCallsAndSql(ctx, src) {
|
|
|
48
56
|
// `endLine` so `codegraph_explore` returns the full body span —
|
|
49
57
|
// not just the signature line.
|
|
50
58
|
const procEndLines = new Map();
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
const cls = {
|
|
60
|
+
name: 'callsAndSql',
|
|
61
|
+
count: 0,
|
|
62
|
+
classifyLine(line, i, ctx) {
|
|
63
|
+
const lineNum = i + 1;
|
|
64
|
+
const procStart = constants_1.PROC_RE.exec(line);
|
|
65
|
+
if (procStart) {
|
|
66
|
+
// Issue #52: mirror the proc push into the shared
|
|
67
|
+
// `procStack` + `currentProcKey` so Const reads in this same
|
|
68
|
+
// sweep see the same scope as the const writes did (during
|
|
69
|
+
// `sweepEnumsAndConsts`).
|
|
70
|
+
const procStartLine = lineNum;
|
|
71
|
+
ctx.procStack.push(procStartLine);
|
|
72
|
+
ctx.currentProcKey = String(procStartLine);
|
|
73
|
+
const name = procStart[3] ?? '';
|
|
74
|
+
const bucket = ctx.localProcs.get(name);
|
|
75
|
+
if (bucket) {
|
|
76
|
+
// Fix 1: select the ProcInfo whose startLine matches the current
|
|
77
|
+
// line, not always bucket[0]. When Property Get/Let/Set share a
|
|
78
|
+
// name, all three exist in the bucket; pushing bucket[0] every time
|
|
79
|
+
// meant Let/Set bodies erroneously attributed to the Get's ProcInfo.
|
|
80
|
+
const proc = bucket.find((p) => p.startLine === lineNum) ?? bucket[0];
|
|
81
|
+
if (proc)
|
|
82
|
+
stack.push(proc);
|
|
83
|
+
}
|
|
84
|
+
procedureStartLines.add(lineNum);
|
|
85
|
+
// FALL THROUGH — on a proc-start line the legacy sweep ALSO ran
|
|
86
|
+
// the masked-line / with-receiver / call-scan / SQL-scan body.
|
|
87
|
+
// A `return` here would silently drop the first body line of every
|
|
88
|
+
// procedure (a real bug — `Sub Foo()\n Bar 1\n` would never see
|
|
89
|
+
// the `Bar 1` call).
|
|
73
90
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
procEndLines.set(ending.startLine, lineNum);
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
// Fix 2 (Issue #2): mask string-literal content before call scanning so
|
|
88
|
-
// patterns like `modHelper.BuildQuery(` inside a string argument are not
|
|
89
|
-
// mistakenly treated as call sites. SQL scanning still uses the original
|
|
90
|
-
// line because SQL lives INSIDE string literals.
|
|
91
|
-
const callScanLine = (0, text_utils_1.maskStringContent)(line);
|
|
92
|
-
if (stack.length > 0 && WITH_END_RE.test(callScanLine)) {
|
|
93
|
-
withReceiverStack.pop();
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (stack.length > 0 && !procedureStartLines.has(lineNum)) {
|
|
97
|
-
const withStart = WITH_START_RE.exec(callScanLine);
|
|
98
|
-
if (withStart) {
|
|
99
|
-
const receiver = (0, calls_1.normalizeWithReceiver)(withStart[1] ?? '');
|
|
100
|
-
if (receiver)
|
|
101
|
-
withReceiverStack.push(receiver);
|
|
102
|
-
continue;
|
|
91
|
+
else if (constants_1.PROCEDURE_END_RE.test(line) && stack.length > 0) {
|
|
92
|
+
const ending = stack.pop();
|
|
93
|
+
// Issue #52: mirror the pop into the shared scope state.
|
|
94
|
+
ctx.procStack.pop();
|
|
95
|
+
ctx.currentProcKey =
|
|
96
|
+
ctx.procStack.length > 0
|
|
97
|
+
? String(ctx.procStack[ctx.procStack.length - 1])
|
|
98
|
+
: 'module';
|
|
99
|
+
procEndLines.set(ending.startLine, lineNum);
|
|
100
|
+
return;
|
|
103
101
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
(0
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(0, sql_wrapper_1.trackSqlVariableAssignment)(lines, i, sqlVariables);
|
|
121
|
-
(0, sql_wrapper_1.scanSqlInLine)(ctx, line, lineNum, sqlTargetsThisFile, sqlVariables);
|
|
122
|
-
}
|
|
123
|
-
// H1 fix: detect statement-form Sub calls (no parens, no `Call` keyword).
|
|
124
|
-
// Issue #45: split single-line `If … Then <body>` clauses first so the
|
|
125
|
-
// actual call after `Then`/`Else`/`:` is not shadowed by the leading
|
|
126
|
-
// keyword.
|
|
127
|
-
if (stack.length > 0 && !procedureStartLines.has(lineNum)) {
|
|
128
|
-
// Issue #46: `Set x = New <Type>[.<Inner>]` late-instantiation.
|
|
129
|
-
// Run BEFORE the call-site scan so a later `<x>.Member ...` line
|
|
130
|
-
// finds `x` already registered in `localVarTypeMap`.
|
|
131
|
-
const setNew = SET_NEW_RE.exec(callScanLine);
|
|
132
|
-
if (setNew) {
|
|
133
|
-
const varName = setNew[1] ?? '';
|
|
134
|
-
const outerType = setNew[2] ?? '';
|
|
135
|
-
const innerType = setNew[3] ?? '';
|
|
136
|
-
if (varName && outerType) {
|
|
137
|
-
// Skip primitives defensively — consistent with the Dim sweep guard.
|
|
138
|
-
if (!constants_1.PRIMITIVE_TYPES.has(outerType.toLowerCase())) {
|
|
139
|
-
ctx.localVarTypeMap.set(varName.toLowerCase(), {
|
|
140
|
-
outer: outerType,
|
|
141
|
-
// Mirror `Dim x As Foo.Bar`: qualified `Set rs = New
|
|
142
|
-
// DAO.Recordset` registers `qualified: true` so the PR #61
|
|
143
|
-
// gate keeps downstream `rs.Method` calls silent.
|
|
144
|
-
qualified: !!innerType,
|
|
145
|
-
assignedWithSet: true,
|
|
146
|
-
variableName: varName,
|
|
147
|
-
});
|
|
148
|
-
ctx.emitReference(outerType, lineNum, 0, 'vba-set-new');
|
|
149
|
-
}
|
|
102
|
+
// Fix 2 (Issue #2): mask string-literal content before call scanning so
|
|
103
|
+
// patterns like `modHelper.BuildQuery(` inside a string argument are not
|
|
104
|
+
// mistakenly treated as call sites. SQL scanning still uses the original
|
|
105
|
+
// line because SQL lives INSIDE string literals.
|
|
106
|
+
const callScanLine = (0, text_utils_1.maskStringContent)(line);
|
|
107
|
+
if (stack.length > 0 && WITH_END_RE.test(callScanLine)) {
|
|
108
|
+
withReceiverStack.pop();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (stack.length > 0 && !procedureStartLines.has(lineNum)) {
|
|
112
|
+
const withStart = WITH_START_RE.exec(callScanLine);
|
|
113
|
+
if (withStart) {
|
|
114
|
+
const receiver = (0, calls_1.normalizeWithReceiver)(withStart[1] ?? '');
|
|
115
|
+
if (receiver)
|
|
116
|
+
withReceiverStack.push(receiver);
|
|
117
|
+
return;
|
|
150
118
|
}
|
|
151
119
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
120
|
+
// Don't scan call sites on the line that declares the procedure — it
|
|
121
|
+
// would match the proc name itself in `Sub Outer()`.
|
|
122
|
+
if (!procedureStartLines.has(lineNum) && stack.length > 0) {
|
|
123
|
+
const currentProc = stack[stack.length - 1];
|
|
124
|
+
(0, calls_1.scanRaiseEvents)(ctx, callScanLine, currentProc, lineNum);
|
|
125
|
+
(0, calls_1.scanCallSites)(ctx, callScanLine, currentProc, lineNum);
|
|
126
|
+
}
|
|
127
|
+
// Hueco 1: capture `Me.<Control>` references. Only inside procedures
|
|
128
|
+
// because `Me` is only meaningful inside a form's class module.
|
|
129
|
+
if (!procedureStartLines.has(lineNum) && stack.length > 0) {
|
|
130
|
+
(0, controls_1.scanMeControlReferences)(ctx, callScanLine, stack[stack.length - 1], lineNum);
|
|
131
|
+
}
|
|
132
|
+
// SQL wrappers — only inside a procedure. Use the ORIGINAL line — SQL is
|
|
133
|
+
// inside string literals, so the masked line would strip the SQL content.
|
|
134
|
+
if (stack.length > 0) {
|
|
135
|
+
(0, sql_wrapper_1.trackSqlVariableAssignment)(lines, i, sqlVariables);
|
|
136
|
+
(0, sql_wrapper_1.scanSqlInLine)(ctx, line, lineNum, sqlTargetsThisFile, sqlVariables);
|
|
137
|
+
}
|
|
138
|
+
// H1 fix: detect statement-form Sub calls (no parens, no `Call` keyword).
|
|
139
|
+
// Issue #45: split single-line `If … Then <body>` clauses first so the
|
|
140
|
+
// actual call after `Then`/`Else`/`:` is not shadowed by the leading
|
|
141
|
+
// keyword.
|
|
142
|
+
if (stack.length > 0 && !procedureStartLines.has(lineNum)) {
|
|
143
|
+
// Issue #46: `Set x = New <Type>[.<Inner>]` late-instantiation.
|
|
144
|
+
// Run BEFORE the call-site scan so a later `<x>.Member ...` line
|
|
145
|
+
// finds `x` already registered in `localVarTypeMap`.
|
|
146
|
+
const setNew = SET_NEW_RE.exec(callScanLine);
|
|
147
|
+
if (setNew) {
|
|
148
|
+
const varName = setNew[1] ?? '';
|
|
149
|
+
const outerType = setNew[2] ?? '';
|
|
150
|
+
const innerType = setNew[3] ?? '';
|
|
151
|
+
if (varName && outerType) {
|
|
152
|
+
// Skip primitives defensively — consistent with the Dim sweep guard.
|
|
153
|
+
if (!constants_1.PRIMITIVE_TYPES.has(outerType.toLowerCase())) {
|
|
154
|
+
ctx.localVarTypeMap.set(varName.toLowerCase(), {
|
|
155
|
+
outer: outerType,
|
|
156
|
+
// Mirror `Dim x As Foo.Bar`: qualified `Set rs = New
|
|
157
|
+
// DAO.Recordset` registers `qualified: true` so the PR #61
|
|
158
|
+
// gate keeps downstream `rs.Method` calls silent.
|
|
159
|
+
qualified: !!innerType,
|
|
160
|
+
assignedWithSet: true,
|
|
161
|
+
variableName: varName,
|
|
162
|
+
});
|
|
163
|
+
ctx.emitReference(outerType, lineNum, 0, 'vba-set-new');
|
|
164
|
+
}
|
|
165
|
+
}
|
|
158
166
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
else {
|
|
168
|
+
// Factory-return inference: `Set x = <Factory>(...)`. Type x from a
|
|
169
|
+
// same-file function's project-class return type so a later
|
|
170
|
+
// `x.Method` resolves to the factory's class. Overrides a generic
|
|
171
|
+
// `Dim x As Object/Variant` (or an untyped x), but yields to an
|
|
172
|
+
// explicit `Dim x As <ProjectClass>` — the declaration is the
|
|
173
|
+
// authoritative type. Runs after SET_NEW (which owns the `New` form).
|
|
174
|
+
const setCall = SET_CALL_RE.exec(callScanLine);
|
|
175
|
+
if (setCall) {
|
|
176
|
+
const varName = setCall[1] ?? '';
|
|
177
|
+
const factory = (setCall[2] ?? '').toLowerCase();
|
|
178
|
+
const retType = factory ? ctx.functionReturnTypes.get(factory) : undefined;
|
|
179
|
+
if (varName && retType) {
|
|
180
|
+
const existing = ctx.localVarTypeMap.get(varName.toLowerCase());
|
|
181
|
+
const existingIsProjectClass = !!existing &&
|
|
182
|
+
!existing.qualified &&
|
|
183
|
+
!constants_1.PRIMITIVE_TYPES.has(existing.outer.toLowerCase());
|
|
184
|
+
if (!existingIsProjectClass) {
|
|
185
|
+
ctx.localVarTypeMap.set(varName.toLowerCase(), {
|
|
186
|
+
outer: retType,
|
|
187
|
+
qualified: false,
|
|
188
|
+
assignedWithSet: true,
|
|
189
|
+
variableName: varName,
|
|
190
|
+
});
|
|
191
|
+
ctx.emitReference(retType, lineNum, 0, 'vba-factory-return');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
166
194
|
}
|
|
167
195
|
}
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
196
|
+
const clauseLines = (0, calls_1.splitSingleLineIfClauses)(callScanLine);
|
|
197
|
+
for (const clauseLine of clauseLines) {
|
|
198
|
+
const stmtCall = (0, calls_1.detectStatementCall)(clauseLine);
|
|
199
|
+
if (stmtCall) {
|
|
200
|
+
const caller = stack[stack.length - 1];
|
|
201
|
+
(0, calls_1.emitStatementCallEdge)(ctx, caller, stmtCall, lineNum);
|
|
202
|
+
}
|
|
203
|
+
// Fix 7 + Fix 2 + Issue #40: qualified statement-form calls
|
|
204
|
+
// (`Receiver.Member args`) — the dominant cross-object call shape.
|
|
205
|
+
const qualStmt = (0, calls_1.detectQualifiedStatementCall)(clauseLine);
|
|
206
|
+
if (qualStmt) {
|
|
172
207
|
const caller = stack[stack.length - 1];
|
|
173
|
-
|
|
208
|
+
if (ctx.shouldProcessQualifiedCall(qualStmt.receiver)) {
|
|
209
|
+
(0, calls_1.emitQualifiedStatementCallEdge)(ctx, caller, qualStmt.receiver, qualStmt.member, lineNum);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const withReceiver = withReceiverStack[withReceiverStack.length - 1];
|
|
213
|
+
if (withReceiver) {
|
|
214
|
+
const withCall = (0, calls_1.detectWithMemberCall)(clauseLine);
|
|
215
|
+
if (withCall && ctx.isLocalProjectClassVar(withReceiver)) {
|
|
216
|
+
const caller = stack[stack.length - 1];
|
|
217
|
+
(0, calls_1.emitQualifiedStatementCallEdge)(ctx, caller, withReceiver, withCall.member, lineNum);
|
|
218
|
+
}
|
|
174
219
|
}
|
|
175
220
|
}
|
|
221
|
+
// B4 (hueco 6): `DoCmd.OpenForm "FormName"` modelling — the literal
|
|
222
|
+
// form name lives INSIDE a string literal, so scan the ORIGINAL
|
|
223
|
+
// (unmasked) line. The receiver is the same proc-stack frame.
|
|
224
|
+
const caller2 = stack[stack.length - 1];
|
|
225
|
+
// Issue #48: shared OpenForm/OpenReport dispatch; OpenQuery emits an
|
|
226
|
+
// `UnresolvedReference` and stays separate.
|
|
227
|
+
(0, docmd_1.scanDoCmdOpenCalls)(ctx, line, caller2, lineNum);
|
|
228
|
+
(0, docmd_1.scanDoCmdOpenQuery)(ctx, line, caller2, lineNum);
|
|
229
|
+
// Issue #44: cross-form bang references (`Forms!X` / `Forms("X")!Y`) —
|
|
230
|
+
// scan the unmasked line (form name lives in a string literal in the
|
|
231
|
+
// paren form).
|
|
232
|
+
(0, controls_1.scanFormsBang)(ctx, line, caller2, lineNum);
|
|
233
|
+
// Issue #50: cross-form TempVars key accesses. Bang form scans the
|
|
234
|
+
// masked line, paren + Add forms scan the original.
|
|
235
|
+
(0, tempvars_1.sweepTempVars)(ctx, callScanLine, line, lineNum, caller2);
|
|
176
236
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
237
|
+
},
|
|
238
|
+
finalize(ctx) {
|
|
239
|
+
// Apply endLine to every emitted function node keyed by its startLine.
|
|
240
|
+
// Functions without a recorded endLine (e.g. malformed VBA without an
|
|
241
|
+
// `End`) keep their `endLine = startLine` from sweepProcedures —
|
|
242
|
+
// which is the correct "single line" representation.
|
|
243
|
+
for (const n of ctx.nodes) {
|
|
244
|
+
if (n.kind !== 'function')
|
|
245
|
+
continue;
|
|
246
|
+
const end = procEndLines.get(n.startLine);
|
|
247
|
+
if (end !== undefined)
|
|
248
|
+
n.endLine = end;
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
// Issue #52: reset the shared scope state on the first call so leftover
|
|
253
|
+
// state from a previous extract() (impossible in production but possible
|
|
254
|
+
// in unit tests that construct a fresh extractor and run twice) never
|
|
255
|
+
// leaks across sweeps. The walker here updates the scope every iteration
|
|
256
|
+
// AFTER the enums-consts classifier runs (it runs first per line); on the
|
|
257
|
+
// first call we also reset, so the initial state matches the legacy
|
|
258
|
+
// pre-loop setup.
|
|
259
|
+
let initialized = false;
|
|
260
|
+
const originalClassify = cls.classifyLine;
|
|
261
|
+
cls.classifyLine = function (line, i, ctx) {
|
|
262
|
+
if (!initialized) {
|
|
263
|
+
ctx.procStack.length = 0;
|
|
264
|
+
ctx.currentProcKey = 'module';
|
|
265
|
+
initialized = true;
|
|
192
266
|
}
|
|
267
|
+
return originalClassify.call(this, line, i, ctx);
|
|
268
|
+
};
|
|
269
|
+
return cls;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Backward-compat wrapper (see procedures.ts). Returns void — the calls
|
|
273
|
+
* sweep never contributed to `hasAnySymbols` directly (every other
|
|
274
|
+
* concern's `count` is the signal the orchestrator reads).
|
|
275
|
+
*/
|
|
276
|
+
function sweepCallsAndSql(ctx, src) {
|
|
277
|
+
const lines = src.split('\n');
|
|
278
|
+
const cls = createCallsAndSqlClassifier(lines);
|
|
279
|
+
for (let i = 0; i < lines.length; i++) {
|
|
280
|
+
cls.classifyLine(lines[i] ?? '', i, ctx);
|
|
193
281
|
}
|
|
194
|
-
|
|
195
|
-
// Functions without a recorded endLine (e.g. malformed VBA without an
|
|
196
|
-
// `End`) keep their `endLine = startLine` from sweepProcedures —
|
|
197
|
-
// which is the correct "single line" representation.
|
|
198
|
-
for (const n of ctx.nodes) {
|
|
199
|
-
if (n.kind !== 'function')
|
|
200
|
-
continue;
|
|
201
|
-
const end = procEndLines.get(n.startLine);
|
|
202
|
-
if (end !== undefined)
|
|
203
|
-
n.endLine = end;
|
|
204
|
-
}
|
|
282
|
+
cls.finalize?.(ctx);
|
|
205
283
|
}
|
|
206
284
|
//# sourceMappingURL=call-sweep.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call-sweep.js","sourceRoot":"","sources":["../../../src/extraction/vba/call-sweep.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"call-sweep.js","sourceRoot":"","sources":["../../../src/extraction/vba/call-sweep.ts"],"names":[],"mappings":";;AAyDA,kEA8OC;AAOD,4CAOC;AArTD;;;;;;GAMG;AACH,2CAAyE;AACzE,6CAAiD;AAEjD,mCAUiB;AACjB,yCAAoE;AACpE,mCAAiE;AACjE,yCAA2C;AAC3C,+CAA0E;AAE1E;;;;;GAKG;AACH,MAAM,UAAU,GACd,+FAA+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,WAAW,EAAE,CAAC;YACjB,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACzB,GAAG,CAAC,cAAc,GAAG,QAAQ,CAAC;YAC9B,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;QACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;IACnD,CAAC,CAAC;IACF,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,GAAwB,EAAE,GAAW;IACpE,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAC/C,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,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -19,6 +19,29 @@ export interface ProcInfo {
|
|
|
19
19
|
visibility: 'public' | 'private' | 'protected' | 'internal';
|
|
20
20
|
startLine: number;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Issue #83: the per-concern classifier shape. The single walker in
|
|
24
|
+
* `vba-extractor.ts` calls `classifyLine(line, index, ctx)` once per
|
|
25
|
+
* pre-split line, in a stable order across all six concerns. No internal
|
|
26
|
+
* `.split('\n')` — the split happens once in the walker.
|
|
27
|
+
*/
|
|
28
|
+
export interface VbaClassifier {
|
|
29
|
+
/** Stable, human-readable name for logs/metrics. */
|
|
30
|
+
readonly name: string;
|
|
31
|
+
/**
|
|
32
|
+
* Number of top-level symbols this classifier emitted. Read by the
|
|
33
|
+
* orchestrator to compute `hasAnySymbols` (skip module-node creation
|
|
34
|
+
* for files with NO symbols per REQ-CODE-10).
|
|
35
|
+
*/
|
|
36
|
+
count: number;
|
|
37
|
+
/** Classify one pre-split line. May mutate `ctx` and bump `count`. */
|
|
38
|
+
classifyLine(line: string, index: number, ctx: VbaExtractorContext): void;
|
|
39
|
+
/**
|
|
40
|
+
* Optional end-of-file hook. Used by the calls-and-sql classifier to
|
|
41
|
+
* flush `procEndLines` → function node `endLine`.
|
|
42
|
+
*/
|
|
43
|
+
finalize?(ctx: VbaExtractorContext): void;
|
|
44
|
+
}
|
|
22
45
|
export declare class VbaExtractorContext {
|
|
23
46
|
filePath: string;
|
|
24
47
|
nodes: Node[];
|
|
@@ -44,6 +67,14 @@ export declare class VbaExtractorContext {
|
|
|
44
67
|
* Let Foo`, and `Property Set Foo` all share the name `Foo`.
|
|
45
68
|
*/
|
|
46
69
|
localProcs: Map<string, ProcInfo[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Issue #83: flat list of every `ProcInfo` produced by the procedures
|
|
72
|
+
* classifier, in declaration order. Mirrors the array the legacy
|
|
73
|
+
* `sweepProcedures` returned; the orchestrator reads it after the single
|
|
74
|
+
* walker pass to (a) decide `hasAnySymbols`, and (b) check for a
|
|
75
|
+
* `New` initializer to set `hasClassInitializer` on the class node.
|
|
76
|
+
*/
|
|
77
|
+
procedures: ProcInfo[];
|
|
47
78
|
/**
|
|
48
79
|
* Cache: procedure name → first matching function node emitted for that
|
|
49
80
|
* name (audit S2 — O(1) same-file call resolution).
|
|
@@ -114,6 +145,17 @@ export declare class VbaExtractorContext {
|
|
|
114
145
|
procStack: number[];
|
|
115
146
|
/** Local event name (lowercase) → event node for `RaiseEvent` edge emission. */
|
|
116
147
|
localEvents: Map<string, Node>;
|
|
148
|
+
/**
|
|
149
|
+
* Same-file function/property return types, keyed by lowercase proc name →
|
|
150
|
+
* declared return type. ONLY non-primitive (project-class) return types are
|
|
151
|
+
* stored. Populated by `sweepProcedures` (which runs before the call sweep);
|
|
152
|
+
* consumed by the call sweep's `Set x = Factory(...)` handling to type the
|
|
153
|
+
* assigned local var so a later `x.Method` qualified call resolves to the
|
|
154
|
+
* factory's class instead of a dead-end `x.Method` stub. Cross-file
|
|
155
|
+
* factories are not covered here (no return type is visible at extraction
|
|
156
|
+
* time) — that stays the resolver's frontier.
|
|
157
|
+
*/
|
|
158
|
+
functionReturnTypes: Map<string, string>;
|
|
117
159
|
constructor(filePath: string);
|
|
118
160
|
/**
|
|
119
161
|
* Emit a `contains` edge from the (lazily-created) module/class node to
|
|
@@ -156,8 +198,16 @@ export declare class VbaExtractorContext {
|
|
|
156
198
|
* node named `targetName`. Used by Dim, WithEvents, Set-New, and SQL sweeps.
|
|
157
199
|
* Fix 5: the synthetic node id is keyed on (filePath, kind, name) WITHOUT
|
|
158
200
|
* lineNum so the same type/table referenced on N lines produces ONE node.
|
|
159
|
-
|
|
160
|
-
|
|
201
|
+
*
|
|
202
|
+
* `access` (optional): when a caller can classify the reference as a data
|
|
203
|
+
* read or write — SQL table references derive it from the statement verb —
|
|
204
|
+
* it is stamped onto `edge.metadata.access` so consumers can answer "who
|
|
205
|
+
* WRITES table X" vs "who READS table X". Mirrors the read/write tagging the
|
|
206
|
+
* TempVars sweep already emits (`emitTempVarReference`). Omitted for
|
|
207
|
+
* structural references (Dim/WithEvents/Set-New) where the direction is not
|
|
208
|
+
* meaningful.
|
|
209
|
+
*/
|
|
210
|
+
emitReference(targetName: string, lineNum: number, column: number, synthesizedBy: string, access?: 'read' | 'write'): void;
|
|
161
211
|
/**
|
|
162
212
|
* Issue #52: shared lookup helper for `scanDoCmdOpenCalls` and
|
|
163
213
|
* `scanDoCmdOpenQuery`. The current scope is the procedure whose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,I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