Skip to main content

fallow_types/
extract_semantic.rs

1//! Persisted semantic facts shared by extraction and analysis.
2use super::*;
3
4/// A typed extraction fact for cross-layer analysis.
5#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, bitcode::Encode, bitcode::Decode)]
6#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
7#[serde(tag = "kind", rename_all = "snake_case")]
8pub enum SemanticFact {
9    /// A class member referenced from an Angular template, host binding, or
10    /// component metadata entry.
11    AngularTemplateMemberAccess(AngularTemplateMemberAccessFact),
12    /// An Angular component field whose value is an array of a class.
13    AngularComponentFieldArrayType(AngularComponentFieldArrayTypeFact),
14    /// An Angular component spreads `this` into an object literal, so component
15    /// input/output usage is opaque.
16    AngularThisSpread(AngularThisSpreadFact),
17    /// A member access on a value returned by an imported static factory call.
18    FactoryCallMemberAccess(FactoryCallMemberAccessFact),
19    /// A member access on a value returned by an imported free-function factory
20    /// (`const x = importedFactory(); x.member`). See issue #1441 (Part A).
21    FactoryFnMemberAccess(FactoryFnMemberAccessFact),
22    /// A member access reached through a property of a value whose declared
23    /// type is an imported named type (`this.opts.c.optM()` where `opts` is
24    /// typed by an imported interface). See issue #1785.
25    TypedPropertyMemberAccess(TypedPropertyMemberAccessFact),
26    /// A member access on a fluent chain rooted at an imported static factory.
27    FluentChainMemberAccess(FluentChainMemberAccessFact),
28    /// A member access on a fluent chain rooted at a `new` expression.
29    FluentChainNewMemberAccess(FluentChainNewMemberAccessFact),
30    /// A member access on a Playwright fixture object inside a test callback.
31    PlaywrightFixtureUse(PlaywrightFixtureUseFact),
32    /// A Playwright fixture definition declared by a typed `test.extend<T>()`.
33    PlaywrightFixtureDefinition(PlaywrightFixtureDefinitionFact),
34    /// A Playwright fixture wrapper alias declared by `mergeTests` or `.extend`.
35    PlaywrightFixtureAlias(PlaywrightFixtureAliasFact),
36    /// A nested Playwright fixture binding declared by a fixture type alias.
37    PlaywrightFixtureType(PlaywrightFixtureTypeFact),
38    /// An exported value whose runtime instance targets a local class or interface.
39    InstanceExportBinding(InstanceExportBindingFact),
40    /// A dynamic custom-element tag render that makes static Lit tag credit opaque.
41    DynamicCustomElementRender(DynamicCustomElementRenderFact),
42    /// A factory-returned value consumed in a way that can expose ANY property
43    /// (`const { a, ...rest } = importedFactory()`, a computed destructure key).
44    /// The returned class must be treated as wholly used: crediting only the
45    /// visible keys would leave a live member reported as dead.
46    ///
47    /// Appended, never inserted: `bitcode` encodes an enum by ordinal, so moving an
48    /// existing variant would make an old cache decode one fact as another.
49    FactoryFnWholeObject(FactoryFnWholeObjectFact),
50    /// A member access reached through a property of a value returned by an
51    /// imported factory that returns an object literal (`const ui = createUi();
52    /// ui.orders.member`). Appended after `FactoryFnWholeObject`, never inserted
53    /// (bitcode encodes by ordinal). See issue #1858.
54    FactoryReturnObjectPropertyAccess(FactoryReturnObjectPropertyAccessFact),
55    /// A `this.<field>.<member>` access tied to its exact enclosing class.
56    /// Appended because bitcode encodes enum variants by ordinal.
57    ClassThisMemberAccess(ClassThisMemberAccessFact),
58    /// A whole-object use of `this.<field>...` tied to its exact enclosing class.
59    /// Appended because bitcode encodes enum variants by ordinal.
60    ClassThisWholeObjectUse(ClassThisWholeObjectUseFact),
61    /// An ordered Vitest module-mock operation with direct imported-`vi`
62    /// provenance.
63    ///
64    /// Appended because bitcode encodes enum variants by ordinal. The ordinary
65    /// dynamic-import fact for the same source remains authoritative for graph
66    /// reachability and unresolved-import diagnostics.
67    VitestModuleMockOperation(VitestModuleMockOperationFact),
68    /// Direct declarations that form one legal TypeScript declaration merge.
69    /// Appended because bitcode encodes enum variants by ordinal.
70    DeclarationMerge(DeclarationMergeFact),
71    /// A named type whose direct receiver surface is contributed by another
72    /// named type (for example `Pick<Base, ...>` or a union constituent).
73    /// Appended because bitcode encodes enum variants by ordinal.
74    TypeAliasSurfaceTarget(TypeAliasSurfaceTargetFact),
75    /// A string-valued TypeScript enum member available as a static property key.
76    /// Appended because bitcode encodes enum variants by ordinal.
77    StringEnumMemberValue(StringEnumMemberValueFact),
78    /// A computed property access keyed by a static enum member.
79    /// Appended because bitcode encodes enum variants by ordinal.
80    ComputedEnumKeyUse(ComputedEnumKeyUseFact),
81    /// A directly declared non-optional member required by a named interface
82    /// or object type.
83    /// Appended because bitcode encodes enum variants by ordinal.
84    RequiredTypeMember(RequiredTypeMemberFact),
85    /// The file's complete CommonJS assignment surface is exactly one
86    /// top-level `module.exports = { ... }` object literal whose keys are all
87    /// static and which has no transpilation marker or competing assignment.
88    /// Appended because bitcode encodes enum variants by ordinal.
89    CjsSingleStaticObjectMap,
90    /// A default import binding was handed on as a whole object.
91    /// Appended because bitcode encodes enum variants by ordinal.
92    DefaultImportWholeObjectUse(DefaultImportWholeObjectUseFact),
93    /// A property of an exported object contains a local class instance.
94    /// Appended because bitcode encodes enum variants by ordinal.
95    ExportedObjectInstanceProperty(ExportedObjectInstancePropertyFact),
96    /// A proven class member read selected through a namespace import.
97    /// Appended because bitcode encodes enum variants by ordinal.
98    QualifiedClassMemberAccess(QualifiedClassMemberAccessFact),
99    /// A Module Federation runtime call (`registerRemotes`, `loadRemote`,
100    /// `init` or `createInstance`) imported from a Federation runtime package.
101    /// Appended because bitcode encodes enum variants by ordinal.
102    FederationRuntimeRemote(FederationRuntimeRemoteFact),
103    /// A dynamic import or an import pattern whose load kind differs from the
104    /// default of its list: `Dynamic` for `dynamic_imports` and
105    /// `DynamicPattern` for `dynamic_import_patterns`.
106    /// Appended because bitcode encodes enum variants by ordinal.
107    ImportLoadKindOverride(ImportLoadKindOverrideFact),
108    /// A source-owned class-producing property of an exported object factory.
109    /// Appended because bitcode encodes enum variants by ordinal.
110    FactoryReturnObjectPropertySource(Box<FactoryReturnObjectPropertySourceFact>),
111    /// Property read whose bound factory receiver passed source-time lexical and value checks.
112    ProvenFactoryReturnObjectPropertyAccess(FactoryReturnObjectPropertyAccessFact),
113    /// Caller-owned callback origins for a source-proven returned property.
114    CallbackFactoryPropertyAccess(Box<CallbackFactoryPropertyAccessFact>),
115    /// A Playwright fixture definition from `<base>.extend<T>()` where `base`
116    /// is imported. Analysis applies it only when `base` resolves to a
117    /// Playwright test. Appended because bitcode encodes enum variants by ordinal.
118    PlaywrightConditionalFixtureDefinition(Box<PlaywrightConditionalFixtureDefinitionFact>),
119    /// A local name that the extractor proved holds a Playwright test.
120    /// Appended because bitcode encodes enum variants by ordinal.
121    PlaywrightTestBinding(PlaywrightTestBindingFact),
122    /// A top-level statement or declaration emits runtime code beyond module
123    /// imports and exports, which have their own extraction records.
124    /// Appended because bitcode encodes enum variants by ordinal.
125    TopLevelRuntimeStatement,
126    /// A static member name probed with `"name" in value` or `Reflect.has(value, "name")`.
127    /// Appended because bitcode encodes enum variants by ordinal.
128    MemberNameProbe(MemberNameProbeFact),
129    /// A use of a member of a TypeScript namespace that a plain member access
130    /// does not record: a nested chain (`N.Inner.x`), a value that leaves the
131    /// chain (`use(N)`), or a reference inside the namespace body.
132    /// Appended because bitcode encodes enum variants by ordinal.
133    NamespaceMemberUse(NamespaceMemberUseFact),
134    /// Direct imported/global property access, collected only on request.
135    SharedState(crate::shared_state::StateAccessFact),
136    /// The per-file shared-state fact limit was reached.
137    SharedStateTruncated,
138}