@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
|
@@ -98,8 +98,52 @@ class VbaExtractorContext {
|
|
|
98
98
|
* of every procedure whose `End` marker the sweep has not yet seen.
|
|
99
99
|
*/
|
|
100
100
|
procStack = [];
|
|
101
|
+
/**
|
|
102
|
+
* Issue #153: per-extraction state for the events/types/declares
|
|
103
|
+
* classifier's `Type <Name> ... End Type` block tracking. The
|
|
104
|
+
* `currentTypeBlock` is set when a `type-start` rule fires and
|
|
105
|
+
* cleared when the matching `type-end` rule fires. Lives on `ctx`
|
|
106
|
+
* (instead of the factory's closure) so the declarative RULES
|
|
107
|
+
* table's `emit` functions can read/write it without taking a
|
|
108
|
+
* closure-captured mutable reference. `null` means "outside any
|
|
109
|
+
* type block right now". Reset implicitly per-extraction (a fresh
|
|
110
|
+
* `VbaExtractorContext` is constructed every `extract()` call).
|
|
111
|
+
*/
|
|
112
|
+
vbaDeclTypeBlock = null;
|
|
113
|
+
/**
|
|
114
|
+
* Issue #153: per-extraction state for the enum/consts classifier's
|
|
115
|
+
* `Enum <Name> ... End Enum` block tracking. Same shape and
|
|
116
|
+
* rationale as `vbaDeclTypeBlock`: lives on `ctx` so the
|
|
117
|
+
* declarative RULES table's `emit` functions can read/write it
|
|
118
|
+
* without taking a closure-captured mutable reference.
|
|
119
|
+
* `null` means "outside any enum block right now".
|
|
120
|
+
*/
|
|
121
|
+
vbaEnumBlock = null;
|
|
122
|
+
/**
|
|
123
|
+
* Issue #153: per-extraction state for the calls/SQL classifier's
|
|
124
|
+
* `With <receiver> ... End With` block tracking. The with-receiver
|
|
125
|
+
* stack mirrors the textual nesting of `With` blocks inside a
|
|
126
|
+
* procedure body — the top of the stack is the active receiver
|
|
127
|
+
* for `.Member` and `.Member(args)` statement-form calls. Reset
|
|
128
|
+
* implicitly per-extraction (a fresh `VbaExtractorContext` is
|
|
129
|
+
* constructed every `extract()` call). Replaces the per-factory
|
|
130
|
+
* closure variable that lived in `sweepCallsAndSql` before the
|
|
131
|
+
* Issue #153 RULES-table refactor.
|
|
132
|
+
*/
|
|
133
|
+
vbaWithStack = [];
|
|
101
134
|
/** Local event name (lowercase) → event node for `RaiseEvent` edge emission. */
|
|
102
135
|
localEvents = new Map();
|
|
136
|
+
/**
|
|
137
|
+
* Issue #152: per-event counter for `RaiseEvent <EventName>` sites. Keyed
|
|
138
|
+
* by event node id (so two different events that share a name across
|
|
139
|
+
* files don't collide — the gate is per-file). The count is incremented
|
|
140
|
+
* in `scanRaiseEvents` BEFORE the edge is pushed, so the count equals
|
|
141
|
+
* the number of raise sites regardless of the gate decision downstream.
|
|
142
|
+
* The orchestrator's fanout-gate pass reads this map to decide which
|
|
143
|
+
* event nodes to flag `metadata.highFanout: true` and which `raises-event`
|
|
144
|
+
* edges to drop.
|
|
145
|
+
*/
|
|
146
|
+
raiseEventCounts = new Map();
|
|
103
147
|
/**
|
|
104
148
|
* Same-file function/property return types, keyed by lowercase proc name →
|
|
105
149
|
* declared return type. ONLY non-primitive (project-class) return types are
|
|
@@ -111,9 +155,45 @@ class VbaExtractorContext {
|
|
|
111
155
|
* time) — that stays the resolver's frontier.
|
|
112
156
|
*/
|
|
113
157
|
functionReturnTypes = new Map();
|
|
158
|
+
/**
|
|
159
|
+
* Issue #156: per-stage timings, lazily allocated ONLY when
|
|
160
|
+
* `CODEGRAPH_VBA_TIMING=1|2` is set. The default path (env var unset)
|
|
161
|
+
* keeps this `null` so `recordStage` is a single null-check and we
|
|
162
|
+
* pay zero Map-allocation cost in the hot path. Stage names are
|
|
163
|
+
* dot-separated: `preprocess.stripVbaComments`,
|
|
164
|
+
* `preprocess.cc.lexer+parser`, `walk.procedures`, `walk.main`,
|
|
165
|
+
* `classifier.<name>`. Counters are in milliseconds (float).
|
|
166
|
+
*/
|
|
167
|
+
timings = null;
|
|
168
|
+
/**
|
|
169
|
+
* Issue #156: how many times each classifier's `classifyLine` was
|
|
170
|
+
* invoked. Only allocated together with `timings` so the default path
|
|
171
|
+
* pays no cost.
|
|
172
|
+
*/
|
|
173
|
+
classifierInvokeCounts = null;
|
|
114
174
|
constructor(filePath) {
|
|
115
175
|
this.filePath = filePath;
|
|
116
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Issue #156: ensure the timings Maps exist. Called once per
|
|
179
|
+
* `extract()` by the orchestrator right after it reads the env var.
|
|
180
|
+
* No-op when already allocated.
|
|
181
|
+
*/
|
|
182
|
+
ensureTimings() {
|
|
183
|
+
if (this.timings === null) {
|
|
184
|
+
this.timings = new Map();
|
|
185
|
+
this.classifierInvokeCounts = new Map();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Issue #156: add `ms` to the stage named `name`. No-op when
|
|
190
|
+
* `timings` is null (default path).
|
|
191
|
+
*/
|
|
192
|
+
recordStage(name, ms) {
|
|
193
|
+
if (this.timings === null)
|
|
194
|
+
return;
|
|
195
|
+
this.timings.set(name, (this.timings.get(name) ?? 0) + ms);
|
|
196
|
+
}
|
|
117
197
|
/**
|
|
118
198
|
* Emit a `contains` edge from the (lazily-created) module/class node to
|
|
119
199
|
* `targetId`. Mirrors the pending-source pattern the procedure and
|
|
@@ -209,6 +289,66 @@ class VbaExtractorContext {
|
|
|
209
289
|
// `sweepProcedures` (audit S2 — replaced an O(n) linear scan per call site).
|
|
210
290
|
return this.functionNodeByName.get(name);
|
|
211
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Issue #152: apply the per-file `RaiseEvent` fanout gate. For every
|
|
294
|
+
* event whose `raiseEventCounts` value exceeds `maxFanout`:
|
|
295
|
+
* 1. Stamp the event node's `metadata.highFanout = true` and
|
|
296
|
+
* `metadata.raiseCount = <count>` so consumers (codegraph_explore,
|
|
297
|
+
* vba-event-tracer) can recognize a high-fanout event.
|
|
298
|
+
* 2. Drop every `raises-event` edge targeting that event id from
|
|
299
|
+
* `edges`. The event node itself stays — declaration site, handler
|
|
300
|
+
* linkage via `subscribes-event`, and metadata are all preserved.
|
|
301
|
+
*
|
|
302
|
+
* Events with `<= maxFanout` raise sites are untouched (no flag, edges
|
|
303
|
+
* stay). When `maxFanout` is undefined, the gate is disabled and the
|
|
304
|
+
* method is a no-op. Mirrors the upstream `EVENT_FANOUT_CAP` discipline
|
|
305
|
+
* in `src/resolution/callback-synthesizer.ts:43` (this side suppresses
|
|
306
|
+
* the producer side, the upstream side suppresses the synthesized
|
|
307
|
+
* cross-file dispatcher/handler edges).
|
|
308
|
+
*
|
|
309
|
+
* Returns the number of `raises-event` edges dropped (zero when the
|
|
310
|
+
* gate is disabled or no event exceeds the cap — useful for tests).
|
|
311
|
+
*/
|
|
312
|
+
applyRaiseFanoutGate(maxFanout) {
|
|
313
|
+
if (maxFanout === undefined)
|
|
314
|
+
return 0;
|
|
315
|
+
if (maxFanout < 0)
|
|
316
|
+
return 0;
|
|
317
|
+
// 1. Build the set of event node ids that exceed the cap.
|
|
318
|
+
const overThreshold = new Set();
|
|
319
|
+
for (const [eventId, count] of this.raiseEventCounts) {
|
|
320
|
+
if (count > maxFanout)
|
|
321
|
+
overThreshold.add(eventId);
|
|
322
|
+
}
|
|
323
|
+
if (overThreshold.size === 0)
|
|
324
|
+
return 0;
|
|
325
|
+
// 2. Stamp the metadata on the event nodes.
|
|
326
|
+
for (const eventId of overThreshold) {
|
|
327
|
+
const eventNode = this.nodes.find((n) => n.id === eventId && n.kind === 'event');
|
|
328
|
+
if (!eventNode)
|
|
329
|
+
continue;
|
|
330
|
+
const md = (eventNode.metadata ?? {});
|
|
331
|
+
md.highFanout = true;
|
|
332
|
+
md.raiseCount = this.raiseEventCounts.get(eventId) ?? 0;
|
|
333
|
+
eventNode.metadata = md;
|
|
334
|
+
}
|
|
335
|
+
// 3. Drop every `raises-event` edge targeting an over-threshold event.
|
|
336
|
+
// Re-build the edges array so the dropped edges vanish without
|
|
337
|
+
// disturbing the other edges' order. `edges.length` is the only
|
|
338
|
+
// property kept; this matches how every other sweep mutates `edges`
|
|
339
|
+
// (push-only, never splice).
|
|
340
|
+
const before = this.edges.length;
|
|
341
|
+
const kept = [];
|
|
342
|
+
for (const e of this.edges) {
|
|
343
|
+
if (e.kind === 'raises-event' && overThreshold.has(e.target))
|
|
344
|
+
continue;
|
|
345
|
+
kept.push(e);
|
|
346
|
+
}
|
|
347
|
+
this.edges.length = 0;
|
|
348
|
+
for (const e of kept)
|
|
349
|
+
this.edges.push(e);
|
|
350
|
+
return before - kept.length;
|
|
351
|
+
}
|
|
212
352
|
/**
|
|
213
353
|
* Emit a `references` edge from the file's module/class node to a synthetic
|
|
214
354
|
* node named `targetName`. Used by Dim, WithEvents, Set-New, and SQL sweeps.
|
|
@@ -222,8 +362,18 @@ class VbaExtractorContext {
|
|
|
222
362
|
* TempVars sweep already emits (`emitTempVarReference`). Omitted for
|
|
223
363
|
* structural references (Dim/WithEvents/Set-New) where the direction is not
|
|
224
364
|
* meaningful.
|
|
365
|
+
*
|
|
366
|
+
* `extras` (optional): additional metadata fields to merge into the
|
|
367
|
+
* emitted edge's `metadata` object. Used by the WithEvents sweep to
|
|
368
|
+
* stamp `variableName` (issue #150) so the post-extraction
|
|
369
|
+
* event-handler synthesis pass can find the `m_<var>_<event>`
|
|
370
|
+
* handler Sub even after `resolveVbaReferenceStubs` CASCADE-deletes
|
|
371
|
+
* the companion `subscribes-event` edge along with the synthetic
|
|
372
|
+
* class stub. Fields here are merged AFTER the standard
|
|
373
|
+
* `{ synthesizedBy [, access] }` shape, so callers can override
|
|
374
|
+
* (rarely useful) but not accidentally drop the stamp.
|
|
225
375
|
*/
|
|
226
|
-
emitReference(targetName, lineNum, column, synthesizedBy, access) {
|
|
376
|
+
emitReference(targetName, lineNum, column, synthesizedBy, access, extras) {
|
|
227
377
|
if (!targetName)
|
|
228
378
|
return;
|
|
229
379
|
const targetId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'class', // placeholder kind; cross-file resolution will re-type at lookup
|
|
@@ -247,12 +397,15 @@ class VbaExtractorContext {
|
|
|
247
397
|
updatedAt: Date.now(),
|
|
248
398
|
});
|
|
249
399
|
}
|
|
400
|
+
const metadata = access
|
|
401
|
+
? { synthesizedBy, access, ...(extras ?? {}) }
|
|
402
|
+
: { synthesizedBy, ...(extras ?? {}) };
|
|
250
403
|
const edge = {
|
|
251
404
|
source: '', // rewritten after module node exists
|
|
252
405
|
target: targetId,
|
|
253
406
|
kind: 'references',
|
|
254
407
|
provenance: 'heuristic',
|
|
255
|
-
metadata
|
|
408
|
+
metadata,
|
|
256
409
|
line: lineNum,
|
|
257
410
|
column,
|
|
258
411
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/extraction/vba/context.ts"],"names":[],"mappings":";;;AAmBA,gEAAwD;AACxD,2CAA8C;AAkC9C,MAAa,mBAAmB;IACvB,QAAQ,CAAS;IACjB,KAAK,GAAW,EAAE,CAAC;IACnB,KAAK,GAAW,EAAE,CAAC;I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AAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;YACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAreD,kDAqeC"}
|
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
import { VbaExtractorContext, VbaClassifier } from './context';
|
|
2
|
+
import { VbaExtractionRule } from './rules';
|
|
2
3
|
/**
|
|
3
|
-
* Issue #
|
|
4
|
-
*
|
|
4
|
+
* Issue #153: the declarative rule table for the events/types/declares
|
|
5
|
+
* concern. Five rules, partitioned by where they fire:
|
|
6
|
+
*
|
|
7
|
+
* - `event-decl` (outside-type-block) — match an `Event <Name>` decl
|
|
8
|
+
* - `type-start` (outside-type-block) — match a `Type <Name>` header;
|
|
9
|
+
* sets `ctx.vbaDeclTypeBlock` on a successful match
|
|
10
|
+
* - `type-end` (inside-type-block) — match `End Type`; clears
|
|
11
|
+
* `ctx.vbaDeclTypeBlock` on a successful match
|
|
12
|
+
* - `type-member` (inside-type-block) — match `<Member> As <Type>`
|
|
13
|
+
* inside an open type block
|
|
14
|
+
* - `dll-declare` (outside-type-block) — match a `[Private|Public]
|
|
15
|
+
* Declare [PtrSafe] Sub|Function <Name> Lib "<dll>"
|
|
16
|
+
* [Alias "<x>"]` Win32 API declaration
|
|
17
|
+
*
|
|
18
|
+
* The `requires` field encodes the type-block precondition. The
|
|
19
|
+
* dispatcher (the factory's `classifyLine`) filters rules whose
|
|
20
|
+
* precondition does not hold, so an `End Type` line never
|
|
21
|
+
* accidentally re-enters the `event-decl` / `dll-declare` paths.
|
|
22
|
+
*
|
|
23
|
+
* Inter-line state lives on `ctx.vbaDeclTypeBlock` (replaces the
|
|
24
|
+
* pre-#153 factory closure variable) so the emit functions can
|
|
25
|
+
* read/write it without taking a mutable closure reference.
|
|
26
|
+
*/
|
|
27
|
+
export declare const RULES: readonly VbaExtractionRule<unknown>[];
|
|
28
|
+
/**
|
|
29
|
+
* Issue #83: factory for the events/types/declares classifier.
|
|
30
|
+
*
|
|
31
|
+
* Inter-line state (`ctx.vbaDeclTypeBlock`) lives on `ctx` — the
|
|
32
|
+
* declarative RULES table's `emit` functions read/write it directly.
|
|
33
|
+
* The dispatcher below honours each rule's `requires` precondition
|
|
34
|
+
* so the per-line dispatch mirrors the legacy cascade exactly:
|
|
35
|
+
*
|
|
36
|
+
* if (currentType) {
|
|
37
|
+
* try type-end, then type-member; return early
|
|
38
|
+
* } else {
|
|
39
|
+
* try event-decl, type-start, dll-declare
|
|
40
|
+
* }
|
|
5
41
|
*/
|
|
6
42
|
export declare function createEventsTypesDeclaresClassifier(): VbaClassifier;
|
|
7
43
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/declarations.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../../src/extraction/vba/declarations.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAyB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqBnE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,iBAAiB,CAAC,OAAO,CAAC,EA2JtD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mCAAmC,IAAI,aAAa,CA+BnE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAOzF"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULES = void 0;
|
|
3
4
|
exports.createEventsTypesDeclaresClassifier = createEventsTypesDeclaresClassifier;
|
|
4
5
|
exports.sweepEventsTypesAndDeclares = sweepEventsTypesAndDeclares;
|
|
5
6
|
const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
|
|
6
7
|
const text_utils_1 = require("./text-utils");
|
|
8
|
+
const rules_1 = require("./rules");
|
|
7
9
|
/** `[visibility] Event <Name>(...)` custom event declaration. */
|
|
8
10
|
const EVENT_DECL_RE = /^\s*((?:Public|Private|Friend)\s+)?Event\s+(\p{L}[\p{L}\p{N}_]*)\b/iu;
|
|
9
11
|
/** `[visibility] Type <Name>` user-defined type block start. */
|
|
@@ -15,143 +17,229 @@ const TYPE_MEMBER_RE = /^\s*(\p{L}[\p{L}\p{N}_]*)\s*(?:\([^)]*\))?\s+As\s+(.+?)\
|
|
|
15
17
|
/** `[visibility] Declare [PtrSafe] Sub|Function <Name> Lib "dll" [Alias "x"] ...` */
|
|
16
18
|
const DLL_DECLARE_RE = /^\s*((?:Public|Private)\s+)?Declare\s+(PtrSafe\s+)?(Sub|Function)\s+(\p{L}[\p{L}\p{N}_]*)\s+Lib\s+"([^"]+)"(?:\s+Alias\s+"([^"]+)")?/iu;
|
|
17
19
|
/**
|
|
18
|
-
* Issue #
|
|
19
|
-
*
|
|
20
|
+
* Issue #153: the declarative rule table for the events/types/declares
|
|
21
|
+
* concern. Five rules, partitioned by where they fire:
|
|
22
|
+
*
|
|
23
|
+
* - `event-decl` (outside-type-block) — match an `Event <Name>` decl
|
|
24
|
+
* - `type-start` (outside-type-block) — match a `Type <Name>` header;
|
|
25
|
+
* sets `ctx.vbaDeclTypeBlock` on a successful match
|
|
26
|
+
* - `type-end` (inside-type-block) — match `End Type`; clears
|
|
27
|
+
* `ctx.vbaDeclTypeBlock` on a successful match
|
|
28
|
+
* - `type-member` (inside-type-block) — match `<Member> As <Type>`
|
|
29
|
+
* inside an open type block
|
|
30
|
+
* - `dll-declare` (outside-type-block) — match a `[Private|Public]
|
|
31
|
+
* Declare [PtrSafe] Sub|Function <Name> Lib "<dll>"
|
|
32
|
+
* [Alias "<x>"]` Win32 API declaration
|
|
33
|
+
*
|
|
34
|
+
* The `requires` field encodes the type-block precondition. The
|
|
35
|
+
* dispatcher (the factory's `classifyLine`) filters rules whose
|
|
36
|
+
* precondition does not hold, so an `End Type` line never
|
|
37
|
+
* accidentally re-enters the `event-decl` / `dll-declare` paths.
|
|
38
|
+
*
|
|
39
|
+
* Inter-line state lives on `ctx.vbaDeclTypeBlock` (replaces the
|
|
40
|
+
* pre-#153 factory closure variable) so the emit functions can
|
|
41
|
+
* read/write it without taking a mutable closure reference.
|
|
42
|
+
*/
|
|
43
|
+
exports.RULES = [
|
|
44
|
+
(0, rules_1.defineRule)({
|
|
45
|
+
id: 'event-decl',
|
|
46
|
+
description: 'Match an `[Public|Private|Friend] Event <Name>(...)` custom event declaration; emit an `event` node + `contains` edge from the module/class.',
|
|
47
|
+
pattern: EVENT_DECL_RE,
|
|
48
|
+
requires: 'outside-type-block',
|
|
49
|
+
emit: (m, ctx, line, lineNum) => {
|
|
50
|
+
const visibility = (0, text_utils_1.foldVisibility)(m[1] ?? '');
|
|
51
|
+
const name = m[2] ?? '';
|
|
52
|
+
if (!name)
|
|
53
|
+
return null;
|
|
54
|
+
const eventId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'event', name, lineNum);
|
|
55
|
+
const eventNode = {
|
|
56
|
+
id: eventId,
|
|
57
|
+
kind: 'event',
|
|
58
|
+
name,
|
|
59
|
+
signature: line.trim(),
|
|
60
|
+
qualifiedName: ctx.classNamePrefix ? `${ctx.classNamePrefix}.${name}` : name,
|
|
61
|
+
filePath: ctx.filePath,
|
|
62
|
+
language: 'vba',
|
|
63
|
+
startLine: lineNum,
|
|
64
|
+
endLine: lineNum,
|
|
65
|
+
startColumn: 0,
|
|
66
|
+
endColumn: line.length,
|
|
67
|
+
visibility,
|
|
68
|
+
updatedAt: Date.now(),
|
|
69
|
+
};
|
|
70
|
+
ctx.nodes.push(eventNode);
|
|
71
|
+
ctx.localEvents.set(name.toLowerCase(), eventNode);
|
|
72
|
+
ctx.pushContainsFromModule(eventId);
|
|
73
|
+
return { name };
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
(0, rules_1.defineRule)({
|
|
77
|
+
id: 'type-start',
|
|
78
|
+
description: 'Match a `[Public|Private|Friend] Type <Name>` UDT block header; emit a `type` node + `contains` edge and mark `ctx.vbaDeclTypeBlock` so subsequent member lines route to `type-member` / `End Type` lines route to `type-end`.',
|
|
79
|
+
pattern: TYPE_START_RE,
|
|
80
|
+
requires: 'outside-type-block',
|
|
81
|
+
emit: (m, ctx, line, lineNum) => {
|
|
82
|
+
const visibility = (0, text_utils_1.foldVisibility)(m[1] ?? '');
|
|
83
|
+
const name = m[2] ?? '';
|
|
84
|
+
if (!name)
|
|
85
|
+
return null;
|
|
86
|
+
const typeId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'type', name, lineNum);
|
|
87
|
+
ctx.nodes.push({
|
|
88
|
+
id: typeId,
|
|
89
|
+
kind: 'type',
|
|
90
|
+
name,
|
|
91
|
+
qualifiedName: ctx.classNamePrefix ? `${ctx.classNamePrefix}.${name}` : name,
|
|
92
|
+
filePath: ctx.filePath,
|
|
93
|
+
language: 'vba',
|
|
94
|
+
startLine: lineNum,
|
|
95
|
+
endLine: lineNum,
|
|
96
|
+
startColumn: 0,
|
|
97
|
+
endColumn: line.length,
|
|
98
|
+
visibility,
|
|
99
|
+
updatedAt: Date.now(),
|
|
100
|
+
});
|
|
101
|
+
ctx.pushContainsFromModule(typeId);
|
|
102
|
+
// Mark the open type block on ctx so the next non-End line is
|
|
103
|
+
// dispatched to `type-member` / `type-end` instead of the
|
|
104
|
+
// outside-type-block rules.
|
|
105
|
+
ctx.vbaDeclTypeBlock = { id: typeId, name };
|
|
106
|
+
return { name, typeId };
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
109
|
+
(0, rules_1.defineRule)({
|
|
110
|
+
id: 'type-end',
|
|
111
|
+
description: 'Match `End Type` while inside a type block; emit nothing and clear `ctx.vbaDeclTypeBlock` so subsequent lines route back to the outside-type-block rules.',
|
|
112
|
+
pattern: TYPE_END_RE,
|
|
113
|
+
requires: 'inside-type-block',
|
|
114
|
+
emit: (_m, ctx) => {
|
|
115
|
+
ctx.vbaDeclTypeBlock = null;
|
|
116
|
+
return { kind: 'end-type-block' };
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
(0, rules_1.defineRule)({
|
|
120
|
+
id: 'type-member',
|
|
121
|
+
description: 'Match `<MemberName> [As <Type>]` inside an open type block; emit a `type_member` node + a `type-member` edge from the open type to the member.',
|
|
122
|
+
pattern: TYPE_MEMBER_RE,
|
|
123
|
+
requires: 'inside-type-block',
|
|
124
|
+
emit: (m, ctx, line, lineNum) => {
|
|
125
|
+
const memberName = m[1] ?? '';
|
|
126
|
+
const memberType = (m[2] ?? '').trim();
|
|
127
|
+
if (!memberName || !ctx.vbaDeclTypeBlock)
|
|
128
|
+
return null;
|
|
129
|
+
const memberId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'type_member', memberName, lineNum);
|
|
130
|
+
ctx.nodes.push({
|
|
131
|
+
id: memberId,
|
|
132
|
+
kind: 'type_member',
|
|
133
|
+
name: memberName,
|
|
134
|
+
qualifiedName: `${ctx.vbaDeclTypeBlock.name}.${memberName}`,
|
|
135
|
+
filePath: ctx.filePath,
|
|
136
|
+
language: 'vba',
|
|
137
|
+
startLine: lineNum,
|
|
138
|
+
endLine: lineNum,
|
|
139
|
+
startColumn: 0,
|
|
140
|
+
endColumn: line.length,
|
|
141
|
+
metadata: { memberType },
|
|
142
|
+
updatedAt: Date.now(),
|
|
143
|
+
});
|
|
144
|
+
ctx.edges.push({
|
|
145
|
+
source: ctx.vbaDeclTypeBlock.id,
|
|
146
|
+
target: memberId,
|
|
147
|
+
kind: 'type-member',
|
|
148
|
+
provenance: 'parser',
|
|
149
|
+
});
|
|
150
|
+
return { name: memberName };
|
|
151
|
+
},
|
|
152
|
+
}),
|
|
153
|
+
(0, rules_1.defineRule)({
|
|
154
|
+
id: 'dll-declare',
|
|
155
|
+
description: 'Match a `[Public|Private] Declare [PtrSafe] Sub|Function <Name> Lib "<dll>" [Alias "<x>"]` Win32 API declaration; emit a `declare` node + `contains` edge and register the name in `functionNodeByName` so call-site scanning can resolve it.',
|
|
156
|
+
pattern: DLL_DECLARE_RE,
|
|
157
|
+
requires: 'outside-type-block',
|
|
158
|
+
emit: (m, ctx, line, lineNum) => {
|
|
159
|
+
const visibility = (0, text_utils_1.foldVisibility)(m[1] ?? '');
|
|
160
|
+
const ptrSafe = !!m[2];
|
|
161
|
+
const declareKind = (m[3] ?? '').toLowerCase();
|
|
162
|
+
const name = m[4] ?? '';
|
|
163
|
+
const dll = m[5] ?? '';
|
|
164
|
+
const aliasName = m[6] ?? undefined;
|
|
165
|
+
if (!name)
|
|
166
|
+
return null;
|
|
167
|
+
const declareId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'declare', name, lineNum);
|
|
168
|
+
const declareNode = {
|
|
169
|
+
id: declareId,
|
|
170
|
+
kind: 'declare',
|
|
171
|
+
name,
|
|
172
|
+
qualifiedName: ctx.classNamePrefix ? `${ctx.classNamePrefix}.${name}` : name,
|
|
173
|
+
filePath: ctx.filePath,
|
|
174
|
+
language: 'vba',
|
|
175
|
+
startLine: lineNum,
|
|
176
|
+
endLine: lineNum,
|
|
177
|
+
startColumn: 0,
|
|
178
|
+
endColumn: line.length,
|
|
179
|
+
visibility,
|
|
180
|
+
metadata: {
|
|
181
|
+
isDeclare: true,
|
|
182
|
+
dll,
|
|
183
|
+
declareKind,
|
|
184
|
+
ptrSafe,
|
|
185
|
+
...(aliasName ? { aliasName } : {}),
|
|
186
|
+
},
|
|
187
|
+
updatedAt: Date.now(),
|
|
188
|
+
};
|
|
189
|
+
ctx.nodes.push(declareNode);
|
|
190
|
+
if (!ctx.functionNodeByName.has(name)) {
|
|
191
|
+
ctx.functionNodeByName.set(name, declareNode);
|
|
192
|
+
}
|
|
193
|
+
ctx.pushContainsFromModule(declareId);
|
|
194
|
+
return { name };
|
|
195
|
+
},
|
|
196
|
+
}),
|
|
197
|
+
];
|
|
198
|
+
/**
|
|
199
|
+
* Issue #83: factory for the events/types/declares classifier.
|
|
200
|
+
*
|
|
201
|
+
* Inter-line state (`ctx.vbaDeclTypeBlock`) lives on `ctx` — the
|
|
202
|
+
* declarative RULES table's `emit` functions read/write it directly.
|
|
203
|
+
* The dispatcher below honours each rule's `requires` precondition
|
|
204
|
+
* so the per-line dispatch mirrors the legacy cascade exactly:
|
|
205
|
+
*
|
|
206
|
+
* if (currentType) {
|
|
207
|
+
* try type-end, then type-member; return early
|
|
208
|
+
* } else {
|
|
209
|
+
* try event-decl, type-start, dll-declare
|
|
210
|
+
* }
|
|
20
211
|
*/
|
|
21
212
|
function createEventsTypesDeclaresClassifier() {
|
|
22
|
-
let currentType = null;
|
|
23
213
|
const cls = {
|
|
24
214
|
name: 'eventsTypesDeclares',
|
|
25
215
|
count: 0,
|
|
26
216
|
classifyLine(line, i, ctx) {
|
|
27
217
|
const lineNum = i + 1;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
qualifiedName: `${currentType.name}.${memberName}`,
|
|
45
|
-
filePath: ctx.filePath,
|
|
46
|
-
language: 'vba',
|
|
47
|
-
startLine: lineNum,
|
|
48
|
-
endLine: lineNum,
|
|
49
|
-
startColumn: 0,
|
|
50
|
-
endColumn: line.length,
|
|
51
|
-
metadata: { memberType },
|
|
52
|
-
updatedAt: Date.now(),
|
|
53
|
-
});
|
|
54
|
-
ctx.edges.push({
|
|
55
|
-
source: currentType.id,
|
|
56
|
-
target: memberId,
|
|
57
|
-
kind: 'type-member',
|
|
58
|
-
provenance: 'parser',
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const eventDecl = EVENT_DECL_RE.exec(line);
|
|
64
|
-
if (eventDecl) {
|
|
65
|
-
const visibility = (0, text_utils_1.foldVisibility)(eventDecl[1] ?? '');
|
|
66
|
-
const name = eventDecl[2] ?? '';
|
|
67
|
-
if (!name)
|
|
68
|
-
return;
|
|
69
|
-
const eventId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'event', name, lineNum);
|
|
70
|
-
const eventNode = {
|
|
71
|
-
id: eventId,
|
|
72
|
-
kind: 'event',
|
|
73
|
-
name,
|
|
74
|
-
signature: line.trim(),
|
|
75
|
-
qualifiedName: ctx.classNamePrefix ? `${ctx.classNamePrefix}.${name}` : name,
|
|
76
|
-
filePath: ctx.filePath,
|
|
77
|
-
language: 'vba',
|
|
78
|
-
startLine: lineNum,
|
|
79
|
-
endLine: lineNum,
|
|
80
|
-
startColumn: 0,
|
|
81
|
-
endColumn: line.length,
|
|
82
|
-
visibility,
|
|
83
|
-
updatedAt: Date.now(),
|
|
84
|
-
};
|
|
85
|
-
ctx.nodes.push(eventNode);
|
|
86
|
-
ctx.localEvents.set(name.toLowerCase(), eventNode);
|
|
87
|
-
ctx.pushContainsFromModule(eventId);
|
|
88
|
-
this.count++;
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const typeStart = TYPE_START_RE.exec(line);
|
|
92
|
-
if (typeStart) {
|
|
93
|
-
const visibility = (0, text_utils_1.foldVisibility)(typeStart[1] ?? '');
|
|
94
|
-
const name = typeStart[2] ?? '';
|
|
95
|
-
if (!name)
|
|
96
|
-
return;
|
|
97
|
-
const typeId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'type', name, lineNum);
|
|
98
|
-
ctx.nodes.push({
|
|
99
|
-
id: typeId,
|
|
100
|
-
kind: 'type',
|
|
101
|
-
name,
|
|
102
|
-
qualifiedName: ctx.classNamePrefix ? `${ctx.classNamePrefix}.${name}` : name,
|
|
103
|
-
filePath: ctx.filePath,
|
|
104
|
-
language: 'vba',
|
|
105
|
-
startLine: lineNum,
|
|
106
|
-
endLine: lineNum,
|
|
107
|
-
startColumn: 0,
|
|
108
|
-
endColumn: line.length,
|
|
109
|
-
visibility,
|
|
110
|
-
updatedAt: Date.now(),
|
|
111
|
-
});
|
|
112
|
-
ctx.pushContainsFromModule(typeId);
|
|
113
|
-
currentType = { id: typeId, name };
|
|
114
|
-
this.count++;
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
const declaration = DLL_DECLARE_RE.exec(line);
|
|
118
|
-
if (declaration) {
|
|
119
|
-
const visibility = (0, text_utils_1.foldVisibility)(declaration[1] ?? '');
|
|
120
|
-
const ptrSafe = !!declaration[2];
|
|
121
|
-
const declareKind = (declaration[3] ?? '').toLowerCase();
|
|
122
|
-
const name = declaration[4] ?? '';
|
|
123
|
-
const dll = declaration[5] ?? '';
|
|
124
|
-
const aliasName = declaration[6] ?? undefined;
|
|
125
|
-
if (!name)
|
|
126
|
-
return;
|
|
127
|
-
const declareId = (0, tree_sitter_helpers_1.generateNodeId)(ctx.filePath, 'declare', name, lineNum);
|
|
128
|
-
const declareNode = {
|
|
129
|
-
id: declareId,
|
|
130
|
-
kind: 'declare',
|
|
131
|
-
name,
|
|
132
|
-
qualifiedName: ctx.classNamePrefix ? `${ctx.classNamePrefix}.${name}` : name,
|
|
133
|
-
filePath: ctx.filePath,
|
|
134
|
-
language: 'vba',
|
|
135
|
-
startLine: lineNum,
|
|
136
|
-
endLine: lineNum,
|
|
137
|
-
startColumn: 0,
|
|
138
|
-
endColumn: line.length,
|
|
139
|
-
visibility,
|
|
140
|
-
metadata: {
|
|
141
|
-
isDeclare: true,
|
|
142
|
-
dll,
|
|
143
|
-
declareKind,
|
|
144
|
-
ptrSafe,
|
|
145
|
-
...(aliasName ? { aliasName } : {}),
|
|
146
|
-
},
|
|
147
|
-
updatedAt: Date.now(),
|
|
148
|
-
};
|
|
149
|
-
ctx.nodes.push(declareNode);
|
|
150
|
-
if (!ctx.functionNodeByName.has(name)) {
|
|
151
|
-
ctx.functionNodeByName.set(name, declareNode);
|
|
218
|
+
for (const rule of exports.RULES) {
|
|
219
|
+
// Gate by the rule's `requires` precondition. The
|
|
220
|
+
// `outside-type-block` / `inside-type-block` values are the
|
|
221
|
+
// concrete preconditions the dispatcher knows about today;
|
|
222
|
+
// unknown strings are treated as "always" so adding new
|
|
223
|
+
// preconditions does not require touching this loop.
|
|
224
|
+
if (rule.requires === 'inside-type-block' && !ctx.vbaDeclTypeBlock)
|
|
225
|
+
continue;
|
|
226
|
+
if (rule.requires === 'outside-type-block' && ctx.vbaDeclTypeBlock)
|
|
227
|
+
continue;
|
|
228
|
+
const m = (0, rules_1.matchRule)(rule.pattern, line);
|
|
229
|
+
if (!m)
|
|
230
|
+
continue;
|
|
231
|
+
const result = rule.emit(m, ctx, line, lineNum);
|
|
232
|
+
if (result !== null && result !== undefined) {
|
|
233
|
+
this.count += rule.count ? rule.count(result) : 1;
|
|
152
234
|
}
|
|
153
|
-
|
|
154
|
-
|
|
235
|
+
// `type-end` cleared the type block — nothing else on this
|
|
236
|
+
// line can apply (a VBA `End Type` line cannot also be an
|
|
237
|
+
// `Event <Name>` declaration). The legacy cascade did the
|
|
238
|
+
// same short-circuit via `return`. Break out of the loop
|
|
239
|
+
// explicitly so a later refactor cannot accidentally let an
|
|
240
|
+
// outside-type-block rule fire on the same line.
|
|
241
|
+
if (rule.id === 'type-end')
|
|
242
|
+
break;
|
|
155
243
|
}
|
|
156
244
|
},
|
|
157
245
|
};
|