1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
//! The member access facts, the fixture, binding and mock facts, and the
//! `this` spread, dynamic custom element and misplaced directive facts that
//! the extractor records for the analysis.
/// A member name referenced from an Angular template surface.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct AngularTemplateMemberAccessFact {
/// Referenced class member name.
pub member: String,
}
/// A typed Angular component field that exposes array elements to templates.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct AngularComponentFieldArrayTypeFact {
/// Component field name used as the template iterable.
pub field: String,
/// Array element class name.
pub element_class: String,
}
/// Opaque Angular `{ ...this }` forwarding marker.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct AngularThisSpreadFact;
/// A member access on a static factory call result.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct FactoryCallMemberAccessFact {
/// Local imported class or namespace object used as the factory callee.
pub callee_object: String,
/// Static factory method invoked on the callee object.
pub callee_method: String,
/// Member accessed on the returned instance-like object.
pub member: String,
}
/// A factory-returned value consumed opaquely, so every member of the class it
/// returns must be treated as used.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct FactoryFnWholeObjectFact {
/// Local imported function used as the factory callee.
pub callee_name: String,
}
/// A member access reached through a property of a value returned by an imported
/// factory that returns an object literal.
///
/// `const ui = createUi(); ui.orders.member` emits one fact per member read on a
/// factory-result property. The analyze layer resolves `callee_name` through the
/// consumer's imports to the factory's origin module, reads that module's
/// `exported_factory_return_object_shapes` to find the property whose path equals
/// `property_path` and its class local name, resolves THAT through the factory
/// module's own imports to the class export, and credits `member` on the class
/// (gated on the export actually being a class with members). See issue #1858.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct FactoryReturnObjectPropertyAccessFact {
/// Local imported function used as the factory callee.
pub callee_name: String,
/// Dotted property path between the factory-result local and the final member
/// (e.g. `"orders"` for `ui.orders.member`, `"invoke.orders"` for `ui.invoke.orders.member`).
pub property_path: String,
/// Member accessed on the terminal property's instance.
pub member: String,
}
/// A member access reached through a typed property hop that the extraction
/// layer could not resolve locally.
///
/// `constructor(private opts: Opts) { ... this.opts.c.optM() }` where `Opts`
/// is NOT declared in this file emits
/// `TypedPropertyMemberAccessFact { type_name: "Opts", property_path: "c", member: "optM" }`.
/// The analyze layer resolves `type_name` through the consumer's imports to the
/// declaring module, walks `property_path` through that module's
/// `type_member_types`, resolves the terminal type name through the declaring
/// module's own imports, and credits `member` on the resolved class (gated on
/// the export actually being a class with members). See issue #1785.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct TypedPropertyMemberAccessFact {
/// Local (usually imported) named-type symbol the receiver is typed by.
pub type_name: String,
/// Remaining dotted property segments between the typed binding and the
/// final member (e.g. `"c"` for `this.opts.c.optM()`).
pub property_path: String,
/// Member accessed on the terminal property's instance.
pub member: String,
}
/// A class member directly required by a named structural type.
///
/// Optional properties and methods are excluded: removing an optional
/// implementation can preserve assignability, while removing a required one
/// from an explicit `implements` contract cannot.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct RequiredTypeMemberFact {
/// Module-local interface or object-type alias name.
pub type_name: String,
/// Static required property or method name.
pub member: String,
}
/// A named interface that a module-local interface extends.
///
/// Analysis follows these edges to give an `implements` contract the required
/// members of each parent interface, also across modules.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct InterfaceExtendsFact {
/// Module-local interface declaration name.
pub interface_name: String,
/// Module-local or imported name of the parent interface.
pub parent_name: String,
}
/// One direct contributor to a named type alias's receiver surface.
///
/// Nested property types are deliberately excluded: in
/// `{ nested: Nested }`, `Alias.member` does not access `Nested.member`.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct TypeAliasSurfaceTargetFact {
/// Module-local alias declaration name.
pub alias_name: String,
/// Module-local or imported named type contributing the direct surface.
pub target_name: String,
}
/// A statically known string value of a TypeScript enum member.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct StringEnumMemberValueFact {
/// Module-local enum declaration name.
pub enum_name: String,
/// Static enum member name.
pub member_name: String,
/// Exact string initializer value.
pub value: String,
}
/// A computed property access whose key is a static enum member.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ComputedEnumKeyUseFact {
/// Local enum object used as the key source.
pub key_object: String,
/// Static member selected from the enum object.
pub key_member: String,
}
/// A fluent chain rooted at a static factory call, one fact per chain. A step is
/// used when the root method is a factory and each earlier step returns `this`.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct FluentChainMemberAccessFact {
/// Local imported class or namespace object used as the chain root.
pub root_object: String,
/// Static factory method that starts the fluent chain.
pub root_method: String,
/// The methods called after the root method, each once, in first-call order.
pub steps: Vec<String>,
}
/// A fluent chain rooted at a `new` expression, one fact per chain. A step is
/// used when the first method and each earlier step return `this`.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct FluentChainNewMemberAccessFact {
/// Local imported class constructed by the `new` expression.
pub class_name: String,
/// The method called on the new instance.
pub first_method: String,
/// The methods called after the first method, each once, in first-call order.
pub steps: Vec<String>,
}
/// A member access on a Playwright fixture object inside a test callback.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PlaywrightFixtureUseFact {
/// Local test function or wrapper used as the callback callee.
pub test_name: String,
/// Fixture name or dotted fixture path referenced in the callback.
pub fixture_name: String,
/// Member accessed on the fixture target.
pub member: String,
}
/// A Playwright fixture definition declared by a typed `test.extend<T>()`.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PlaywrightFixtureDefinitionFact {
/// Local test function or wrapper receiving the fixture definition.
pub test_name: String,
/// Fixture name or dotted fixture path declared by the fixture type.
pub fixture_name: String,
/// Local type symbol used as the fixture target.
pub type_name: String,
}
/// A Playwright fixture definition from `<base>.extend<T>()` where `base` is
/// an imported name. The extractor cannot prove that `base` holds a Playwright
/// test, so analysis applies the definition only when `base` resolves to one.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PlaywrightConditionalFixtureDefinitionFact {
/// Local test function or wrapper receiving the fixture definition.
pub test_name: String,
/// Imported local name that `.extend<T>()` is called on.
pub base_name: String,
/// Fixture name or dotted fixture path declared by the fixture type.
pub fixture_name: String,
/// Local type symbol used as the fixture target.
pub type_name: String,
}
/// A local name that holds a Playwright test: the result of an `.extend()` on
/// the `@playwright/test` `test` import or of a `mergeTests(...)` call.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PlaywrightTestBindingFact {
/// Local name of the Playwright test.
pub test_name: String,
}
/// A Playwright fixture wrapper alias declared by `mergeTests` or `.extend`.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PlaywrightFixtureAliasFact {
/// Local test function or wrapper that inherits fixture definitions.
pub test_name: String,
/// Local test function or wrapper inherited by `test_name`.
pub base_name: String,
}
/// A nested Playwright fixture binding declared by a fixture type alias.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct PlaywrightFixtureTypeFact {
/// Local type alias containing the nested fixture binding.
pub alias_name: String,
/// Fixture name or dotted fixture path declared inside the type alias.
pub fixture_name: String,
/// Local type symbol used as the nested fixture target.
pub type_name: String,
}
/// An exported value whose runtime instance targets a local class or interface.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct InstanceExportBindingFact {
/// Exported binding name.
pub export_name: String,
/// Local class or interface symbol used as the instance target.
pub target_name: String,
/// The static method of `target_name` whose call result the export
/// holds (`export const sm = Cls.getInstance()`). `None` when the export
/// is a direct instance. The class can be imported, so the analyze layer
/// checks that the method returns an instance.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub factory_method: Option<String>,
}
/// A property of an exported object whose value is an instance of a local class.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ExportedObjectInstancePropertyFact {
/// Public export name of the containing object.
pub export_name: String,
/// Dotted path from the exported object to the instance property.
pub property_path: String,
/// Local class symbol instantiated at that property.
pub class_local_name: String,
}
/// A proven class member read through a namespace-qualified constructor or local subclass.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct QualifiedClassMemberAccessFact {
/// Local namespace-import binding.
pub namespace_local: String,
/// Class export selected from that namespace.
pub class_export_name: String,
/// Member accessed through the proven class or instance binding.
pub member: String,
}
/// Opaque marker for a dynamic custom-element render site.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct DynamicCustomElementRenderFact;
/// The action performed by a Vitest module-mock operation.
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "snake_case")]
pub enum VitestModuleMockAction {
/// Register a mock. `factory_replaces_original` is true only when the
/// factory is structurally closed and cannot load the original module.
///
/// Automock (`vi.mock` / `jest.mock` without a factory) is always
/// `factory_replaces_original: false` by decision (issue #2082). For
/// Vitest, the runner derives the mocked shape by importing the original
/// module, so its top-level code executes at collection time, and
/// file-level masking cannot express "module evaluated but exports
/// stubbed". For Jest, a `__mocks__` sibling takes precedence and the
/// original is genuinely not required, but the manual mock itself may
/// load the original (`jest.requireActual`), and proving it never does
/// would need a cross-file factory proof. Both runners therefore keep
/// coverage credit for the automock form.
Mock {
/// Whether the factory provably replaces the original module.
factory_replaces_original: bool,
},
/// Remove a registered mock and restore the original module.
Unmock,
}
impl VitestModuleMockAction {
/// Whether this operation registers a proven complete replacement.
#[must_use]
pub const fn replaces_original(self) -> bool {
matches!(
self,
Self::Mock {
factory_replaces_original: true
}
)
}
}
/// Ordered Vitest module-mock operation with a static source target.
///
/// The declaring [`ModuleInfo::file_id`](crate::extract::ModuleInfo::file_id) owns the test-root provenance. The
/// resolver consumes `source` through its canonical specifier pipeline; this
/// fact deliberately carries no resolved path or duplicate diagnostic span.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct VitestModuleMockOperationFact {
/// Static module specifier passed to `vi.mock` or `vi.unmock`.
pub source: String,
/// Source-order position of the call within the declaring module.
pub call_start: u32,
/// Typed mock or unmock action.
pub action: VitestModuleMockAction,
}
/// A `this`-rooted member access with exact enclosing-class provenance.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ClassThisMemberAccessFact {
/// Enclosing class local name, or `default` for an anonymous default class.
pub class_local_name: String,
/// Dotted receiver spelling beginning with `this.`.
pub object: String,
/// Terminal member being accessed.
pub member: String,
}
/// A whole-object use of a `this`-rooted chain with enclosing-class provenance.
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ClassThisWholeObjectUseFact {
/// Enclosing class local name, or `default` for an anonymous default class.
pub class_local_name: String,
/// Dotted receiver spelling beginning with `this.`.
pub object: String,
}
/// A `"use client"` / `"use server"` directive string written as an expression
/// statement in `program.body` (NOT the leading prologue), so the RSC bundler
/// silently ignores it. One entry per offending occurrence. Consumed by the
/// `misplaced-directive` detector.
#[derive(Debug, Clone, PartialEq, Eq, bitcode::Encode, bitcode::Decode)]
pub struct MisplacedDirectiveSite {
/// `true` for `"use server"`, `false` for `"use client"`.
pub is_server: bool,
/// Start byte offset of the misplaced directive statement.
pub span_start: u32,
}