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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Immutable world snapshot for request handling.
//!
//! Each LSP request receives an immutable snapshot of the world state.
//! This allows requests to be processed concurrently without locks.
use Arc;
use ;
/// Global revision counter used by [`Snapshot`].
///
/// Note: the LSP main loop maintains its OWN per-instance revision
/// counter on `MainLoopState`. This global is kept only because the
/// `Snapshot` API exposes `is_current` / `is_cancelled`, which today
/// has no production callers and is exercised only by the test below.
/// New cancellation-detection logic should use the per-instance
/// counter on `MainLoopState` so multiple LSP instances in one
/// process (e.g., integration tests) don't clobber each other.
static REVISION: AtomicU64 = new;
/// Bump the global revision counter. See [`REVISION`] note about
/// preferring the per-instance counter on `MainLoopState`.
///
/// Kept `#[allow(dead_code)]` because production no longer calls it
/// (the per-instance counter on `MainLoopState` replaced it); the
/// remaining caller is `test_snapshot_cancellation` below, which
/// pins the `Snapshot::is_cancelled` contract even though no
/// production handler reads `Snapshot` today.
/// Get the current revision. See [`REVISION`] note about preferring
/// the per-instance counter on `MainLoopState`.
/// An immutable snapshot of the world state.
///
/// Snapshots capture the revision at creation time, allowing
/// handlers to detect if they should cancel (revision changed).