pub struct TscProvider { /* private fields */ }Expand description
The project’s own TypeScript compiler, driven through a sidecar process.
Implementations§
Source§impl TscProvider
impl TscProvider
Sourcepub fn spawn(
root: &Path,
config: &TypesConfig,
budget: AnalysisBudget,
) -> Result<Self, ProviderError>
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.
Sourcepub fn spawn_with_env(
root: &Path,
config: &TypesConfig,
budget: AnalysisBudget,
env: &[(&str, &str)],
) -> Result<Self, ProviderError>
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
Sourcepub fn typescript_version(&self) -> &str
pub fn typescript_version(&self) -> &str
The TypeScript version the sidecar loaded.
Sourcepub fn programs(&self, files: &[FilePath]) -> Result<(), ProviderError>
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
Sourcepub fn failure(&self) -> Option<ProviderError>
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.
Sourcepub fn programs_hash(&self) -> [u8; 32]
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
impl Debug for TscProvider
Source§impl Drop for TscProvider
impl Drop for TscProvider
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.
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
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
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>
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>
fn notices(&self) -> Vec<String>
Source§fn return_type_of(&self, q: Query<'_>) -> Option<Type>
fn return_type_of(&self, q: Query<'_>) -> Option<Type>
q.node yields. Read moreSource§fn is_assignable_to(
&self,
q: Query<'_>,
module: &str,
name: &str,
) -> Option<bool>
fn is_assignable_to( &self, q: Query<'_>, module: &str, name: &str, ) -> Option<bool>
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 moreSource§fn complete(&self, q: Query<'_>) -> bool
fn complete(&self, q: Query<'_>) -> bool
q’s file resolved to something this provider could read. Read more