Skip to main content

TscProvider

Struct TscProvider 

Source
pub struct TscProvider { /* private fields */ }
Expand description

The project’s own TypeScript compiler, driven through a sidecar process.

Implementations§

Source§

impl TscProvider

Source

pub fn spawn( root: &Path, config: &TypesConfig, budget: AnalysisBudget, ) -> Result<Self, ProviderError>

Write the driver, start the sidecar, and complete the handshake.

§Errors

ProviderError::Unavailable when the command cannot be run, ProviderError::Unloadable when it runs and the typescript package cannot be used, ProviderError::Unwritable when the driver cannot be written into the project’s .lanekeep/, ProviderError::Refused when the sidecar answers something this cannot read, and ProviderError::Timeout when hello outlives the budget. The first two are split because only one of their remedies can work; see the variants.

Source

pub fn spawn_with_env( root: &Path, config: &TypesConfig, budget: AnalysisBudget, env: &[(&str, &str)], ) -> Result<Self, ProviderError>

TscProvider::spawn with extra environment for the child.

The only caller that passes anything is the budget test, which needs a real process to spend real time. Kept as a separate entry point rather than as a parameter on spawn so that no production call site can pass one by accident.

§Errors

As TscProvider::spawn.

Source

pub fn typescript_version(&self) -> &str

The TypeScript version the sidecar loaded.

Source

pub fn programs(&self, files: &[FilePath]) -> Result<(), ProviderError>

Build every program the run’s files belong to, and record their hash.

Called once at prepare, before run_key. Eager because §5.6’s dependency mechanism for this provider is the whole program listing rather than per-query tracked reads: the listing is the key, so it has to exist before a key does.

§Errors

As TscProvider::spawn.

Source

pub fn failure(&self) -> Option<ProviderError>

The first error this provider produced, if it has produced one.

See the failure field: every TypeProvider method answers None/false on a failure because the trait has nowhere to put an error, so this is the only way a caller can tell “the compiler says there is no type here” from “the compiler is gone”. The engine asks after every file and cancels the run when it is Some.

Source

pub fn programs_hash(&self) -> [u8; 32]

The hash of every program’s files, as analysis_hash folds it.

Trait Implementations§

Source§

impl Debug for TscProvider

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for TscProvider

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl TypeProvider for TscProvider

A program’s own reads reach the key through TypeProvider::begin_run’s listing, folded before any answer exists. A query’s reads — a resolution made outside any program’s host, answering a single question — are the other half: TscProvider::ask_recording records each through the asking Query’s own FileAccess, as an ordinary per-entry tracked read.

Source§

fn spends_analysis_budget(&self) -> bool

Yes. This provider’s whole cost is a process building programs and answering requests, which is exactly what timeouts.analysis bounds.

Source§

fn needs_rebuild(&self) -> bool

True once the sidecar is gone, which for this provider is unrecoverable in place.

Every failure path that leaves the protocol out of step kills the child (see stop), and nothing here starts another: the Session holds one Child, and a provider is shared behind an Arc across the run’s workers, so respawning under them would be a second sidecar answering questions the first was asked. A session builds a new provider instead — see TypeProvider::needs_rebuild.

try_wait rather than a flag set where the child is killed: the child may also have died on its own — out of memory building a program is the realistic one — and a flag would only ever know about the deaths lanekeep caused.

SessionProvider::for_request_with calls this holding its own lock, so what could block here is not try_wait — it does not wait — but acquiring self.session’s mutex. That is sound only because no request is in flight when for_request_with runs: the session’s held lock serializes callers, and each one either returns before touching the sidecar or acquires self.session itself, so this call never contends with a request already holding it.

Source§

fn failure(&self) -> Option<BeginRunError>

The sticky first error, in the shape the engine takes its exit from.

Read after every file. The mapping is begin_run’s, deliberately: one failure must take the same exit whether it happened while the programs were being built or while a rule was asking a question, or the same broken sidecar would name timeouts.analysis in one phase and the toolchain in the other.

The budget the overrun is measured against is the run’s when begin_run set one, so a provider a session holds across runs reports against the run that broke rather than the one that spawned it.

Source§

fn notices(&self) -> Vec<String>

Lines this provider wants said about the run it has just prepared. Read more
Source§

fn type_of(&self, q: Query<'_>) -> Option<Type>

The type of the expression at q.node.
Source§

fn symbol_of(&self, q: Query<'_>) -> Option<Symbol>

Where the name at q.node came from.
Source§

fn return_type_of(&self, q: Query<'_>) -> Option<Type>

What calling the function at q.node yields. Read more
Source§

fn is_assignable_to( &self, q: Query<'_>, module: &str, name: &str, ) -> Option<bool>

Whether the type at q.node is the type module exports as name, or declares a relationship to it — extends or implements — across files, through aliases of the named type. Read more
Source§

fn complete(&self, q: Query<'_>) -> bool

Whether every import in q’s file resolved to something this provider could read. Read more
Source§

fn identity(&self) -> Vec<u8>

What this provider is, for the cache key. Read more
Source§

fn dependency_paths(&self) -> BTreeSet<FilePath>

Every path this provider’s own dependency mechanism named for the run it last prepared. Read more
Source§

fn revalidate(&self, _files: &FileAccess)

Drop whatever this provider holds that the files no longer support. Read more
Source§

fn begin_run( &self, files: &dyn Fn() -> Vec<FilePath>, budget: AnalysisBudget, ) -> Result<Vec<u8>, BeginRunError>

Prepare for a run over the corpus files yields, and answer the per-run key term. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.