Skip to main content

TypeCache

Struct TypeCache 

Source
pub struct TypeCache {
    pub symbol_types: FxHashMap<SymbolId, TypeId>,
    pub symbol_instance_types: FxHashMap<SymbolId, TypeId>,
    pub node_types: FxHashMap<u32, TypeId>,
    pub symbol_dependencies: FxHashMap<SymbolId, FxHashSet<SymbolId>>,
    pub def_to_symbol: FxHashMap<DefId, SymbolId>,
    pub flow_analysis_cache: FxHashMap<(FlowNodeId, SymbolId, TypeId), TypeId>,
    pub class_instance_type_to_decl: FxHashMap<TypeId, NodeIndex>,
    pub class_instance_type_cache: FxHashMap<NodeIndex, TypeId>,
    pub class_constructor_type_cache: FxHashMap<NodeIndex, TypeId>,
    pub type_only_nodes: FxHashSet<NodeIndex>,
}
Expand description

Persistent cache for type checking results across LSP queries. This cache survives between LSP requests but is invalidated when the file changes.

Fields§

§symbol_types: FxHashMap<SymbolId, TypeId>

Cached types for symbols.

§symbol_instance_types: FxHashMap<SymbolId, TypeId>

Cached instance types for class symbols (for TYPE position). Distinguishes from symbol_types which holds constructor types for VALUE position.

§node_types: FxHashMap<u32, TypeId>

Cached types for nodes.

§symbol_dependencies: FxHashMap<SymbolId, FxHashSet<SymbolId>>

Symbol dependency graph (symbol -> referenced symbols).

§def_to_symbol: FxHashMap<DefId, SymbolId>

Maps DefIds to SymbolIds for declaration emit usage analysis. Populated by CheckerContext during type checking, consumed by UsageAnalyzer.

§flow_analysis_cache: FxHashMap<(FlowNodeId, SymbolId, TypeId), TypeId>

Cache for control flow analysis results. Key: (FlowNodeId, SymbolId, InitialTypeId) -> NarrowedTypeId

§class_instance_type_to_decl: FxHashMap<TypeId, NodeIndex>

Maps class instance TypeIds to their class declaration NodeIndex. Used by get_class_decl_from_type to correctly identify the class for derived classes that have no private/protected members.

§class_instance_type_cache: FxHashMap<NodeIndex, TypeId>

Forward cache: class declaration NodeIndex -> computed instance TypeId. Avoids recomputing the full class instance type on every member check.

§class_constructor_type_cache: FxHashMap<NodeIndex, TypeId>

Forward cache: class declaration NodeIndex -> computed constructor TypeId. Avoids recomputing constructor shape/inheritance on repeated class queries.

§type_only_nodes: FxHashSet<NodeIndex>

Set of import specifier nodes that should be elided from JavaScript output. These are imports that reference type-only declarations (interfaces, type aliases).

Implementations§

Source§

impl TypeCache

Source

pub fn invalidate_symbols(&mut self, roots: &[SymbolId]) -> usize

Invalidate cached symbol types that depend on the provided roots. Returns the number of affected symbols.

Source

pub fn merge(&mut self, other: Self)

Merge another TypeCache into this one. Used to accumulate type information from multiple file checks for declaration emit.

Trait Implementations§

Source§

impl Clone for TypeCache

Source§

fn clone(&self) -> TypeCache

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TypeCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more