Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Debouncer ¶ added in v0.11.0
type Debouncer struct {
// contains filtered or unexported fields
}
func NewDebouncer ¶ added in v0.11.0
NewDebouncer returns a Debouncer with the given idle window. A typical value for LSP diagnostics is 150-250ms; long enough that a burst of typing doesn't publish per keystroke, short enough that the user sees errors when they pause.
func (*Debouncer) Stop ¶ added in v0.11.0
func (d *Debouncer) Stop()
Stop cancels all pending timers. Idempotent; after Stop, subsequent Trigger calls are no-ops.
func (*Debouncer) Trigger ¶ added in v0.11.0
Trigger schedules `fn` to run after the configured delay. If another Trigger lands on the same key first, the existing timer is stopped and the new fn replaces it - the most recent fn wins. This matters because the publish closure usually wants to grab the latest snapshot at fire time, not the one at trigger time, so it's fine that earlier fns are dropped.
A zero delay short-circuits to a synchronous call: fn runs inline on the caller's goroutine. Useful in tests that want deterministic publish behavior without racing a goroutine scheduler.
If the Debouncer has been Stopped, Trigger is a no-op.
Each pending timer is tracked by a generation counter so the "fired-but-running" race can be detected: a callback whose timer has been superseded by a later Trigger must not delete the new timer's map entry on its way out.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
func (*Mux) AddNotificationHandler ¶
func (m *Mux) AddNotificationHandler(method string, handler NotificationHandler)
func (*Mux) AddRequestHandler ¶
func (m *Mux) AddRequestHandler(method string, handler RequestHandler)
type NotificationHandler ¶
type NotificationHandler func(ctx context.Context, params json.RawMessage) (err error)
NotificationHandler handles a JSON-RPC notification. Notifications have no response, so the only return value is an error for logging. The context carries cancellation derived from the server's session context - if the session shuts down, in-flight notifications get cancelled too.
type RequestHandler ¶
RequestHandler handles a JSON-RPC request. The context carries cancellation that the client can flip via $/cancelRequest. Long- running handlers should check ctx.Err() at sensible checkpoints and bail out with a partial result (or the context's error) rather than spending budget on work the client no longer wants.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
NewServer creates a server using the default diagnostics debounce delay. Tests that need synchronous publish should use NewServerWithDebounce(r, w, 0) instead.
func NewServerWithDebounce ¶ added in v0.11.0
NewServerWithDebounce lets tests override the publish-diagnostics debounce delay. A zero delay makes Trigger synchronous, which keeps the snapshot-test harness deterministic without forcing it to sleep for arbitrary windows.