A hover, definition, type definition, highlight, prepare-rename or signature help on a name the file itself declares, and the outline, folding and selection ranges, are answered from the open buffer ahead of a scan, a rescan or a widen (server/ahead.rs, same_file.rs). The precondition is stated once, on Server::answer_from_the_buffer; ahead::REACH lists the notifications proved unable to change a buffer and everything else blocks. Completion offers what the file can reach (imported package members, inherited class members, included headers' macros) right after its own names (completion/related.rs), and its answers are half the size (completion/wire.rs). A new largeFile.threshold re-classifies buffers already open. The client's answer to a settings pull is now ordered like a notification (amends scan-ordering); colours answered while anything is held count as unsettled. TODO 71.2. Four dev rounds, four QA rounds; the last ran with Fable 5.2 as dev and QA after two QA failures. docs/features/fast-actions. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
94 lines
3.5 KiB
Rust
94 lines
3.5 KiB
Rust
//! A test's hand on the mid-scan drain: what the client "sends" at each
|
|
//! interleave point, and how often a scan handed back what it was holding.
|
|
//!
|
|
//! Test-only. The real transport cannot be timed against a scan's files —
|
|
//! the forwarder thread delivers whenever it likes — so a test that needs a
|
|
//! burst to land *at the third file* scripts it here, and the drain appends it
|
|
//! to what `try_recv` found, exactly where a real arrival would be. Thread
|
|
//! local because every test drives its server on its own thread.
|
|
|
|
use std::cell::RefCell;
|
|
use std::collections::VecDeque;
|
|
|
|
use lsp_server::{Message, RequestId};
|
|
|
|
#[derive(Default)]
|
|
struct Probe {
|
|
/// Bursts to deliver, one per interleave point, oldest first.
|
|
arrivals: VecDeque<Vec<Message>>,
|
|
/// Interleave points reached since the last [`take_counts`].
|
|
points: usize,
|
|
/// How many of those handed messages the scan had been holding back to
|
|
/// `process_batch` — what loops when a held batch is re-held at every file.
|
|
handed_back: usize,
|
|
/// How many scripted bursts a scan received.
|
|
delivered: usize,
|
|
/// The requests answered ahead of whatever held the rest (`ahead.rs`)
|
|
/// since the last [`take_ahead`], in the order they were answered.
|
|
ahead: Vec<RequestId>,
|
|
}
|
|
|
|
/// What [`take_counts`] reports.
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub(super) struct Counts {
|
|
/// Interleave points reached.
|
|
pub(super) points: usize,
|
|
/// Held batches handed back to `process_batch`.
|
|
pub(super) handed_back: usize,
|
|
/// Scripted bursts delivered mid-scan.
|
|
pub(super) delivered: usize,
|
|
}
|
|
|
|
thread_local! {
|
|
static PROBE: RefCell<Probe> = RefCell::default();
|
|
}
|
|
|
|
/// Script `bursts` to arrive at the next interleave points, one each, behind
|
|
/// anything already scripted.
|
|
pub(super) fn script(bursts: impl IntoIterator<Item = Vec<Message>>) {
|
|
PROBE.with(|probe| probe.borrow_mut().arrivals.extend(bursts));
|
|
}
|
|
|
|
/// What is still scripted and has not arrived — the bursts a scan ended
|
|
/// before reaching, which the test then delivers as `run` would.
|
|
pub(super) fn unarrived() -> Vec<Vec<Message>> {
|
|
PROBE.with(|probe| probe.borrow_mut().arrivals.drain(..).collect())
|
|
}
|
|
|
|
/// What the scans did since the last call.
|
|
pub(super) fn take_counts() -> Counts {
|
|
PROBE.with(|probe| {
|
|
let mut probe = probe.borrow_mut();
|
|
Counts {
|
|
points: std::mem::take(&mut probe.points),
|
|
handed_back: std::mem::take(&mut probe.handed_back),
|
|
delivered: std::mem::take(&mut probe.delivered),
|
|
}
|
|
})
|
|
}
|
|
|
|
/// Called by the drain at every interleave point: count it, and deliver the
|
|
/// next scripted burst behind whatever the transport delivered.
|
|
pub(super) fn at_interleave_point(handed_back: bool, arrived: &mut Vec<Message>) {
|
|
PROBE.with(|probe| {
|
|
let mut probe = probe.borrow_mut();
|
|
probe.points += 1;
|
|
probe.handed_back += usize::from(handed_back);
|
|
if let Some(burst) = probe.arrivals.pop_front() {
|
|
probe.delivered += 1;
|
|
arrived.extend(burst);
|
|
}
|
|
});
|
|
}
|
|
|
|
/// Called where a request is answered ahead of what holds the rest.
|
|
pub(super) fn went_ahead(id: &RequestId) {
|
|
PROBE.with(|probe| probe.borrow_mut().ahead.push(id.clone()));
|
|
}
|
|
|
|
/// The requests answered ahead since the last call — what a test compares
|
|
/// with the answer a server taking one message at a time gives.
|
|
pub(super) fn take_ahead() -> Vec<RequestId> {
|
|
PROBE.with(|probe| std::mem::take(&mut probe.borrow_mut().ahead))
|
|
}
|