pub struct QueryCache<'a> { /* private fields */ }Expand description
Query database wrapper with basic caching.
Implementations§
Source§impl<'a> QueryCache<'a>
impl<'a> QueryCache<'a>
pub fn new(interner: &'a TypeInterner) -> Self
pub fn clear(&self)
pub fn relation_cache_stats(&self) -> RelationCacheStats
pub fn reset_relation_cache_stats(&self)
pub fn probe_subtype_cache(&self, key: RelationCacheKey) -> RelationCacheProbe
pub fn probe_assignability_cache( &self, key: RelationCacheKey, ) -> RelationCacheProbe
Trait Implementations§
Source§impl QueryDatabase for QueryCache<'_>
impl QueryDatabase for QueryCache<'_>
Source§fn is_subtype_of(&self, source: TypeId, target: TypeId) -> bool
fn is_subtype_of(&self, source: TypeId, target: TypeId) -> bool
Convenience wrapper for is_subtype_of with default flags.
Source§fn is_assignable_to(&self, source: TypeId, target: TypeId) -> bool
fn is_assignable_to(&self, source: TypeId, target: TypeId) -> bool
Convenience wrapper for is_assignable_to with default flags.
Source§fn as_type_database(&self) -> &dyn TypeDatabase
fn as_type_database(&self) -> &dyn TypeDatabase
Expose the underlying
TypeDatabase view for legacy entry points.Source§fn register_array_base_type(
&self,
type_id: TypeId,
type_params: Vec<TypeParamInfo>,
)
fn register_array_base_type( &self, type_id: TypeId, type_params: Vec<TypeParamInfo>, )
Register the canonical
Array<T> base type used by property access resolution. Read moreSource§fn register_boxed_type(&self, kind: IntrinsicKind, type_id: TypeId)
fn register_boxed_type(&self, kind: IntrinsicKind, type_id: TypeId)
Register a boxed interface type for a primitive intrinsic kind. Read more
fn evaluate_type(&self, type_id: TypeId) -> TypeId
fn evaluate_type_with_options( &self, type_id: TypeId, no_unchecked_indexed_access: bool, ) -> TypeId
Source§fn lookup_application_eval_cache(
&self,
def_id: DefId,
args: &[TypeId],
no_unchecked_indexed_access: bool,
) -> Option<TypeId>
fn lookup_application_eval_cache( &self, def_id: DefId, args: &[TypeId], no_unchecked_indexed_access: bool, ) -> Option<TypeId>
Look up a shared cache entry for evaluated generic applications.
Source§fn insert_application_eval_cache(
&self,
def_id: DefId,
args: &[TypeId],
no_unchecked_indexed_access: bool,
result: TypeId,
)
fn insert_application_eval_cache( &self, def_id: DefId, args: &[TypeId], no_unchecked_indexed_access: bool, result: TypeId, )
Store an evaluated generic application result in the shared cache.
Source§fn is_subtype_of_with_flags(
&self,
source: TypeId,
target: TypeId,
flags: u16,
) -> bool
fn is_subtype_of_with_flags( &self, source: TypeId, target: TypeId, flags: u16, ) -> bool
Subtype check with explicit compiler flags. Read more
Source§fn is_assignable_to_with_flags(
&self,
source: TypeId,
target: TypeId,
flags: u16,
) -> bool
fn is_assignable_to_with_flags( &self, source: TypeId, target: TypeId, flags: u16, ) -> bool
Assignability check with explicit compiler flags. Read more
Source§fn lookup_subtype_cache(&self, key: RelationCacheKey) -> Option<bool>
fn lookup_subtype_cache(&self, key: RelationCacheKey) -> Option<bool>
Look up a cached subtype result for the given key.
Returns
None if the result is not cached.
Default implementation returns None (no caching).Source§fn insert_subtype_cache(&self, key: RelationCacheKey, result: bool)
fn insert_subtype_cache(&self, key: RelationCacheKey, result: bool)
Cache a subtype result for the given key.
Default implementation is a no-op.
Source§fn lookup_assignability_cache(&self, key: RelationCacheKey) -> Option<bool>
fn lookup_assignability_cache(&self, key: RelationCacheKey) -> Option<bool>
Look up a cached assignability result for the given key.
Returns
None if the result is not cached.
Default implementation returns None (no caching).Source§fn insert_assignability_cache(&self, key: RelationCacheKey, result: bool)
fn insert_assignability_cache(&self, key: RelationCacheKey, result: bool)
Cache an assignability result for the given key.
Default implementation is a no-op.
Source§fn get_index_signatures(&self, type_id: TypeId) -> IndexInfo
fn get_index_signatures(&self, type_id: TypeId) -> IndexInfo
Get index signatures for a type
Source§fn is_nullish_type(&self, type_id: TypeId) -> bool
fn is_nullish_type(&self, type_id: TypeId) -> bool
Check if a type contains null or undefined
Source§fn remove_nullish(&self, type_id: TypeId) -> TypeId
fn remove_nullish(&self, type_id: TypeId) -> TypeId
Remove null and undefined from a type
fn resolve_property_access( &self, object_type: TypeId, prop_name: &str, ) -> PropertyAccessResult
fn resolve_property_access_with_options( &self, object_type: TypeId, prop_name: &str, no_unchecked_indexed_access: bool, ) -> PropertyAccessResult
Source§fn resolve_element_access_type(
&self,
object_type: TypeId,
index_type: TypeId,
literal_index: Option<usize>,
) -> TypeId
fn resolve_element_access_type( &self, object_type: TypeId, index_type: TypeId, literal_index: Option<usize>, ) -> TypeId
Resolve element access type with cache-friendly error normalization.
Source§fn collect_object_spread_properties(
&self,
spread_type: TypeId,
) -> Vec<PropertyInfo>
fn collect_object_spread_properties( &self, spread_type: TypeId, ) -> Vec<PropertyInfo>
Collect properties that can be spread into object literals.
fn no_unchecked_indexed_access(&self) -> bool
fn set_no_unchecked_indexed_access(&self, enabled: bool)
Source§fn get_type_param_variance(&self, def_id: DefId) -> Option<Arc<[Variance]>>
fn get_type_param_variance(&self, def_id: DefId) -> Option<Arc<[Variance]>>
Task #41: Get the variance mask for a generic type definition. Read more
Source§fn canonical_id(&self, type_id: TypeId) -> TypeId
fn canonical_id(&self, type_id: TypeId) -> TypeId
Get the canonical
TypeId for a type, achieving O(1) structural identity checks. Read moreSource§fn factory(&self) -> TypeFactory<'_>
fn factory(&self) -> TypeFactory<'_>
Expose the checked construction surface for type constructors.
fn evaluate_conditional(&self, cond: &ConditionalType) -> TypeId
fn evaluate_index_access( &self, object_type: TypeId, index_type: TypeId, ) -> TypeId
fn evaluate_index_access_with_options( &self, object_type: TypeId, index_type: TypeId, no_unchecked_indexed_access: bool, ) -> TypeId
fn evaluate_mapped(&self, mapped: &MappedType) -> TypeId
fn evaluate_keyof(&self, operand: TypeId) -> TypeId
fn narrow(&self, type_id: TypeId, narrower: TypeId) -> TypeIdwhere
Self: Sized,
fn property_access_type( &self, object_type: TypeId, prop_name: &str, ) -> PropertyAccessResult
fn contextual_property_type( &self, expected: TypeId, prop_name: &str, ) -> Option<TypeId>
fn is_property_readonly(&self, object_type: TypeId, prop_name: &str) -> bool
fn is_readonly_index_signature( &self, object_type: TypeId, wants_string: bool, wants_number: bool, ) -> bool
Source§fn resolve_element_access(
&self,
object_type: TypeId,
index_type: TypeId,
literal_index: Option<usize>,
) -> ElementAccessResult
fn resolve_element_access( &self, object_type: TypeId, index_type: TypeId, literal_index: Option<usize>, ) -> ElementAccessResult
Resolve element access (array/tuple indexing) with detailed error reporting
fn new_inference_context(&self) -> InferenceContext<'_>
Source§impl TypeDatabase for QueryCache<'_>
impl TypeDatabase for QueryCache<'_>
fn intern(&self, key: TypeData) -> TypeId
fn lookup(&self, id: TypeId) -> Option<TypeData>
fn intern_string(&self, s: &str) -> Atom
fn resolve_atom(&self, atom: Atom) -> String
fn resolve_atom_ref(&self, atom: Atom) -> Arc<str>
fn type_list(&self, id: TypeListId) -> Arc<[TypeId]>
fn tuple_list(&self, id: TupleListId) -> Arc<[TupleElement]>
fn template_list(&self, id: TemplateLiteralId) -> Arc<[TemplateSpan]>
fn object_shape(&self, id: ObjectShapeId) -> Arc<ObjectShape>
fn object_property_index( &self, shape_id: ObjectShapeId, name: Atom, ) -> PropertyLookup
fn function_shape(&self, id: FunctionShapeId) -> Arc<FunctionShape>
fn callable_shape(&self, id: CallableShapeId) -> Arc<CallableShape>
fn conditional_type(&self, id: ConditionalTypeId) -> Arc<ConditionalType>
fn mapped_type(&self, id: MappedTypeId) -> Arc<MappedType>
fn type_application(&self, id: TypeApplicationId) -> Arc<TypeApplication>
fn literal_string(&self, value: &str) -> TypeId
fn literal_number(&self, value: f64) -> TypeId
fn literal_boolean(&self, value: bool) -> TypeId
fn literal_bigint(&self, value: &str) -> TypeId
fn literal_bigint_with_sign(&self, negative: bool, digits: &str) -> TypeId
fn union(&self, members: Vec<TypeId>) -> TypeId
fn union_from_sorted_vec(&self, flat: Vec<TypeId>) -> TypeId
fn union2(&self, left: TypeId, right: TypeId) -> TypeId
fn union3(&self, first: TypeId, second: TypeId, third: TypeId) -> TypeId
fn intersection(&self, members: Vec<TypeId>) -> TypeId
fn intersection2(&self, left: TypeId, right: TypeId) -> TypeId
Source§fn intersect_types_raw2(&self, left: TypeId, right: TypeId) -> TypeId
fn intersect_types_raw2(&self, left: TypeId, right: TypeId) -> TypeId
Raw intersection without normalization (used to avoid infinite recursion)
fn array(&self, element: TypeId) -> TypeId
fn tuple(&self, elements: Vec<TupleElement>) -> TypeId
fn object(&self, properties: Vec<PropertyInfo>) -> TypeId
fn object_with_flags( &self, properties: Vec<PropertyInfo>, flags: ObjectFlags, ) -> TypeId
fn object_with_flags_and_symbol( &self, properties: Vec<PropertyInfo>, flags: ObjectFlags, symbol: Option<SymbolId>, ) -> TypeId
fn object_with_index(&self, shape: ObjectShape) -> TypeId
fn function(&self, shape: FunctionShape) -> TypeId
fn callable(&self, shape: CallableShape) -> TypeId
fn template_literal(&self, spans: Vec<TemplateSpan>) -> TypeId
fn conditional(&self, conditional: ConditionalType) -> TypeId
fn mapped(&self, mapped: MappedType) -> TypeId
fn reference(&self, symbol: SymbolRef) -> TypeId
fn lazy(&self, def_id: DefId) -> TypeId
fn bound_parameter(&self, index: u32) -> TypeId
fn recursive(&self, depth: u32) -> TypeId
fn type_param(&self, info: TypeParamInfo) -> TypeId
fn type_query(&self, symbol: SymbolRef) -> TypeId
fn enum_type(&self, def_id: DefId, structural_type: TypeId) -> TypeId
fn application(&self, base: TypeId, args: Vec<TypeId>) -> TypeId
fn literal_string_atom(&self, atom: Atom) -> TypeId
fn union_preserve_members(&self, members: Vec<TypeId>) -> TypeId
fn readonly_type(&self, inner: TypeId) -> TypeId
fn keyof(&self, inner: TypeId) -> TypeId
fn index_access(&self, object_type: TypeId, index_type: TypeId) -> TypeId
fn this_type(&self) -> TypeId
fn no_infer(&self, inner: TypeId) -> TypeId
fn unique_symbol(&self, symbol: SymbolRef) -> TypeId
fn infer(&self, info: TypeParamInfo) -> TypeId
fn string_intrinsic( &self, kind: StringIntrinsicKind, type_arg: TypeId, ) -> TypeId
Source§fn get_class_base_type(&self, symbol_id: SymbolId) -> Option<TypeId>
fn get_class_base_type(&self, symbol_id: SymbolId) -> Option<TypeId>
Get the base class type for a symbol (class/interface).
Returns the
TypeId of the extends clause, or None if the symbol doesn’t extend anything.
This is used by the BCT algorithm to find common base classes.Source§fn is_identity_comparable_type(&self, type_id: TypeId) -> bool
fn is_identity_comparable_type(&self, type_id: TypeId) -> bool
Check if a type can be compared by
TypeId identity alone (O(1) equality).
Identity-comparable types include literals, enum members, unique symbols, null, undefined,
void, never, and tuples composed entirely of identity-comparable types.
Results are cached for O(1) lookup after first computation.fn object_fresh(&self, properties: Vec<PropertyInfo>) -> TypeId
Source§impl TypeResolver for QueryCache<'_>
Implement TypeResolver for QueryCache with noop resolution.
impl TypeResolver for QueryCache<'_>
Implement TypeResolver for QueryCache with noop resolution.
QueryCache doesn’t have access to the Binder or type environment,
so it cannot resolve symbol references or DefIds. Only resolve_ref
(required) is explicitly implemented; all other resolution methods
inherit the trait’s default None/false behavior. The three boxed/array
methods delegate to the underlying interner.
Source§fn resolve_ref(
&self,
_symbol: SymbolRef,
_interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn resolve_ref( &self, _symbol: SymbolRef, _interner: &dyn TypeDatabase, ) -> Option<TypeId>
Resolve a symbol reference to its structural type.
Returns None if the symbol cannot be resolved. Read more
Source§fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>
fn get_boxed_type(&self, kind: IntrinsicKind) -> Option<TypeId>
Get the boxed interface type for a primitive intrinsic (Rule #33).
For example,
IntrinsicKind::Number -> TypeId of the Number interface.
This enables primitives to be subtypes of their boxed interfaces.Source§fn get_array_base_type(&self) -> Option<TypeId>
fn get_array_base_type(&self) -> Option<TypeId>
Get the Array interface type from lib.d.ts.
Source§fn get_array_base_type_params(&self) -> &[TypeParamInfo]
fn get_array_base_type_params(&self) -> &[TypeParamInfo]
Get the type parameters for the Array interface.
Source§fn resolve_symbol_ref(
&self,
symbol: SymbolRef,
interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn resolve_symbol_ref( &self, symbol: SymbolRef, interner: &dyn TypeDatabase, ) -> Option<TypeId>
Resolve a symbol reference to a structural type, preferring DefId-based lazy paths. Read more
Source§fn resolve_lazy(
&self,
_def_id: DefId,
_interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn resolve_lazy( &self, _def_id: DefId, _interner: &dyn TypeDatabase, ) -> Option<TypeId>
Resolve a
DefId reference to its structural type. Read moreSource§fn get_type_params(&self, _symbol: SymbolRef) -> Option<Vec<TypeParamInfo>>
fn get_type_params(&self, _symbol: SymbolRef) -> Option<Vec<TypeParamInfo>>
Get type parameters for a symbol (for generic type aliases/interfaces).
Returns None by default; implementations can override to support
Application type expansion.
Source§fn get_lazy_type_params(&self, _def_id: DefId) -> Option<Vec<TypeParamInfo>>
fn get_lazy_type_params(&self, _def_id: DefId) -> Option<Vec<TypeParamInfo>>
Get type parameters for a
DefId (for generic type aliases/interfaces). Read moreSource§fn is_boxed_def_id(&self, _def_id: DefId, _kind: IntrinsicKind) -> bool
fn is_boxed_def_id(&self, _def_id: DefId, _kind: IntrinsicKind) -> bool
Check if a
DefId corresponds to a boxed type for the given intrinsic kind.Source§fn is_boxed_type_id(&self, _type_id: TypeId, _kind: IntrinsicKind) -> bool
fn is_boxed_type_id(&self, _type_id: TypeId, _kind: IntrinsicKind) -> bool
Check if a
TypeId is any known resolved form of a boxed type. Read moreSource§fn get_lazy_export(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
fn get_lazy_export(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
Get an export from a namespace/module by name. Read more
Source§fn get_lazy_enum_member(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
fn get_lazy_enum_member(&self, _def_id: DefId, _name: Atom) -> Option<TypeId>
Get enum member type by name from an enum
DefId. Read moreSource§fn is_numeric_enum(&self, _def_id: DefId) -> bool
fn is_numeric_enum(&self, _def_id: DefId) -> bool
Check if a
DefId corresponds to a numeric enum (not a string enum). Read moreSource§fn is_enum_type(&self, _type_id: TypeId, _interner: &dyn TypeDatabase) -> bool
fn is_enum_type(&self, _type_id: TypeId, _interner: &dyn TypeDatabase) -> bool
Check if a
TypeId represents a full Enum type (not a specific member).Source§fn is_user_enum_def(&self, _def_id: DefId) -> bool
fn is_user_enum_def(&self, _def_id: DefId) -> bool
Check if a
DefId represents a user-defined enum (not an intrinsic type).Source§fn get_base_type(
&self,
_type_id: TypeId,
_interner: &dyn TypeDatabase,
) -> Option<TypeId>
fn get_base_type( &self, _type_id: TypeId, _interner: &dyn TypeDatabase, ) -> Option<TypeId>
Get the base class type for a class/interface type. Read more
Auto Trait Implementations§
impl<'a> !Freeze for QueryCache<'a>
impl<'a> !RefUnwindSafe for QueryCache<'a>
impl<'a> Send for QueryCache<'a>
impl<'a> Sync for QueryCache<'a>
impl<'a> Unpin for QueryCache<'a>
impl<'a> UnsafeUnpin for QueryCache<'a>
impl<'a> !UnwindSafe for QueryCache<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more