Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

One Completion Request, Fully Traced

1. The main loop receives JSON-RPC

GlobalState::run selects events from LSP, worker tasks, VFS, flycheck, workspace loading, and test processes. One thread owns mutable GlobalState and establishes their order.

2. Typed dispatch claims the method

RequestDispatcher is a compile-time routing chain. Parsing turns raw JSON into the request type’s associated Params; the handler must return its associated Result. Typing-related requests may run synchronously for minimal scheduling latency; most read-only work uses the pool.

3. The server takes a snapshot

GlobalState::snapshot clones Arc configuration/workspace/VFS views and obtains an immutable Analysis snapshot from AnalysisHost. The worker never borrows mutable server state.

4. IDE façade lowers position to semantics

LSP coordinates become a file ID and offset. ide calls into HIR and Salsa queries: parse this file, resolve the enclosing syntax node, build scopes, infer types, and construct completion candidates. Only demanded facts compute; unchanged dependencies reuse memoized values.

5. The result crosses back as a task

The worker converts IDE POD values to LSP types and sends Task::Response. The main loop matches the request ID, records completion, and sends JSON-RPC. If a new input revision cancelled the analysis, dispatch maps that outcome to content-modified or retry policy instead of sending stale semantics.