1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Chunked, cancellable workspace-indexing primitives.
//!
//! These types support the rust-analyzer-style **eager background indexing**
//! model: at session start the consumer enumerates every project + vendor file
//! (see [`crate::composer::Psr4Map::all_vendor_files`]) and pumps them through
//! [`crate::AnalysisSession::index_batch`] in bounded chunks. Each chunk takes
//! one short write window and merges its declarations into the workspace symbol
//! index incrementally, so the analyzer stays responsive (no multi-second
//! freeze) while the index fills, and the input set becomes static afterward —
//! no per-edit churn of the warm cache.
//!
//! The library owns **no** background thread. The consumer drives the pump:
//! an LSP server runs it on a worker thread; a single-threaded wasm host pumps
//! one chunk per `requestIdleCallback`/`setTimeout(0)` tick. Both pass the same
//! API; only [`IndexParallelism`] differs.
use ;
use Arc;
/// Cooperative cancellation flag shared between a consumer's driver and the
/// indexing/analysis calls it makes.
///
/// Salsa's own cancellation is query-granular and does not unwind the
/// plain-Rust body-analysis walk, so long-running loops here check this flag at
/// chunk / file boundaries instead. On each new edit the consumer should drop
/// the old flag and create a fresh one for the new work rather than reusing a
/// single flag.
;
/// How an [`crate::AnalysisSession::index_batch`] call parses the files in a
/// chunk. `Sequential` is required on wasm (no threads / no rayon); `Rayon`
/// parallelises the parse across the global thread pool on native consumers.
/// Result of one [`crate::AnalysisSession::index_batch`] call.