Skip to main content

TypePredicateVisitor

Struct TypePredicateVisitor 

Source
pub struct TypePredicateVisitor<F>
where F: Fn(&TypeData) -> bool,
{ pub predicate: F, }
Expand description

Visitor that checks if a type matches a specific predicate.

Fields§

§predicate: F

Predicate function to test against TypeData.

Implementations§

Source§

impl<F> TypePredicateVisitor<F>
where F: Fn(&TypeData) -> bool,

Source

pub const fn new(predicate: F) -> Self

Create a new TypePredicateVisitor.

Trait Implementations§

Source§

impl<F> TypeVisitor for TypePredicateVisitor<F>
where F: Fn(&TypeData) -> bool,

Source§

type Output = bool

The output type produced by visiting.
Source§

fn visit_type_key( &mut self, _types: &dyn TypeDatabase, type_key: &TypeData, ) -> Self::Output

Visit a TypeData by dispatching to the appropriate method.
Source§

fn visit_intrinsic(&mut self, _kind: IntrinsicKind) -> Self::Output

Visit an intrinsic type (any, unknown, never, void, etc.).
Source§

fn visit_literal(&mut self, _value: &LiteralValue) -> Self::Output

Visit a literal type (string, number, boolean, bigint literals).
Source§

fn default_output() -> Self::Output

Default output for unimplemented variants.
Source§

fn visit_object(&mut self, _shape_id: u32) -> Self::Output

Visit an object type with properties.
Source§

fn visit_object_with_index(&mut self, _shape_id: u32) -> Self::Output

Visit an object type with index signatures.
Source§

fn visit_union(&mut self, _list_id: u32) -> Self::Output

Visit a union type (A | B | C).
Source§

fn visit_intersection(&mut self, _list_id: u32) -> Self::Output

Visit an intersection type (A & B & C).
Source§

fn visit_array(&mut self, _element_type: TypeId) -> Self::Output

Visit an array type T[].
Source§

fn visit_tuple(&mut self, _list_id: u32) -> Self::Output

Visit a tuple type [T, U, V].
Source§

fn visit_function(&mut self, _shape_id: u32) -> Self::Output

Visit a function type.
Source§

fn visit_callable(&mut self, _shape_id: u32) -> Self::Output

Visit a callable type with call/construct signatures.
Source§

fn visit_type_parameter(&mut self, _param_info: &TypeParamInfo) -> Self::Output

Visit a type parameter (generic type variable).
Source§

fn visit_bound_parameter(&mut self, _de_bruijn_index: u32) -> Self::Output

Visit a bound type parameter using De Bruijn index for alpha-equivalence. Read more
Source§

fn visit_ref(&mut self, _symbol_ref: u32) -> Self::Output

Visit a named type reference (interface, class, type alias).
Source§

fn visit_enum(&mut self, _def_id: u32, _member_type: TypeId) -> Self::Output

Visit an enum type with nominal identity and structural member types.
Source§

fn visit_lazy(&mut self, _def_id: u32) -> Self::Output

Visit a lazy type reference using DefId.
Source§

fn visit_recursive(&mut self, _de_bruijn_index: u32) -> Self::Output

Visit a recursive type reference using De Bruijn index. Read more
Source§

fn visit_application(&mut self, _app_id: u32) -> Self::Output

Visit a generic type application Base.
Source§

fn visit_conditional(&mut self, _cond_id: u32) -> Self::Output

Visit a conditional type T extends U ? X : Y.
Source§

fn visit_mapped(&mut self, _mapped_id: u32) -> Self::Output

Visit a mapped type { [K in Keys]: V }.
Source§

fn visit_index_access( &mut self, _object_type: TypeId, _key_type: TypeId, ) -> Self::Output

Visit an indexed access type T[K].
Source§

fn visit_template_literal(&mut self, _template_id: u32) -> Self::Output

Visit a template literal type hello${x}world.
Source§

fn visit_type_query(&mut self, _symbol_ref: u32) -> Self::Output

Visit a type query (typeof expr).
Source§

fn visit_keyof(&mut self, _type_id: TypeId) -> Self::Output

Visit a keyof type.
Source§

fn visit_readonly_type(&mut self, _inner_type: TypeId) -> Self::Output

Visit a readonly type modifier.
Source§

fn visit_unique_symbol(&mut self, _symbol_ref: u32) -> Self::Output

Visit a unique symbol type.
Source§

fn visit_infer(&mut self, _param_info: &TypeParamInfo) -> Self::Output

Visit an infer type (for type inference in conditional types).
Source§

fn visit_this_type(&mut self) -> Self::Output

Visit a this type (polymorphic this parameter).
Source§

fn visit_string_intrinsic( &mut self, _kind: StringIntrinsicKind, _type_arg: TypeId, ) -> Self::Output

Visit a string manipulation intrinsic type.
Source§

fn visit_error(&mut self) -> Self::Output

Visit an error type.
Source§

fn visit_no_infer(&mut self, _inner: TypeId) -> Self::Output

Visit a NoInfer type (TypeScript 5.4+). Traverses the inner type (NoInfer is transparent for traversal).
Source§

fn visit_module_namespace(&mut self, _symbol_ref: u32) -> Self::Output

Visit a module namespace type (import * as ns).
Source§

fn visit_type( &mut self, types: &dyn TypeDatabase, type_id: TypeId, ) -> Self::Output

Visit a type by dispatching to the appropriate method. Read more

Auto Trait Implementations§

§

impl<F> Freeze for TypePredicateVisitor<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for TypePredicateVisitor<F>
where F: RefUnwindSafe,

§

impl<F> Send for TypePredicateVisitor<F>
where F: Send,

§

impl<F> Sync for TypePredicateVisitor<F>
where F: Sync,

§

impl<F> Unpin for TypePredicateVisitor<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for TypePredicateVisitor<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for TypePredicateVisitor<F>
where F: UnwindSafe,

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> 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, 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